aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-11-04 15:00:19 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-11-04 15:00:19 +0000
commit73e1aab26413c9ff586b3fa1c3b902eb35a08d70 (patch)
tree7b95a286257766685786111802f198e9155d2f29 /src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
parentb29032a326a9e64b534a24df0ced668b67b34835 (diff)
downloadjitsi-73e1aab26413c9ff586b3fa1c3b902eb35a08d70.zip
jitsi-73e1aab26413c9ff586b3fa1c3b902eb35a08d70.tar.gz
jitsi-73e1aab26413c9ff586b3fa1c3b902eb35a08d70.tar.bz2
Refactors the ConfigurationService implementation in preparation for providing a database store.
Diffstat (limited to 'src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java')
-rw-r--r--src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java79
1 files changed, 63 insertions, 16 deletions
diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
index b7b9279..68b28b3 100644
--- a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
+++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
@@ -13,7 +13,7 @@ import net.java.sip.communicator.util.*;
/**
* @author Emil Ivov
- * @author Lubomir Marinov
+ * @author Lyubomir Marinov
*/
public class ConfigurationActivator
implements BundleActivator
@@ -26,6 +26,12 @@ public class ConfigurationActivator
= Logger.getLogger(ConfigurationServiceImpl.class);
/**
+ * The <tt>BundleContext</tt> in which the configuration bundle has been
+ * started and has not been stopped yet.
+ */
+ private static BundleContext bundleContext;
+
+ /**
* The <tt>ConfigurationService</tt> implementation provided by the bundle
* represented by this <tt>ConfigurationActivator</tt>.
*/
@@ -33,6 +39,18 @@ public class ConfigurationActivator
= new ConfigurationServiceImpl();
/**
+ * Gets the <tt>BundleContext</tt> in which the configuration bundle has
+ * been started and has not been stopped yet.
+ *
+ * @return the <tt>BundleContext</tt> in which the configuration bundle has
+ * been started and has not been stopped yet
+ */
+ public static BundleContext getBundleContext()
+ {
+ return bundleContext;
+ }
+
+ /**
* Starts the configuration service
*
* @param bundleContext the <tt>BundleContext</tt> as provided by the OSGi
@@ -42,19 +60,41 @@ public class ConfigurationActivator
public void start(BundleContext bundleContext)
throws Exception
{
- if (logger.isDebugEnabled())
- logger.debug("Service Impl: " + getClass().getName() +
- " [ STARTED ]");
+ boolean started = false;
+
+ ConfigurationActivator.bundleContext = bundleContext;
+ try
+ {
+ if (logger.isDebugEnabled())
+ {
+ logger.debug(
+ "Service Impl: "
+ + getClass().getName()
+ + " [ STARTED ]");
+ }
- impl.start(bundleContext);
+ impl.start(bundleContext);
+ bundleContext.registerService(
+ ConfigurationService.class.getName(),
+ impl,
+ null);
- bundleContext.registerService(ConfigurationService.class.getName(),
- impl,
- null);
+ if (logger.isDebugEnabled())
+ {
+ logger.debug(
+ "Service Impl: "
+ + getClass().getName()
+ + " [REGISTERED]");
+ }
- if (logger.isDebugEnabled())
- logger.debug("Service Impl: " + getClass().getName() +
- " [REGISTERED]");
+ started = true;
+ }
+ finally
+ {
+ if (!started
+ && (ConfigurationActivator.bundleContext == bundleContext))
+ ConfigurationActivator.bundleContext = null;
+ }
}
/**
@@ -69,10 +109,17 @@ public class ConfigurationActivator
public void stop(BundleContext bundleContext)
throws Exception
{
- logger.logEntry();
- impl.stop();
- if (logger.isInfoEnabled())
- logger.info(
- "The ConfigurationService stop method has been called.");
+ try
+ {
+ logger.logEntry();
+ impl.stop();
+ if (logger.isInfoEnabled())
+ logger.info("ConfigurationService#stop() has been called.");
+ }
+ finally
+ {
+ if (ConfigurationActivator.bundleContext == bundleContext)
+ ConfigurationActivator.bundleContext = null;
+ }
}
}