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()
Dependency
true
if the dependency is available.isAvailable
in interface Dependency
true
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 Dependency
true
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)
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 void updated(Dictionary settings) throws org.osgi.service.cm.ConfigurationException
updated
in interface org.osgi.service.cm.ManagedService
org.osgi.service.cm.ConfigurationException
public ConfigurationDependency setPid(String pid)
service.pid
of the configuration you
are depending on.public ConfigurationDependency setPropagate(boolean propagate)
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.