org.apache.felix.scr.impl.manager
Class ComponentContextImpl

java.lang.Object
  extended by org.apache.felix.scr.impl.manager.ComponentContextImpl
All Implemented Interfaces:
ComponentContext, ComponentInstance

public class ComponentContextImpl
extends Object
implements ComponentContext, ComponentInstance

Implementation for the ComponentContext interface


Method Summary
 void disableComponent(String name)
          Disables the specified component name.
 void dispose()
          Dispose of the component configuration for this component instance.
 void enableComponent(String name)
          Enables the specified component name.
 BundleContext getBundleContext()
          Returns the BundleContext of the bundle which contains this component.
 ComponentInstance getComponentInstance()
          Returns the Component Instance object for the component instance associated with this Component Context.
protected  AbstractComponentManager getComponentManager()
           
 Object getInstance()
          Returns the component instance of the activated component configuration.
 Dictionary getProperties()
          Returns the component properties for this Component Context.
 ServiceReference getServiceReference()
          If the component instance is registered as a service using the service element, then this method returns the service reference of the service provided by this component instance.
 Bundle getUsingBundle()
          If the component instance is registered as a service using the servicefactory="true" attribute, then this method returns the bundle using the service provided by the component instance.
 Object locateService(String name)
          Returns the service object for the specified reference name.
 Object locateService(String name, ServiceReference ref)
          Returns the service object for the specified reference name and ServiceReference.
 Object[] locateServices(String name)
          Returns the service objects for the specified reference name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getComponentManager

protected AbstractComponentManager getComponentManager()

getProperties

public final Dictionary getProperties()
Description copied from interface: ComponentContext
Returns the component properties for this Component Context.

Specified by:
getProperties in interface ComponentContext
Returns:
The properties for this Component Context. The Dictionary is read only and cannot be modified.

locateService

public Object locateService(String name)
Description copied from interface: ComponentContext
Returns the service object for the specified reference name.

If the cardinality of the reference is 0..n or 1..n and multiple services are bound to the reference, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned. If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.

Specified by:
locateService in interface ComponentContext
Parameters:
name - The name of a reference as specified in a reference element in this component's description.
Returns:
A service object for the referenced service or null if the reference cardinality is 0..1 or 0..n and no bound service is available.

locateService

public Object locateService(String name,
                            ServiceReference ref)
Description copied from interface: ComponentContext
Returns the service object for the specified reference name and ServiceReference.

Specified by:
locateService in interface ComponentContext
Parameters:
name - The name of a reference as specified in a reference element in this component's description.
ref - The ServiceReference to a bound service. This must be a ServiceReference provided to the component via the bind or unbind method for the specified reference name.
Returns:
A service object for the referenced service or null if the specified ServiceReference is not a bound service for the specified reference name.

locateServices

public Object[] locateServices(String name)
Description copied from interface: ComponentContext
Returns the service objects for the specified reference name.

Specified by:
locateServices in interface ComponentContext
Parameters:
name - The name of a reference as specified in a reference element in this component's description.
Returns:
An array of service objects for the referenced service or null if the reference cardinality is 0..1 or 0..n and no bound service is available. If the reference cardinality is 0..1 or 1..1 and a bound service is available, the array will have exactly one element.

getBundleContext

public BundleContext getBundleContext()
Description copied from interface: ComponentContext
Returns the BundleContext of the bundle which contains this component.

Specified by:
getBundleContext in interface ComponentContext
Returns:
The BundleContext of the bundle containing this component.

getUsingBundle

public Bundle getUsingBundle()
Description copied from interface: ComponentContext
If the component instance is registered as a service using the servicefactory="true" attribute, then this method returns the bundle using the service provided by the component instance.

This method will return null if:

Specified by:
getUsingBundle in interface ComponentContext
Returns:
The bundle using the component instance as a service or null.

getComponentInstance

public ComponentInstance getComponentInstance()
Description copied from interface: ComponentContext
Returns the Component Instance object for the component instance associated with this Component Context.

Specified by:
getComponentInstance in interface ComponentContext
Returns:
The Component Instance object for the component instance.

enableComponent

public void enableComponent(String name)
Description copied from interface: ComponentContext
Enables the specified component name. The specified component name must be in the same bundle as this component.

Specified by:
enableComponent in interface ComponentContext
Parameters:
name - The name of a component or null to indicate all components in the bundle.

disableComponent

public void disableComponent(String name)
Description copied from interface: ComponentContext
Disables the specified component name. The specified component name must be in the same bundle as this component.

Specified by:
disableComponent in interface ComponentContext
Parameters:
name - The name of a component.

getServiceReference

public ServiceReference getServiceReference()
Description copied from interface: ComponentContext
If the component instance is registered as a service using the service element, then this method returns the service reference of the service provided by this component instance.

This method will return null if the component instance is not registered as a service.

Specified by:
getServiceReference in interface ComponentContext
Returns:
The ServiceReference object for the component instance or null if the component instance is not registered as a service.

getInstance

public Object getInstance()
Description copied from interface: ComponentInstance
Returns the component instance of the activated component configuration.

Specified by:
getInstance in interface ComponentInstance
Returns:
The component instance or null if the component configuration has been deactivated.

dispose

public void dispose()
Description copied from interface: ComponentInstance
Dispose of the component configuration for this component instance. The component configuration will be deactivated. If the component configuration has already been deactivated, this method does nothing.

Specified by:
dispose in interface ComponentInstance


Copyright © 2011 Apache Software Foundation. All Rights Reserved.