Top Description Inners Fields Constructors Methods
org.javamoney.moneta

public final Class OSGIServiceHelper

extends Object
Class Inheritance
Imports
org.javamoney.moneta.spi.PriorityServiceComparator, org.osgi.framework.*, java.net.URL, java.util.*, java.util.logging.Level, .Logger

ServiceContext implementation based on OSGI Service mechanisms.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
OSGIServiceHelper.JDKUtilServiceFactory<S>

Service factory simply instantiating the configured service.

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Enumeration<URL>
getResources(BundleContext bundleContext, String resource)

public static <T> void
registerService(Bundle bundle, Class<T> serviceClass, Class<? extends T> implClass)

public static <T> void
unregisterService(Bundle bundle, Class<T> serviceClass, Class<? extends T> implClass)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG

Constructor Detail

OSGIServiceHelperback to summary
private OSGIServiceHelper()

Method Detail

getResourcesback to summary
public Enumeration<URL> getResources(BundleContext bundleContext, String resource)
registerServiceback to summary
public static <T> void registerService(Bundle bundle, Class<T> serviceClass, Class<? extends T> implClass)
unregisterServiceback to summary
public static <T> void unregisterService(Bundle bundle, Class<T> serviceClass, Class<? extends T> implClass)
org.javamoney.moneta back to summary

pack-priv Class OSGIServiceHelper.JDKUtilServiceFactory<S>

extends Object
implements ServiceFactory<S>
Class Inheritance
All Implemented Interfaces
org.osgi.framework.ServiceFactory

Service factory simply instantiating the configured service.

Field Summary

Modifier and TypeField and Description
private final Class<? extends S>

Constructor Summary

AccessConstructor and Description
public
JDKUtilServiceFactory(Class<? extends S> serviceClass)

Method Summary

Modifier and TypeMethod and Description
public S
getService(Bundle bundle, ServiceRegistration<S> registration)

Implements org.osgi.framework.ServiceFactory.getService.

Returns a service object for a bundle.

public void
ungetService(Bundle bundle, ServiceRegistration<S> registration, S service)

Implements org.osgi.framework.ServiceFactory.ungetService.

Releases a service object customized for a bundle.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serviceClassback to summary
private final Class<? extends S> serviceClass

Constructor Detail

JDKUtilServiceFactoryback to summary
public JDKUtilServiceFactory(Class<? extends S> serviceClass)

Method Detail

getServiceback to summary
public S getService(Bundle bundle, ServiceRegistration<S> registration)

Implements org.osgi.framework.ServiceFactory.getService.

Doc from org.osgi.framework.ServiceFactory.getService.

Returns a service object for a bundle.

The Framework invokes this method the first time the specified bundle requests a service object using the BundleContext#getService(ServiceReference) method. The factory can then return a customized service object for each bundle.

The Framework must check that the returned service object is valid. If the returned service object is null or is not an instanceof all the classes named when the service was registered, a framework event of type FrameworkEvent#ERROR is fired containing a service exception of type ServiceException#FACTORY_ERROR and null is returned to the bundle. If this method throws an exception, a framework event of type FrameworkEvent#ERROR is fired containing a service exception of type ServiceException#FACTORY_EXCEPTION with the thrown exception as the cause and null is returned to the bundle. If this method is recursively called for the specified bundle, a framework event of type FrameworkEvent#ERROR is fired containing a service exception of type ServiceException#FACTORY_RECURSION and null is returned to the bundle.

The Framework caches the valid service object and will return the same service object on any future call to BundleContext#getService(ServiceReference) for the specified bundle. This means the Framework must not allow this method to be concurrently called for the specified bundle.

Annotations
@Override
ungetServiceback to summary
public void ungetService(Bundle bundle, ServiceRegistration<S> registration, S service)

Implements org.osgi.framework.ServiceFactory.ungetService.

Doc from org.osgi.framework.ServiceFactory.ungetService.

Releases a service object customized for a bundle.

The Framework invokes this method when a service has been released by a bundle. The service object may then be destroyed.

If this method throws an exception, a framework event of type FrameworkEvent#ERROR is fired containing a service exception of type ServiceException#FACTORY_EXCEPTION with the thrown exception as the cause.

Annotations
@Override