cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r726940 - in /cxf/branches/2.0.x-fixes/rt/transports/jms/src: main/java/org/apache/cxf/transport/jms/ main/java/org/apache/cxf/transport/jms/spring/ main/resources/schemas/configuration/ test/java/org/apache/cxf/transport/jms/ test/resources/
Date Tue, 16 Dec 2008 04:05:11 GMT
Author: ningjiang
Date: Mon Dec 15 20:05:10 2008
New Revision: 726940

URL: http://svn.apache.org/viewvc?rev=726940&view=rev
Log:
Merged revisions 726745 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.1.x-fixes

................
  r726745 | dkulp | 2008-12-16 01:57:02 +0800 (Tue, 16 Dec 2008) | 9 lines
  
  Merged revisions 726342 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r726342 | ningjiang | 2008-12-13 22:03:13 -0500 (Sat, 13 Dec 2008) | 1 line
    
    CXF-1943 added the jms transport injection support for JMSDestination
  ........
................

Modified:
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spring/JMSDestinationBeanDefinitionParser.java
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/resources/schemas/configuration/jms.xsd
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
    cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/resources/jms_test_config.xml

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
Mon Dec 15 20:05:10 2008
@@ -31,6 +31,7 @@
 public class JMSConfiguration implements InitializingBean {
     static final boolean DEFAULT_USEJMS11 = false;
     
+    private boolean usingEndpointInfo = true;
     private ConnectionFactory connectionFactory;
     private DestinationResolver destinationResolver;
     private PlatformTransactionManager transactionManager;
@@ -60,6 +61,13 @@
     private String messageType = JMSConstants.TEXT_MESSAGE_TYPE;
     private boolean pubSubDomain;
 
+    public boolean isUsingEndpointInfo() {
+        return this.usingEndpointInfo;
+    }
+    
+    public void setUsingEndpointInfo(boolean usingEndpointInfo) {
+        this.usingEndpointInfo = usingEndpointInfo;
+    }
     public boolean isUseJndi() {
         return useJndi;
     }

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
Mon Dec 15 20:05:10 2008
@@ -33,6 +33,7 @@
 import org.springframework.jms.connection.SingleConnectionFactory;
 import org.springframework.jms.connection.SingleConnectionFactory102;
 import org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter;
+import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.support.destination.JndiDestinationResolver;
 import org.springframework.jndi.JndiTemplate;
 
@@ -87,7 +88,6 @@
     public JMSConfiguration createJMSConfigurationFromEndpointInfo(Bus bus,
                                                                    EndpointInfo endpointInfo,
                                                                    boolean isConduit) {
-        jmsConfig = new JMSConfiguration();
 
         // Retrieve configuration information that was extracted from the WSDL
         address = endpointInfo.getTraversedExtensor(new AddressType(), AddressType.class);
@@ -99,63 +99,68 @@
         serverBehavior = endpointInfo.getTraversedExtensor(new ServerBehaviorPolicyType(),
                                                            ServerBehaviorPolicyType.class);
         String name = endpointInfo.getName().toString() + (isConduit ? ".jms-conduit" : ".jms-destination");
-
+       
         // Try to retrieve configuration information from the spring
         // config. Search for a conduit or destination with name=endpoint name + ".jms-conduit"
         // or ".jms-destination"
+        
         Configurer configurer = bus.getExtension(Configurer.class);
         if (null != configurer) {
             configurer.configureBean(name, this);
         }
-
-        JndiTemplate jt = new JndiTemplate();
-        jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(address));
-        boolean pubSubDomain = false;
-        if (address.isSetDestinationStyle()) {
-            pubSubDomain = DestinationStyleType.TOPIC == address.getDestinationStyle();
-        }
-        ConnectionFactory cf = getConnectionFactoryFromJndi(jt, pubSubDomain);
-
-        jmsConfig.setConnectionFactory(cf);
-        jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
-        jmsConfig.setExplicitQosEnabled(true);
-        // jmsConfig.setMessageIdEnabled(messageIdEnabled);
-        jmsConfig.setMessageSelector(serverBehavior.getMessageSelector());
-        // jmsConfig.setMessageTimestampEnabled(messageTimestampEnabled);
-        if (runtimePolicy.isSetMessageType()) {
-            jmsConfig.setMessageType(runtimePolicy.getMessageType().value());
-        }
-        // jmsConfig.setOneWay(oneWay);
-        // jmsConfig.setPriority(priority);
-        jmsConfig.setPubSubDomain(pubSubDomain);
-        jmsConfig.setPubSubNoLocal(true);
-        jmsConfig.setReceiveTimeout(clientConfig.getClientReceiveTimeout());
-        jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
-        long timeToLive = isConduit ? clientConfig.getMessageTimeToLive() : serverConfig
-            .getMessageTimeToLive();
-        jmsConfig.setTimeToLive(timeToLive);
-        if (address.isSetUseJms11()) {
-            jmsConfig.setUseJms11(address.isUseJms11());
-        }
-        boolean useJndi = address.isSetJndiDestinationName();
-        jmsConfig.setUseJndi(useJndi);
-        jmsConfig.setSessionTransacted(serverBehavior.isSetTransactional());
-
-        if (useJndi) {
-            // Setup Destination jndi destination resolver
-            final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
-            jndiDestinationResolver.setJndiTemplate(jt);
-            jmsConfig.setDestinationResolver(jndiDestinationResolver);
-            jmsConfig.setTargetDestination(address.getJndiDestinationName());
-            jmsConfig.setReplyDestination(address.getJndiReplyDestinationName());
-        } else {
-            // Use the default dynamic destination resolver
-            jmsConfig.setTargetDestination(address.getJmsDestinationName());
-            jmsConfig.setReplyDestination(address.getJmsReplyDestinationName());
+        
+        if (jmsConfig == null) {
+            jmsConfig = new JMSConfiguration();
         }
 
-        jmsConfig.setConnectionFactory(cf);
+        if (jmsConfig.isUsingEndpointInfo()) {
+            JndiTemplate jt = new JndiTemplate();
+            jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(address));
+            boolean pubSubDomain = false;
+            if (address.isSetDestinationStyle()) {
+                pubSubDomain = DestinationStyleType.TOPIC == address.getDestinationStyle();
+            }
+            ConnectionFactory cf = getConnectionFactoryFromJndi(jt, pubSubDomain);      
     
+            jmsConfig.setConnectionFactory(cf);
+        
+            jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
+            jmsConfig.setExplicitQosEnabled(true);        
+            jmsConfig.setMessageSelector(serverBehavior.getMessageSelector());        
+            if (isConduit && runtimePolicy.isSetMessageType()) {
+                jmsConfig.setMessageType(runtimePolicy.getMessageType().value());
+            }        
+            jmsConfig.setPubSubDomain(pubSubDomain);
+            jmsConfig.setPubSubNoLocal(true);
+            if (jmsConfig.getReceiveTimeout() == JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT)
{
+                jmsConfig.setReceiveTimeout(clientConfig.getClientReceiveTimeout());
+            }            
+            jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
      
+            jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
       
+        
+            long timeToLive = isConduit ? clientConfig.getMessageTimeToLive() : serverConfig
+                .getMessageTimeToLive();
+            jmsConfig.setTimeToLive(timeToLive);
+            if (address.isSetUseJms11()) {                
+                jmsConfig.setUseJms11(address.isUseJms11());        
+            }
+            boolean useJndi = address.isSetJndiDestinationName();
+            jmsConfig.setUseJndi(useJndi);
+        
+            jmsConfig.setSessionTransacted(serverBehavior.isSetTransactional());
 
+            if (useJndi) {
+                // Setup Destination jndi destination resolver
+                final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
+                jndiDestinationResolver.setJndiTemplate(jt);
+                jmsConfig.setDestinationResolver(jndiDestinationResolver);
+                jmsConfig.setTargetDestination(address.getJndiDestinationName());
+                jmsConfig.setReplyDestination(address.getJndiReplyDestinationName());
+            } else {
+                // Use the default dynamic destination resolver
+                jmsConfig.setTargetDestination(address.getJmsDestinationName());
+                jmsConfig.setReplyDestination(address.getJmsReplyDestinationName());
+            }
+        }
         return jmsConfig;
     }
 

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spring/JMSDestinationBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spring/JMSDestinationBeanDefinitionParser.java?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spring/JMSDestinationBeanDefinitionParser.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spring/JMSDestinationBeanDefinitionParser.java
Mon Dec 15 20:05:10 2008
@@ -21,6 +21,8 @@
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.transport.jms.AddressType;
@@ -46,6 +48,12 @@
                                  AddressType.class);
         mapElementToJaxbProperty(element, bean, new QName(JMS_NS, "sessionPool"), "sessionPool",
                                  SessionPoolType.class);
