org.apache.felix.ipojo.handlers.providedservice
Class ProvidedService

java.lang.Object
  extended by org.apache.felix.ipojo.handlers.providedservice.ProvidedService
All Implemented Interfaces:
ServiceFactory

public class ProvidedService
extends Object
implements ServiceFactory

Provided Service represent a provided service by the component.

Author:
Felix Project Team

Field Summary
static int INSTANCE_STRATEGY
          Factory policy : INSTANCE.
static int REGISTERED
          Service State : REGISTRED.
static int SERVICE_STRATEGY
          Factory policy : SERVICE_FACTORY.
static int SINGLETON_STRATEGY
          Factory Policy : SINGLETON_FACTORY.
static int STATIC_STRATEGY
          Factory policy : STATIC_FACTORY.
static int UNREGISTERED
          Service State : UNREGISTRED.
 
Constructor Summary
ProvidedService(ProvidedServiceHandler handler, String[] specification, int factoryPolicy, Class creationStrategyClass, Dictionary conf)
          Creates a provided service object.
 
Method Summary
protected  void addProperties(Dictionary props)
          Add properties to the list.
protected  void deleteProperties(Dictionary props)
          Remove properties from the list.
 org.apache.felix.ipojo.handlers.providedservice.ProvidedService.ServiceController getController(String field)
           
 org.apache.felix.ipojo.handlers.providedservice.ProvidedService.ServiceController getControllerBySpecification(String spec)
           
protected  InstanceManager getInstanceManager()
           
 Property[] getProperties()
          Get the list of properties attached to the service registration.
 Object getService(Bundle bundle, ServiceRegistration registration)
          Returns a service object for the dependency.
 ServiceReference getServiceReference()
          Get the service reference of the service registration.
 ServiceRegistration getServiceRegistration()
          Get the service registration.
 String[] getServiceSpecifications()
          Get the published service specifications.
 int getState()
          Get the current provided service state.
protected  void registerService()
          Registers the service.
 void setController(String field, boolean value, String specification)
          Sets the service controller on this provided service.
 void setPostRegistrationCallback(Callback cb)
           
 void setPostUnregistrationCallback(Callback cb)
           
protected  void setProperties(Property[] props)
          Add properties to the provided service.
 void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
          The unget method.
protected  void unregisterService()
          Unregisters the service.
 void update()
          Update the service properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGISTERED

public static final int REGISTERED
Service State : REGISTRED.

See Also:
Constant Field Values

UNREGISTERED

public static final int UNREGISTERED
Service State : UNREGISTRED.

See Also:
Constant Field Values

SINGLETON_STRATEGY

public static final int SINGLETON_STRATEGY
Factory Policy : SINGLETON_FACTORY.

See Also:
Constant Field Values

SERVICE_STRATEGY

public static final int SERVICE_STRATEGY
Factory policy : SERVICE_FACTORY.

See Also:
Constant Field Values

STATIC_STRATEGY

public static final int STATIC_STRATEGY
Factory policy : STATIC_FACTORY.

See Also:
Constant Field Values

INSTANCE_STRATEGY

public static final int INSTANCE_STRATEGY
Factory policy : INSTANCE. Creates one service object per instance consuming the service.

See Also:
Constant Field Values
Constructor Detail

ProvidedService

public ProvidedService(ProvidedServiceHandler handler,
                       String[] specification,
                       int factoryPolicy,
                       Class creationStrategyClass,
                       Dictionary conf)
Creates a provided service object.

Parameters:
handler - the the provided service handler.
specification - the specifications provided by this provided service
factoryPolicy - the service providing policy
creationStrategyClass - the customized service object creation strategy.
conf - the instance configuration.
Method Detail

setProperties

protected void setProperties(Property[] props)
Add properties to the provided service.

Parameters:
props - : the properties to attached to the service registration

getServiceReference

public ServiceReference getServiceReference()
Get the service reference of the service registration.

Returns:
the service reference of the provided service (null if the service is not published).

getService

public Object getService(Bundle bundle,
                         ServiceRegistration registration)
Returns a service object for the dependency.

Specified by:
getService in interface ServiceFactory
Parameters:
bundle - : the bundle
registration - : the service registration of the registered service
Returns:
a new service object or a already created service object (in the case of singleton) or null if the instance is no more valid.
See Also:
ServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)

ungetService

public void ungetService(Bundle bundle,
                         ServiceRegistration registration,
                         Object service)
The unget method.

Specified by:
ungetService in interface ServiceFactory
Parameters:
bundle - : bundle
registration - : service registration
service - : service object
See Also:
ServiceFactory.ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)

registerService

protected void registerService()
Registers the service. The service object must be able to serve this service. This method also notifies the creation strategy of the publication.


unregisterService

protected void unregisterService()
Unregisters the service.


getState

public int getState()
Get the current provided service state.

Returns:
The state of the provided service.

getInstanceManager

protected InstanceManager getInstanceManager()

getProperties

public Property[] getProperties()
Get the list of properties attached to the service registration.

Returns:
the properties attached to the provided service.

update

public void update()
Update the service properties. The new list of properties is sent to the service registry.


addProperties

protected void addProperties(Dictionary props)
Add properties to the list.

Parameters:
props - : properties to add

deleteProperties

protected void deleteProperties(Dictionary props)
Remove properties from the list.

Parameters:
props - : properties to remove

getServiceSpecifications

public String[] getServiceSpecifications()
Get the published service specifications.

Returns:
the list of provided service specifications (i.e. java interface).

getServiceRegistration

public ServiceRegistration getServiceRegistration()
Get the service registration.

Returns:
the service registration of this service.

setController

public void setController(String field,
                          boolean value,
                          String specification)
Sets the service controller on this provided service.

Parameters:
field - the field attached to this controller
value - the value the initial value
specification - the target specification, if null affect all specifications.

getController

public org.apache.felix.ipojo.handlers.providedservice.ProvidedService.ServiceController getController(String field)

getControllerBySpecification

public org.apache.felix.ipojo.handlers.providedservice.ProvidedService.ServiceController getControllerBySpecification(String spec)

setPostRegistrationCallback

public void setPostRegistrationCallback(Callback cb)

setPostUnregistrationCallback

public void setPostUnregistrationCallback(Callback cb)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.