org.apache.felix.ipojo.composite.service.provides
Class ProvidedServiceHandler

java.lang.Object
  extended by org.apache.felix.ipojo.Handler
      extended by org.apache.felix.ipojo.composite.CompositeHandler
          extended by org.apache.felix.ipojo.composite.service.provides.ProvidedServiceHandler
All Implemented Interfaces:
DependencyStateListener

public class ProvidedServiceHandler
extends CompositeHandler
implements DependencyStateListener

Composite Provided Service Handler.

Author:
Felix Project Team

Field Summary
private  org.osgi.framework.BundleContext m_context
          External context.
private  ProvidedServiceHandlerDescription m_description
          Handler description.
private  java.util.List m_exporters
          List of exporters.
private  java.util.List m_managedServices
          List of managed services.
private  java.util.List m_services
          List of "available" services in the internal context.
private  java.util.List m_types
          List of component type.
 
Fields inherited from class org.apache.felix.ipojo.composite.CompositeHandler
HANDLER_TYPE
 
Fields inherited from class org.apache.felix.ipojo.Handler
HANDLER_LEVEL_PROPERTY, HANDLER_NAME_PROPERTY, HANDLER_NAMESPACE_PROPERTY, HANDLER_TYPE_PROPERTY, m_instance, m_isValid
 
Constructor Summary
ProvidedServiceHandler()
           
 
Method Summary
private  void checkRequirement(ServiceImporter imp, Element elem)
          Check the correctness of the composite requirement against the service level dependency.
private  void checkServiceSpecification(ProvidedService svc)
          Check composite requirement against service specification requirement is available.
private  void computeAvailableServices()
          Build the list of available specifications.
private  void computeAvailableTypes()
          Build available instance types.
 void configure(Element metadata, java.util.Dictionary configuration)
          Configure the handler.
private  ServiceImporter getAttachedRequirement(Element element)
          Look for the implementation (i.e.
 HandlerDescription getDescription()
          Returns the current handler description.
 java.util.List getInstanceType()
           
protected  java.util.List getSpecifications()
          Build the list of available specification.
 void initializeComponentFactory(ComponentTypeDescription desc, Element metadata)
          Initialize the component type.
 void invalidate(DependencyModel exporter)
          Notify the handler that an exporter becomes invalid.
private  void isHandlerValid()
          Check the handler validity.
 void start()
          Start method.
 void stateChanged(int state)
          Handler state changed.
 void stop()
          Stop method.
 void validate(DependencyModel exporter)
          Notify the handler that an exporter becomes valid.
 
Methods inherited from class org.apache.felix.ipojo.composite.CompositeHandler
attach, getCompositeManager, getHandler, getLogger, setFactory
 
Methods inherited from class org.apache.felix.ipojo.Handler
debug, error, error, getHandlerManager, getValidity, info, isValid, reconfigure, setValidity, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_context

private org.osgi.framework.BundleContext m_context
External context.


m_services

private java.util.List m_services
List of "available" services in the internal context.


m_exporters

private java.util.List m_exporters
List of exporters.


m_managedServices

private java.util.List m_managedServices
List of managed services.


m_types

private java.util.List m_types
List of component type.


m_description

private ProvidedServiceHandlerDescription m_description
Handler description.

Constructor Detail

ProvidedServiceHandler

public ProvidedServiceHandler()
Method Detail

initializeComponentFactory

public void initializeComponentFactory(ComponentTypeDescription desc,
                                       Element metadata)
                                throws ConfigurationException
Initialize the component type.

Overrides:
initializeComponentFactory in class Handler
Parameters:
desc - : component type description to populate.
metadata - : component type metadata.
Throws:
ConfigurationException - : metadata are incorrect.
See Also:
Handler.initializeComponentFactory(org.apache.felix.ipojo.architecture.ComponentTypeDescription, org.apache.felix.ipojo.metadata.Element)

configure

public void configure(Element metadata,
                      java.util.Dictionary configuration)
               throws ConfigurationException
Configure the handler.

Specified by:
configure in class Handler
Parameters:
metadata - : the metadata of the component
configuration - : the instance configuration
Throws:
ConfigurationException - : the exporter cannot be created
See Also:
org.apache.felix.ipojo.CompositeHandler#configure(org.apache.felix.ipojo.CompositeManager, org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)

start

public void start()
Start method. Start all managed provided service.

Specified by:
start in class Handler
See Also:
org.apache.felix.ipojo.CompositeHandler#start()

stop

public void stop()
Stop method. Stop all managed provided service.

Specified by:
stop in class Handler
See Also:
org.apache.felix.ipojo.CompositeHandler#stop()

isHandlerValid

private void isHandlerValid()
Check the handler validity.

See Also:
org.apache.felix.ipojo.CompositeHandler#isValid()

stateChanged

public void stateChanged(int state)
Handler state changed.

Overrides:
stateChanged in class Handler
Parameters:
state - : the new instance state.
See Also:
org.apache.felix.ipojo.CompositeHandler#stateChanged(int)

invalidate

public void invalidate(DependencyModel exporter)
Notify the handler that an exporter becomes invalid.

Specified by:
invalidate in interface DependencyStateListener
Parameters:
exporter - : the implicated exporter.

validate

public void validate(DependencyModel exporter)
Notify the handler that an exporter becomes valid.

Specified by:
validate in interface DependencyStateListener
Parameters:
exporter - : the implicated exporter.

getSpecifications

protected java.util.List getSpecifications()
Build the list of available specification.

Returns:
the list of available specification.

computeAvailableServices

private void computeAvailableServices()
Build the list of available specifications.


checkServiceSpecification

private void checkServiceSpecification(ProvidedService svc)
                                throws CompositionException
Check composite requirement against service specification requirement is available.

Parameters:
svc - : the provided service to check
Throws:
CompositionException - : occurs if the specification field of the service specification cannot be analyzed correctly.

getAttachedRequirement

private ServiceImporter getAttachedRequirement(Element element)
Look for the implementation (i.e. composite) requirement for the given service-level requirement metadata.

Parameters:
element - : the service-level requirement metadata
Returns:
the ServiceImporter object, null if not found or if the DependencyHandler is not plugged to the instance

checkRequirement

private void checkRequirement(ServiceImporter imp,
                              Element elem)
                       throws CompositionException
Check the correctness of the composite requirement against the service level dependency.

Parameters:
imp - : requirement to check
elem - : service-level dependency metadata
Throws:
CompositionException - : occurs if the requirement does not match with service-level specification requirement

getDescription

public HandlerDescription getDescription()
Description copied from class: Handler
Returns the current handler description. The simplest description contains only the name and the validity of the handler. If the handler override this method, it can customize the description. By default, this method returns the simplest description.

Overrides:
getDescription in class Handler
Returns:
the description of the handler.

computeAvailableTypes

private void computeAvailableTypes()
Build available instance types.


getInstanceType

public java.util.List getInstanceType()


Copyright © 2006-2010 The Apache Software Foundation. All Rights Reserved.