]> git.argeo.org Git - lgpl/argeo-commons.git/blob - Activator.java
e10da3aedb534d32fd074e81ffa7a9a3b9618bdf
[lgpl/argeo-commons.git] / Activator.java
1 package org.argeo.cms.ui.internal;
2
3 import org.argeo.api.cms.CmsState;
4 import org.osgi.framework.BundleActivator;
5 import org.osgi.framework.BundleContext;
6 import org.osgi.util.tracker.ServiceTracker;
7
8 public class Activator implements BundleActivator {
9
10 // avoid dependency to RWT OSGi
11 private final static String CONTEXT_NAME_PROP = "contextName";
12
13 private static ServiceTracker<CmsState, CmsState> nodeState;
14
15 // @Override
16 public void start(BundleContext bc) throws Exception {
17 // UI
18 // bc.registerService(ApplicationConfiguration.class, new MaintenanceUi(),
19 // LangUtils.dico(CONTEXT_NAME_PROP, "system"));
20 // bc.registerService(ApplicationConfiguration.class, new UserUi(), LangUtils.dico(CONTEXT_NAME_PROP, "user"));
21
22 nodeState = new ServiceTracker<>(bc, CmsState.class, null);
23 nodeState.open();
24 }
25
26 @Override
27 public void stop(BundleContext context) throws Exception {
28 if (nodeState != null) {
29 nodeState.close();
30 nodeState = null;
31 }
32 }
33
34 public static CmsState getNodeState() {
35 return nodeState.getService();
36 }
37 }