cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r702656 - in /cxf/trunk/rt/transports/jms/src: main/java/org/apache/cxf/transport/jms/ test/java/org/apache/cxf/transport/jms/
Date Tue, 07 Oct 2008 22:17:26 GMT
Author: cschneider
Date: Tue Oct  7 15:17:25 2008
New Revision: 702656

URL: http://svn.apache.org/viewvc?rev=702656&view=rev
Log:
Added Configuration Exceptions when JMSConduit, JMSDestination or JMSConfigFeature are not
configured properly.

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/JMSConfigFeature.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/JMSTransportFactory.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
    cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.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=702656&r1=702655&r2=702656&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
Tue Oct  7 15:17:25 2008
@@ -33,9 +33,11 @@
 import javax.jms.Session;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfigurationException;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.AbstractConduit;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.springframework.jms.core.JmsTemplate;
@@ -52,14 +54,15 @@
 public class JMSConduit extends AbstractConduit implements JMSExchangeSender, MessageListener
{
     static final Logger LOG = LogUtils.getL7dLogger(JMSConduit.class);
 
+    private EndpointInfo endpointInfo;
     private JMSConfiguration jmsConfig;
     private Map<String, Message> correlationMap;
-
     private DefaultMessageListenerContainer jmsListener;
 
-    public JMSConduit(EndpointReferenceType target, JMSConfiguration jmsConfig) {
+    public JMSConduit(EndpointInfo endpointInfo, EndpointReferenceType target, JMSConfiguration
jmsConfig) {
         super(target);
         this.jmsConfig = jmsConfig;
+        this.endpointInfo = endpointInfo;
         correlationMap = new ConcurrentHashMap<String, Message>();
     }
 
@@ -70,10 +73,9 @@
      */
     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 ?");
+            String name =  endpointInfo.getName().toString() + ".jms-conduit";
+            throw new ConfigurationException(
+                new org.apache.cxf.common.i18n.Message("INSUFFICIENT_CONFIGURATION_CONDUIT",
LOG, name));
         }
         boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType());
         JMSOutputStream out = new JMSOutputStream(this, message.getExchange(), isTextPayload);

Modified: 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=702656&r1=702655&r2=702656&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFeature.java
Tue Oct  7 15:17:25 2008
@@ -18,7 +18,12 @@
  */
 package org.apache.cxf.transport.jms;
 
+import java.util.logging.Logger;
+
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfigurationException;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
@@ -32,28 +37,34 @@
  * configuration that is generated from the old configuration style.
  */
 public class JMSConfigFeature extends AbstractFeature {
+    static final Logger LOG = LogUtils.getL7dLogger(JMSConfigFeature.class);
+
     JMSConfiguration jmsConfig;
 
     @Override
     public void initialize(Client client, Bus bus) {
+        checkJmsConfig();
         Conduit conduit = client.getConduit();
-        if (conduit instanceof JMSConduit && jmsConfig != null) {
-            JMSConduit jmsConduit = (JMSConduit)conduit;
-            jmsConduit.setJmsConfig(jmsConfig);
+        if (!(conduit instanceof JMSConduit)) {
+            throw new ConfigurationException(new Message("JMSCONFIGFEATURE_ONLY_JMS", LOG));
         }
+        JMSConduit jmsConduit = (JMSConduit)conduit;
+        jmsConduit.setJmsConfig(jmsConfig);
         super.initialize(client, bus);
     }
 
     @Override
     public void initialize(Server server, Bus bus) {
+        checkJmsConfig();
         Destination destination = server.getDestination();
-        if (destination instanceof JMSDestination && jmsConfig != null) {
-            JMSDestination jmsConduit = (JMSDestination)destination;
-            jmsConduit.setJmsConfig(jmsConfig);
+        if (!(destination instanceof JMSDestination)) {
+            throw new ConfigurationException(new Message("JMSCONFIGFEATURE_ONLY_JMS", LOG));
         }
+        JMSDestination jmsDestination = (JMSDestination)destination;
+        jmsDestination.setJmsConfig(jmsConfig);
         super.initialize(server, bus);
     }
-    
+
     public JMSConfiguration getJmsConfig() {
         return jmsConfig;
     }
@@ -63,4 +74,9 @@
         this.jmsConfig = jmsConfig;
     }
 
+    private void checkJmsConfig() {
+        if (jmsConfig == null) {
+            throw new ConfigurationException(new Message("JMSCONFIG_REQUIRED", LOG));
+        }
+    }
 }

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=702656&r1=702655&r2=702656&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
Tue Oct  7 15:17:25 2008
@@ -42,6 +42,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfigurationException;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -91,12 +92,10 @@
         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 ?");
+            throw new ConfigurationException(
+                new org.apache.cxf.common.i18n.Message("INSUFFICIENT_CONFIGURATION_DESTINATION",
LOG, name));
         }
         jmsListener = JMSFactory.createJmsListener(jmsConfig, this, jmsConfig.getTargetDestination());
-        jmsConfig.getTargetDestination();
     }
 
     public void deactivate() {

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportFactory.java?rev=702656&r1=702655&r2=702656&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportFactory.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportFactory.java
Tue Oct  7 15:17:25 2008
@@ -63,7 +63,7 @@
     public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target) throws
IOException {
         JMSOldConfigHolder old = new JMSOldConfigHolder();
         JMSConfiguration jmsConf = old.createJMSConfigurationFromEndpointInfo(bus, endpointInfo,
true);
-        return new JMSConduit(target, jmsConf);
+        return new JMSConduit(endpointInfo, target, jmsConf);
     }
 
     /**

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties?rev=702656&r1=702655&r2=702656&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
Tue Oct  7 15:17:25 2008
@@ -19,3 +19,7 @@
 #
 #
 DISPATCH_FAILURE_MSG = Dispatch of incoming JMS request failed
+INSUFFICIENT_CONFIGURATION_CONDUIT = Insufficient configuration for Conduit. Did you configure
a <jms:conduit name=\"{0}\"> and set the jndiConnectionFactoryName ?
+INSUFFICIENT_CONFIGURATION_DESTINATION = Insufficient configuration for Destination. Did
you configure a <jms:destination name=\"{0}\"> and set the jndiConnectionFactoryName
?
+JMSCONFIGFEATURE_ONLY_JMS = You can only use JMSConfigFeature with the jms transport
+JMSCONFIG_REQUIRED = You have to set the property jmsConfig
\ No newline at end of file

Modified: cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java?rev=702656&r1=702655&r2=702656&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
(original)
+++ cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
Tue Oct  7 15:17:25 2008
@@ -114,7 +114,7 @@
         
         JMSConfiguration jmsConfig = new JMSOldConfigHolder()
             .createJMSConfigurationFromEndpointInfo(bus, endpointInfo, true);
-        JMSConduit jmsConduit = new JMSConduit(target, jmsConfig);
+        JMSConduit jmsConduit = new JMSConduit(endpointInfo, target, jmsConfig);
         if (send) {
             // setMessageObserver
             observer = new MessageObserver() {



Mime
View raw message