ServiceFactory

Syntax

public interface ServiceFactory

Description

Service factories allow services to provide customized service objects. In order to gain control over the specific service object given to a bundle using the service, a bundle programmer can register a ServiceFactory object instead of a service object when registering a service.

When this is done, the BundleContext.getService(ServiceReference) method calls the service factory's getService(Bundle, ServiceRegistration) to create a service object specifically for the requesting bundle. The service object returned by the service factory is cached by the framework until the bundle releases its use of the service.

When the bundle's use count for the service drops to zero (including ...

Get Programming Open Service Gateways with Java Embedded Server™ Technology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.