+        NodeList el = element.getElementsByTagNameNS(JMS_NS, "jmsConfig-ref");
+
+        if (el.getLength() == 1) {
+            Node el1 = el.item(0);
+            bean.addPropertyReference("jmsConfig", el1.getTextContent());
+        }
     }
 
     @Override

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/resources/schemas/configuration/jms.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/resources/schemas/configuration/jms.xsd?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/resources/schemas/configuration/jms.xsd
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/resources/schemas/configuration/jms.xsd
Mon Dec 15 20:05:10 2008
@@ -39,6 +39,7 @@
                         <xs:element name="runtimePolicy" type="jms:ServerBehaviorPolicyType"
minOccurs="0"/>
                         <xs:element name="sessionPool" type="jms:SessionPoolType" minOccurs="0"/>
                         <xs:element name="address" type="jms:AddressType" minOccurs="0"/>
+                        <xs:element name="jmsConfig-ref" type="xs:string" maxOccurs="1"
minOccurs="0"/>                    	
                     </xs:sequence>
                     <xs:attributeGroup ref="cxf-beans:beanAttributes"/>
                 </xs:extension>
@@ -59,9 +60,7 @@
                     		type="jms:SessionPoolType" minOccurs="0" />
                     	<xs:element name="address"
                     		type="jms:AddressType" minOccurs="0" />
