org.apache.servicemix.jbi.framework
Class ComponentContextImpl

java.lang.Object
  extended by org.apache.servicemix.jbi.framework.ComponentContextImpl
All Implemented Interfaces:
javax.jbi.component.ComponentContext, javax.jbi.management.MBeanNames

public class ComponentContextImpl
extends Object
implements javax.jbi.component.ComponentContext, javax.jbi.management.MBeanNames

This context provides access to data needed by all JBI components running in the JBI environment.

Version:
$Revision: 564374 $

Field Summary
 
Fields inherited from interface javax.jbi.management.MBeanNames
BOOTSTRAP_EXTENSION, COMPONENT_LIFE_CYCLE_EXTENSION
 
Constructor Summary
ComponentContextImpl(JBIContainer container, ComponentNameSpace componentName)
          Constructor
 
Method Summary
 void activate(javax.jbi.component.Component comp, ComponentEnvironment env, ActivationSpec spec)
          Activate the ComponentContext
 javax.jbi.servicedesc.ServiceEndpoint activateEndpoint(QName serviceName, String endpointName)
           
 javax.jbi.servicedesc.ServiceEndpoint[] availableEndpoints(QName serviceName)
           
 ObjectName createCustomComponentMBeanName(String customName)
          Formulate and return the MBean ObjectName of a custom control MBean for a JBI component.
 void deactivateEndpoint(javax.jbi.servicedesc.ServiceEndpoint endpoint)
          Deregister the endpoint with the NMR
 void deregisterExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint externalEndpoint)
          Deregisters the given external endpoint with the NMR.
 InternalEndpoint deregisterSubscription(ComponentContextImpl context, SubscriptionSpec subscription)
           
 void deregisterSubscriptions(ComponentContextImpl context, ActivationSpec as)
          Deregister All subscriptions
 ActivationSpec getActivationSpec()
           
 javax.jbi.component.Component getComponent()
           
 String getComponentName()
           
 ComponentNameSpace getComponentNameSpace()
          get the id of the ComponentConnector
 JBIContainer getContainer()
           
 javax.jbi.messaging.DeliveryChannel getDeliveryChannel()
           
 javax.jbi.servicedesc.ServiceEndpoint getEndpoint(QName service, String name)
          Get the service endpoint for the named activated endpoint, if any.
 Document getEndpointDescriptor(javax.jbi.servicedesc.ServiceEndpoint endpoint)
          Retrieve the service description metadata for the specified endpoint.
 javax.jbi.servicedesc.ServiceEndpoint[] getEndpoints(QName interfaceName)
          Queries the NMR for active endpoints that implement the given interface.
 javax.jbi.servicedesc.ServiceEndpoint[] getEndpointsForService(QName serviceName)
          Queries the NMR for active endpoints belonging to the given service.
 ComponentEnvironment getEnvironment()
           
 javax.jbi.servicedesc.ServiceEndpoint[] getExternalEndpoints(QName interfaceName)
          Queries the NMR for external endpoints that implement the given interface name.
 javax.jbi.servicedesc.ServiceEndpoint[] getExternalEndpointsForService(QName serviceName)
          Queries the NMR for external endpoints that are part of the given service.
 String getInstallRoot()
          Get the installation root directory path for this component.
 String getJmxDomainName()
          Retrieve the default JMX Domain Name for MBeans registered in this instance of the JBI implementation.
 Logger getLogger(String suffix, String resourceBundleName)
          Get a logger instance from JBI.
 javax.jbi.management.MBeanNames getMBeanNames()
           
 MBeanServer getMBeanServer()
           
 InitialContext getNamingContext()
           
 Object getTransactionManager()
          Get the TransactionManager for this implementation.
 String getWorkspaceRoot()
           
 void registerExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint externalEndpoint)
          Registers the given external endpoint with the NMR.
 void registerSubscription(ComponentContextImpl context, SubscriptionSpec subscription, javax.jbi.servicedesc.ServiceEndpoint endpoint)
           
 void registerSubscriptions(ComponentContextImpl context, ActivationSpec as)
          Register All subscriptions
 javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(DocumentFragment epr)
          Resolve the given endpoint reference into a service endpoint.
 void setContainer(JBIContainer container)
           
 void setDeliveryChannel(javax.jbi.messaging.DeliveryChannel deliveryChannel)
           
 void setEnvironment(ComponentEnvironment ce)
          Set the ComponentEnvironment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentContextImpl

