activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r368957 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq: ActiveMQConnectionFactory.java command/ActiveMQDestination.java
Date Sat, 14 Jan 2006 02:10:27 GMT
Author: aco
Date: Fri Jan 13 18:10:14 2006
New Revision: 368957

URL: http://svn.apache.org/viewcvs?rev=368957&view=rev
Log:
Added initial implementation to make ActiveMQConnectionFactory and ActiveMQDestination referenceable.

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java?rev=368957&r1=368956&r2=368957&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Fri Jan 13 18:10:14 2006
@@ -20,6 +20,7 @@
 import java.net.URISyntaxException;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Enumeration;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -29,6 +30,9 @@
 import javax.jms.TopicConnection;
 import javax.jms.TopicConnectionFactory;
 import javax.naming.Context;
+import javax.naming.Referenceable;
+import javax.naming.Reference;
+import javax.naming.NamingException;
 
 import org.apache.activemq.management.JMSStatsImpl;
 import org.apache.activemq.management.StatsCapable;
@@ -53,7 +57,7 @@
  * @version $Revision: 1.9 $
  * @see javax.jms.ConnectionFactory
  */
-public class ActiveMQConnectionFactory implements ConnectionFactory, QueueConnectionFactory,
TopicConnectionFactory, StatsCapable {
+public class ActiveMQConnectionFactory implements ConnectionFactory, QueueConnectionFactory,
TopicConnectionFactory, StatsCapable, Referenceable {
 
     public static final String DEFAULT_BROKER_URL = "tcp://localhost:61616";
     public static final String DEFAULT_USER = null;
@@ -377,6 +381,25 @@
         }
     }
 
+    public Properties getProperties() {
+        Properties props = new Properties();
+        props.setProperty("asyncDispatch", Boolean.toString(isAsyncDispatch()));
+        props.setProperty("brokerURL", getBrokerURL());
+        props.setProperty("clientID", getClientID());
+        props.setProperty("copyMessageOnSend", Boolean.toString(isCopyMessageOnSend()));
+        props.setProperty("disableTimeStampsByDefault", Boolean.toString(isDisableTimeStampsByDefault()));
+        props.setProperty("objectMessageSerializationDefered", Boolean.toString(isObjectMessageSerializationDefered()));
+        props.setProperty("onSendPrepareMessageBody", Boolean.toString(isOnSendPrepareMessageBody()));
+        props.setProperty("optimizedMessageDispatch", Boolean.toString(isOptimizedMessageDispatch()));
+        props.setProperty("password", getPassword());
+        props.setProperty("useAsyncSend", Boolean.toString(isUseAsyncSend()));
+        props.setProperty("useCompression", Boolean.toString(isUseCompression()));
+        props.setProperty("useRetroactiveConsumer", Boolean.toString(isUseRetroactiveConsumer()));
+        props.setProperty("username", getUserName());
+
+        return props;
+    }
+
     public boolean isOnSendPrepareMessageBody() {
         return onSendPrepareMessageBody;
     }
@@ -407,6 +430,29 @@
 
     public void setAsyncDispatch(boolean asyncDispatch) {
         this.asyncDispatch = asyncDispatch;
+    }
+
+    /**
+     * Retrieve a Reference for this instance to store in JNDI
+     *
+     * @return the built Reference
+     * @throws NamingException if error on building Reference
+     */
+    public Reference getReference() throws NamingException {
+        Reference ref = new Reference(this.getClass().getName());
+
+        try {
+            Properties props = getProperties();
+            for (Enumeration iter = props.propertyNames(); iter.hasMoreElements();) {
+                String key = (String) iter.nextElement();
+                String value = props.getProperty(key);
+                javax.naming.StringRefAddr addr = new javax.naming.StringRefAddr(key, value);
+                ref.add(addr);
+            }
+        } catch (Exception e) {
+            throw new NamingException(e.getMessage());
+        }
+        return ref;
     }
 
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java?rev=368957&r1=368956&r2=368957&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
Fri Jan 13 18:10:14 2006
@@ -25,6 +25,8 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.Properties;
+import java.util.Enumeration;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -32,6 +34,9 @@
 import javax.jms.TemporaryQueue;
 import javax.jms.TemporaryTopic;
 import javax.jms.Topic;
+import javax.naming.Reference;
+import javax.naming.NamingException;
+import javax.naming.Referenceable;
 
 import org.apache.activemq.util.URISupport;
 
@@ -39,7 +44,7 @@
  * @openwire:marshaller
  * @version $Revision: 1.10 $
  */
-abstract public class ActiveMQDestination implements DataStructure, Destination, Externalizable,
Comparable {
+abstract public class ActiveMQDestination implements DataStructure, Destination, Externalizable,
Comparable, Referenceable {
 
     private static final long serialVersionUID = -3885260014960795889L;
 
@@ -330,4 +335,43 @@
         return false;
     }
 
+    public Properties getProperties() {
+        Properties props = new Properties();
+
+        props.setProperty("composite", Boolean.toString(isComposite()));
+        props.setProperty("destinationType", Byte.toString(getDestinationType()));
+        props.setProperty("destinationTypeAsString", getDestinationTypeAsString());
+        props.setProperty("marshallAware", Boolean.toString(isMarshallAware()));
+        props.setProperty("physicalName", getPhysicalName());
+        props.setProperty("qualifiedName", getQualifiedName());
+        props.setProperty("qualifiedPrefix", getQualifiedPrefix());
+        props.setProperty("queue", Boolean.toString(isQueue()));
+        props.setProperty("temporary", Boolean.toString(isTemporary()));
+        props.setProperty("topic", Boolean.toString(isTopic()));
+
+        return props;
+    }
+
+    /**
+     * Retrieve a Reference for this instance to store in JNDI
+     *
+     * @return the built Reference
+     * @throws javax.naming.NamingException if error on building Reference
+     */
+    public Reference getReference() throws NamingException {
+        Reference ref = new Reference(this.getClass().getName());
+
+        try {
+            Properties props = getProperties();
+            for (Enumeration iter = props.propertyNames(); iter.hasMoreElements();) {
+                String key = (String) iter.nextElement();
+                String value = props.getProperty(key);
+                javax.naming.StringRefAddr addr = new javax.naming.StringRefAddr(key, value);
+                ref.add(addr);
+            }
+        } catch (Exception e) {
+            throw new NamingException(e.getMessage());
+        }
+        return ref;
+    }
 }



Mime
View raw message