-                    	<xs:element name="jmsConfig-ref"
-                    		type="xs:string" maxOccurs="1" minOccurs="0">
-                    	</xs:element>
+                    	<xs:element name="jmsConfig-ref" type="xs:string" maxOccurs="1" minOccurs="0"/>
                   	
                     </xs:sequence>
                     <xs:attributeGroup ref="cxf-beans:beanAttributes"/>
                 </xs:extension>

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
Mon Dec 15 20:05:10 2008
@@ -25,6 +25,7 @@
 
 import javax.jms.DeliveryMode;
 
+import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.message.Exchange;
@@ -104,8 +105,8 @@
                          "/wsdl/jms_test_no_addr.wsdl",
                          "HelloWorldQueueBinMsgService",
                          "HelloWorldQueueBinMsgPort");
-        JMSDestination destination = setupJMSDestination(false);
-        JMSConfiguration jmsConfig = destination.getJmsConfig();
+        JMSDestination destination = setupJMSDestination(false);        
+        JMSConfiguration jmsConfig = destination.getJmsConfig();        
         //JmsTemplate jmsTemplate = destination.getJmsTemplate();
         //AbstractMessageListenerContainer jmsListener = destination.getJmsListener();
         assertEquals("Can't get the right ServerConfig's MessageTimeToLive ", 500L, jmsConfig
@@ -118,6 +119,21 @@
         // .getConnectionPassword());
         assertEquals("Can't get the right DurableSubscriberName", "cxf_subscriber", jmsConfig
             .getDurableSubscriptionName());
+        
+        /*setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
+                         "HelloWorldQueueBinMsgService", "HelloWorldQueueBinMsgPort");
+        destination = setupJMSDestination(false);
+        jmsConfig = destination.getJmsConfig();*/
+        assertEquals("The concurrentConsumer should be set", jmsConfig.getConcurrentConsumers(),
3);
+        assertEquals("The maxConcurrentConsumer should be set", jmsConfig.getMaxConcurrentConsumers(),
5);
+        assertNotNull("The connectionFactory should not be null", jmsConfig.getConnectionFactory());
+        assertTrue("Should get the instance of ActiveMQConnectionFactory", 
+                   jmsConfig.getConnectionFactory() instanceof ActiveMQConnectionFactory);
+        ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory)jmsConfig.getConnectionFactory();
+        assertEquals("The borker URL is wrong", cf.getBrokerURL(), "tcp://localhost:61500");
+        assertEquals("Get a wrong TargetDestination", jmsConfig.getTargetDestination(), "queue:test");
+        assertEquals("Get the wrong pubSubDomain value", jmsConfig.isPubSubDomain(), false);
+        
         BusFactory.setDefaultBus(null);
 
     }

