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 2006/11/03 19:39:35 UTC
svn commit: r470938 - in
/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src:
main/java/org/apache/servicemix/jms/ test/java/org/apache/servicemix/jms/
test/resources/org/apache/servicemix/jms/
Author: gnodet
Date: Fri Nov 3 10:39:34 2006
New Revision: 470938
URL: http://svn.apache.org/viewvc?view=rev&rev=470938
Log:
Use the new servicemix-common classes and fix jca config for junit tests
Removed:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsExternalEndpoint.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsResolvedEndpoint.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsSpringComponent.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsXBeanDeployer.java
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsStandardTest.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsComponent.java Fri Nov 3 10:39:34 2006
@@ -16,36 +16,163 @@
*/
package org.apache.servicemix.jms;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import javax.jbi.messaging.MessageExchange;
import javax.jbi.servicedesc.ServiceEndpoint;
-import org.apache.servicemix.common.BaseComponent;
-import org.apache.servicemix.common.BaseLifeCycle;
import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.DefaultComponent;
import org.apache.servicemix.common.Deployer;
-import org.w3c.dom.DocumentFragment;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.xbean.BaseXBeanDeployer;
+import org.apache.servicemix.jbi.security.auth.AuthenticationService;
+import org.apache.servicemix.jbi.security.auth.impl.JAASAuthenticationService;
+import org.apache.servicemix.jbi.security.keystore.KeystoreManager;
+import org.apache.servicemix.jbi.util.IntrospectionSupport;
+import org.apache.servicemix.jbi.util.URISupport;
+
+/**
+ *
+ * @org.apache.xbean.XBean element="component"
+ * description="A jms component"
+ */
+public class JmsComponent extends DefaultComponent {
+
+ protected JmsConfiguration configuration = new JmsConfiguration();
+ protected JmsEndpoint[] endpoints;
+
+ protected List getConfiguredEndpoints() {
+ return asList(endpoints);
+ }
-public class JmsComponent extends BaseComponent {
+ protected Class[] getEndpointClasses() {
+ return new Class[] { JmsEndpoint.class };
+ }
+
+ /**
+ * @return Returns the configuration.
+ * @org.apache.xbean.Flat
+ */
+ public JmsConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(JmsConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public JmsEndpoint[] getEndpoints() {
+ return endpoints;
+ }
+
+ public void setEndpoints(JmsEndpoint[] endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ /**
+ * @return the keystoreManager
+ */
+ public KeystoreManager getKeystoreManager() {
+ return configuration.getKeystoreManager();
+ }
+
+ /**
+ * @param keystoreManager the keystoreManager to set
+ */
+ public void setKeystoreManager(KeystoreManager keystoreManager) {
+ this.configuration.setKeystoreManager(keystoreManager);
+ }
+
+ /**
+ * @return the authenticationService
+ */
+ public AuthenticationService getAuthenticationService() {
+ return configuration.getAuthenticationService();
+ }
+
+ /**
+ * @param authenticationService the authenticationService to set
+ */
+ public void setAuthenticationService(AuthenticationService authenticationService) {
+ this.configuration.setAuthenticationService(authenticationService);
+ }
/* (non-Javadoc)
- * @see org.apache.servicemix.common.BaseComponent#createLifeCycle()
+ * @see org.servicemix.common.BaseComponentLifeCycle#getExtensionMBean()
*/
- protected BaseLifeCycle createLifeCycle() {
- return new JmsLifeCycle(this);
+ protected Object getExtensionMBean() throws Exception {
+ return configuration;
}
/* (non-Javadoc)
* @see org.apache.servicemix.common.BaseComponent#createServiceUnitManager()
*/
public BaseServiceUnitManager createServiceUnitManager() {
- Deployer[] deployers = new Deployer[] { new JmsXBeanDeployer(this), new JmsWsdl1Deployer(this) };
+ Deployer[] deployers = new Deployer[] { new BaseXBeanDeployer(this, getEndpointClasses()),
+ new JmsWsdl1Deployer(this) };
return new BaseServiceUnitManager(this, deployers);
}
/* (non-Javadoc)
- * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
+ * @see org.apache.servicemix.common.DefaultComponent#doInit()
*/
- public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
- return JmsResolvedEndpoint.resolveEndpoint(epr);
+ protected void doInit() throws Exception {
+ super.doInit();
+ configuration.setRootDir(context.getWorkspaceRoot());
+ configuration.load();
+ // Lookup keystoreManager and authenticationService
+ if (configuration.getKeystoreManager() == null) {
+ try {
+ String name = configuration.getKeystoreManagerName();
+ Object km = context.getNamingContext().lookup(name);
+ configuration.setKeystoreManager((KeystoreManager) km);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (configuration.getAuthenticationService() == null) {
+ try {
+ String name = configuration.getAuthenticationServiceName();
+ Object as = context.getNamingContext().lookup(name);
+ configuration.setAuthenticationService((AuthenticationService) as);
+ } catch (Exception e) {
+ configuration.setAuthenticationService(new JAASAuthenticationService());
+ }
+ }
}
+ protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {
+ // We receive an exchange for an EPR that has not been used yet.
+ // Register a provider endpoint and restart processing.
+ JmsEndpoint jmsEp = new JmsEndpoint();
+ jmsEp.setServiceUnit(new ServiceUnit(component));
+ jmsEp.setService(ep.getServiceName());
+ jmsEp.setEndpoint(ep.getEndpointName());
+ jmsEp.setRole(MessageExchange.Role.PROVIDER);
+ URI uri = new URI(ep.getEndpointName());
+ Map map = URISupport.parseQuery(uri.getQuery());
+ if( IntrospectionSupport.setProperties(jmsEp, map, "jms.") ) {
+ uri = URISupport.createRemainingURI(uri, map);
+ }
+ if (uri.getPath() != null) {
+ String path = uri.getSchemeSpecificPart();
+ while (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ if (path.startsWith(AbstractJmsProcessor.STYLE_QUEUE + "/")) {
+ jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE);
+ jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_QUEUE.length() + 1));
+ } else if (path.startsWith(AbstractJmsProcessor.STYLE_TOPIC + "/")) {
+ jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_TOPIC);
+ jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_TOPIC.length() + 1));
+ }
+ }
+ jmsEp.activateDynamic();
+ return jmsEp;
+ }
+
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java Fri Nov 3 10:39:34 2006
@@ -21,7 +21,6 @@
import java.util.Iterator;
import java.util.Properties;
-import javax.jbi.component.ComponentLifeCycle;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
@@ -33,6 +32,7 @@
import javax.wsdl.Service;
import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.common.ExternalEndpoint;
import org.apache.servicemix.jbi.security.auth.AuthenticationService;
import org.apache.servicemix.jbi.security.keystore.KeystoreManager;
import org.apache.servicemix.soap.SoapEndpoint;
@@ -310,8 +310,7 @@
try {
String procName = processorName;
if (processorName == null) {
- JmsLifeCycle lf = (JmsLifeCycle) getServiceUnit().getComponent().getLifeCycle();
- procName = lf.getConfiguration().getProcessorName();
+ procName = getConfiguration().getProcessorName();
}
String uri = "META-INF/services/org/apache/servicemix/jms/" + procName;
InputStream in = loadResource(uri);
@@ -358,7 +357,16 @@
}
protected ServiceEndpoint createExternalEndpoint() {
- return new JmsExternalEndpoint(this);
+ return new ExternalEndpoint(getServiceUnit().getComponent().getEPRElementName(),
+ getLocationURI(),
+ getService(),
+ getEndpoint(),
+ getInterfaceName());
+ }
+
+ protected String getLocationURI() {
+ // Need to return a real URI
+ return getService() + "#" + getEndpoint();
}
protected void overrideDefinition(Definition def) {
@@ -436,18 +444,18 @@
}
public JmsConfiguration getConfiguration() {
- JmsLifeCycle lifeCycle = (JmsLifeCycle) getServiceUnit().getComponent().getLifeCycle();
- return lifeCycle.getConfiguration();
+ JmsComponent component = (JmsComponent) getServiceUnit().getComponent();
+ return component.getConfiguration();
}
public AuthenticationService getAuthenticationService() {
- ComponentLifeCycle lf = getServiceUnit().getComponent().getLifeCycle();
- return ((JmsLifeCycle) lf).getAuthenticationService();
+ JmsComponent component = (JmsComponent) getServiceUnit().getComponent();
+ return component.getAuthenticationService();
}
public KeystoreManager getKeystoreManager() {
- ComponentLifeCycle lf = getServiceUnit().getComponent().getLifeCycle();
- return ((JmsLifeCycle) lf).getKeystoreManager();
+ JmsComponent component = (JmsComponent) getServiceUnit().getComponent();
+ return component.getKeystoreManager();
}
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsWsdl1Deployer.java Fri Nov 3 10:39:34 2006
@@ -19,7 +19,6 @@
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
-import org.apache.servicemix.common.BaseComponent;
import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.wsdl1.AbstractWsdl1Deployer;
import org.apache.servicemix.common.wsdl1.JbiEndpoint;
@@ -33,7 +32,7 @@
*/
public class JmsWsdl1Deployer extends AbstractWsdl1Deployer {
- public JmsWsdl1Deployer(BaseComponent component) {
+ public JmsWsdl1Deployer(JmsComponent component) {
super(component);
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsStandardTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsStandardTest.java?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsStandardTest.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsStandardTest.java Fri Nov 3 10:39:34 2006
@@ -65,7 +65,7 @@
}
public void test() throws Exception {
- JmsSpringComponent jms = new JmsSpringComponent();
+ JmsComponent jms = new JmsComponent();
JmsEndpoint ep = new JmsEndpoint();
ep.setInitialContextFactory(ActiveMQInitialContextFactory.class.getName());
ep.setJndiProviderURL("tcp://localhost:61216");
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsURITest.java Fri Nov 3 10:39:34 2006
@@ -72,8 +72,8 @@
}
public void testResolveEndpoint() throws Exception {
- JmsSpringComponent jms = new JmsSpringComponent();
- ((JmsLifeCycle) jms.getLifeCycle()).getConfiguration().setConnectionFactory(connectionFactory);
+ JmsComponent jms = new JmsComponent();
+ jms.getConfiguration().setConnectionFactory(connectionFactory);
JmsEndpoint ep = new JmsEndpoint();
ep.setRole(MessageExchange.Role.CONSUMER);
ep.setService(ReceiverComponent.SERVICE);
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml?view=diff&rev=470938&r1=470937&r2=470938
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml Fri Nov 3 10:39:34 2006
@@ -18,9 +18,11 @@
-->
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
- xmlns:jms="http://servicemix.apache.org/jms/1.0"
- xmlns:amq="http://activemq.org/config/1.0"
- xmlns:test="http://test">
+ xmlns:jms="http://servicemix.apache.org/jms/1.0"
+ xmlns:amq="http://activemq.org/config/1.0"
+ xmlns:amqra="http://activemq.org/ra/1.0"
+ xmlns:jencks="http://jencks.org/2.0"
+ xmlns:test="http://test">
<!-- the JBI container -->
<sm:container id="jbi"
@@ -30,8 +32,7 @@
transactionManager="#transactionManager">
<sm:flows>
<sm:sedaFlow />
- <sm:jcaFlow bootstrapContext="#bootstrapContext"
- connectionManager="#connectionManager"
+ <sm:jcaFlow connectionManager="#connectionManager"
jmsURL="tcp://localhost:61616?jms.asyncDispatch=true&jms.useAsyncSend=true" />
</sm:flows>
@@ -53,10 +54,7 @@
bootstrapContext="#bootstrapContext"
synchronous="true">
<jms:activationSpec>
- <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
- <property name="destination" value="queue/synchronous"/>
- <property name="destinationType" value="javax.jms.Queue"/>
- </bean>
+ <amqra:activationSpec destination="queue/synchronous" destinationType="javax.jms.Queue" />
</jms:activationSpec>
</jms:endpoint>
@@ -79,10 +77,7 @@
bootstrapContext="#bootstrapContext"
synchronous="false">
<jms:activationSpec>
- <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
- <property name="destination" value="queue/async"/>
- <property name="destinationType" value="javax.jms.Queue"/>
- </bean>
+ <amqra:activationSpec destination="queue/async" destinationType="javax.jms.Queue" />
</jms:activationSpec>
</jms:endpoint>
@@ -120,16 +115,11 @@
</bean>
<!-- A managed JMS ConnectionFactory for ActiveMQ -->
- <bean id="activemqMCF" class="org.apache.activemq.ra.ActiveMQManagedConnectionFactory">
- <property name="resourceAdapter" ref="resourceAdapter" />
- </bean>
- <bean id="connectionFactory" class="org.springframework.jca.support.LocalConnectionFactoryBean">
- <property name="managedConnectionFactory" ref="activemqMCF"/>
- <property name="connectionManager" ref="connectionManager"/>
- </bean>
- <bean id="resourceAdapter" class="org.apache.activemq.ra.ActiveMQResourceAdapter">
- <property name="serverUrl" value="tcp://localhost:61616?jms.asyncDispatch=true&jms.useAsyncSend=true"/>
- </bean>
+ <amqra:managedConnectionFactory id="activemqMCF" resourceAdapter="#resourceAdapter" />
+ <amqra:resourceAdapter id="resourceAdapter" serverUrl="tcp://localhost:61616?jms.asyncDispatch=true&jms.useAsyncSend=true"/>
+ <jencks:connectionFactory id="connectionFactory"
+ managedConnectionFactory="#activemqMCF"
+ connectionManager="#connectionManager" />
<amq:broker id="broker" persistent="false">
@@ -139,58 +129,23 @@
</amq:broker>
- <!-- Transaction log -->
- <bean id="transactionLog" class="org.apache.geronimo.transaction.log.UnrecoverableLog" />
-
- <!-- Internal transaction manager -->
- <bean id="extendedTransactionManager" class="org.jencks.factory.TransactionManagerFactoryBean">
- <property name="transactionLog" ref="transactionLog" />
- <property name="defaultTransactionTimeoutSeconds" value="600"/>
- </bean>
-
- <!-- Transaction context manager -->
- <bean id="transactionContextManager" class="org.jencks.factory.TransactionContextManagerFactoryBean">
- <property name="transactionManager" ref="extendedTransactionManager"/>
- </bean>
-
- <!-- Public transaction manager -->
- <bean id="transactionManager" class="org.jencks.factory.GeronimoTransactionManagerFactoryBean">
- <property name="transactionContextManager" ref="transactionContextManager"/>
- </bean>
+ <!-- Transaction manager -->
+ <jencks:transactionManager id="transactionManager" />
<!-- Work manager -->
- <bean id="workManager" class="org.jencks.factory.WorkManagerFactoryBean">
- <property name="threadPoolSize" value="30"/>
- <property name="transactionContextManager" ref="transactionContextManager"/>
- </bean>
+ <jencks:workManager id="workManager" transactionManager="#transactionManager" />
<!-- Bootstrap context for JCA -->
- <bean id="bootstrapContext" class="org.jencks.factory.BootstrapContextFactoryBean">
- <property name="workManager" ref="workManager"/>
- </bean>
+ <jencks:bootstrapContext id="bootstrapContext" workManager="#workManager" transactionManager="#transactionManager" />
<!-- Connection manager for JCA -->
- <bean id="connectionTracker" class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator"/>
- <bean id="poolingSupport" class="org.jencks.factory.SinglePoolFactoryBean">
- <property name="maxSize" value="16"/>
- <property name="minSize" value="1"/>
- <property name="blockingTimeoutMilliseconds" value="60"/>
- <property name="idleTimeoutMinutes" value="60"/>
- <property name="matchOne" value="true"/>
- <property name="matchAll" value="true"/>
- <property name="selectOneAssumeMatch" value="true"/>
- </bean>
- <bean id="transactionSupport" class="org.jencks.factory.XATransactionFactoryBean">
- <property name="useTransactionCaching" value="true"/>
- <property name="useThreadCaching" value="true"/>
- </bean>
- <bean id="connectionManager" class="org.jencks.factory.ConnectionManagerFactoryBean">
- <property name="containerManagedSecurity" value="false"/>
- <property name="transactionContextManager" ref="transactionContextManager"/>
- <property name="poolingSupport" ref="poolingSupport"/>
- <property name="transactionSupport" ref="transactionSupport"/>
- <property name="connectionTracker" ref="connectionTracker"/>
- </bean>
-
+ <jencks:connectionTracker id="connectionTracker" geronimoTransactionManager="#transactionManager" />
+ <jencks:poolingSupport id="poolingSupport" allConnectionsEqual="false" />
+ <jencks:connectionManager id="connectionManager"
+ containerManagedSecurity="false"
+ transaction="xa"
+ transactionManager="#transactionManager"
+ poolingSupport="#poolingSupport"
+ connectionTracker="#connectionTracker" />
</beans>