public ComponentContextImpl(JBIContainer container,
                            ComponentNameSpace componentName)
Constructor

Parameters:
container -
componentName -
Method Detail

activate

public void activate(javax.jbi.component.Component comp,
                     ComponentEnvironment env,
                     ActivationSpec spec)
Activate the ComponentContext

Parameters:
comp -
channel -
env -
spec -
installRoot -

getComponentNameSpace

public ComponentNameSpace getComponentNameSpace()
get the id of the ComponentConnector

Returns:
the id

getComponentName

public String getComponentName()
Specified by:
getComponentName in interface javax.jbi.component.ComponentContext
Returns:
the unique component name

getComponent

public javax.jbi.component.Component getComponent()
Returns:
this component instance

activateEndpoint

public javax.jbi.servicedesc.ServiceEndpoint activateEndpoint(QName serviceName,
                                                              String endpointName)
                                                       throws javax.jbi.JBIException
Specified by:
activateEndpoint in interface javax.jbi.component.ComponentContext
Parameters:
serviceName -
endpointName -
Returns:
EndPointReference
Throws:
javax.jbi.JBIException

availableEndpoints

public javax.jbi.servicedesc.ServiceEndpoint[] availableEndpoints(QName serviceName)
                                                           throws javax.jbi.JBIException
Parameters:
serviceName -
Returns:
endpoints registered against the service
Throws:
javax.jbi.JBIException

deactivateEndpoint

public void deactivateEndpoint(javax.jbi.servicedesc.ServiceEndpoint endpoint)
                        throws javax.jbi.JBIException
Deregister the endpoint with the NMR

Specified by:
deactivateEndpoint in interface javax.jbi.component.ComponentContext
Parameters:
endpoint -
Throws:
javax.jbi.JBIException

registerSubscriptions

public void registerSubscriptions(ComponentContextImpl context,
                                  ActivationSpec as)
Register All subscriptions

Parameters:
context -
as -

deregisterSubscriptions

public void deregisterSubscriptions(ComponentContextImpl context,
                                    ActivationSpec as)
Deregister All subscriptions

Parameters:
context -
as -

registerSubscription

public void registerSubscription(ComponentContextImpl context,
                                 SubscriptionSpec subscription,
                                 javax.jbi.servicedesc.ServiceEndpoint endpoint)
Parameters:
context -
subscription -
endpoint -

deregisterSubscription

public InternalEndpoint deregisterSubscription(ComponentContextImpl context,
                                               SubscriptionSpec subscription)
Parameters:
context -
subscription -
Returns:
the ServiceEndpoint

getDeliveryChannel

public javax.jbi.messaging.DeliveryChannel getDeliveryChannel()
Specified by:
getDeliveryChannel in interface javax.jbi.component.ComponentContext
Returns:
the Delivery Channel
Throws:
MessagingException

getJmxDomainName

public String getJmxDomainName()
Retrieve the default JMX Domain Name for MBeans registered in this instance of the JBI implementation.

Specified by:
getJmxDomainName in interface javax.jbi.management.MBeanNames
Returns:
the JMX domain name for this instance of the JBI implementation.

createCustomComponentMBeanName

public ObjectName createCustomComponentMBeanName(String customName)
Formulate and return the MBean ObjectName of a custom control MBean for a JBI component.

Specified by:
createCustomComponentMBeanName in interface javax.jbi.management.MBeanNames
Parameters:
customName - the name of the custom control.
Returns:
the JMX ObjectName of the MBean, or null if customName is invalid.

getMBeanNames

public javax.jbi.management.MBeanNames getMBeanNames()
Specified by:
getMBeanNames in interface javax.jbi.component.ComponentContext
Returns:
the MBeanNames service

getMBeanServer

