|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.wsspi.runtime.service.WsServiceRegistry
public final class WsServiceRegistry
A meta-service that provides methods for WebSphere components to register services and locate services.
In order to use this registry, clients must be exeucting in a bundle and that bundle must register with the registry (see registerBundleContext).
Examples
Registering as a Service
Suppose you have a service interface and an implementation of that interface
which you wish to register:
public interface MyServiceIF {...}
public class MyServiceImpl implements MyServiceIF {...}
The service can be registered via the following pattern:
MyServiceImpl impl = ...;
WsServiceRegistry.addService(impl, MyServiceIF.class);
Locating a Registered Service
Given the service registered in the previous example, code elsewhere in the
server can access that service via the following pattern:
MyServiceImpl service = (MyServiceImpl)WsServiceRegistry.getService(this,MyServiceImpl.class);
service.foo();
Constructor Summary | |
---|---|
WsServiceRegistry()
|
Method Summary | |
---|---|
static java.lang.Object |
addService(java.lang.Object serviceImplementation,
java.lang.Class serviceInterface)
Registers a service (implementation) via the given service interface. |
static java.lang.Object |
getService(java.lang.Object requestor,
java.lang.Class serviceInterface)
Returns the service that registered with the specified service class. |
static void |
registerBundleContext(org.osgi.framework.BundleActivator activator,
org.osgi.framework.BundleContext context)
Registers BundleContext object with this meta-service. |
static void |
unregisterBundleContext(org.osgi.framework.BundleActivator activator,
org.osgi.framework.BundleContext context)
Unregisters BundleContext object with this meta-service. |
static void |
unregisterService(java.lang.Object token)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WsServiceRegistry()
Method Detail |
---|
public static java.lang.Object addService(java.lang.Object serviceImplementation, java.lang.Class serviceInterface) throws java.lang.Exception
serviceImplementation
- The implementation of the service that is being registered.serviceInterface
- The interface of the service that is being registered. The
serviceImplementation must implement this interface.
java.lang.Exception
- When registration fails.public static void unregisterService(java.lang.Object token)
public static java.lang.Object getService(java.lang.Object requestor, java.lang.Class serviceInterface) throws java.lang.Exception
requestor
- Component requesting access to service (typically this
).serviceInterface
- Interface class for the service registered.
java.lang.Exception
- thrown if service could not be obtained.public static void registerBundleContext(org.osgi.framework.BundleActivator activator, org.osgi.framework.BundleContext context) throws java.lang.Exception
context
- BundleContext to register
java.lang.IllegalArgumentException
- if parameters are illegal
java.lang.Exception
- if the bundle context had already been registeredpublic static void unregisterBundleContext(org.osgi.framework.BundleActivator activator, org.osgi.framework.BundleContext context) throws java.lang.Exception
context
-
java.lang.Exception
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |