You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/08/09 22:33:52 UTC
svn commit: r564374 [3/7] - in
/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix:
./ client/ components/util/ components/util/xstream/
components/varscheduler/ expression/ jbi/ jbi/container/ jbi/deployment/
jbi/event...
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.java Thu Aug 9 13:33:26 2007
@@ -16,30 +16,33 @@
*/
package org.apache.servicemix.expression;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlSaxHandler;
-
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.TransformerException;
import javax.xml.transform.sax.SAXResult;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlSaxHandler;
+
/**
* An {@link Expression} which evaluates an XPath expression using <a href="http://xmlbeans.apache.org/">XMLBeans</a>
*
* @version $Revision$
*/
public class XMLBeansXPathExpression implements Expression {
+
private String xpath;
+
private XmlOptions options = new XmlOptions();
+
private SourceTransformer transformer = new SourceTransformer();
- public XMLBeansXPathExpression(String xpath) {
- this.xpath = xpath;
+ public XMLBeansXPathExpression(String xp) {
+ this.xpath = xp;
}
public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
@@ -49,17 +52,15 @@
transformer.toResult(message.getContent(), result);
XmlObject object = handler.getObject();
return evaluateXPath(object, xpath, options);
- }
- catch (TransformerException e) {
+ } catch (TransformerException e) {
throw new MessagingException(e);
- }
- catch (XmlException e) {
+ } catch (XmlException e) {
throw new MessagingException(e);
}
}
- protected Object evaluateXPath(XmlObject object, String xpath, XmlOptions options) {
- XmlObject[] xmlObjects = object.selectPath(this.xpath, this.options);
+ protected Object evaluateXPath(XmlObject object, String xp, XmlOptions opts) {
+ XmlObject[] xmlObjects = object.selectPath(xp, opts);
if (xmlObjects.length == 1) {
return xmlObjects[0];
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/ExchangeTimeoutException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/ExchangeTimeoutException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/ExchangeTimeoutException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/ExchangeTimeoutException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class ExchangeTimeoutException extends MessagingException {
- private MessageExchange exchange;
+
+ private final MessageExchange exchange;
public ExchangeTimeoutException(MessageExchange exchange) {
super("Exchange has timed out: " + exchange);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/FaultException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/FaultException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/FaultException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/FaultException.java Thu Aug 9 13:33:26 2007
@@ -26,23 +26,23 @@
* @version $Revision$
*/
public class FaultException extends MessagingException {
- private MessageExchange exchange;
- private Fault fault;
+
+ private final MessageExchange exchange;
+ private final Fault fault;
+
+ public FaultException(String text, MessageExchange exchange, Fault fault) {
+ super(text);
+ this.exchange = exchange;
+ this.fault = fault;
+ }
public static FaultException newInstance(MessageExchange exchange) throws NoFaultAvailableException {
Fault fault = exchange.getFault();
if (fault == null) {
throw new NoFaultAvailableException(exchange);
- }
- else {
+ } else {
return new FaultException("Fault occurred invoking server: " + fault, exchange, fault);
}
- }
-
- public FaultException(String text, MessageExchange exchange, Fault fault) {
- super(text);
- this.exchange = exchange;
- this.fault = fault;
}
public MessageExchange getExchange() {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/MissingPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/MissingPropertyException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/MissingPropertyException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/MissingPropertyException.java Thu Aug 9 13:33:26 2007
@@ -24,7 +24,8 @@
* @version $Revision$
*/
public class MissingPropertyException extends JBIException {
- private String property;
+
+ private final String property;
public MissingPropertyException(String property) {
super("Cannot use this component as the property '" + property + "' was not configured");
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoFaultAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoFaultAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoFaultAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoFaultAvailableException.java Thu Aug 9 13:33:26 2007
@@ -26,7 +26,8 @@
* @version $Revision$
*/
public class NoFaultAvailableException extends MessagingException {
- private MessageExchange messageExchange;
+
+ private final MessageExchange messageExchange;
public NoFaultAvailableException(MessageExchange messageExchange) {
super("No Fault available for message exchange: " + messageExchange);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInMessageAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInMessageAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInMessageAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInMessageAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoInMessageAvailableException extends MessagingException {
- private MessageExchange messageExchange;
+
+ private final MessageExchange messageExchange;
public NoInMessageAvailableException(MessageExchange messageExchange) {
super("No in message available for message exchange: " + messageExchange);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInterfaceAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInterfaceAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInterfaceAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoInterfaceAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoInterfaceAvailableException extends NoEndpointAvailableException {
- private QName interfaceName;
+
+ private final QName interfaceName;
public NoInterfaceAvailableException(QName interfaceName) {
super("Cannot find an instance of the service: " + interfaceName);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoMessageContentAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoMessageContentAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoMessageContentAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoMessageContentAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoMessageContentAvailableException extends MessagingException {
- private MessageExchange messageExchange;
+
+ private final MessageExchange messageExchange;
public NoMessageContentAvailableException(MessageExchange messageExchange) {
super("No message content in the inbound message for message exchange: " + messageExchange);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoOutMessageAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoOutMessageAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoOutMessageAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoOutMessageAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoOutMessageAvailableException extends MessagingException {
- private MessageExchange messageExchange;
+
+ private final MessageExchange messageExchange;
public NoOutMessageAvailableException(MessageExchange messageExchange) {
super("No out message available for message exchange: " + messageExchange);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoServiceAvailableException extends NoEndpointAvailableException {
- private QName serviceName;
+
+ private final QName serviceName;
public NoServiceAvailableException(QName serviceName) {
super("Cannot find an instance of the service: " + serviceName);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceEndpointAvailableException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceEndpointAvailableException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceEndpointAvailableException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoServiceEndpointAvailableException.java Thu Aug 9 13:33:26 2007
@@ -25,8 +25,9 @@
* @version $Revision$
*/
public class NoServiceEndpointAvailableException extends NoEndpointAvailableException {
- private QName serviceName;
- private String endpointName;
+
+ private final QName serviceName;
+ private final String endpointName;
public NoServiceEndpointAvailableException(QName serviceName, String endpointName) {
super("Cannot find an instance of the service: " + serviceName + " and endpoint: " + endpointName);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoSuchOperationException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoSuchOperationException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoSuchOperationException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/NoSuchOperationException.java Thu Aug 9 13:33:26 2007
@@ -25,7 +25,8 @@
* @version $Revision$
*/
public class NoSuchOperationException extends MessagingException {
- private QName operationName;
+
+ private final QName operationName;
public NoSuchOperationException(QName operationName) {
super("No such operation name: " + operationName);
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/RuntimeJBIException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/RuntimeJBIException.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/RuntimeJBIException.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/RuntimeJBIException.java Thu Aug 9 13:33:26 2007
@@ -25,6 +25,7 @@
* @version $Revision$
*/
public class RuntimeJBIException extends RuntimeException {
+
private static final long serialVersionUID = -6386553476156600457L;
/**
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ActivationSpec.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ActivationSpec.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ActivationSpec.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ActivationSpec.java Thu Aug 9 13:33:26 2007
@@ -16,6 +16,10 @@
*/
package org.apache.servicemix.jbi.container;
+import java.io.Serializable;
+
+import javax.xml.namespace.QName;
+
import org.apache.servicemix.jbi.messaging.PojoMarshaler;
import org.apache.servicemix.jbi.resolver.EndpointChooser;
import org.apache.servicemix.jbi.resolver.EndpointResolver;
@@ -24,22 +28,20 @@
import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
import org.apache.servicemix.jbi.resolver.URIResolver;
-import javax.xml.namespace.QName;
-
-import java.io.Serializable;
-
/**
* Represents the registration of a component with the {@link JBIContainer}
- *
- * @org.apache.xbean.XBean element="activationSpec"
- * description="The Component configuration consisting of its container related properties such as its routing information"
+ *
+ * @org.apache.xbean.XBean element="activationSpec" description="The Component
+ * configuration consisting of its container related
+ * properties such as its routing information"
*
* @version $Revision$
*/
public class ActivationSpec implements Serializable {
-
- static final long serialVersionUID = 8458586342841647313L;
- private String id;
+
+ static final long serialVersionUID = 8458586342841647313L;
+
+ private String id;
private String componentName;
private Object component;
private QName service;
@@ -59,7 +61,6 @@
private Boolean persistent;
private String destinationUri;
-
public ActivationSpec() {
}
@@ -74,7 +75,7 @@
/**
* The unique component ID
- *
+ *
* @return the unique ID
*/
public String getId() {
@@ -83,7 +84,7 @@
/**
* Sets the unique component ID
- *
+ *
* @param id
*/
public void setId(String id) {
@@ -149,9 +150,9 @@
}
/**
- * Returns the destination resolver used to decide which
- * destination the container should route this component to.
- *
+ * Returns the destination resolver used to decide which destination the
+ * container should route this component to.
+ *
* @return the destination resolver, lazily creating one if possible
*/
public EndpointResolver getDestinationResolver() {
@@ -162,16 +163,15 @@
}
/**
- * Sets the destination resolver used by the container to route
- * requests send on the default endpoint.
- *
+ * Sets the destination resolver used by the container to route requests
+ * send on the default endpoint.
+ *
* @param destinationResolver
*/
public void setDestinationResolver(EndpointResolver destinationResolver) {
this.destinationResolver = destinationResolver;
}
-
public EndpointChooser getInterfaceChooser() {
return interfaceChooser;
}
@@ -247,15 +247,16 @@
public void setSubscriptions(SubscriptionSpec[] subscriptions) {
this.subscriptions = subscriptions;
}
-
+
public boolean isFailIfNoDestinationEndpoint() {
return failIfNoDestinationEndpoint;
}
/**
- * Sets whether or not there should be a failure if there is no matching endpoint for the service dispatch.
- * It may be in a pure publish/subscribe model you want all available subscribes to receive the message but do not mind
- * if there is not a single destination endpoint that can be found.
+ * Sets whether or not there should be a failure if there is no matching
+ * endpoint for the service dispatch. It may be in a pure publish/subscribe
+ * model you want all available subscribes to receive the message but do not
+ * mind if there is not a single destination endpoint that can be found.
*
* @param failIfNoDestinationEndpoint
*/
@@ -271,12 +272,10 @@
if (destinationService != null) {
if (destinationEndpoint != null) {
return new ServiceAndEndpointNameResolver(destinationService, destinationEndpoint);
- }
- else {
+ } else {
return new ServiceNameEndpointResolver(destinationService);
}
- }
- else if (destinationInterface != null) {
+ } else if (destinationInterface != null) {
return new InterfaceNameEndpointResolver(destinationInterface);
} else if (destinationUri != null) {
return new URIResolver(destinationUri);
@@ -284,20 +283,22 @@
return null;
}
- public Boolean getPersistent() {
- return persistent;
- }
-
- /**
- * Set if message exchanges issued by the component should be persistent
- * or not. This value will override the default one given on the
- * {@link org.apache.servicemix.jbi.container.JBIContainer#persistent} attribute.
- *
- * @param persistent the new value to set
- */
- public void setPersistent(Boolean persistent) {
- this.persistent = persistent;
- }
+ public Boolean getPersistent() {
+ return persistent;
+ }
+
+ /**
+ * Set if message exchanges issued by the component should be persistent or
+ * not. This value will override the default one given on the
+ * {@link org.apache.servicemix.jbi.container.JBIContainer#persistent}
+ * attribute.
+ *
+ * @param persistent
+ * the new value to set
+ */
+ public void setPersistent(Boolean persistent) {
+ this.persistent = persistent;
+ }
/**
* @return the destinationUri
@@ -307,11 +308,11 @@
}
/**
- * @param destinationUri the destinationUri to set
+ * @param destinationUri
+ * the destinationUri to set
*/
public void setDestinationUri(String destinationUri) {
this.destinationUri = destinationUri;
}
-
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java Thu Aug 9 13:33:26 2007
@@ -19,6 +19,8 @@
import java.io.File;
import java.io.IOException;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.jbi.JBIException;
@@ -29,9 +31,6 @@
import org.apache.servicemix.jbi.util.FileUtil;
import org.apache.servicemix.jbi.util.FileVersionUtil;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
/**
* Holder for environment information
*
@@ -49,7 +48,8 @@
* @version $Revision$
*/
public class EnvironmentContext extends BaseSystemService implements EnvironmentContextMBean {
- private static final Log log = LogFactory.getLog(EnvironmentContext.class);
+
+ private static final Log LOG = LogFactory.getLog(EnvironmentContext.class);
private File jbiRootDir;
private File componentsDir;
@@ -61,7 +61,6 @@
private Map envMap = new ConcurrentHashMap();
private AtomicBoolean started = new AtomicBoolean(false);
-
/**
* @return the current version of servicemix
*/
@@ -78,9 +77,10 @@
* Get Description
* @return description
*/
- public String getDescription(){
+ public String getDescription() {
return "Manages Environment for the Container";
}
+
/**
* @return Returns the componentsDir.
*/
@@ -94,16 +94,15 @@
public File getInstallationDir() {
return installationDir;
}
-
+
/**
* Set the installationDir - rge default location
* is root/<container name>/installation
* @param installationDir
*/
- public void setInstallationDir(File installationDir){
+ public void setInstallationDir(File installationDir) {
this.installationDir = installationDir;
}
-
/**
* @return Returns the deploymentDir.
@@ -118,12 +117,12 @@
public void setDeploymentDir(File deploymentDir) {
this.deploymentDir = deploymentDir;
}
-
+
/**
*
* @return Returns the shared library directory
*/
- public File getSharedLibDir(){
+ public File getSharedLibDir() {
return sharedLibDir;
}
@@ -137,14 +136,12 @@
return tmpDir;
}
-
/**
* @return Returns service asseblies directory
*/
- public File getServiceAssembliesDir(){
+ public File getServiceAssembliesDir() {
return serviceAssembliesDir;
- }
-
+ }
/**
* Initialize the Environment
@@ -206,7 +203,7 @@
public ComponentEnvironment registerComponent(ComponentMBeanImpl connector) throws JBIException {
return registerComponent(null, connector);
}
-
+
/**
* register the ComponentConnector
*
@@ -214,8 +211,7 @@
* @return the CompponentEnvironment
* @throws JBIException
*/
- public ComponentEnvironment registerComponent(ComponentEnvironment result,
- ComponentMBeanImpl connector) throws JBIException {
+ public ComponentEnvironment registerComponent(ComponentEnvironment result, ComponentMBeanImpl connector) throws JBIException {
if (result == null) {
result = new ComponentEnvironment();
}
@@ -246,8 +242,8 @@
result.setLocalConnector(connector);
envMap.put(connector, result);
return result;
- }
-
+ }
+
/**
* Get root directory for a Component
*
@@ -277,7 +273,7 @@
File result = FileUtil.getDirectoryPath(getComponentsDir(), componentName);
return result;
}
-
+
/**
* Get a new versionned directory for installation
*
@@ -291,7 +287,7 @@
result = FileVersionUtil.getNewVersionDirectory(result);
return result;
}
-
+
/**
* Create installation directory for a Component
*
@@ -305,11 +301,11 @@
result = FileVersionUtil.getLatestVersionDirectory(result);
return result;
}
-
+
public ComponentEnvironment getNewComponentEnvironment(String compName) throws IOException {
- File rootDir = FileUtil.getDirectoryPath(getComponentsDir(), compName);
- File instDir = FileVersionUtil.getNewVersionDirectory(rootDir);
- File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
+ File rootDir = FileUtil.getDirectoryPath(getComponentsDir(), compName);
+ File instDir = FileVersionUtil.getNewVersionDirectory(rootDir);
+ File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
ComponentEnvironment env = new ComponentEnvironment();
env.setComponentRoot(rootDir);
@@ -318,11 +314,11 @@
env.setStateFile(stateFile);
return env;
}
-
+
public ComponentEnvironment getComponentEnvironment(String compName) throws IOException {
- File rootDir = FileUtil.getDirectoryPath(getComponentsDir(), compName);
- File instDir = FileVersionUtil.getLatestVersionDirectory(rootDir);
- File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
+ File rootDir = FileUtil.getDirectoryPath(getComponentsDir(), compName);
+ File instDir = FileVersionUtil.getLatestVersionDirectory(rootDir);
+ File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
ComponentEnvironment env = new ComponentEnvironment();
env.setComponentRoot(rootDir);
@@ -331,12 +327,12 @@
env.setStateFile(stateFile);
return env;
}
-
+
public ServiceAssemblyEnvironment getNewServiceAssemblyEnvironment(String saName) throws IOException {
- File rootDir = FileUtil.getDirectoryPath(getServiceAssembliesDir(), saName);
- File versDir = FileVersionUtil.getNewVersionDirectory(rootDir);
- File instDir = FileUtil.getDirectoryPath(versDir, "install");
- File susDir = FileUtil.getDirectoryPath(versDir, "sus");
+ File rootDir = FileUtil.getDirectoryPath(getServiceAssembliesDir(), saName);
+ File versDir = FileVersionUtil.getNewVersionDirectory(rootDir);
+ File instDir = FileUtil.getDirectoryPath(versDir, "install");
+ File susDir = FileUtil.getDirectoryPath(versDir, "sus");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
ServiceAssemblyEnvironment env = new ServiceAssemblyEnvironment();
env.setRootDir(rootDir);
@@ -345,12 +341,12 @@
env.setStateFile(stateFile);
return env;
}
-
+
public ServiceAssemblyEnvironment getServiceAssemblyEnvironment(String saName) {
- File rootDir = FileUtil.getDirectoryPath(getServiceAssembliesDir(), saName);
- File versDir = FileVersionUtil.getLatestVersionDirectory(rootDir);
- File instDir = FileUtil.getDirectoryPath(versDir, "install");
- File susDir = FileUtil.getDirectoryPath(versDir, "sus");
+ File rootDir = FileUtil.getDirectoryPath(getServiceAssembliesDir(), saName);
+ File versDir = FileVersionUtil.getLatestVersionDirectory(rootDir);
+ File instDir = FileUtil.getDirectoryPath(versDir, "install");
+ File susDir = FileUtil.getDirectoryPath(versDir, "sus");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
ServiceAssemblyEnvironment env = new ServiceAssemblyEnvironment();
env.setRootDir(rootDir);
@@ -359,7 +355,7 @@
env.setStateFile(stateFile);
return env;
}
-
+
/**
* Create workspace directory for a Component
*
@@ -373,7 +369,7 @@
FileUtil.buildDirectory(result);
return result;
}
-
+
/**
* deregister the ComponentConnector
*
@@ -393,14 +389,13 @@
File file = getComponentRootDir(componentName);
if (file != null) {
if (!FileUtil.deleteFile(file)) {
- log.warn("Failed to remove directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
- }
- else {
- log.info("Removed directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
+ LOG.warn("Failed to remove directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
+ } else {
+ LOG.info("Removed directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
}
}
- }
-
+ }
+
/**
* create a shared library directory
*
@@ -413,7 +408,7 @@
FileUtil.buildDirectory(result);
return result;
}
-
+
/**
* remove shared library directory
* @param name
@@ -424,8 +419,7 @@
FileUtil.deleteFile(result);
}
-
- private void buildDirectoryStructure() throws JBIException {
+ private void buildDirectoryStructure() throws JBIException {
// We want ServiceMix to be able to run embedded
// so do not create the directory structure if the root does not exist
if (container.isEmbedded()) {
@@ -435,23 +429,23 @@
jbiRootDir = jbiRootDir.getCanonicalFile();
if (!jbiRootDir.exists()) {
if (!jbiRootDir.mkdirs()) {
- throw new JBIException("Directory could not be created: "+jbiRootDir.getCanonicalFile());
+ throw new JBIException("Directory could not be created: " + jbiRootDir.getCanonicalFile());
}
} else if (!jbiRootDir.isDirectory()) {
- throw new JBIException("Not a directory: " + jbiRootDir.getCanonicalFile());
- }
- if (installationDir == null){
+ throw new JBIException("Not a directory: " + jbiRootDir.getCanonicalFile());
+ }
+ if (installationDir == null) {
installationDir = FileUtil.getDirectoryPath(jbiRootDir, "install");
}
installationDir = installationDir.getCanonicalFile();
- if (deploymentDir == null){
+ if (deploymentDir == null) {
deploymentDir = FileUtil.getDirectoryPath(jbiRootDir, "deploy");
}
deploymentDir = deploymentDir.getCanonicalFile();
componentsDir = FileUtil.getDirectoryPath(jbiRootDir, "components").getCanonicalFile();
tmpDir = FileUtil.getDirectoryPath(jbiRootDir, "tmp").getCanonicalFile();
sharedLibDir = FileUtil.getDirectoryPath(jbiRootDir, "sharedlibs").getCanonicalFile();
- serviceAssembliesDir = FileUtil.getDirectoryPath(jbiRootDir,"service-assemblies").getCanonicalFile();
+ serviceAssembliesDir = FileUtil.getDirectoryPath(jbiRootDir, "service-assemblies").getCanonicalFile();
//actually create the sub directories
FileUtil.buildDirectory(installationDir);
FileUtil.buildDirectory(deploymentDir);
@@ -464,10 +458,8 @@
}
}
-
public File getJbiRootDir() {
return jbiRootDir;
}
-
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java Thu Aug 9 13:33:26 2007
@@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.EventListener;
import java.util.MissingResourceException;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import javax.jbi.JBIException;
@@ -42,6 +43,8 @@
import javax.transaction.TransactionManager;
import javax.xml.namespace.QName;
+import org.w3c.dom.DocumentFragment;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.JbiConstants;
@@ -78,9 +81,6 @@
import org.apache.servicemix.jbi.nmr.Broker;
import org.apache.servicemix.jbi.nmr.DefaultBroker;
import org.apache.servicemix.jbi.nmr.flow.Flow;
-import org.w3c.dom.DocumentFragment;
-
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* The main container
@@ -92,15 +92,9 @@
* Default Container name - must be unique if used in a cluster
*/
public static final String DEFAULT_NAME = "ServiceMix";
- private static final Log log = LogFactory.getLog(JBIContainer.class);
- private String name = DEFAULT_NAME;
- private InitialContext namingContext;
- private MBeanServer mbeanServer;
- private TransactionManager transactionManager;
- private String rootDir = "." + File.separator + "rootDir";
- private AtomicBoolean started = new AtomicBoolean(false);
- private AtomicBoolean containerInitialized = new AtomicBoolean(false);
- private IdGenerator idGenerator = new IdGenerator();
+
+ private static final Log LOG = LogFactory.getLog(JBIContainer.class);
+
protected Broker broker = new DefaultBroker();
protected ServiceUnitManager serviceManager;
protected ManagementContext managementContext = new ManagementContext();
@@ -112,16 +106,24 @@
protected BaseSystemService[] services;
protected ClientFactory clientFactory = new ClientFactory();
protected Registry registry = new Registry();
- protected boolean autoEnlistInTransaction = false;
- protected boolean persistent = false;
- protected boolean embedded = false;
- protected boolean notifyStatistics = false;
+ protected boolean autoEnlistInTransaction;
+ protected boolean persistent;
+ protected boolean embedded;
+ protected boolean notifyStatistics;
protected EventListenerList listeners = new EventListenerList();
protected EventListener[] configuredListeners;
protected boolean useShutdownHook = true;
protected transient Thread shutdownHook;
- protected ExecutorFactory executorFactory;
-
+ protected ExecutorFactory executorFactory;
+ private String name = DEFAULT_NAME;
+ private InitialContext namingContext;
+ private MBeanServer mbeanServer;
+ private TransactionManager transactionManager;
+ private String rootDir = "." + File.separator + "rootDir";
+ private AtomicBoolean started = new AtomicBoolean(false);
+ private AtomicBoolean containerInitialized = new AtomicBoolean(false);
+ private IdGenerator idGenerator = new IdGenerator();
+
/**
* Default Constructor
*/
@@ -172,7 +174,7 @@
public void setFlowName(String flowName) {
getDefaultBroker().setFlowNames(flowName);
}
-
+
/**
* @return Returns the flowNames.
*/
@@ -186,7 +188,7 @@
public void setFlowNames(String flowNames) {
getDefaultBroker().setFlowNames(flowNames);
}
-
+
/**
* @return the subscriptionFlowName
*/
@@ -208,7 +210,7 @@
* @param flow
*/
public void setFlow(Flow flow) {
- getDefaultBroker().setFlows(new Flow[] { flow });
+ getDefaultBroker().setFlows(new Flow[] {flow });
}
/**
@@ -287,28 +289,27 @@
/**
* @return Return the registry
*/
- public Registry getRegistry() {
+ public Registry getRegistry() {
return registry;
}
-
+
/**
* Return the DefaultBroker instance
*/
public DefaultBroker getDefaultBroker() {
- if (broker == null ||
- broker instanceof DefaultBroker == false) {
+ if (broker == null || !(broker instanceof DefaultBroker)) {
throw new IllegalStateException("Broker is not a DefaultBroker");
}
return (DefaultBroker) broker;
}
-
+
/**
* @return Return the NMR broker
*/
- public Broker getBroker(){
+ public Broker getBroker() {
return broker;
}
-
+
/**
* Set the Broker to use
*/
@@ -373,18 +374,18 @@
public void setMonitorInstallationDirectory(boolean monitorInstallationDirectory) {
autoDeployService.setMonitorInstallationDirectory(monitorInstallationDirectory);
}
-
+
/**
* @return Returns the monitorDeploymentDirectory.
*/
- public boolean isMonitorDeploymentDirectory(){
+ public boolean isMonitorDeploymentDirectory() {
return autoDeployService.isMonitorDeploymentDirectory();
}
/**
* @param monitorDeploymentDirectory The monitorDeploymentDirectory to set.
*/
- public void setMonitorDeploymentDirectory(boolean monitorDeploymentDirectory){
+ public void setMonitorDeploymentDirectory(boolean monitorDeploymentDirectory) {
autoDeployService.setMonitorDeploymentDirectory(monitorDeploymentDirectory);
}
@@ -428,14 +429,14 @@
* @return Returns the monitorInterval (in secs).
*/
public int getMonitorInterval() {
- return autoDeployService.getMonitorInterval();
+ return autoDeployService.getMonitorInterval();
}
-
+
/**
* @param monitorInterval The monitorInterval to set (in secs).
*/
public void setMonitorInterval(int monitorInterval) {
- autoDeployService.setMonitorInterval(monitorInterval);
+ autoDeployService.setMonitorInterval(monitorInterval);
}
/**
@@ -461,7 +462,7 @@
public void installArchive(String url) throws DeploymentException {
installationService.install(url, null, true);
}
-
+
/**
* load an archive from an external location.
* The archive can be a Component, Service Assembly or Shared Library.
@@ -469,10 +470,10 @@
* @param autoStart - if true will start the component/service assembly
* @throws DeploymentException
*/
- public void updateExternalArchive(String location,boolean autoStart) throws DeploymentException {
+ public void updateExternalArchive(String location, boolean autoStart) throws DeploymentException {
autoDeployService.updateExternalArchive(location, autoStart);
}
-
+
/**
* load an archive from an external location and starts it
* The archive can be a Component, Service Assembly or Shared Library.
@@ -482,10 +483,6 @@
public void updateExternalArchive(String location) throws DeploymentException {
updateExternalArchive(location, true);
}
-
-
-
-
/**
* @return Returns the deploymentService.
@@ -515,12 +512,11 @@
public AdminCommandsService getAdminCommandsService() {
return adminCommandsService;
}
-
+
public ClientFactory getClientFactory() {
return clientFactory;
}
-
/**
* light weight initialization - default values for mbeanServer, TransactionManager etc are null
*
@@ -528,10 +524,8 @@
*/
public void init() throws JBIException {
if (containerInitialized.compareAndSet(false, true)) {
- log.info("ServiceMix " +
- EnvironmentContext.getVersion() +
- " JBI Container (" + getName() + ") is starting");
- log.info("For help or more informations please see: http://incubator.apache.org/servicemix/");
+ LOG.info("ServiceMix " + EnvironmentContext.getVersion() + " JBI Container (" + getName() + ") is starting");
+ LOG.info("For help or more informations please see: http://incubator.apache.org/servicemix/");
addShutdownHook();
if (this.executorFactory == null) {
this.executorFactory = createExecutorFactory();
@@ -539,18 +533,17 @@
if (this.namingContext == null) {
try {
this.namingContext = new InitialContext();
- }
- catch (NamingException e) {
+ } catch (NamingException e) {
// Log a warning, with exception only in debug
- if (log.isDebugEnabled()) {
- log.warn("Failed to set InitialContext", e);
+ if (LOG.isDebugEnabled()) {
+ LOG.warn("Failed to set InitialContext", e);
} else {
- log.warn("Failed to set InitialContext");
+ LOG.warn("Failed to set InitialContext");
}
}
}
managementContext.init(this, getMBeanServer());
- mbeanServer = this.managementContext.getMBeanServer();// just in case ManagementContext creates it
+ mbeanServer = this.managementContext.getMBeanServer(); // just in case ManagementContext creates it
environmentContext.init(this, rootDir);
clientFactory.init(this);
if (services != null) {
@@ -567,12 +560,12 @@
// register self with the ManagementContext
try {
- managementContext.registerMBean(ManagementContext.getContainerObjectName(managementContext.getJmxDomainName(), getName()),
- this, LifeCycleMBean.class);
+ managementContext.registerMBean(ManagementContext.getContainerObjectName(managementContext.getJmxDomainName(), getName()),
+ this, LifeCycleMBean.class);
} catch (JMException e) {
throw new JBIException(e);
}
-
+
// Initialize listeners after the whole container has been initialized
// so that they can register themselves as JMX mbeans for example
if (configuredListeners != null) {
@@ -607,7 +600,7 @@
autoDeployService.start();
adminCommandsService.start();
super.start();
- log.info("ServiceMix JBI Container (" + getName() + ") started");
+ LOG.info("ServiceMix JBI Container (" + getName() + ") started");
}
}
@@ -619,7 +612,7 @@
public void stop() throws JBIException {
checkInitialized();
if (started.compareAndSet(true, false)) {
- log.info("ServiceMix JBI Container (" + getName() + ") stopping");
+ LOG.info("ServiceMix JBI Container (" + getName() + ") stopping");
adminCommandsService.stop();
autoDeployService.stop();
deploymentService.stop();
@@ -665,11 +658,10 @@
super.shutDown();
managementContext.unregisterMBean(this);
managementContext.shutDown();
- log.info("ServiceMix JBI Container (" + getName() + ") stopped");
+ LOG.info("ServiceMix JBI Container (" + getName() + ") stopped");
}
}
-
protected void addShutdownHook() {
if (useShutdownHook) {
shutdownHook = new Thread("ServiceMix ShutdownHook") {
@@ -685,9 +677,8 @@
if (shutdownHook != null) {
try {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
- }
- catch (Exception e) {
- log.debug("Caught exception, must be shutting down: " + e);
+ } catch (Exception e) {
+ LOG.debug("Caught exception, must be shutting down: " + e);
}
}
}
@@ -698,8 +689,7 @@
protected void containerShutdown() {
try {
shutDown();
- }
- catch (Exception e) {
+ } catch (Exception e) {
System.err.println("Failed to shut down: " + e);
}
}
@@ -743,14 +733,12 @@
if (transactionManager == null && namingContext != null) {
try {
transactionManager = (TransactionManager) namingContext.lookup("java:appserver/TransactionManager");
- }
- catch (NamingException e) {
- log.debug("No transaction manager found from naming context: " + e.getMessage());
+ } catch (NamingException e) {
+ LOG.debug("No transaction manager found from naming context: " + e.getMessage());
try {
transactionManager = (TransactionManager) namingContext.lookup("javax.transaction.TransactionManager");
- }
- catch (NamingException e1) {
- log.debug("No transaction manager found from naming context: " + e1.getMessage());
+ } catch (NamingException e1) {
+ LOG.debug("No transaction manager found from naming context: " + e1.getMessage());
}
}
}
@@ -791,23 +779,19 @@
public void sendExchange(MessageExchangeImpl exchange) throws MessagingException {
try {
broker.sendExchangePacket(exchange);
- }
- catch (MessagingException e) {
+ } catch (MessagingException e) {
throw e;
- }
- catch (JBIException e) {
+ } catch (JBIException e) {
throw new MessagingException(e);
}
}
-
-
+
/**
* @param context
* @param externalEndpoint
* @throws JBIException
*/
- public void registerExternalEndpoint(ComponentNameSpace cns, ServiceEndpoint externalEndpoint)
- throws JBIException {
+ public void registerExternalEndpoint(ComponentNameSpace cns, ServiceEndpoint externalEndpoint) throws JBIException {
registry.registerExternalEndpoint(cns, externalEndpoint);
}
@@ -816,8 +800,7 @@
* @param externalEndpoint
* @throws JBIException
*/
- public void deregisterExternalEndpoint(ComponentNameSpace cns, ServiceEndpoint externalEndpoint)
- throws JBIException {
+ public void deregisterExternalEndpoint(ComponentNameSpace cns, ServiceEndpoint externalEndpoint) throws JBIException {
registry.deregisterExternalEndpoint(cns, externalEndpoint);
}
@@ -833,11 +816,11 @@
/**
* @param context
* @param service
- * @param name
+ * @param endpointName
* @return the matching endpoint
*/
- public ServiceEndpoint getEndpoint(ComponentContextImpl context, QName service, String name) {
- return registry.getEndpoint(service, name);
+ public ServiceEndpoint getEndpoint(ComponentContextImpl context, QName service, String endpointName) {
+ return registry.getEndpoint(service, endpointName);
}
/**
@@ -894,21 +877,20 @@
/**
* Used for Simple POJO's
*
- * @param name - the unique component ID
+ * @param componentName - the unique component ID
* @throws JBIException
*/
- public void deactivateComponent(String name) throws JBIException {
- ComponentMBeanImpl component = registry.getComponent(name);
+ public void deactivateComponent(String componentName) throws JBIException {
+ ComponentMBeanImpl component = registry.getComponent(componentName);
if (component != null) {
component.doShutDown();
- component.unregisterMbeans(managementContext);
+ component.unregisterMbeans(managementContext);
registry.deregisterComponent(component);
environmentContext.unreregister(component);
component.dispose();
- log.info("Deactivating component " + name);
- }
- else {
- throw new JBIException("Could not find component " + name);
+ LOG.info("Deactivating component " + componentName);
+ } else {
+ throw new JBIException("Could not find component " + componentName);
}
}
@@ -978,8 +960,7 @@
}
activateComponent(component, activationSpec);
return component;
- }
- else if (bean instanceof ComponentLifeCycle) {
+ } else if (bean instanceof ComponentLifeCycle) {
// lets support just plain lifecycle pojos
ComponentLifeCycle lifeCycle = (ComponentLifeCycle) bean;
if (bean instanceof PojoSupport) {
@@ -988,18 +969,15 @@
Component adaptor = createComponentAdaptor(lifeCycle, activationSpec);
activateComponent(adaptor, activationSpec);
return adaptor;
- }
- else if (bean instanceof MessageExchangeListener) {
+ } else if (bean instanceof MessageExchangeListener) {
// lets support just plain listener pojos
MessageExchangeListener listener = (MessageExchangeListener) bean;
Component adaptor = createComponentAdaptor(listener, activationSpec);
activateComponent(adaptor, activationSpec);
return adaptor;
- }
- else {
+ } else {
throw new IllegalArgumentException("Component name: " + id
- + " is bound to an object which is not a JBI component, it is of type: "
- + bean.getClass().getName());
+ + " is bound to an object which is not a JBI component, it is of type: " + bean.getClass().getName());
}
}
@@ -1007,13 +985,13 @@
* Activate a POJO Component
*
* @param component
- * @param name
+ * @param componentName
* @return the ObjectName of the MBean for the Component
* @throws JBIException
*/
- public ObjectName activateComponent(Component component, String name) throws JBIException {
+ public ObjectName activateComponent(Component component, String componentName) throws JBIException {
ActivationSpec activationSpec = new ActivationSpec();
- ComponentNameSpace cns = new ComponentNameSpace(getName(), name);
+ ComponentNameSpace cns = new ComponentNameSpace(getName(), componentName);
activationSpec.setComponent(component);
activationSpec.setComponentName(cns.getName());
return activateComponent(component, activationSpec);
@@ -1043,9 +1021,8 @@
* @return the ObjectName of the Component's MBean
* @throws JBIException
*/
- public ObjectName activateComponent(File installDir, Component component, String description,
- ComponentContextImpl context, boolean binding, boolean service,
- String[] sharedLibraries) throws JBIException {
+ public ObjectName activateComponent(File installDir, Component component, String description, ComponentContextImpl context,
+ boolean binding, boolean service, String[] sharedLibraries) throws JBIException {
ComponentNameSpace cns = context.getComponentNameSpace();
ActivationSpec activationSpec = new ActivationSpec();
activationSpec.setComponent(component);
@@ -1063,9 +1040,8 @@
* @return the ObjectName of the Component's MBean
* @throws JBIException
*/
- public ObjectName activateComponent(Component component, String description, ActivationSpec activationSpec,
- boolean pojo, boolean binding, boolean service,
- String[] sharedLibraries) throws JBIException {
+ public ObjectName activateComponent(Component component, String description, ActivationSpec activationSpec, boolean pojo,
+ boolean binding, boolean service, String[] sharedLibraries) throws JBIException {
ComponentNameSpace cns = new ComponentNameSpace(getName(), activationSpec.getComponentName());
if (registry.getComponent(cns) != null) {
throw new JBIException("A component is already registered for " + cns);
@@ -1086,28 +1062,26 @@
* @return the ObjectName of the Component's MBean
* @throws JBIException
*/
- public ObjectName activateComponent(File installationDir, Component component, String description,
- ComponentContextImpl context, ActivationSpec activationSpec,
- boolean pojo, boolean binding, boolean service,
- String[] sharedLibraries)
- throws JBIException {
+ public ObjectName activateComponent(File installationDir, Component component,
+ String description, ComponentContextImpl context,
+ ActivationSpec activationSpec, boolean pojo,
+ boolean binding, boolean service, String[] sharedLibraries) throws JBIException {
ObjectName result = null;
ComponentNameSpace cns = new ComponentNameSpace(getName(), activationSpec.getComponentName());
- if (log.isDebugEnabled()) {
- log.info("Activating component for: " + cns + " with service: " + activationSpec.getService() + " component: "
- + component);
+ if (LOG.isDebugEnabled()) {
+ LOG.info("Activating component for: " + cns + " with service: " + activationSpec.getService() + " component: " + component);
}
ComponentMBeanImpl lcc = registry.registerComponent(cns, description, component, binding, service, sharedLibraries);
if (lcc != null) {
lcc.setPojo(pojo);
- ComponentEnvironment env = environmentContext.registerComponent(context.getEnvironment(),lcc);
+ ComponentEnvironment env = environmentContext.registerComponent(context.getEnvironment(), lcc);
if (env.getInstallRoot() == null) {
env.setInstallRoot(installationDir);
}
context.activate(component, env, activationSpec);
lcc.setContext(context);
lcc.setActivationSpec(activationSpec);
-
+
if (lcc.isPojo()) {
//non-pojo's are either started by the auto deployer
//or manually
@@ -1145,7 +1119,6 @@
return new ExecutorFactoryImpl();
}
-
/**
* Factory method to create a new component adaptor from the given lifecycle
*
@@ -1156,10 +1129,9 @@
protected Component createComponentAdaptor(ComponentLifeCycle lifeCycle, ActivationSpec activationSpec) {
ComponentAdaptor answer = null;
if (lifeCycle instanceof MessageExchangeListener) {
- answer = new ComponentAdaptorMEListener(lifeCycle, activationSpec.getService(), activationSpec
- .getEndpoint(), (MessageExchangeListener) lifeCycle);
- }
- else {
+ answer = new ComponentAdaptorMEListener(lifeCycle, activationSpec.getService(), activationSpec.getEndpoint(),
+ (MessageExchangeListener) lifeCycle);
+ } else {
answer = new ComponentAdaptor(lifeCycle, activationSpec.getService(), activationSpec.getEndpoint());
}
answer.setServiceManager(serviceManager);
@@ -1167,8 +1139,7 @@
}
protected Component createComponentAdaptor(MessageExchangeListener listener, ActivationSpec activationSpec) {
- ComponentLifeCycle lifecCycle = new PojoLifecycleAdaptor(listener, activationSpec.getService(), activationSpec
- .getEndpoint());
+ ComponentLifeCycle lifecCycle = new PojoLifecycleAdaptor(listener, activationSpec.getService(), activationSpec.getEndpoint());
return new ComponentAdaptorMEListener(lifecCycle, listener);
}
@@ -1182,7 +1153,7 @@
}
protected void checkInitialized() throws JBIException {
- if (containerInitialized.get() == false) {
+ if (!containerInitialized.get()) {
throw new JBIException("The Container is not initialized - please call init(...)");
}
}
@@ -1191,39 +1162,39 @@
* Retrieve the value for automatic transaction enlistment.
* @return
*/
- public boolean isAutoEnlistInTransaction() {
- return autoEnlistInTransaction;
- }
-
- /**
- * Set the new value for automatic transaction enlistment.
- * When this parameter is set to <code>true</code> and a transaction
- * is running when sending / receiving an exchange, this operation will
- * automatically be done in the current transaction.
- *
- * @param autoEnlistInTransaction
- */
- public void setAutoEnlistInTransaction(boolean autoEnlistInTransaction) {
- this.autoEnlistInTransaction = autoEnlistInTransaction;
- }
-
- public boolean isPersistent() {
- return persistent;
- }
-
- /**
- * Set the new default value for exchange persistence.
- * This value will be the default if none is configured on
- * the activation spec of the component or on the message.
- *
- * @param persistent
- */
- public void setPersistent(boolean persistent) {
- this.persistent = persistent;
- }
-
+ public boolean isAutoEnlistInTransaction() {
+ return autoEnlistInTransaction;
+ }
+
+ /**
+ * Set the new value for automatic transaction enlistment.
+ * When this parameter is set to <code>true</code> and a transaction
+ * is running when sending / receiving an exchange, this operation will
+ * automatically be done in the current transaction.
+ *
+ * @param autoEnlistInTransaction
+ */
+ public void setAutoEnlistInTransaction(boolean autoEnlistInTransaction) {
+ this.autoEnlistInTransaction = autoEnlistInTransaction;
+ }
+
+ public boolean isPersistent() {
+ return persistent;
+ }
+
+ /**
+ * Set the new default value for exchange persistence.
+ * This value will be the default if none is configured on
+ * the activation spec of the component or on the message.
+ *
+ * @param persistent
+ */
+ public void setPersistent(boolean persistent) {
+ this.persistent = persistent;
+ }
+
public void addListener(EventListener listener) {
- log.debug("Adding listener: " + listener.getClass());
+ LOG.debug("Adding listener: " + listener.getClass());
if (listener instanceof ContainerAware) {
ContainerAware containerAware = (ContainerAware) listener;
containerAware.setContainer(this);
@@ -1247,9 +1218,9 @@
listeners.add(DeploymentListener.class, (DeploymentListener) listener);
}
}
-
+
public void removeListener(EventListener listener) {
- log.debug("Removing listener: " + listener.getClass());
+ LOG.debug("Removing listener: " + listener.getClass());
if (listener instanceof ExchangeListener) {
listeners.remove(ExchangeListener.class, (ExchangeListener) listener);
}
@@ -1269,17 +1240,17 @@
listeners.remove(DeploymentListener.class, (DeploymentListener) listener);
}
}
-
+
public Object[] getListeners(Class lc) {
return listeners.getListeners(lc);
}
-
+
public void setListeners(EventListener[] listeners) {
configuredListeners = listeners;
}
-
+
public void resendExchange(MessageExchange exchange) throws JBIException {
- if (exchange instanceof MessageExchangeImpl == false) {
+ if (!(exchange instanceof MessageExchangeImpl)) {
throw new IllegalArgumentException("exchange should be a MessageExchangeImpl");
}
MessageExchangeImpl me = (MessageExchangeImpl) exchange;
@@ -1295,7 +1266,7 @@
try {
l[i].exchangeSent(event);
} catch (Exception e) {
- log.warn("Error calling listener: " + e.getMessage(), e);
+ LOG.warn("Error calling listener: " + e.getMessage(), e);
}
}
me.handleSend(false);
@@ -1309,13 +1280,13 @@
public void setEmbedded(boolean embedded) {
this.embedded = embedded;
}
-
- public void setRmiPort( int portNum ) {
- getManagementContext().setNamingPort( portNum );
+
+ public void setRmiPort(int portNum) {
+ getManagementContext().setNamingPort(portNum);
}
public int getRmiPort() {
- return getManagementContext().getNamingPort();
+ return getManagementContext().getNamingPort();
}
/**
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java Thu Aug 9 13:33:26 2007
@@ -40,7 +40,6 @@
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.util.ClassUtils;
-
/**
* An enhanced JBI container which adds some Spring helper methods for
* easier configuration through spring's XML configuration file.
@@ -50,9 +49,9 @@
*
* @version $Revision$
*/
-public class SpringJBIContainer extends JBIContainer
- implements InitializingBean, DisposableBean, BeanFactoryAware, ApplicationContextAware {
-
+public class SpringJBIContainer extends JBIContainer implements InitializingBean, DisposableBean,
+ BeanFactoryAware, ApplicationContextAware {
+
private String[] componentNames;
private ActivationSpec[] activationSpecs;
private BeanFactory beanFactory;
@@ -64,7 +63,7 @@
public void afterPropertiesSet() throws Exception {
init();
-
+
// lets iterate through all the component names and register them
if (componentNames != null) {
for (int i = 0; i < componentNames.length; i++) {
@@ -86,14 +85,14 @@
installArchive(archive);
}
}
-
+
if (components != null) {
for (Iterator it = components.entrySet().iterator(); it.hasNext();) {
Map.Entry e = (Map.Entry) it.next();
- if (e.getKey() instanceof String == false) {
+ if (!(e.getKey() instanceof String)) {
throw new JBIException("Component must have a non null string name");
}
- if (e.getValue() instanceof Component == false) {
+ if (!(e.getValue() instanceof Component)) {
throw new JBIException("Component is not a known component");
}
String name = (String) e.getKey();
@@ -101,72 +100,80 @@
getComponent(name).init();
}
}
-
+
if (endpoints != null) {
- if (components == null) {
- components = new LinkedHashMap();
- }
- Class componentClass = Class.forName("org.apache.servicemix.common.DefaultComponent");
- Class endpointClass = Class.forName("org.apache.servicemix.common.Endpoint");
- Method addEndpointMethod = componentClass.getDeclaredMethod("addEndpoint", new Class[] { endpointClass });
- addEndpointMethod.setAccessible(true);
- Method getEndpointClassesMethod = componentClass.getDeclaredMethod("getEndpointClasses", null);
- getEndpointClassesMethod.setAccessible(true);
- for (Iterator it = endpoints.entrySet().iterator(); it.hasNext();) {
- Map.Entry e = (Map.Entry) it.next();
- String key = (String) e.getKey();
- List l = (List) e.getValue();
- for (Iterator itEp = l.iterator(); itEp.hasNext();) {
- Object endpoint = itEp.next();
- Component c = null;
- if (key.length() > 0) {
- Component comp = (Component) components.get(key);
- if (comp == null) {
- throw new JBIException("Could not find component '" + key + "' specified for endpoint");
- }
- c = comp;
- } else {
- for (Iterator itCmp = components.values().iterator(); itCmp.hasNext();) {
- Component comp = (Component) itCmp.next();
- Class[] endpointClasses = (Class[]) getEndpointClassesMethod.invoke(comp, null);
- if (isKnownEndpoint(endpoint, endpointClasses)) {
- c = comp;
- break;
- }
+ initEndpoints();
+ }
+
+ start();
+ }
+
+ private void initEndpoints() throws Exception {
+ if (components == null) {
+ components = new LinkedHashMap();
+ }
+ Class componentClass = Class.forName("org.apache.servicemix.common.DefaultComponent");
+ Class endpointClass = Class.forName("org.apache.servicemix.common.Endpoint");
+ Method addEndpointMethod = componentClass.getDeclaredMethod("addEndpoint", new Class[] {endpointClass });
+ addEndpointMethod.setAccessible(true);
+ Method getEndpointClassesMethod = componentClass.getDeclaredMethod("getEndpointClasses", null);
+ getEndpointClassesMethod.setAccessible(true);
+ for (Iterator it = endpoints.entrySet().iterator(); it.hasNext();) {
+ Map.Entry e = (Map.Entry) it.next();
+ String key = (String) e.getKey();
+ List l = (List) e.getValue();
+ for (Iterator itEp = l.iterator(); itEp.hasNext();) {
+ Object endpoint = itEp.next();
+ Component c = null;
+ if (key.length() > 0) {
+ Component comp = (Component) components.get(key);
+ if (comp == null) {
+ throw new JBIException("Could not find component '" + key + "' specified for endpoint");
+ }
+ c = comp;
+ } else {
+ for (Iterator itCmp = components.values().iterator(); itCmp.hasNext();) {
+ Component comp = (Component) itCmp.next();
+ Class[] endpointClasses = (Class[]) getEndpointClassesMethod.invoke(comp, null);
+ if (isKnownEndpoint(endpoint, endpointClasses)) {
+ c = comp;
+ break;
}
+ }
+ if (c == null) {
+ c = getComponentForEndpoint(getEndpointClassesMethod, endpoint);
if (c == null) {
- Properties namespaces = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.handlers");
- for (Iterator itNs = namespaces.keySet().iterator(); itNs.hasNext();) {
- String namespaceURI = (String) itNs.next();
- String uri = NamespaceHelper.createDiscoveryPathName(namespaceURI);
- Properties props = PropertiesLoaderUtils.loadAllProperties(uri);
- String compClassName = props.getProperty("component");
- if (compClassName != null) {
- Class compClass = ClassUtils.forName(compClassName);
- Component comp = (Component) BeanUtils.instantiateClass(compClass);
- Class[] endpointClasses = (Class[]) getEndpointClassesMethod.invoke(comp, null);
- if (isKnownEndpoint(endpoint, endpointClasses)) {
- c = comp;
- String name = chooseComponentName(c);
- activateComponent(c, name);
- components.put(name, c);
- break;
- }
- }
- }
- if (c == null) {
- throw new JBIException("Unable to find a component for endpoint class: " + endpoint.getClass());
- }
+ throw new JBIException("Unable to find a component for endpoint class: " + endpoint.getClass());
}
}
- addEndpointMethod.invoke(c, new Object[] { endpoint });
}
+ addEndpointMethod.invoke(c, new Object[] {endpoint });
}
}
+ }
- start();
+ private Component getComponentForEndpoint(Method getEndpointClassesMethod, Object endpoint) throws Exception {
+ Properties namespaces = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.handlers");
+ for (Iterator itNs = namespaces.keySet().iterator(); itNs.hasNext();) {
+ String namespaceURI = (String) itNs.next();
+ String uri = NamespaceHelper.createDiscoveryPathName(namespaceURI);
+ Properties props = PropertiesLoaderUtils.loadAllProperties(uri);
+ String compClassName = props.getProperty("component");
+ if (compClassName != null) {
+ Class compClass = ClassUtils.forName(compClassName);
+ Component comp = (Component) BeanUtils.instantiateClass(compClass);
+ Class[] endpointClasses = (Class[]) getEndpointClassesMethod.invoke(comp, null);
+ if (isKnownEndpoint(endpoint, endpointClasses)) {
+ String name = chooseComponentName(comp);
+ activateComponent(comp, name);
+ components.put(name, comp);
+ return comp;
+ }
+ }
+ }
+ return null;
}
-
+
private String chooseComponentName(Object c) {
String className = c.getClass().getName();
if (className.startsWith("org.apache.servicemix.")) {
@@ -179,7 +186,7 @@
}
return createComponentID();
}
-
+
private boolean isKnownEndpoint(Object endpoint, Class[] knownClasses) {
if (knownClasses != null) {
for (int i = 0; i < knownClasses.length; i++) {
@@ -196,8 +203,7 @@
DisposableBean disposable = (DisposableBean) beanFactory;
try {
disposable.destroy();
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new JBIException("Failed to dispose of the Spring BeanFactory due to: " + e, e);
}
}
@@ -219,7 +225,6 @@
return bean;
}
-
// Properties
//-------------------------------------------------------------------------
/**
@@ -262,8 +267,7 @@
protected Object lookupBean(String componentName) {
Object bean = beanFactory.getBean(componentName);
if (bean == null) {
- throw new IllegalArgumentException("Component name: " + componentName
- + " is not found in the Spring BeanFactory");
+ throw new IllegalArgumentException("Component name: " + componentName + " is not found in the Spring BeanFactory");
}
return bean;
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SubscriptionSpec.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SubscriptionSpec.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SubscriptionSpec.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SubscriptionSpec.java Thu Aug 9 13:33:26 2007
@@ -16,17 +16,17 @@
*/
package org.apache.servicemix.jbi.container;
+import java.io.Serializable;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+
import org.apache.servicemix.jbi.framework.ComponentNameSpace;
import org.apache.servicemix.jbi.framework.Registry;
import org.apache.servicemix.jbi.messaging.ExchangePacket;
import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
import org.apache.servicemix.jbi.resolver.SubscriptionFilter;
import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
-
-import javax.jbi.servicedesc.ServiceEndpoint;
-import javax.xml.namespace.QName;
-
-import java.io.Serializable;
/**
* Represents a subscription to a JBI endpoint.
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/ClassPath.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/ClassPath.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/ClassPath.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/ClassPath.java Thu Aug 9 13:33:26 2007
@@ -60,15 +60,14 @@
//SM-199: Hashcode method added
public int hashCode() {
- if (pathElements == null)
+ if (pathElements == null) {
return 0;
-
+ }
int result = 1;
-
- for (int i=0;i < pathElements.length;i++)
+ for (int i = 0; i < pathElements.length; i++) {
result = 31 * result + (pathElements[i] == null ? 0 : pathElements[i].hashCode());
-
- return result;
+ }
+ return result;
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/Connections.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/Connections.java?view=diff&rev=564374&r1=564373&r2=564374
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/Connections.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/Connections.java Thu Aug 9 13:33:26 2007
@@ -21,13 +21,14 @@
*
*/
public class Connections {
- private Connection[] connections;
- public Connection[] getConnections() {
- return connections;
- }
+ private Connection[] connections;
- public void setConnections(Connection[] connections) {
- this.connections = connections;
- }
+ public Connection[] getConnections() {
+ return connections;
+ }
+
+ public void setConnections(Connection[] connections) {
+ this.connections = connections;
+ }
}