|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.dm.impl.dependencies.DependencyBase
org.apache.felix.dm.impl.dependencies.ServiceDependencyImpl
public class ServiceDependencyImpl
Service dependency that can track an OSGi service.
Field Summary | |
---|---|
protected BundleContext |
m_context
|
protected ServiceReference |
m_reference
|
protected Object |
m_serviceInstance
|
protected List |
m_services
|
protected Class |
m_trackedServiceName
|
protected ServiceTracker |
m_tracker
|
Fields inherited from class org.apache.felix.dm.impl.dependencies.DependencyBase |
---|
m_logger |
Fields inherited from interface org.apache.felix.dm.ComponentDependencyDeclaration |
---|
STATE_AVAILABLE_OPTIONAL, STATE_AVAILABLE_REQUIRED, STATE_NAMES, STATE_UNAVAILABLE_OPTIONAL, STATE_UNAVAILABLE_REQUIRED |
Constructor Summary | |
---|---|
ServiceDependencyImpl(BundleContext context,
Logger logger)
Creates a new service dependency. |
|
ServiceDependencyImpl(ServiceDependencyImpl prototype)
Copying constructor that clones an existing instance. |
Method Summary | |
---|---|
void |
addedService(ServiceReference ref,
Object service)
marrs: A service has been added to the ServiceTracker. |
Object |
addingService(ServiceReference ref)
A service is being added to the ServiceTracker . |
Dependency |
createCopy()
Creates a copy of this dependency, cloning all declared state, but not the runtime state. |
Object |
getAutoConfigInstance()
Returns the instance that is injected. |
String |
getAutoConfigName()
Returns the name of the member in the class of the component instance to inject into. |
Class |
getAutoConfigType()
Returns the type of the instance that is injected. |
Class |
getInterface()
|
String |
getName()
Returns the name of this dependency. |
Dictionary |
getProperties()
|
Object |
getService()
|
int |
getState()
Returns the state of this dependency. |
String |
getType()
Returns the name of the type of this dependency. |
void |
invoke(DependencyService dependencyService,
ServiceReference reference,
Object service,
String name)
|
void |
invokeAdded(DependencyService service)
Invoke the "added" callback on a required dependency. |
void |
invokeAdded(DependencyService dependencyService,
ServiceReference reference,
Object service)
|
void |
invokeChanged(DependencyService dependencyService,
ServiceReference reference,
Object service)
|
void |
invokeRemoved(DependencyService service)
Invoke the "removed" callback on a required dependency. |
void |
invokeRemoved(DependencyService dependencyService,
ServiceReference reference,
Object service)
|
boolean |
isAutoConfig()
Returns true>code> if auto configuration is enabled for this dependency. |
boolean |
isAvailable()
Returns true if the dependency is available. |
boolean |
isPropagated()
|
Object |
lookupService()
|
ServiceReference |
lookupServiceReference()
|
protected boolean |
makeAvailable()
|
void |
modifiedService(ServiceReference ref,
Object service)
A service tracked by the ServiceTracker has been modified. |
void |
removedService(ServiceReference ref,
Object service)
A service tracked by the ServiceTracker has been removed. |
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. |
void |
start(DependencyService service)
|
void |
stop(DependencyService service)
|
String |
toString()
|
Methods inherited from class org.apache.felix.dm.impl.dependencies.DependencyBase |
---|
isInstanceBound, isRequired, setIsInstanceBound, setIsRequired |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.felix.dm.Dependency |
---|
isInstanceBound, isRequired |
Field Detail |
---|
protected List m_services
protected volatile ServiceTracker m_tracker
protected BundleContext m_context
protected volatile Class m_trackedServiceName
protected ServiceReference m_reference
protected Object m_serviceInstance
Constructor Detail |
---|
public ServiceDependencyImpl(BundleContext context, Logger logger)
context
- the bundle contextlogger
- the loggerpublic ServiceDependencyImpl(ServiceDependencyImpl prototype)
Method Detail |
---|
public Dependency createCopy()
Dependency
createCopy
in interface Dependency
public boolean isAutoConfig()
Dependency
true>code> if auto configuration is enabled for this dependency.
Auto configuration means that a dependency is injected in the component instance
when it's available, and if it's unavailable, a "null object" will be inserted
instead.
- Specified by:
isAutoConfig
in interface Dependency
- Returns:
true
if auto configuration is enabled for this dependency
public boolean isAvailable()
Dependency
true
if the dependency is available.
isAvailable
in interface Dependency
true
if the dependency is availablepublic Object getService()
public Object lookupService()
public ServiceReference lookupServiceReference()
public Class getInterface()
public void start(DependencyService service)
start
in interface DependencyActivation
public void stop(DependencyService service)
stop
in interface DependencyActivation
public Object addingService(ServiceReference ref)
ServiceTrackerCustomizer
ServiceTracker
.
This method is called before a service which matched the search
parameters of the ServiceTracker
is added to the
ServiceTracker
. This method should return the service object
to be tracked for the specified ServiceReference
. The
returned service object is stored in the ServiceTracker
and
is available from the getService
and
getServices
methods.
addingService
in interface ServiceTrackerCustomizer
ref
- The reference to the service being added to the
ServiceTracker
.
null
if the specified referenced service
should not be tracked.public void addedService(ServiceReference ref, Object service)
ServiceTrackerCustomizer
addedService
in interface ServiceTrackerCustomizer
public void modifiedService(ServiceReference ref, Object service)
ServiceTrackerCustomizer
ServiceTracker
has been modified.
This method is called when a service being tracked by the
ServiceTracker
has had it properties modified.
modifiedService
in interface ServiceTrackerCustomizer
ref
- The reference to the service that has been modified.service
- The service object for the specified referenced service.public void removedService(ServiceReference ref, Object service)
ServiceTrackerCustomizer
ServiceTracker
has been removed.
This method is called after a service is no longer being tracked by the
ServiceTracker
.
removedService
in interface ServiceTrackerCustomizer
ref
- The reference to the service that has been removed.service
- The service object for the specified referenced service.public void invokeAdded(DependencyService dependencyService, ServiceReference reference, Object service)
public void invokeChanged(DependencyService dependencyService, ServiceReference reference, Object service)
public void invokeRemoved(DependencyService dependencyService, ServiceReference reference, Object service)
public void invoke(DependencyService dependencyService, ServiceReference reference, Object service, String name)
protected boolean makeAvailable()
public ServiceDependency setService(Class serviceName)
setService
in interface ServiceDependency
serviceName
- the name of the service
public ServiceDependency setService(Class serviceName, String serviceFilter)
setService
in interface ServiceDependency
serviceName
- the name of the serviceserviceFilter
- the filter condition
public ServiceDependency setService(String serviceFilter)
ServiceDependency
setService
in interface ServiceDependency
serviceFilter
- the filter condition
public ServiceDependency setService(Class serviceName, ServiceReference serviceReference)
setService
in interface ServiceDependency
serviceName
- the name of the serviceserviceReference
- the service reference to track
public ServiceDependency setDefaultImplementation(Object implementation)
setDefaultImplementation
in interface ServiceDependency
implementation
- the instance to use or the class to instantiate if you want to lazily
instantiate this implementation
public ServiceDependency setRequired(boolean required)
setRequired
in interface ServiceDependency
required
- the required flag
public ServiceDependency setInstanceBound(boolean isInstanceBound)
setInstanceBound
in interface ServiceDependency
public ServiceDependency setAutoConfig(boolean autoConfig)
setAutoConfig
in interface ServiceDependency
autoConfig
- the value of auto config
public ServiceDependency setAutoConfig(String instanceName)
setAutoConfig
in interface ServiceDependency
instanceName
- the name of attribute to auto config
public ServiceDependency setCallbacks(String added, String removed)
setCallbacks
in interface ServiceDependency
added
- the method to call when a service was addedremoved
- the method to call when a service was removed
public ServiceDependency setCallbacks(String added, String changed, String removed)
setCallbacks
in interface ServiceDependency
added
- the method to call when a service was addedchanged
- the method to call when a service was changedremoved
- the method to call when a service was removed
public ServiceDependency setCallbacks(Object instance, String added, String removed)
setCallbacks
in interface ServiceDependency
instance
- the instance to call the callbacks onadded
- the method to call when a service was addedremoved
- the method to call when a service was removed
public ServiceDependency setCallbacks(Object instance, String added, String changed, String removed)
setCallbacks
in interface ServiceDependency
instance
- the instance to call the callbacks onadded
- the method to call when a service was addedchanged
- the method to call when a service was changedremoved
- the method to call when a service was removed
public String toString()
toString
in class Object
public String getAutoConfigName()
Dependency
getAutoConfigName
in interface Dependency
public Object getAutoConfigInstance()
Dependency
getAutoConfigInstance
in interface Dependency
public Class getAutoConfigType()
Dependency
getAutoConfigType
in interface Dependency
public String getName()
ComponentDependencyDeclaration
getName
in interface ComponentDependencyDeclaration
public int getState()
ComponentDependencyDeclaration
getState
in interface ComponentDependencyDeclaration
public String getType()
ComponentDependencyDeclaration
getType
in interface ComponentDependencyDeclaration
public void invokeAdded(DependencyService service)
Dependency
invokeAdded
in interface Dependency
public void invokeRemoved(DependencyService service)
Dependency
invokeRemoved
in interface Dependency
public Dictionary getProperties()
getProperties
in interface Dependency
public boolean isPropagated()
isPropagated
in interface Dependency
public ServiceDependency setPropagate(boolean propagate)
ServiceDependency
setPropagate
in interface ServiceDependency
public ServiceDependency setPropagate(Object instance, String method)
ServiceDependency
setPropagate
in interface ServiceDependency
instance
- the Object instance which is used to retrieve propagated service propertiesmethod
- the method to invoke for retrieving the properties to be propagated to the service properties.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |