org.apache.felix.dm
Interface ServiceDependency

All Superinterfaces:
ComponentDependencyDeclaration, Dependency
All Known Subinterfaces:
TemporalServiceDependency
All Known Implementing Classes:
ServiceDependencyImpl, TemporalServiceDependencyImpl

public interface ServiceDependency
extends Dependency, ComponentDependencyDeclaration

Service dependency that can track an OSGi service.

Author:
Felix Project Team

Field Summary
 
Fields inherited from interface org.apache.felix.dm.ComponentDependencyDeclaration
STATE_AVAILABLE_OPTIONAL, STATE_AVAILABLE_REQUIRED, STATE_NAMES, STATE_UNAVAILABLE_OPTIONAL, STATE_UNAVAILABLE_REQUIRED
 
Method Summary
 ServiceDependency setAutoConfig(boolean autoConfig)
          Sets auto configuration for this service.
 ServiceDependency setAutoConfig(String instanceName)
          Sets auto configuration for this service.
 ServiceDependency setCallbacks(Object instance, String added, String removed)
          Sets the callbacks for this service.
 ServiceDependency setCallbacks(Object instance, String added, String changed, String removed)
          Sets the callbacks for this service.
 ServiceDependency setCallbacks(String added, String removed)
          Sets the callbacks for this service.
 ServiceDependency setCallbacks(String added, String changed, String removed)
          Sets the callbacks for this service.
 ServiceDependency setDefaultImplementation(Object implementation)
          Sets the default implementation for this service dependency.
 ServiceDependency setInstanceBound(boolean isInstanceBound)
           
 ServiceDependency setPropagate(boolean propagate)
          Sets propagation of the service dependency properties to the provided service properties.
 ServiceDependency setPropagate(Object instance, String method)
          Sets an Object instance and a callback method used to propagate some properties to the provided service properties.
 ServiceDependency setRequired(boolean required)
          Sets the required flag which determines if this service is required or not.
 ServiceDependency setService(Class serviceName)
          Sets the name of the service that should be tracked.
 ServiceDependency setService(Class serviceName, ServiceReference serviceReference)
          Sets the name of the service that should be tracked.
 ServiceDependency setService(Class serviceName, String serviceFilter)
          Sets the name of the service that should be tracked.
 ServiceDependency setService(String serviceFilter)
          Sets the filter for the services that should be tracked.
 
Methods inherited from interface org.apache.felix.dm.Dependency
createCopy, getAutoConfigInstance, getAutoConfigName, getAutoConfigType, getProperties, invokeAdded, invokeRemoved, isAutoConfig, isAvailable, isInstanceBound, isPropagated, isRequired
 
Methods inherited from interface org.apache.felix.dm.ComponentDependencyDeclaration
getName, getState, getType
 

Method Detail

setService

ServiceDependency setService(Class serviceName)
Sets the name of the service that should be tracked.

Parameters:
serviceName - the name of the service
Returns:
this service dependency

setService

ServiceDependency setService(Class serviceName,
                             String serviceFilter)
Sets the name of the service that should be tracked. You can either specify only the name, or the name and a filter. In the latter case, the filter is used to track the service and should only return services of the type that was specified in the name. To make sure of this, the filter is actually extended internally to filter on the correct name.

Parameters:
serviceName - the name of the service
serviceFilter - the filter condition
Returns:
this service dependency

setService

ServiceDependency setService(String serviceFilter)
Sets the filter for the services that should be tracked. Any service object matching the filter will be returned, without any additional filter on the class.

Parameters:
serviceFilter - the filter condition
Returns:
this service dependency

setService

ServiceDependency setService(Class serviceName,
                             ServiceReference serviceReference)
Sets the name of the service that should be tracked. You can either specify only the name, or the name and a reference. In the latter case, the service reference is used to track the service and should only return services of the type that was specified in the name.

Parameters:
serviceName - the name of the service
serviceReference - the service reference to track
Returns:
this service dependency

setDefaultImplementation

ServiceDependency setDefaultImplementation(Object implementation)
Sets the default implementation for this service dependency. You can use this to supply your own implementation that will be used instead of a Null Object when the dependency is not available. This is also convenient if the service dependency is not an interface (which would cause the Null Object creation to fail) but a class.

Parameters:
implementation - the instance to use or the class to instantiate if you want to lazily instantiate this implementation
Returns:
this service dependency

setRequired

ServiceDependency setRequired(boolean required)
Sets the required flag which determines if this service is required or not.

Parameters:
required - the required flag
Returns:
this service dependency

setAutoConfig

ServiceDependency setAutoConfig(boolean autoConfig)
Sets auto configuration for this service. Auto configuration allows the dependency to fill in any attributes in the service implementation that are of the same type as this dependency. Default is on.

Parameters:
autoConfig - the value of auto config
Returns:
this service dependency

setAutoConfig

ServiceDependency setAutoConfig(String instanceName)
Sets auto configuration for this service. Auto configuration allows the dependency to fill in the attribute in the service implementation that has the same type and instance name.

Parameters:
instanceName - the name of attribute to auto config
Returns:
this service dependency

setCallbacks

ServiceDependency setCallbacks(String added,
                               String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added or removed. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Parameters:
added - the method to call when a service was added
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

ServiceDependency setCallbacks(String added,
                               String changed,
                               String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added, changed or removed. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Parameters:
added - the method to call when a service was added
changed - the method to call when a service was changed
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

ServiceDependency setCallbacks(Object instance,
                               String added,
                               String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added or removed. They are called on the instance you provide. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Parameters:
instance - the instance to call the callbacks on
added - the method to call when a service was added
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

ServiceDependency setCallbacks(Object instance,
                               String added,
                               String changed,
                               String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added, changed or removed. They are called on the instance you provide. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Parameters:
instance - the instance to call the callbacks on
added - the method to call when a service was added
changed - the method to call when a service was changed
removed - the method to call when a service was removed
Returns:
this service dependency

setPropagate

ServiceDependency setPropagate(boolean propagate)
Sets propagation of the service dependency properties to the provided service properties. Any additional service properties specified directly are merged with these.


setPropagate

ServiceDependency setPropagate(Object instance,
                               String method)
Sets an Object instance and a callback method used to propagate some properties to the provided service properties. The method will be invoked on the specified object instance and must have one of the following signatures:

Parameters:
instance - the Object instance which is used to retrieve propagated service properties
method - the method to invoke for retrieving the properties to be propagated to the service properties.
Returns:
this service dependency.

setInstanceBound

ServiceDependency setInstanceBound(boolean isInstanceBound)


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.