Modified: cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/resources/jms_test_config.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/resources/jms_test_config.xml?rev=726940&r1=726939&r2=726940&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/resources/jms_test_config.xml (original)
+++ cxf/branches/2.0.x-fixes/rt/transports/jms/src/test/resources/jms_test_config.xml Mon
Dec 15 20:05:10 2008
@@ -46,15 +46,7 @@
       <jms:jmsConfig-ref>jmsConf1</jms:jmsConfig-ref>
     </jms:conduit>
     
-    <jms:destination name="{http://cxf.apache.org/jms_conf_test}HelloWorldQueueBinMsgPort.jms-destination">
-      <jms:serverConfig
-        messageTimeToLive="500"
-        durableSubscriptionClientId="test-server-id"/>
-      <jms:runtimePolicy               
-         messageSelector="cxf_message_selector"
-         useMessageIDAsCorrelationID="true"
-         transactional="true"
-         durableSubscriberName="cxf_subscriber"/>
+    <jms:destination name="{http://cxf.apache.org/jms_conf_test}HelloWorldQueueBinMsgPort.jms-destination">
    
       <jms:sessionPool
           lowWaterMark="10"
           highWaterMark="5000"/>
@@ -66,11 +58,12 @@
           connectionUserName="testUser"
           connectionPassword="testPassword">
           <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
-          <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61500"/>
-      </jms:address>   
-  </jms:destination> 
+          <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61511"/>
+      </jms:address> 
+      <jms:jmsConfig-ref>jmsConf2</jms:jmsConfig-ref>  
+  </jms:destination>
   
-   <jms:destination name="{http://cxf.apache.org/hello_world_jms}HelloWorldPubSubPort.jms-destination">
+  <jms:destination name="{http://cxf.apache.org/hello_world_jms}HelloWorldPubSubPort.jms-destination">
       <jms:serverConfig
         messageTimeToLive="500"
         durableSubscriptionClientId="test-server-id"/>      
@@ -93,7 +86,29 @@
   	p:connectionFactory-ref="connectionFactory"
   	p:targetDestination="queue:test"
   	p:pubSubDomain="false"
+  	
+  />
+  
+  <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
+    p:brokerURL="tcp://localhost:61500"
   />
+  
+
+  
+  <bean id="jmsConf2" class="org.apache.cxf.transport.jms.JMSConfiguration"
+  	p:connectionFactory-ref="jmsConnectionFactory"
+  	p:timeToLive="500"
+  	p:messageSelector="cxf_message_selector"
+  	p:sessionTransacted="true"
+    p:durableSubscriptionName="cxf_subscriber"
+  	p:targetDestination="queue:test"
+  	p:replyDestination="queue:test.reply"
+  	p:pubSubDomain="false"
+  	p:usingEndpointInfo="false"
+  	p:concurrentConsumers="3"
+  	p:maxConcurrentConsumers="5"
+  />    
+ 
 <!--
   <bean class="org.apache.cxf.transport.jms.JMSTransportFactory"
 	  id="org.apache.cxf.transport.jms.JMSTransportFactory"



Mime
View raw message