Application Platform 10.3 | Application Platform API | Looking up Services from the OSGi Registry
 
Looking up Services from the OSGi Registry
 
Configuring POJO Services Dynamically
The following table describes the class you can use to look up services from the OSGi registry.
Class and Description
com.softwareag.applatform.sdk.ServiceUtil
A helper class that provides utility methods when working with OSGi services. Use this class to look up registered services.
Public API Methods in ServiceUtil Class
The following table describes the public API methods in the ServiceUtil class and specifies the return type and method arguments for each method type.
Method Name
Return Type
Method Arguments
Description
getService
T
ServletContext servletCtxClass<T> serviceCls
Returns the instance of the OSGi service of type serviceCls from the specified ServletContext. This method looks for an instance of BundleContext in the ServletContext under the attribute name osgi-bundlecontext and use the obtained BundleContext to look up the service.
getService
T
Class<T> serviceClsBundleContext bundleCtx
Gets the OSGi service of given serviceCls type using the given BundleContext. If no service of the serviceCls type is registered, this method returns a null value.
getBundleContext
BundleContext
Class<?> bundleCls
Gets the BundleContext from the bundle containing the given class. If there is no BundleContext specified, this method returns a null value.
getService
T
Class<T> serviceCls
Gets the OSGi service for the given service class type. If no service of the specified type is registered, this method returns a null value.