org.apache.felix.dependencymanager.impl
Class ServiceDependencyImpl

java.lang.Object
  extended by org.apache.felix.dependencymanager.ServiceDependency
      extended by org.apache.felix.dependencymanager.impl.ServiceDependencyImpl
All Implemented Interfaces:
Dependency

public class ServiceDependencyImpl
extends ServiceDependency


Constructor Summary
ServiceDependencyImpl(DependencyManager dm)
           
 
Method Summary
 ServiceDependency getDelegate()
           
 boolean isAutoConfig()
          Returns true>code> if auto configuration is enabled for this dependency.
 boolean isAvailable()
          Returns true if the dependency is available.
 boolean isRequired()
          Returns true if this a required dependency.
 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 changed, String removed)
          Sets the callbacks for this service.
 ServiceDependency setDefaultImplementation(Object implementation)
          Sets the default implementation for this service dependency.
 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.
 
Methods inherited from class org.apache.felix.dependencymanager.ServiceDependency
setCallbacks, setCallbacks, setCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceDependencyImpl

public ServiceDependencyImpl(DependencyManager dm)
Method Detail

getDelegate

public ServiceDependency getDelegate()

setService

public ServiceDependency setService(Class serviceName)
Description copied from class: ServiceDependency
Sets the name of the service that should be tracked.

Specified by:
setService in class ServiceDependency
Parameters:
serviceName - the name of the service
Returns:
this service dependency

setService

public ServiceDependency setService(Class serviceName,
                                    String serviceFilter)
Description copied from class: ServiceDependency
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.

Specified by:
setService in class ServiceDependency
Parameters:
serviceName - the name of the service
serviceFilter - the filter condition
Returns:
this service dependency

setService

public ServiceDependency setService(Class serviceName,
                                    ServiceReference serviceReference)
Description copied from class: ServiceDependency
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.

Specified by:
setService in class ServiceDependency
Parameters:
serviceName - the name of the service
serviceReference - the service reference to track
Returns:
this service dependency

setDefaultImplementation

public ServiceDependency setDefaultImplementation(Object implementation)
Description copied from class: ServiceDependency
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.

Specified by:
setDefaultImplementation in class ServiceDependency
Parameters:
implementation - the instance to use or the class to instantiate if you want to lazily instantiate this implementation
Returns:
this service dependency

setRequired

public ServiceDependency setRequired(boolean required)
Description copied from class: ServiceDependency
Sets the required flag which determines if this service is required or not.

Specified by:
setRequired in class ServiceDependency
Parameters:
required - the required flag
Returns:
this service dependency

setAutoConfig

public ServiceDependency setAutoConfig(boolean autoConfig)
Description copied from class: ServiceDependency
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.

Specified by:
setAutoConfig in class ServiceDependency
Parameters:
autoConfig - the value of auto config
Returns:
this service dependency

setAutoConfig

public ServiceDependency setAutoConfig(String instanceName)
Description copied from class: ServiceDependency
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.

Specified by:
setAutoConfig in class ServiceDependency
Parameters:
instanceName - the name of attribute to auto config
Returns:
this service dependency

setCallbacks

public ServiceDependency setCallbacks(Object instance,
                                      String added,
                                      String changed,
                                      String removed)
Description copied from class: ServiceDependency
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 default auto configuration feature is automatically turned off, because we're assuming you don't need it in this case. If you need both features (callbacks + autoconfig), then, you must explicitly invoke setAutoConfig(true) and setCallbacks methods.

Specified by:
setCallbacks in class ServiceDependency
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

isAutoConfig

public boolean isAutoConfig()
Description copied from class: ServiceDependency
Returns true>code> if auto configuration is enabled for this dependency. Auto configuration means that a dependency is injected in the service instance when it's available, and if it's unavailable, a "null object" will be inserted instead.

Specified by:
isAutoConfig in class ServiceDependency
Returns:
true>code> if auto configuration is enabled for this dependency

isAvailable

public boolean isAvailable()
Description copied from class: ServiceDependency
Returns true if the dependency is available.

Specified by:
isAvailable in interface Dependency
Specified by:
isAvailable in class ServiceDependency
Returns:
true if the dependency is available

isRequired

public boolean isRequired()
Description copied from class: ServiceDependency
Returns true if this a required dependency. Required dependencies are dependencies that must be available before the service can be activated.

Specified by:
isRequired in interface Dependency
Specified by:
isRequired in class ServiceDependency
Returns:
true if the dependency is required


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