| Commit in servicemix/base/src/main/java/org/servicemix/jbi/framework on MAIN | |||
| ComponentContextImpl.java | +128 | -169 | 1.3 -> 1.4 |
added more logging
servicemix/base/src/main/java/org/servicemix/jbi/framework
diff -u -r1.3 -r1.4 --- ComponentContextImpl.java 1 Aug 2005 00:04:41 -0000 1.3 +++ ComponentContextImpl.java 1 Aug 2005 01:38:35 -0000 1.4 @@ -18,13 +18,12 @@
**/ package org.servicemix.jbi.framework;
-
import java.io.File; import java.util.MissingResourceException; import java.util.logging.Logger; import javax.jbi.JBIException;
-import javax.jbi.component.ComponentContext;
import javax.jbi.component.Component;
+import javax.jbi.component.ComponentContext;
import javax.jbi.management.MBeanNames; import javax.jbi.messaging.DeliveryChannel; import javax.jbi.messaging.MessagingException;
@@ -34,6 +33,8 @@
import javax.naming.InitialContext; import javax.resource.spi.work.WorkManager; import javax.xml.namespace.QName;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory;
import org.servicemix.jbi.container.ActivationSpec; import org.servicemix.jbi.container.ComponentEnvironment; import org.servicemix.jbi.container.JBIContainer;
@@ -42,11 +43,12 @@
import org.w3c.dom.DocumentFragment; /**
- * This context provides access to data needed by all JBI components running in the JBI environment. - * - * @version $Revision: 1.3 $
+ * This context provides access to data needed by all JBI components running in the JBI environment. + * + * @version $Revision: 1.4 $
*/
-public class ComponentContextImpl implements ComponentContext, MBeanNames{
+public class ComponentContextImpl implements ComponentContext, MBeanNames {
+ private static final Log log = LogFactory.getLog(ComponentContextImpl.class);
private ComponentNameSpace componentName;
private ComponentEnvironment environment;
private JBIContainer container;
@@ -56,27 +58,28 @@
private File installRoot;
private boolean activated;
-
/**
* Constructor
+ *
* @param container
* @param componentName
*/
- public ComponentContextImpl(JBIContainer container, ComponentNameSpace componentName){
+ public ComponentContextImpl(JBIContainer container, ComponentNameSpace componentName) {
this.componentName = componentName;
this.container = container;
}
- -
+
/**
* Activate the ComponentContext
+ *
* @param component
* @param channel
* @param env
* @param spec
- * @param installRoot
+ * @param installRoot
*/
- public void activate(Component component, DeliveryChannelImpl channel, ComponentEnvironment env, ActivationSpec spec,File installRoot){
+ public void activate(Component component, DeliveryChannelImpl channel, ComponentEnvironment env,
+ ActivationSpec spec, File installRoot) {
this.component = component;
this.deliveryChannel = channel;
this.environment = env;
@@ -85,19 +88,20 @@
channel.setContext(this);
activated = true;
}
-
+
/**
* get the id of the ComponentConnector
+ *
* @return the id
*/
- public ComponentNameSpace getComponentNameSpace(){
+ public ComponentNameSpace getComponentNameSpace() {
return componentName;
}
-
+
/**
* @return the unique component name
*/
- public String getComponentName(){
+ public String getComponentName() {
return componentName.getName();
}
@@ -107,12 +111,13 @@
public Component getComponent() {
return component;
}
-
+
/**
* Get WorkManager
+ *
* @return the Container's WorkManager
*/
- public WorkManager getWorkManager(){
+ public WorkManager getWorkManager() {
return container.getWorkManager();
}
@@ -124,6 +129,7 @@
*/
public ServiceEndpoint activateEndpoint(QName serviceName, String endpointName) throws JBIException {
checkActivated();
+ log.info("Component: " + componentName.getName() + " activated endpoint: " + serviceName + " : " + endpointName);
return container.activateEndpoint(this, serviceName, endpointName);
}
@@ -139,7 +145,7 @@
/**
* Deregister the endpoint with the NMR
- *
+ *
* @param endpoint
* @throws JBIException
*/
@@ -156,29 +162,24 @@
return deliveryChannel;
}
-
/**
- * Retrieve the default JMX Domain Name for MBeans registered in this - * instance of the JBI implementation. - *
+ * Retrieve the default JMX Domain Name for MBeans registered in this instance of the JBI implementation. + *
* @return the JMX domain name for this instance of the JBI implementation.
*/
- public String getJmxDomainName(){
- return container.getManagementContext().getJmxDomainName();
- }
-
- /**
- * Formulate and return the MBean ObjectName of a custom control MBean for
- * a JBI component.
- *
- * @param customName the name of the custom control.
- * @return the JMX ObjectName of the MBean, or <code>null</code> if
- * <code>customName</code> is invalid.
- */
- public ObjectName createCustomComponentMBeanName(String customName){
- return container.getManagementContext().createCustomComponentMBeanName(componentName.getName(), customName);
- }
-
+ public String getJmxDomainName() {
+ return container.getManagementContext().getJmxDomainName();
+ }
+
+ /**
+ * Formulate and return the MBean ObjectName of a custom control MBean for a JBI component.
+ *
+ * @param customName the name of the custom control.
+ * @return the JMX ObjectName of the MBean, or <code>null</code> if <code>customName</code> is invalid.
+ */
+ public ObjectName createCustomComponentMBeanName(String customName) {
+ return container.getManagementContext().createCustomComponentMBeanName(componentName.getName(), customName);
+ }
/**
* @return the MBeanNames service
@@ -201,29 +202,22 @@
return container.getNamingContext();
}
-
/**
- * Get the TransactionManager for this implementation. The instance - * returned is an implementation of the standard JTA interface. If none - * is available, this method returns <code>null</code>.
+ * Get the TransactionManager for this implementation. The instance returned is an implementation of the standard + * JTA interface. If none is available, this method returns <code>null</code>.
* <p>
- * 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 - * <code>javax.transaction.TransactionManager</code>.
+ * 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 <code>javax.transaction.TransactionManager</code>.
* <p>
- * 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. - * - * @return A TransactionManager instance, or <code>null</code> if none - * is available in the execution environment.
+ * 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. + * + * @return A TransactionManager instance, or <code>null</code> if none is available in the execution environment.
*/
public Object getTransactionManager() {
return container.getTransactionManager();
}
-
/**
* @return the root directory path
*/
@@ -237,11 +231,11 @@
public JBIContainer getContainer() {
return container;
}
-
+
/**
* @return Returns the ComponentEnvironment
*/
- public ComponentEnvironment getEnvironment(){
+ public ComponentEnvironment getEnvironment() {
return environment;
}
@@ -261,52 +255,43 @@
}
/**
- * 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). - * - * @param externalEndpoint the external endpoint to be registered, must be - * non-null. - * @exception JBIException if an external endpoint with the same name is - * already registered, by this or another component.
+ * 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). + * + * @param externalEndpoint the external endpoint to be registered, must be non-null. + * @exception JBIException if an external endpoint with the same name is already registered, by this or another + * component.
*/
public void registerExternalEndpoint(ServiceEndpoint externalEndpoint) throws JBIException {
checkActivated();
container.registerExternalEndpoint(this, externalEndpoint);
-
}
/**
- * 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. - * - * @param externalEndpoint the external endpoint to be deregistered; must - * be non-null. - * @exception JBIException if the given external endpoint was not previously - * registered.
+ * 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. + * + * @param externalEndpoint the external endpoint to be deregistered; must be non-null. + * @exception JBIException if the given external endpoint was not previously registered.
*/
public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint) throws JBIException {
checkActivated();
container.deregisterExternalEndpoint(this, externalEndpoint);
-
}
/**
- * 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.
+ * 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.
* <p>
- * 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. - *
+ * 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. + *
* @param epr endpoint reference as an XML fragment; must be non-null.
- * @return the service endpoint corresponding to the given endpoint - * reference; <code>null</code> if the reference cannot be resolved.
+ * @return the service endpoint corresponding to the given endpoint reference; <code>null</code> if the reference + * cannot be resolved.
*/
public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
checkActivated();
@@ -315,91 +300,74 @@
/**
* Get the service endpoint for the named activated endpoint, if any.
- * - * @param service qualified-name of the endpoint's service; must be - * non-null.
+ * + * @param service qualified-name of the endpoint's service; must be non-null.
* @param name name of the endpoint; must be non-null.
- * @return the named endpoint, or <code>null</code> if the named endpoint - * is not activated.
+ * @return the named endpoint, or <code>null</code> if the named endpoint is not activated.
*/
public ServiceEndpoint getEndpoint(QName service, String name) {
checkActivated();
- return container.getEndpoint(this,service,name);
+ return container.getEndpoint(this, service, name);
}
/**
* Retrieve the service description metadata for the specified endpoint.
* <p>
- * Note that the result can use either the WSDL 1.1 or WSDL 2.0 description - * language. - *
+ * Note that the result can use either the WSDL 1.1 or WSDL 2.0 description language. + *
* @param endpoint endpoint reference; must be non-null.
- * @return metadata describing endpoint, or <code>null</code> if metadata - * is unavailable.
+ * @return metadata describing endpoint, or <code>null</code> if metadata is unavailable.
* @exception JBIException invalid endpoint reference.
*/
public Document getEndpointDescriptor(ServiceEndpoint endpoint) throws JBIException {
checkActivated();
- return container.getEndpointDescriptor(this, endpoint);
+ return container.getEndpointDescriptor(this, endpoint);
}
/**
- * 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 - * [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. - * - * @param interfaceName qualified name of interface/portType that is - * implemented by the endpoint; if <code>null</code> then all - * activated endpoints in the JBI environment must be returned. - * @return an array of available endpoints for the specified interface name; - * must be non-null; may be empty. - */
+ * 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 [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. + * + * @param interfaceName qualified name of interface/portType that is implemented by the endpoint; if + * <code>null</code> then all activated endpoints in the JBI environment must be returned. + * @return an array of available endpoints for the specified interface name; must be non-null; may be empty. + */
public ServiceEndpoint[] getEndpoints(QName interfaceName) {
checkActivated();
- return container.getEndpoints(this,interfaceName);
+ return container.getEndpoints(this, interfaceName);
}
/**
- * Queries the NMR for active endpoints belonging to the given service. This - * method does NOT include external endpoints (those registered using - * [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. - * - * @param serviceName qualified name of the service that the endpoints - * are part of; must be non-null. - * @return an array of available endpoints for the specified service name; - * must be non-null; may be empty.
+ * Queries the NMR for active endpoints belonging to the given service. This method does NOT include external + * endpoints (those registered using [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. + * + * @param serviceName qualified name of the service that the endpoints are part of; must be non-null. + * @return an array of available endpoints for the specified service name; must be non-null; may be empty.
*/
public ServiceEndpoint[] getEndpointsForService(QName serviceName) {
checkActivated();
return container.getEndpointsForService(this, serviceName);
}
-
/**
- * Queries the NMR for external endpoints that implement the given - * interface name. This methods returns only registered external endpoints - * (see [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. - * - * @param interfaceName qualified name of interface implemented by the - * endpoints; must be non-null. - * @return an array of available external endpoints for the specified - * interface name; must be non-null; may be empty.
+ * Queries the NMR for external endpoints that implement the given interface name. This methods returns only + * registered external endpoints (see [EMAIL PROTECTED] #registerExternalEndpoint(ServiceEndpoint)}. + * + * @param interfaceName qualified name of interface implemented by the endpoints; must be non-null. + * @return an array of available external endpoints for the specified interface name; must be non-null; may be + * empty.
*/
public ServiceEndpoint[] getExternalEndpoints(QName interfaceName) {
checkActivated();
- return container.getExternalEndpoints(this,interfaceName);
+ return container.getExternalEndpoints(this, interfaceName);
}
/**
- * Queries the NMR for external endpoints that are part of the given - * service. - * - * @param serviceName qualified name of service that contains the endpoints; - * must be non-null. - * @return an array of available external endpoints for the specified - * service name; must be non-null; may be empty.
+ * Queries the NMR for external endpoints that are part of the given service. + * + * @param serviceName qualified name of service that contains the endpoints; must be non-null. + * @return an array of available external endpoints for the specified service name; must be non-null; may be empty.
*/
public ServiceEndpoint[] getExternalEndpointsForService(QName serviceName) {
checkActivated();
@@ -407,40 +375,32 @@
}
/**
- * Get the installation root directory path for this component. - * <p> - * This method MUST return the file path formatted for the underlying - * platform. - * - * @return the installation root directory path, in platform-specific - * form; must be non-null and non-empty. - */
+ * Get the installation root directory path for this component. + * <p> + * This method MUST return the file path formatted for the underlying platform. + * + * @return the installation root directory path, in platform-specific form; must be non-null and non-empty. + */
public String getInstallRoot() {
return installRoot.getAbsolutePath();
}
/**
- * 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. - * - * @param suffix for creating subloggers; use an empty string for the base - * component logger; must be non-null. - * @param resourceBundleName name of <code>ResourceBundle</code> to be used - * for localizing messages for the logger. May be <code>null</code> - * 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. - * @return a standard logger, named uniquely for this component (plus the - * given suffix, if applicable); must be non-null. - * @exception MissingResourceException if the ResourceBundleName is non-null - * and no corresponding resource can be found. - * @exception JBIException if the resourceBundleName has changed from - * a previous invocation by this component of this method with - * the same suffix.
+ * 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. + * + * @param suffix for creating subloggers; use an empty string for the base component logger; must be non-null. + * @param resourceBundleName name of <code>ResourceBundle</code> to be used for localizing messages for the + * logger. May be <code>null</code> 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. + * @return a standard logger, named uniquely for this component (plus the given suffix, if applicable); must be + * non-null. + * @exception MissingResourceException if the ResourceBundleName is non-null and no corresponding resource can be + * found. + * @exception JBIException if the resourceBundleName has changed from a previous invocation by this component of + * this method with the same suffix.
*/
public Logger getLogger(String suffix, String resourceBundleName) throws MissingResourceException, JBIException {
String name = suffix != null ? suffix : "";
@@ -454,11 +414,10 @@
public ActivationSpec getActivationSpec() {
return activationSpec;
}
-
- private void checkActivated(){
- if (!activated){
+
+ private void checkActivated() {
+ if (!activated) {
throw new IllegalStateException("ComponentContext not activated");
}
}
-
}
