public class ServiceDependency extends Object implements Dependency, ServiceTrackerCustomizer, ServiceComponentDependency
STATE_AVAILABLE_OPTIONAL, STATE_AVAILABLE_REQUIRED, STATE_NAMES, STATE_UNAVAILABLE_OPTIONAL, STATE_UNAVAILABLE_REQUIRED
Constructor and Description |
---|
ServiceDependency(org.osgi.framework.BundleContext context,
Logger logger)
Creates a new service dependency.
|
Modifier and Type | Method and Description |
---|---|
void |
addedService(org.osgi.framework.ServiceReference ref,
Object service) |
Object |
addingService(org.osgi.framework.ServiceReference ref) |
String |
getAutoConfigName() |
Class |
getInterface() |
String |
getName()
Returns the name of this dependency.
|
Object |
getService() |
int |
getState()
Returns the state of this dependency.
|
String |
getType()
Returns the name of the type of this dependency.
|
void |
invokeAdded() |
void |
invokeAdded(org.osgi.framework.ServiceReference reference,
Object serviceInstance) |
void |
invokeChanged(org.osgi.framework.ServiceReference reference,
Object serviceInstance) |
void |
invokeRemoved() |
void |
invokeRemoved(org.osgi.framework.ServiceReference reference,
Object serviceInstance) |
boolean |
isAutoConfig() |
boolean |
isAvailable()
Returns
true if the dependency is available. |
boolean |
isRequired()
Returns
true if this a required dependency. |
Object |
lookupService() |
void |
modifiedService(org.osgi.framework.ServiceReference ref,
Object service) |
void |
removedService(org.osgi.framework.ServiceReference ref,
Object service) |
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) |
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) |
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,
org.osgi.framework.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.
|
void |
start(Service service)
Starts tracking the dependency.
|
void |
stop(Service service)
Stops tracking the dependency.
|
String |
toString() |
public ServiceDependency(org.osgi.framework.BundleContext context, Logger logger)
context
- the bundle contextlogger
- the loggerpublic boolean isRequired()
Dependency
true
if this a required dependency. Required dependencies
are dependencies that must be available before the service can be activated.isRequired
in interface Dependency
true
if the dependency is requiredpublic boolean isAvailable()
Dependency
true
if the dependency is available.isAvailable
in interface Dependency
true
if the dependency is availablepublic boolean isAutoConfig()
public Object getService()
public Object lookupService()
public Class getInterface()
public void start(Service service)
Dependency
dependencyAvailable()
on the service.start
in interface Dependency
service
- the service that is associated with this dependencypublic void stop(Service service)
Dependency
dependencyUnavaible()
before stopping itself to ensure
that dependencies that aren't "active" are unavailable.stop
in interface Dependency
public Object addingService(org.osgi.framework.ServiceReference ref)
addingService
in interface ServiceTrackerCustomizer
public void addedService(org.osgi.framework.ServiceReference ref, Object service)
addedService
in interface ServiceTrackerCustomizer
public void invokeAdded()
public void invokeAdded(org.osgi.framework.ServiceReference reference, Object serviceInstance)
public void modifiedService(org.osgi.framework.ServiceReference ref, Object service)
modifiedService
in interface ServiceTrackerCustomizer
public void invokeChanged(org.osgi.framework.ServiceReference reference, Object serviceInstance)
public void removedService(org.osgi.framework.ServiceReference ref, Object service)
removedService
in interface ServiceTrackerCustomizer
public void invokeRemoved()
public void invokeRemoved(org.osgi.framework.ServiceReference reference, Object serviceInstance)
public ServiceDependency setService(Class serviceName)
serviceName
- the name of the servicepublic ServiceDependency setService(Class serviceName, String serviceFilter)
serviceName
- the name of the serviceserviceFilter
- the filter conditionpublic ServiceDependency setService(Class serviceName, org.osgi.framework.ServiceReference serviceReference)
serviceName
- the name of the serviceserviceReference
- the service reference to trackpublic ServiceDependency setDefaultImplementation(Object implementation)
implementation
- the instance to use or the class to instantiate if you want to lazily
instantiate this implementationpublic ServiceDependency setRequired(boolean required)
required
- the required flagpublic ServiceDependency setAutoConfig(boolean autoConfig)
autoConfig
- the value of auto configpublic ServiceDependency setAutoConfig(String instanceName)
instanceName
- the name of attribute to auto configpublic ServiceDependency setCallbacks(String added, String removed)
added
- the method to call when a service was addedremoved
- the method to call when a service was removedpublic ServiceDependency setCallbacks(String added, String changed, String removed)
public ServiceDependency setCallbacks(Object instance, String added, String removed)
public ServiceDependency setCallbacks(Object instance, String added, String changed, String removed)
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 removedpublic String getAutoConfigName()
public String getName()
ServiceComponentDependency
getName
in interface ServiceComponentDependency
public int getState()
ServiceComponentDependency
getState
in interface ServiceComponentDependency
public String getType()
ServiceComponentDependency
getType
in interface ServiceComponentDependency
Copyright © 2006–2013 The Apache Software Foundation. All rights reserved.