public MBeanServer getMBeanServer()
Specified by:
getMBeanServer in interface javax.jbi.component.ComponentContext
Returns:
theMBean server assocated with the JBI

getNamingContext

public InitialContext getNamingContext()
Specified by:
getNamingContext in interface javax.jbi.component.ComponentContext
Returns:
the naming context

getTransactionManager

public Object getTransactionManager()
Get the TransactionManager for this implementation. The instance returned is an implementation of the standard JTA interface. If none is available, this method returns null.

The object returned by this method is untyped, to allow this interface to be compiled in environments that do not support JTA. If not null, the object returned must be of type javax.transaction.TransactionManager.

This downcast is necessary because JBI is used in environments that do not support JTA (i.e., J2SE). Explicit use of JTA types would cause compilation failures in such environments.

Specified by:
getTransactionManager in interface javax.jbi.component.ComponentContext
Returns:
A TransactionManager instance, or null if none is available in the execution environment.

getWorkspaceRoot

public String getWorkspaceRoot()
Specified by:
getWorkspaceRoot in interface javax.jbi.component.ComponentContext
Returns:
the root directory path

getContainer

public JBIContainer getContainer()
Returns:
Returns the container.

getEnvironment

public ComponentEnvironment getEnvironment()
Returns:
Returns the ComponentEnvironment

setEnvironment

public void setEnvironment(ComponentEnvironment ce)
Set the ComponentEnvironment

Parameters:
ce -

setContainer

public void setContainer(JBIContainer container)
Parameters:
container - The container to set.

setDeliveryChannel

public void setDeliveryChannel(javax.jbi.messaging.DeliveryChannel deliveryChannel)
Parameters:
deliveryChannel - The deliveryChannel to set.

registerExternalEndpoint

public void registerExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint externalEndpoint)
                              throws javax.jbi.JBIException
Registers the given external endpoint with the NMR. This indicates to the NMR that the given endpoint is used as a proxy for external service consumers to access an internal service of the same service name (but a different endpoint name).

Specified by:
registerExternalEndpoint in interface javax.jbi.component.ComponentContext
Parameters:
externalEndpoint - the external endpoint to be registered, must be non-null.
Throws:
javax.jbi.JBIException - if an external endpoint with the same name is already registered, by this or another component.

deregisterExternalEndpoint

public void deregisterExternalEndpoint(javax.jbi.servicedesc.ServiceEndpoint externalEndpoint)
                                throws javax.jbi.JBIException
Deregisters the given external endpoint with the NMR. This indicates to the NMR that the given external endpoint can no longer be used as a proxy for external service consumers to access an internal service of the same service name.

Specified by:
deregisterExternalEndpoint in interface javax.jbi.component.ComponentContext
Parameters:
externalEndpoint - the external endpoint to be deregistered; must be non-null.
Throws:
javax.jbi.JBIException - if the given external endpoint was not previously registered.

resolveEndpointReference

public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(DocumentFragment epr)
Resolve the given endpoint reference into a service endpoint. This is called by the component when it has an EPR that it wants to resolve into a service endpoint.

Note that the service endpoint returned refers to a dynamic endpoint; the endpoint will exist only as long as this component retains a strong reference to the object returned by this method. The endpoint may not be included in the list of "activated" endpoints.

Specified by:
resolveEndpointReference in interface javax.jbi.component.ComponentContext
Parameters:
epr - endpoint reference as an XML fragment; must be non-null.
Returns:
the service endpoint corresponding to the given endpoint reference; null if the reference cannot be resolved.

getEndpoint

public javax.jbi.servicedesc.ServiceEndpoint getEndpoint(QName service,
                                                         String name)
Get the service endpoint for the named activated endpoint, if any.

Specified by:
getEndpoint in interface javax.jbi.component.ComponentContext
Parameters:
service - qualified-name of the endpoint's service; must be non-null.
name - name of the endpoint; must be non-null.
Returns:
the named endpoint, or null if the named endpoint is not activated.

getEndpointDescriptor

public Document getEndpointDescriptor(javax.jbi.servicedesc.ServiceEndpoint endpoint)
                               throws javax.jbi.JBIException
Retrieve the service description metadata for the specified endpoint.

