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

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

public class ProvidedService
extends java.lang.Object
implements org.osgi.framework.ServiceFactory

Provided Service represent a provided service by the component.

Author:
Felix Project Team

Field Summary
static int REGISTERED
          Service State : REGISTRED.
static int SERVICE_FACTORY
          Factory policy : SERVICE_FACTORY.
static int SINGLETON_FACTORY
          Factory Policy : SINGLETON_FACTORY.
static int STATIC_FACTORY
          Factory policy : STATIC_FACTORY.
static int UNREGISTERED
          Service State : UNREGISTRED.
 
Constructor Summary
ProvidedService(ProvidedServiceHandler handler, java.lang.String[] specification, int factoryPolicy)
          Construct a provided service object.
 
Method Summary
protected  void addProperties(java.util.Dictionary props)
          Add properties to the list.
protected  void deleteProperties(java.util.Dictionary props)
          Remove properties from the list.
protected  InstanceManager getInstanceManager()
           
 Property[] getProperties()
          Get the list of properties attached to the service registration.
 java.lang.Object getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration registration)
          Return a service object for the dependency.
 org.osgi.framework.ServiceReference getServiceReference()
          Get the service reference of the service registration.
 org.osgi.framework.ServiceRegistration getServiceRegistration()
          Get the service registration.
 java.lang.String[] getServiceSpecification()
          Get the published service specifications.
 int getState()
          Get the current provided service state.
protected  void registerService()
          Register the service.
protected  void setProperties(Property[] props)
          Add properties to the provided service.
 void ungetService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration registration, java.lang.Object service)
          The unget method.
protected  void unregisterService()
          Unregister 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_FACTORY

public static final int SINGLETON_FACTORY
Factory Policy : SINGLETON_FACTORY.

See Also:
Constant Field Values

SERVICE_FACTORY

public static final int SERVICE_FACTORY
Factory policy : SERVICE_FACTORY.

See Also:
Constant Field Values

STATIC_FACTORY

public static final int STATIC_FACTORY
Factory policy : STATIC_FACTORY.

See Also:
Constant Field Values
Constructor Detail

ProvidedService

public ProvidedService(ProvidedServiceHandler handler,
                       java.lang.String[] specification,
                       int factoryPolicy)
Construct a provided service object.

Parameters:
handler - : the provided service handler.
specification - : specifications provided by this provided service
factoryPolicy - : service providing policy
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 org.osgi.framework.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 java.lang.Object getService(org.osgi.framework.Bundle bundle,
                                   org.osgi.framework.ServiceRegistration registration)
Return a service object for the dependency.

Specified by:
getService in interface org.osgi.framework.ServiceFactory
Parameters:
bundle - : the bundle
registration - : the service registration of the registred service
Returns:
: a new service object or a already created service object (in the case of singleton)
See Also:
ServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)

ungetService

public void ungetService(org.osgi.framework.Bundle bundle,
                         org.osgi.framework.ServiceRegistration registration,
                         java.lang.Object service)
The unget method.

Specified by:
ungetService in interface org.osgi.framework.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()
Register the service. The service object must be able to serve this service. To avoid cycle in Check Context, the registered service is set to registered before the real registration.


unregisterService

protected void unregisterService()
Unregister 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 sended to the service registry.


addProperties

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

Parameters:
props - : properties to add

deleteProperties

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

Parameters:
props - : properties to remove

getServiceSpecification

public java.lang.String[] getServiceSpecification()
Get the published service specifications.

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

getServiceRegistration

public org.osgi.framework.ServiceRegistration getServiceRegistration()
Get the service registration.

Returns:
the service registration of this service.