From 0e9b96f460cc3aa57e40dd2063231827a82af2bb Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Fri, 28 Jul 2006 13:49:57 +0000 Subject: [PATCH] Added static methods for retrieving --- .../impl/protocol/sip/SipActivator.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java index cd8de3861..bc35a29e6 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java @@ -8,6 +8,9 @@ import org.osgi.framework.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.service.configuration.*; +import java.util.*; +import net.java.sip.communicator.service.protocol.*; /** * Activates the SIP package @@ -18,6 +21,12 @@ public class SipActivator { private Logger logger = Logger.getLogger(SipActivator.class.getName()); + private ServiceRegistration sipPpFactoryServReg = null; + private static BundleContext bundleContext = null; + private static ConfigurationService configurationService = null; + + private static ProtocolProviderFactorySipImpl sipProviderFactory = null; + /** * Called when this bundle is started so the Framework can perform the * bundle-specific activities necessary to start this bundle. @@ -31,6 +40,63 @@ public class SipActivator public void start(BundleContext context) throws Exception { logger.debug("Started."); + this.bundleContext = context; + Hashtable hashtable = new Hashtable(); + hashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.SIP); + + sipProviderFactory = new ProtocolProviderFactorySipImpl(); + + //load all icq providers + sipProviderFactory.loadStoredAccounts(); + + //reg the icq account man. + sipPpFactoryServReg = context.registerService( + ProtocolProviderFactory.class.getName(), + sipProviderFactory, + hashtable); + + } + + /** + * Returns a reference to a ConfigurationService implementation currently + * registered in the bundle context or null if no such implementation was + * found. + * + * @return ConfigurationService a currently valid implementation of the + * configuration service. + */ + public static ConfigurationService getConfigurationService() + { + if(configurationService == null) + { + ServiceReference confReference + = bundleContext.getServiceReference( + ConfigurationService.class.getName()); + configurationService + = (ConfigurationService) bundleContext.getService(confReference); + } + return configurationService; + } + + /** + * Returns a reference to the bundle context that we were started with. + * @return a reference to the BundleContext instance that we were started + * witn. + */ + public static BundleContext getBundleContext() + { + return bundleContext; + } + + /** + * Retrurns a reference to the protocol provider factory that we have + * registered. + * @return a reference to the ProtocolProviderFactorySipImpl + * instance that we have registered from this package. + */ + static ProtocolProviderFactorySipImpl getProtocolProviderFactory() + { + return sipProviderFactory; } /**