cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r701783 - in /cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms: JMSConduit.java JMSConfigFeature.java JMSConfiguration.java JMSDestination.java JMSFactory.java JMSOldConfigHolder.java
Date Sun, 05 Oct 2008 12:49:52 GMT
Author: cschneider
Date: Sun Oct  5 05:49:52 2008
New Revision: 701783

URL: http://svn.apache.org/viewvc?rev=701783&view=rev
Log:
CXF-1832 Example for JMSConfigFeature

Added:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=701783&r1=701782&r2=701783&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Sun Oct  5 05:49:52 2008
@@ -69,6 +69,12 @@
      * JMSOutputStream will then call back the sendExchange method of this class. {@inheritDoc}
      */
     public void prepare(Message message) throws IOException {
+        if (jmsConfig.getTargetDestination() == null || jmsConfig.getConnectionFactory()
== null) {
+            String name =  ".jms-conduit";
+            throw new RuntimeException("Insufficient configuration for Conduit. "
+                                       + "Did you configure a <jms:conduit name=\"" +
name
+                                       + "\"> and set the jndiConnectionFactoryName ?");
+        }
         boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType());
         JMSOutputStream out = new JMSOutputStream(this, message.getExchange(), isTextPayload);
         message.setContent(OutputStream.class, out);

Added: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java?rev=701783&view=auto
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
(added)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
Sun Oct  5 05:49:52 2008
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.jms;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.transport.Conduit;
+import org.springframework.beans.factory.annotation.Required;
+
+/**
+ * Allows to configure the JMSConfiguration directly at the Client or Endpoint. Simply add
this class to the
+ * Features and reference a JMSConfiguration. The configuration inside this class takes precedence
over a
+ * configuration that is generated from the old configuration style.
+ */
+public class JMSConfigFeature extends AbstractFeature {
+    JMSConfiguration jmsConfig;
+
+    @Override
+    public void initialize(Client client, Bus bus) {
+        Conduit conduit = client.getConduit();
+        if (conduit instanceof JMSConduit && jmsConfig != null) {
+            JMSConduit jmsConduit = (JMSConduit)conduit;
+            jmsConduit.setJmsConfig(jmsConfig);
+        }
+        super.initialize(client, bus);
+    }
+
+    public JMSConfiguration getJmsConfig() {
+        return jmsConfig;
+    }
+
+    @Required
+    public void setJmsConfig(JMSConfiguration jmsConfig) {
+        this.jmsConfig = jmsConfig;
+    }
+
+}

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=701783&r1=701782&r2=701783&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
Sun Oct  5 05:49:52 2008
@@ -23,6 +23,7 @@
 
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.task.TaskExecutor;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.support.destination.DestinationResolver;
 import org.springframework.transaction.PlatformTransactionManager;
@@ -31,6 +32,7 @@
     private ConnectionFactory connectionFactory;
     private DestinationResolver destinationResolver;
     private PlatformTransactionManager transactionManager;
+    private TaskExecutor taskExecutor;
     private boolean useJms11 = true;
     private boolean useJndi;
     private boolean messageIdEnabled = true;
@@ -42,6 +44,9 @@
     private int priority = Message.DEFAULT_PRIORITY;
     private long timeToLive = Message.DEFAULT_TIME_TO_LIVE;
     private boolean sessionTransacted;
+    
+    private int concurrentConsumers = 1;
+    private int maxConcurrentConsumers = 1;
 
     private volatile String messageSelector;
     private boolean subscriptionDurable;
@@ -227,4 +232,28 @@
         this.transactionManager = transactionManager;
     }
 
+    public int getConcurrentConsumers() {
+        return concurrentConsumers;
+    }
+
+    public void setConcurrentConsumers(int concurrentConsumers) {
+        this.concurrentConsumers = concurrentConsumers;
+    }
+
+    public int getMaxConcurrentConsumers() {
+        return maxConcurrentConsumers;
+    }
+
+    public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
+        this.maxConcurrentConsumers = maxConcurrentConsumers;
+    }
+
+    public TaskExecutor getTaskExecutor() {
+        return taskExecutor;
+    }
+
+    public void setTaskExecutor(TaskExecutor taskExecutor) {
+        this.taskExecutor = taskExecutor;
+    }
+
 }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?rev=701783&r1=701782&r2=701783&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Sun Oct  5 05:49:52 2008
