org.appdapter.osgi.registry
Class RegistryServiceFuncs

java.lang.Object
  extended by org.appdapter.osgi.registry.RegistryServiceFuncs

public class RegistryServiceFuncs
extends Object

Can work with or without OSGi. To use (possibly) outside of OSGi, use getTheWellKnownRegistry() (flexible, will try OSGi lookup first), or, to be extra something, you could call getTheWellKnownStaticRegistry(), but that will cause trouble if you really are in OSGi.

Author:
Stu B.

Field Summary
static Class THE_WELL_KNOWN_REG_DEFAULT_IMPL
           
static Class THE_WELL_KNOWN_REG_DEFAULT_INTF
           
 
Constructor Summary
RegistryServiceFuncs()
           
 
Method Summary
static VerySimpleRegistry getTheWellKnownRegistry()
          Attempts to find OSGi bundle context, using OSG Framework.getBundle(RegistryServiceFuncs.class).
static VerySimpleRegistry getTheWellKnownRegistryUsingOptContext(org.osgi.framework.BundleContext bundleCtx)
          Will use the bundleCtx, if it is not null.
static VerySimpleRegistry getTheWellKnownRegistryUsingReqContext(org.osgi.framework.BundleContext bundleCtx)
          Use this when you are sure you should be in OSGi, and bundleCtx should not be null.
static VerySimpleRegistry getTheWellKnownStaticRegistry()
          Don't use in OSGi context, b/c you will probably wind up with two separate well known registries.
static VerySimpleRegistry lookupTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx)
          Requires OSGi context.
static
<RT extends Registry>
RT
lookupTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx, Class<RT> rtClazz)
          Requires OSGi context.
static
<RT extends Registry>
org.osgi.framework.ServiceRegistration
registerTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx, Class<RT> regClazz, RT wellKnownReg)
          Requires OSGi context.
static org.osgi.framework.ServiceRegistration registerTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx, VerySimpleRegistry wellKnownReg)
          Requires OSGi context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THE_WELL_KNOWN_REG_DEFAULT_INTF

public static Class THE_WELL_KNOWN_REG_DEFAULT_INTF

THE_WELL_KNOWN_REG_DEFAULT_IMPL

public static Class THE_WELL_KNOWN_REG_DEFAULT_IMPL
Constructor Detail

RegistryServiceFuncs

public RegistryServiceFuncs()
Method Detail

registerTheWellKnownRegistry

public static <RT extends Registry> org.osgi.framework.ServiceRegistration registerTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx,
                                                                                                        Class<RT> regClazz,
                                                                                                        RT wellKnownReg)
Requires OSGi context.

Type Parameters:
RT -
Parameters:
bundleCtx -
regClazz -
wellKnownReg -
Returns:

registerTheWellKnownRegistry

public static org.osgi.framework.ServiceRegistration registerTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx,
                                                                                  VerySimpleRegistry wellKnownReg)
Requires OSGi context.

Parameters:
bundleCtx -
wellKnownReg -
Returns:

lookupTheWellKnownRegistry

public static <RT extends Registry> RT lookupTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx,
                                                                  Class<RT> rtClazz)
Requires OSGi context.

Type Parameters:
RT -
Parameters:
bundleCtx -
rtClazz -
Returns:

lookupTheWellKnownRegistry

public static VerySimpleRegistry lookupTheWellKnownRegistry(org.osgi.framework.BundleContext bundleCtx)
Requires OSGi context.


getTheWellKnownRegistryUsingReqContext

public static VerySimpleRegistry getTheWellKnownRegistryUsingReqContext(org.osgi.framework.BundleContext bundleCtx)
Use this when you are sure you should be in OSGi, and bundleCtx should not be null.

Parameters:
bundleCtx -
Returns:

getTheWellKnownStaticRegistry

public static VerySimpleRegistry getTheWellKnownStaticRegistry()
Don't use in OSGi context, b/c you will probably wind up with two separate well known registries.


getTheWellKnownRegistryUsingOptContext

public static VerySimpleRegistry getTheWellKnownRegistryUsingOptContext(org.osgi.framework.BundleContext bundleCtx)
Will use the bundleCtx, if it is not null. Else will use static registry.

Parameters:
bundleCtx -
Returns:

getTheWellKnownRegistry

public static VerySimpleRegistry getTheWellKnownRegistry()
Attempts to find OSGi bundle context, using OSG Framework.getBundle(RegistryServiceFuncs.class). Uses it when successful, otherwise uses static version.

Returns:


Copyright © 2010-2012. All Rights Reserved.