org.apache.felix.dm.impl.dependencies
Class ResourceDependencyImpl

java.lang.Object
  extended by org.apache.felix.dm.impl.dependencies.DependencyBase
      extended by org.apache.felix.dm.impl.dependencies.ResourceDependencyImpl
All Implemented Interfaces:
ComponentDependencyDeclaration, Dependency, DependencyActivation, ResourceDependency, ResourceHandler

public class ResourceDependencyImpl
extends DependencyBase
implements ResourceDependency, ResourceHandler, DependencyActivation, ComponentDependencyDeclaration


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
 
Fields inherited from interface org.apache.felix.dm.ResourceHandler
FILTER, HOST, PATH, PORT, PROTOCOL, URL
 
Constructor Summary
ResourceDependencyImpl(BundleContext context, Logger logger)
           
ResourceDependencyImpl(ResourceDependencyImpl prototype)
           
 
Method Summary
 void added(URL resource)
          Invoked whenever a new resource is added.
 void changed(URL resource)
          Invoked whenever an existing resource changes.
 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.
 String getName()
          Returns the name of this dependency.
 Dictionary getProperties()
           
 URL getResource()
           
 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 invokeAdded(DependencyService ds, URL serviceInstance)
           
 void invokeChanged(DependencyService ds, URL serviceInstance)
           
 void invokeRemoved(DependencyService service)
          Invoke the "removed" callback on a required dependency.
 void invokeRemoved(DependencyService ds, URL serviceInstance)
           
 boolean isAutoConfig()
          Returns true>code> if auto configuration is enabled for this dependency.
 boolean isAvailable()
          Returns true if the dependency is available.
 boolean isPropagated()
           
 void removed(URL resource)
          Invoked whenever an existing resource is removed.
 ResourceDependency setAutoConfig(boolean autoConfig)
          Sets auto configuration for this service.
 ResourceDependency setAutoConfig(String instanceName)
          Sets auto configuration for this service.
 ResourceDependency setCallbacks(Object instance, String added, String removed)
          Sets the callbacks for this service.
 ResourceDependency setCallbacks(Object instance, String added, String changed, String removed)
          Sets the callbacks for this service.
 ResourceDependency setCallbacks(String added, String removed)
          Sets the callbacks for this service.
 ResourceDependency setCallbacks(String added, String changed, String removed)
          Sets the callbacks for this service.
 ResourceDependency setFilter(String resourceFilter)
           
 ResourceDependency setInstanceBound(boolean isInstanceBound)
           
 ResourceDependency setPropagate(boolean propagate)
           
 ResourceDependency setPropagate(Object instance, String method)
           
 ResourceDependency setRequired(boolean required)
           
 ResourceDependency setResource(URL resource)
           
 void start(DependencyService service)
           
 void stop(DependencyService service)
           
 
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, toString, wait, wait, wait
 
Methods inherited from interface org.apache.felix.dm.Dependency
isInstanceBound, isRequired
 

Field Detail

m_services

protected List m_services
Constructor Detail

ResourceDependencyImpl

public ResourceDependencyImpl(BundleContext context,
                              Logger logger)

ResourceDependencyImpl

public ResourceDependencyImpl(ResourceDependencyImpl prototype)
Method Detail

createCopy

public Dependency createCopy()
Description copied from interface: Dependency
Creates a copy of this dependency, cloning all declared state, but not the runtime state.

Specified by:
createCopy in interface Dependency

isAvailable

public boolean isAvailable()
Description copied from interface: Dependency
Returns true if the dependency is available.

Specified by:
isAvailable in interface Dependency
Returns:
true if the dependency is available

start

public void start(DependencyService service)
Specified by:
start in interface DependencyActivation

stop

public void stop(DependencyService service)
Specified by:
stop in interface DependencyActivation

added

public void added(URL resource)
Description copied from interface: ResourceHandler
Invoked whenever a new resource is added.

Specified by:
added in interface ResourceHandler

changed

public void changed(URL resource)
Description copied from interface: ResourceHandler
Invoked whenever an existing resource changes.

Specified by:
changed in interface ResourceHandler

removed

public void removed(URL resource)
Description copied from interface: ResourceHandler
Invoked whenever an existing resource is removed.

Specified by:
removed in interface ResourceHandler

invokeAdded

public void invokeAdded(DependencyService ds,
                        URL serviceInstance)

invokeChanged

public void invokeChanged(DependencyService ds,
                          URL serviceInstance)

invokeRemoved

public void invokeRemoved(DependencyService ds,
                          URL serviceInstance)

setCallbacks

