|
||||||||||
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.ConfigurationDependencyImpl
public class ConfigurationDependencyImpl
Configuration dependency that can track the availability of a (valid) configuration.
To use it, specify a PID for the configuration. The dependency is always required,
because if it is not, it does not make sense to use the dependency manager. In that
scenario, simply register your service as a 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.
Field Summary | |
---|---|
protected List |
m_services
|
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 | |
---|---|
ConfigurationDependencyImpl(BundleContext context,
Logger logger)
|
|
ConfigurationDependencyImpl(ConfigurationDependencyImpl prototype)
|
Method Summary | |
---|---|
ConfigurationDependency |
add(PropertyMetaData properties)
Adds a MetaData regarding a given configuration property. |
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. |
BundleContext |
getBundleContext()
|
Dictionary |
getConfiguration()
|
Logger |
getLogger()
|
String |
getName()
Returns the name of this dependency. |
Dictionary |
getProperties()
|
int |
getState()
Returns the state of this dependency. |
String |
getType()
Returns the name of the type of this dependency. |
void |
invokeAdded(DependencyService service)
Invoke the "added" callback on a required dependency. |
void |
invokeRemoved(DependencyService service)
Invoke the "removed" callback on a required dependency. |
void |
invokeUpdate(DependencyService ds,
Object service,
Dictionary settings)
|
boolean |
isAutoConfig()
Returns true>code> if auto configuration is enabled for 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 |
setCallback(String callback)
|
ConfigurationDependency |
setDescription(String description)
A human readable description of the PID this configuration is associated with. |
ConfigurationDependency |
setHeading(String heading)
The label used to display the tab name (or section) where the properties are displayed. |
ConfigurationDependency |
setInstanceBound(boolean isInstanceBound)
|
ConfigurationDependency |
setLocalization(String path)
Points to the basename of the Properties file that can localize the Meta Type informations. |
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. |
ConfigurationDependency |
setPropagate(Object instance,
String method)
|
void |
start(DependencyService service)
|
void |
stop(DependencyService service)
|
String |
toString()
|
void |
updated(Dictionary settings)
|
Methods inherited from class org.apache.felix.dm.impl.dependencies.DependencyBase |
---|
isInstanceBound, 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 |
Field Detail |
---|
protected List m_services
Constructor Detail |
---|
public ConfigurationDependencyImpl(BundleContext context, Logger logger)
public ConfigurationDependencyImpl(ConfigurationDependencyImpl prototype)
Method Detail |
---|
public Dependency createCopy()
Dependency
createCopy
in interface Dependency
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
isRequired
in class DependencyBase
true
if the dependency is requiredpublic boolean isPropagated()
true
when configuration properties should be propagated
as service properties.
isPropagated
in interface Dependency
public ConfigurationDependency setInstanceBound(boolean isInstanceBound)
setInstanceBound
in interface ConfigurationDependency
public Dictionary getConfiguration()
public void start(DependencyService service)
start
in interface DependencyActivation
public void stop(DependencyService service)
stop
in interface DependencyActivation
public ConfigurationDependency setCallback(String callback)
setCallback
in interface ConfigurationDependency
public void updated(Dictionary settings) throws ConfigurationException
updated
in interface ManagedService
ConfigurationException
public void invokeUpdate(DependencyService ds, Object service, Dictionary settings) throws ConfigurationException
ConfigurationException
public ConfigurationDependency setPid(String pid)
service.pid
of the configuration you
are depending on.
setPid
in interface ConfigurationDependency
public ConfigurationDependency setPropagate(boolean propagate)
setPropagate
in interface ConfigurationDependency
public String toString()
toString
in class Object
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 Object getAutoConfigInstance()
Dependency
getAutoConfigInstance
in interface Dependency
public String getAutoConfigName()
Dependency
getAutoConfigName
in interface Dependency
public Class getAutoConfigType()
Dependency
getAutoConfigType
in interface Dependency
public void invokeAdded(DependencyService service)
Dependency
invokeAdded
in interface Dependency
public void invokeRemoved(DependencyService service)
Dependency
invokeRemoved
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 ConfigurationDependency setPropagate(Object instance, String method)
public Dictionary getProperties()
getProperties
in interface Dependency
public BundleContext getBundleContext()
public Logger getLogger()
public ConfigurationDependency add(PropertyMetaData properties)
ConfigurationDependency
add
in interface ConfigurationDependency
public ConfigurationDependency setDescription(String description)
ConfigurationDependency
setDescription
in interface ConfigurationDependency
public ConfigurationDependency setHeading(String heading)
ConfigurationDependency
setHeading
in interface ConfigurationDependency
public ConfigurationDependency setLocalization(String path)
ConfigurationDependency
setLocalization("person")
will match person_du_NL.properties in the root bundle directory.
setLocalization
in interface ConfigurationDependency
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |