Can deploy and Argeo RAP app independently.
[gpl/argeo-suite.git] / org.argeo.suite.e4.rap / src / org / argeo / suite / e4 / rap / settings / AppDeployer.java
index f19220b8e600d7a2606f93327ee1dc6951b51d26..c1588119efd1a8a8ef178c8c94f5e55eec59ac1c 100644 (file)
@@ -8,21 +8,28 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.cms.e4.rap.AbstractRapE4App;
 import org.argeo.cms.ui.util.CmsTheme;
+import org.argeo.util.LangUtils;
 import org.eclipse.rap.rwt.application.ApplicationConfiguration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
 
+/**
+ * Managed service factory deploying Argeo RAP app based on OSGi configurations.
+ */
 public class AppDeployer implements ManagedServiceFactory {
+       public final static String CMS_THEME_BUNDLE_PROPERTY = "argeo.cms.theme.bundle";
+       public final static String DEFAULT_CMS_THEME_BUNDLE = "org.argeo.theme.argeo2";
+
        private final static Log log = LogFactory.getLog(AppDeployer.class);
        private BundleContext bundleContext;
 
        public void init(BundleContext bundleContext, Map<String, String> properties) {
                this.bundleContext = bundleContext;
 
-               deploy(findBundle("org.argeo.suite.studio", null));
-               deploy(findBundle("org.argeo.suite.docs", null));
+               deploy(findBundle("org.argeo.suite.studio", null), properties);
+               deploy(findBundle("org.argeo.suite.docs", null), properties);
        }
 
        public void destroy() {
@@ -37,13 +44,19 @@ public class AppDeployer implements ManagedServiceFactory {
        @Override
        public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
                Bundle bundle = findBundle(pid, properties);
-               deploy(bundle);
+               deploy(bundle, LangUtils.dictToStringMap(properties));
        }
 
-       protected void deploy(Bundle bundle) {
-               CmsTheme cmsTheme = new CmsTheme(bundleContext, "org.argeo.theme.argeo2");
+       protected void deploy(Bundle bundle, Map<String, String> properties) {
+               CmsTheme cmsTheme;
+               if (properties.containsKey(CMS_THEME_BUNDLE_PROPERTY)) {
+                       String cmsThemeBundle = properties.get(CMS_THEME_BUNDLE_PROPERTY);
+                       cmsTheme = new CmsTheme(bundleContext, cmsThemeBundle);
+               } else {
+                       cmsTheme = new CmsTheme(bundleContext, DEFAULT_CMS_THEME_BUNDLE);
+               }
 
-               ArgeoRapApp app = new ArgeoRapApp(bundle, cmsTheme);
+               ArgeoRapApp app = new ArgeoRapApp(bundleContext, bundle, cmsTheme);
 
                Hashtable<String, String> props = new Hashtable<String, String>();
                props.put(AbstractRapE4App.CONTEXT_NAME_PROPERTY, app.getContextName());