1 package org
.argeo
.suite
.e4
.rap
.settings
;
3 import java
.util
.Dictionary
;
4 import java
.util
.Hashtable
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.cms
.e4
.rap
.AbstractRapE4App
;
10 import org
.argeo
.util
.LangUtils
;
11 import org
.eclipse
.rap
.rwt
.application
.ApplicationConfiguration
;
12 import org
.osgi
.framework
.Bundle
;
13 import org
.osgi
.framework
.BundleContext
;
14 import org
.osgi
.service
.cm
.ConfigurationException
;
15 import org
.osgi
.service
.cm
.ManagedServiceFactory
;
18 * Managed service factory deploying Argeo RAP app based on OSGi configurations.
20 public class AppDeployer
implements ManagedServiceFactory
{
21 private final static Log log
= LogFactory
.getLog(AppDeployer
.class);
22 private BundleContext bundleContext
;
24 public void init(BundleContext bundleContext
, Map
<String
, String
> properties
) {
25 this.bundleContext
= bundleContext
;
27 deploy(findBundle("org.argeo.suite.studio", null), properties
);
28 deploy(findBundle("org.argeo.suite.docs", null), properties
);
31 public void destroy() {
36 public String
getName() {
37 return "Argeo App Deployer";
41 public void updated(String pid
, Dictionary
<String
, ?
> properties
) throws ConfigurationException
{
42 Bundle bundle
= findBundle(pid
, properties
);
43 deploy(bundle
, LangUtils
.dictToStringMap(properties
));
46 protected void deploy(Bundle bundle
, Map
<String
, String
> properties
) {
48 // if (properties.containsKey(CmsTheme.CMS_THEME_BUNDLE_PROPERTY)) {
49 // String cmsThemeBundle = properties.get(CmsTheme.CMS_THEME_BUNDLE_PROPERTY);
50 // cmsTheme = new CmsTheme(bundleContext, cmsThemeBundle);
52 // cmsTheme = new CmsTheme(bundleContext, CmsTheme.DEFAULT_CMS_THEME_BUNDLE);
55 ArgeoRapApp app
= new ArgeoRapApp(bundleContext
, bundle
, null);
57 Hashtable
<String
, String
> props
= new Hashtable
<String
, String
>();
58 props
.put(AbstractRapE4App
.CONTEXT_NAME_PROPERTY
, app
.getContextName());
59 bundleContext
.registerService(ApplicationConfiguration
.class, app
, props
);
61 if (log
.isDebugEnabled())
62 log
.debug("Deployed Argeo App " + bundle
.getSymbolicName() + " to " + app
.getContextName());
66 public void deleted(String pid
) {
69 protected Bundle
findBundle(String pid
, Dictionary
<String
, ?
> properties
) {
71 for (Bundle b
: bundleContext
.getBundles()) {
72 if (b
.getSymbolicName().equals(pid
)) {
78 throw new IllegalStateException("Bundle " + pid
+ " not found");