org.apache.felix.ipojo.api

## Class Service

- java.lang.Object
- - org.apache.felix.ipojo.api.Service

All Implemented Interfaces:
  HandlerConfiguration

    public class Service
    extends java.lang.Object
    implements HandlerConfiguration

Allows configuring a provided service.

Author:
  Felix Project Team

### Field Summary

Fields
`static int` `INSTANCE_STRATEGY` Creation strategy : one service object per instance.
`static int` `SERVICE_STRATEGY` Creation strategy : one service object per bundle (OSGi service factory).
`static int` `SINGLETON_STRATEGY` Creation strategy : singleton (default).
`static int` `STATIC_STRATEGY` Creation strategy : delegate on the static factory method.

### Constructor Summary

Constructors
Constructor and Description
`Service()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Service` `addProperty(ServiceProperty ps)` Adds a service property.
`Service` `addProperty(java.lang.String key, java.lang.Object obj)` Adds a service property.
`org.apache.felix.ipojo.metadata.Element` `getElement()` Gets the provided service element.
`ProvidedServiceDescription` `getProvidedServiceDescription(ComponentInstance instance)` Gets the provided service description associated with the current service.
`Service` `setCreationStrategy(int strategy)` Sets the creation strategy.
`Service` `setCreationStrategy(java.lang.String strategy)` Sets the creation strategy.
`Service` `setPostRegistrationCallback(java.lang.String callback)` Sets the post-registration callback.
`Service` `setPostUnregistrationCallback(java.lang.String callback)` Sets the post-unregistration callback.
`Service` `setServiceController(java.lang.String field, boolean initialValue)` Sets the service controller.
`Service` `setSpecification(java.lang.String spec)` Sets the provided service specification.
`Service` `setSpecifications(java.util.List specs)` Sets the provided service specifications.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SINGLETON_STRATEGY

    public static final int SINGLETON_STRATEGY

Creation strategy : singleton (default).

See Also:
  Constant Field Values

#### STATIC_STRATEGY

    public static final int STATIC_STRATEGY

Creation strategy : delegate on the static factory method.

See Also:
  Constant Field Values

#### INSTANCE_STRATEGY

    public static final int INSTANCE_STRATEGY

Creation strategy : one service object per instance.

See Also:
  Constant Field Values

#### SERVICE_STRATEGY

    public static final int SERVICE_STRATEGY

Creation strategy : one service object per bundle (OSGi service factory).

See Also:
  Constant Field Values

### Constructor Detail

#### Service

    public Service()

### Method Detail

#### getElement

    public org.apache.felix.ipojo.metadata.Element getElement()

Gets the provided service element.

Specified by:
  `getElement` in interface `HandlerConfiguration`
Returns:
  the 'provides' element.

#### getProvidedServiceDescription

    public ProvidedServiceDescription getProvidedServiceDescription(ComponentInstance instance)

Gets the provided service description associated with the current service.

Parameters:
  `instance` - the instance on which looking for the provided service description
Returns:
  the provided service description or `null` if not found.

#### addProperty

    public Service addProperty(ServiceProperty ps)

Adds a service property.

Parameters:
  `ps` - the service property to add
Returns:
  the current service object.

#### addProperty

    public Service addProperty(java.lang.String key,
                               java.lang.Object obj)

Adds a service property.

Parameters:
  `key` - the property key
  `obj` - the initial value (can be `null`)
Returns:
  the current service object.

#### setSpecification

    public Service setSpecification(java.lang.String spec)

Sets the provided service specification.

Parameters:
  `spec` - the service specification
Returns:
  the current service object.

#### setSpecifications

    public Service setSpecifications(java.util.List specs)

Sets the provided service specifications.

Parameters:
  `specs` - the service specifications
Returns:
  the current service object.

#### setCreationStrategy

    public Service setCreationStrategy(int strategy)

Sets the creation strategy.

Parameters:
  `strategy` - the service strategy.
Returns:
  the current service object

#### setCreationStrategy

    public Service setCreationStrategy(java.lang.String strategy)

Sets the creation strategy. This method allows using a customized service strategy.

Parameters:
  `strategy` - the service strategy
Returns:
  the current service object

#### setServiceController

    public Service setServiceController(java.lang.String field,
                                        boolean initialValue)

Sets the service controller.

Parameters:
  `field` - the controller field
  `initialValue` - the initial value
Returns:
  the current service object

#### setPostRegistrationCallback

    public Service setPostRegistrationCallback(java.lang.String callback)

Sets the post-registration callback.

Parameters:
  `callback` - the callback name (method name)
Returns:
  the current service object

#### setPostUnregistrationCallback

    public Service setPostUnregistrationCallback(java.lang.String callback)

Sets the post-unregistration callback.

Parameters:
  `callback` - the callback name (method name)
Returns:
  the current service object