Note that the result can use either the WSDL 1.1 or WSDL 2.0 description language.

Specified by:
getEndpointDescriptor in interface javax.jbi.component.ComponentContext
Parameters:
endpoint - endpoint reference; must be non-null.
Returns:
metadata describing endpoint, or null if metadata is unavailable.
Throws:
javax.jbi.JBIException - invalid endpoint reference.

getEndpoints

public javax.jbi.servicedesc.ServiceEndpoint[] getEndpoints(QName interfaceName)
Queries the NMR for active endpoints that implement the given interface. This will return the endpoints for all services and endpoints that implement the named interface (portType in WSDL 1.1). This method does NOT include external endpoints (those registered using registerExternalEndpoint(ServiceEndpoint).

Specified by:
getEndpoints in interface javax.jbi.component.ComponentContext
Parameters:
interfaceName - qualified name of interface/portType that is implemented by the endpoint; if null then all activated endpoints in the JBI environment must be returned.
Returns:
an array of available endpoints for the specified interface name; must be non-null; may be empty.

getEndpointsForService

public javax.jbi.servicedesc.ServiceEndpoint[] getEndpointsForService(QName serviceName)
Queries the NMR for active endpoints belonging to the given service. This method does NOT include external endpoints (those registered using registerExternalEndpoint(ServiceEndpoint).

Specified by:
getEndpointsForService in interface javax.jbi.component.ComponentContext
Parameters:
serviceName - qualified name of the service that the endpoints are part of; must be non-null.
Returns:
an array of available endpoints for the specified service name; must be non-null; may be empty.

getExternalEndpoints

public javax.jbi.servicedesc.ServiceEndpoint[] getExternalEndpoints(QName interfaceName)
Queries the NMR for external endpoints that implement the given interface name. This methods returns only registered external endpoints (see registerExternalEndpoint(ServiceEndpoint).

Specified by:
getExternalEndpoints in interface javax.jbi.component.ComponentContext
Parameters:
interfaceName - qualified name of interface implemented by the endpoints; must be non-null.
Returns:
an array of available external endpoints for the specified interface name; must be non-null; may be empty.

getExternalEndpointsForService

public javax.jbi.servicedesc.ServiceEndpoint[] getExternalEndpointsForService(QName serviceName)
Queries the NMR for external endpoints that are part of the given service.

Specified by:
getExternalEndpointsForService in interface javax.jbi.component.ComponentContext
Parameters:
serviceName - qualified name of service that contains the endpoints; must be non-null.
Returns:
an array of available external endpoints for the specified service name; must be non-null; may be empty.

getInstallRoot

public String getInstallRoot()
Get the installation root directory path for this component.

This method MUST return the file path formatted for the underlying platform.

Specified by:
getInstallRoot in interface javax.jbi.component.ComponentContext
Returns:
the installation root directory path, in platform-specific form; must be non-null and non-empty.

getLogger

public Logger getLogger(String suffix,
                        String resourceBundleName)
                 throws MissingResourceException,
                        javax.jbi.JBIException
Get a logger instance from JBI. Loggers supplied by JBI are guaranteed to have unique names such that they avoid name collisions with loggers from other components created using this method. The suffix parameter allows for the creation of subloggers as needed. The JBI specification says nothing about the exact names to be used, only that they must be unique across components and the JBI implementation itself.

Specified by:
getLogger in interface javax.jbi.component.ComponentContext
Parameters:
suffix - for creating subloggers; use an empty string for the base component logger; must be non-null.
resourceBundleName - name of ResourceBundle to be used for localizing messages for the logger. May be null if none of the messages require localization. The resource, if non-null, must be loadable using the component's class loader as the initiating loader.
Returns:
a standard logger, named uniquely for this component (plus the given suffix, if applicable); must be non-null.
Throws:
MissingResourceException - if the ResourceBundleName is non-null and no corresponding resource can be found.
javax.jbi.JBIException - if the resourceBundleName has changed from a previous invocation by this component of this method with the same suffix.

getActivationSpec

public ActivationSpec getActivationSpec()
Returns:
the ActivationSpec


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.