public class ConfigurationDependency extends Object implements Dependency, org.osgi.service.cm.ManagedService, ServiceComponentDependency
ManagedService(Factory> and
handle everything yourself. Also, only managed services are supported, not factories.
There are a couple of things you need to be aware of when implementing the
updated(Dictionary) method:
ConfigurationException when you get a
configuration that is invalid. In this case, the dependency will not change:
if it was not available, it will still not be. If it was available, it will
remain available and implicitly assume you keep working with your old
configuration.STATE_AVAILABLE_OPTIONAL, STATE_AVAILABLE_REQUIRED, STATE_NAMES, STATE_UNAVAILABLE_OPTIONAL, STATE_UNAVAILABLE_REQUIRED| Constructor and Description |
|---|
ConfigurationDependency(org.osgi.framework.BundleContext context,
Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
Dictionary |
getConfiguration() |
String |
getName()
Returns the name of this dependency.
|
int |
getState()
Returns the state of this dependency.
|
String |
getType()
Returns the name of the type of this dependency.
|
boolean |
isAvailable()
Returns
true if the dependency is available. |
boolean |
isPropagated()
Returns
true when configuration properties should be propagated
as service properties. |
boolean |
isRequired()
Will always return
true as optional configuration dependencies
do not make sense. |
ConfigurationDependency |
setPid(String pid)
Sets the
service.pid of the configuration you
are depending on. |
ConfigurationDependency |
setPropagate(boolean propagate)
Sets propagation of the configuration properties to the service
properties.
|
void |
start(Service service)
Starts tracking the dependency.
|
void |
stop(Service service)
Stops tracking the dependency.
|
String |
toString() |
void |
updated(Dictionary settings) |
public ConfigurationDependency(org.osgi.framework.BundleContext context,
Logger logger)
public boolean isAvailable()
Dependencytrue if the dependency is available.isAvailable in interface Dependencytrue if the dependency is availablepublic boolean isRequired()
true as optional configuration dependencies
do not make sense. You might as well just implement ManagedService
yourself in those cases.isRequired in interface Dependencytrue if the dependency is requiredpublic boolean isPropagated()
true when configuration properties should be propagated
as service properties.public Dictionary getConfiguration()
public void start(Service service)
DependencydependencyAvailable() on the service.start in interface Dependencyservice - the service that is associated with this dependencypublic void stop(Service service)
DependencydependencyUnavaible() before stopping itself to ensure
that dependencies that aren't "active" are unavailable.stop in interface Dependencypublic void updated(Dictionary settings) throws org.osgi.service.cm.ConfigurationException
updated in interface org.osgi.service.cm.ManagedServiceorg.osgi.service.cm.ConfigurationExceptionpublic ConfigurationDependency setPid(String pid)
service.pid of the configuration you
are depending on.public ConfigurationDependency setPropagate(boolean propagate)
public String getName()
ServiceComponentDependencygetName in interface ServiceComponentDependencypublic int getState()
ServiceComponentDependencygetState in interface ServiceComponentDependencypublic String getType()
ServiceComponentDependencygetType in interface ServiceComponentDependencyCopyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.