public ResourceDependency setCallbacks(String added,
                                       String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added or removed. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Specified by:
setCallbacks in interface ResourceDependency
Parameters:
added - the method to call when a service was added
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

public ResourceDependency setCallbacks(String added,
                                       String changed,
                                       String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added, changed or removed. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Specified by:
setCallbacks in interface ResourceDependency
Parameters:
added - the method to call when a service was added
changed - the method to call when a service was changed
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

public ResourceDependency setCallbacks(Object instance,
                                       String added,
                                       String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added or removed. They are called on the instance you provide. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Specified by:
setCallbacks in interface ResourceDependency
Parameters:
instance - the instance to call the callbacks on
added - the method to call when a service was added
removed - the method to call when a service was removed
Returns:
this service dependency

setCallbacks

public ResourceDependency setCallbacks(Object instance,
                                       String added,
                                       String changed,
                                       String removed)
Sets the callbacks for this service. These callbacks can be used as hooks whenever a dependency is added, changed or removed. They are called on the instance you provide. When you specify callbacks, the auto configuration feature is automatically turned off, because we're assuming you don't need it in this case.

Specified by:
setCallbacks in interface ResourceDependency
Parameters:
instance - the instance to call the callbacks on
added - the method to call when a service was added
changed - the method to call when a service was changed
removed - the method to call when a service was removed
Returns:
this service dependency

setAutoConfig

public ResourceDependency setAutoConfig(boolean autoConfig)
Sets auto configuration for this service. Auto configuration allows the dependency to fill in any attributes in the service implementation that are of the same type as this dependency. Default is on.

Specified by:
setAutoConfig in interface ResourceDependency
Parameters:
autoConfig - the value of auto config
Returns:
this service dependency

setAutoConfig

public ResourceDependency setAutoConfig(String instanceName)
Sets auto configuration for this service. Auto configuration allows the dependency to fill in the attribute in the service implementation that has the same type and instance name.

Specified by:
setAutoConfig in interface ResourceDependency
Parameters:
instanceName - the name of attribute to auto config
Returns:
this service dependency

setResource

public ResourceDependency setResource(URL resource)
Specified by:
setResource in interface ResourceDependency

setRequired

public ResourceDependency setRequired(boolean required)
Specified by:
setRequired in interface ResourceDependency

setFilter

public ResourceDependency setFilter(String resourceFilter)
Specified by:
setFilter in interface ResourceDependency

isAutoConfig

public boolean isAutoConfig()
Description copied from interface: Dependency
Returns 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

getResource

public URL getResource()

getAutoConfigInstance

public Object getAutoConfigInstance()
Description copied from interface: Dependency
Returns the instance that is injected.

Specified by:
getAutoConfigInstance in interface Dependency
Returns:
the instance that is injected

getAutoConfigName

public String getAutoConfigName()
Description copied from interface: Dependency
Returns the name of the member in the class of the component instance to inject into. If you specify this, not all members of the right type will be injected, only the member whose name matches.

Specified by:
getAutoConfigName in interface Dependency
Returns:

getAutoConfigType

public Class getAutoConfigType()
Description copied from interface: Dependency
Returns the type of the instance that is injected.

Specified by:
getAutoConfigType in interface Dependency
Returns:
the type of the instance that is injected

invokeAdded

public void invokeAdded(DependencyService service)
Description copied from interface: Dependency
Invoke the "added" callback on a required dependency.

Specified by:
invokeAdded in interface Dependency

invokeRemoved

public void invokeRemoved(DependencyService service)
Description copied from interface: Dependency
Invoke the "removed" callback on a required dependency.

Specified by:
invokeRemoved in interface Dependency

setPropagate

public ResourceDependency setPropagate(boolean propagate)
Specified by:
setPropagate in interface ResourceDependency

setPropagate

public ResourceDependency setPropagate(Object instance,
                                       String method)
Specified by:
setPropagate in interface ResourceDependency

getProperties

public Dictionary getProperties()
Specified by:
getProperties in interface Dependency

isPropagated

public boolean isPropagated()
Specified by:
isPropagated in interface Dependency

setInstanceBound

public ResourceDependency setInstanceBound(boolean isInstanceBound)
Specified by:
setInstanceBound in interface ResourceDependency

getName

public String getName()
Description copied from interface: ComponentDependencyDeclaration
Returns the name of this dependency.

Specified by:
getName in interface ComponentDependencyDeclaration

getState

public int getState()
Description copied from interface: ComponentDependencyDeclaration
Returns the state of this dependency.

Specified by:
getState in interface ComponentDependencyDeclaration

getType

public String getType()
Description copied from interface: ComponentDependencyDeclaration
Returns the name of the type of this dependency.

Specified by:
getType in interface ComponentDependencyDeclaration


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.