@@ -89,6 +89,12 @@
      */
     public void activate() {
         getLogger().log(Level.INFO, "JMSDestination activate().... ");
+        String name = endpointInfo.getName().toString() + ".jms-destination";
+        if (jmsConfig.getTargetDestination() == null || jmsConfig.getConnectionFactory()
== null) {
+            throw new RuntimeException("Insufficient configuration for Destination. "
+                                       + "Did you configure a <jms:destination name=\""
+ name
+                                       + "\"> and set the jndiConnectionFactoryName ?");
+        }
         jmsListener = JMSFactory.createJmsListener(jmsConfig, this, jmsConfig.getTargetDestination());
         jmsConfig.getTargetDestination();
     }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java?rev=701783&r1=701782&r2=701783&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
Sun Oct  5 05:49:52 2008
@@ -79,24 +79,30 @@
     public static DefaultMessageListenerContainer createJmsListener(JMSConfiguration jmsConfig,
                                                                     MessageListener listenerHandler,
                                                                     String destinationName)
{
-        DefaultMessageListenerContainer jmsListener2 = jmsConfig.isUseJms11()
+        DefaultMessageListenerContainer jmsListener = jmsConfig.isUseJms11()
             ? new DefaultMessageListenerContainer() : new DefaultMessageListenerContainer102();
-        jmsListener2.setPubSubDomain(jmsConfig.isPubSubDomain());
-        jmsListener2.setAutoStartup(true);
-        jmsListener2.setConnectionFactory(jmsConfig.getConnectionFactory());
-        jmsListener2.setMessageSelector(jmsConfig.getMessageSelector());
-        jmsListener2.setDurableSubscriptionName(jmsConfig.getDurableSubscriptionName());
-        jmsListener2.setSessionTransacted(jmsConfig.isSessionTransacted());
-        jmsListener2.setTransactionManager(jmsConfig.getTransactionManager());
-        jmsListener2.setMessageListener(listenerHandler);
+        jmsListener.setConcurrentConsumers(jmsConfig.getConcurrentConsumers());
+        jmsListener.setMaxConcurrentConsumers(jmsConfig.getMaxConcurrentConsumers());
+        jmsListener.setPubSubDomain(jmsConfig.isPubSubDomain());
+        jmsListener.setAutoStartup(true);
+        jmsListener.setConnectionFactory(jmsConfig.getConnectionFactory());
+        jmsListener.setMessageSelector(jmsConfig.getMessageSelector());
+        jmsListener.setDurableSubscriptionName(jmsConfig.getDurableSubscriptionName());
+        jmsListener.setSessionTransacted(jmsConfig.isSessionTransacted());
+        jmsListener.setTransactionManager(jmsConfig.getTransactionManager());
+        jmsListener.setMessageListener(listenerHandler);
         if (jmsConfig.getDestinationResolver() != null) {
-            jmsListener2.setDestinationResolver(jmsConfig.getDestinationResolver());
+            jmsListener.setDestinationResolver(jmsConfig.getDestinationResolver());
+        }
+        if (jmsConfig.getTaskExecutor() != null) {
+            jmsListener.setTaskExecutor(jmsConfig.getTaskExecutor());
         }
         JmsTemplate jmsTemplate = createJmsTemplate(jmsConfig, null);
-        jmsListener2.setDestination(JMSFactory.resolveOrCreateDestination(jmsTemplate, destinationName,
-                                                                          jmsConfig.isPubSubDomain()));
-        jmsListener2.initialize();
-        return jmsListener2;
+        Destination dest = JMSFactory.resolveOrCreateDestination(jmsTemplate, destinationName,
jmsConfig
+            .isPubSubDomain());
+        jmsListener.setDestination(dest);
+        jmsListener.initialize();
+        return jmsListener;
     }
 
     /**

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=701783&r1=701782&r2=701783&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
Sun Oct  5 05:49:52 2008
@@ -136,14 +136,6 @@
 
         jmsConfig.setConnectionFactory(cf);
 
-        if (jmsConfig.getTargetDestination() == null || jmsConfig.getConnectionFactory()
== null) {
-            throw new RuntimeException("Insufficient configuration for "
-                                       + (isConduit ? "Conduit" : "Destination") + ". "
-                                       + "Did you configure a <jms:"
-                                       + (isConduit ? "conduit" : "destination") + " name=\""
+ name
-                                       + "\"> and set the jndiConnectionFactoryName ?");
-        }
-
         return jmsConfig;
     }
 



Mime
View raw message