You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/06/01 20:37:54 UTC

svn commit: r780773 [31/31] - in /activemq/sandbox/activemq-flow: activemq-client/ activemq-client/src/main/java/org/ activemq-client/src/main/java/org/apache/ activemq-client/src/main/java/org/apache/activemq/ activemq-client/src/main/java/org/apache/...

Added: activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/util/TypeConversionSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/util/TypeConversionSupport.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/util/TypeConversionSupport.java (added)
+++ activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/util/TypeConversionSupport.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,161 @@
+/**
+ * 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.activemq.util;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import org.apache.activemq.command.ActiveMQDestination;
+
+public final class TypeConversionSupport {
+
+    static class ConversionKey {
+        final Class from;
+        final Class to;
+        final int hashCode;
+
+        public ConversionKey(Class from, Class to) {
+            this.from = from;
+            this.to = to;
+            this.hashCode = from.hashCode() ^ (to.hashCode() << 1);
+        }
+
+        public boolean equals(Object o) {
+            ConversionKey x = (ConversionKey)o;
+            return x.from == from && x.to == to;
+        }
+
+        public int hashCode() {
+            return hashCode;
+        }
+    }
+
+    interface Converter {
+        Object convert(Object value);
+    }
+
+    private static final HashMap<ConversionKey, Converter> CONVERSION_MAP = new HashMap<ConversionKey, Converter>();
+    static {
+        Converter toStringConverter = new Converter() {
+            public Object convert(Object value) {
+                return value.toString();
+            }
+        };
+        CONVERSION_MAP.put(new ConversionKey(Boolean.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Byte.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Short.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Integer.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Long.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Float.class, String.class), toStringConverter);
+        CONVERSION_MAP.put(new ConversionKey(Double.class, String.class), toStringConverter);
+
+        CONVERSION_MAP.put(new ConversionKey(String.class, Boolean.class), new Converter() {
+            public Object convert(Object value) {
+                return Boolean.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Byte.class), new Converter() {
+            public Object convert(Object value) {
+                return Byte.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Short.class), new Converter() {
+            public Object convert(Object value) {
+                return Short.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Integer.class), new Converter() {
+            public Object convert(Object value) {
+                return Integer.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Long.class), new Converter() {
+            public Object convert(Object value) {
+                return Long.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Float.class), new Converter() {
+            public Object convert(Object value) {
+                return Float.valueOf((String)value);
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, Double.class), new Converter() {
+            public Object convert(Object value) {
+                return Double.valueOf((String)value);
+            }
+        });
+
+        Converter longConverter = new Converter() {
+            public Object convert(Object value) {
+                return Long.valueOf(((Number)value).longValue());
+            }
+        };
+        CONVERSION_MAP.put(new ConversionKey(Byte.class, Long.class), longConverter);
+        CONVERSION_MAP.put(new ConversionKey(Short.class, Long.class), longConverter);
+        CONVERSION_MAP.put(new ConversionKey(Integer.class, Long.class), longConverter);
+        CONVERSION_MAP.put(new ConversionKey(Date.class, Long.class), new Converter() {
+            public Object convert(Object value) {
+                return Long.valueOf(((Date)value).getTime());
+            }
+        });
+
+        Converter intConverter = new Converter() {
+            public Object convert(Object value) {
+                return Integer.valueOf(((Number)value).intValue());
+            }
+        };
+        CONVERSION_MAP.put(new ConversionKey(Byte.class, Integer.class), intConverter);
+        CONVERSION_MAP.put(new ConversionKey(Short.class, Integer.class), intConverter);
+
+        CONVERSION_MAP.put(new ConversionKey(Byte.class, Short.class), new Converter() {
+            public Object convert(Object value) {
+                return Short.valueOf(((Number)value).shortValue());
+            }
+        });
+
+        CONVERSION_MAP.put(new ConversionKey(Float.class, Double.class), new Converter() {
+            public Object convert(Object value) {
+                return new Double(((Number)value).doubleValue());
+            }
+        });
+        CONVERSION_MAP.put(new ConversionKey(String.class, ActiveMQDestination.class), new Converter() {
+            public Object convert(Object value) {
+                return ActiveMQDestination.createDestination((String)value, ActiveMQDestination.QUEUE_TYPE);
+            }
+        });
+    }
+
+    private TypeConversionSupport() {
+    }
+
+    public static Object convert(Object value, Class clazz) {
+
+        assert value != null && clazz != null;
+
+        if (value.getClass() == clazz) {
+            return value;
+        }
+
+        Converter c = CONVERSION_MAP.get(new ConversionKey(value.getClass(), clazz));
+        if (c == null) {
+            return null;
+        }
+        return c.convert(value);
+
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/util/TypeConversionSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: activemq/sandbox/activemq-flow/activemq-selector/src/main/java/org/apache/activemq/filter/MessageEvaluationContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-selector/src/main/java/org/apache/activemq/filter/MessageEvaluationContext.java?rev=780773&r1=780772&r2=780773&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-selector/src/main/java/org/apache/activemq/filter/MessageEvaluationContext.java (original)
+++ activemq/sandbox/activemq-flow/activemq-selector/src/main/java/org/apache/activemq/filter/MessageEvaluationContext.java Mon Jun  1 18:37:41 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.filter;
 
-
-
 /**
  * MessageEvaluationContext is used to cache selection results. A message
  * usually has multiple selectors applied against it. Some selector have a high

Modified: activemq/sandbox/activemq-flow/activemq-stomp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-stomp/pom.xml?rev=780773&r1=780772&r2=780773&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-stomp/pom.xml (original)
+++ activemq/sandbox/activemq-flow/activemq-stomp/pom.xml Mon Jun  1 18:37:41 2009
@@ -37,8 +37,11 @@
       <groupId>org.apache.activemq</groupId>
       <artifactId>activemq-broker</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-openwire</artifactId>
+    </dependency>
 
-    <!-- TODO: remove this dependency -->
     <dependency>
       <groupId>org.apache.activemq</groupId>
       <artifactId>activemq-core</artifactId>

Modified: activemq/sandbox/activemq-flow/activemq-util/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/pom.xml?rev=780773&r1=780772&r2=780773&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/pom.xml (original)
+++ activemq/sandbox/activemq-flow/activemq-util/pom.xml Mon Jun  1 18:37:41 2009
@@ -33,6 +33,17 @@
 
   <dependencies>
                 
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jms_1.1_spec</artifactId>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <optional>true</optional>
+    </dependency>
+                
     <!-- Testing Dependencies -->    
     <dependency>
       <groupId>junit</groupId>

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIBaseStorable.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIBaseStorable.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIBaseStorable.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIBaseStorable.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,110 @@
+/**
+ * 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.activemq.jndi;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+
+/**
+ * Facilitates objects to be stored in JNDI as properties
+ */
+
+public abstract class JNDIBaseStorable implements JNDIStorableInterface, Externalizable {
+
+    private Properties properties;
+
+    /**
+     * Set the properties that will represent the instance in JNDI
+     * 
+     * @param props
+     */
+    protected abstract void buildFromProperties(Properties props);
+
+    /**
+     * Initialize the instance from properties stored in JNDI
+     * 
+     * @param props
+     */
+
+    protected abstract void populateProperties(Properties props);
+
+    /**
+     * set the properties for this instance as retrieved from JNDI
+     * 
+     * @param props
+     */
+
+    public synchronized void setProperties(Properties props) {
+        this.properties = props;
+        buildFromProperties(props);
+    }
+
+    /**
+     * Get the properties from this instance for storing in JNDI
+     * 
+     * @return the properties
+     */
+
+    public synchronized Properties getProperties() {
+        if (this.properties == null) {
+            this.properties = new Properties();
+        }
+        populateProperties(this.properties);
+        return this.properties;
+    }
+
+    /**
+     * Retrive 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 {
+        return JNDIReferenceFactory.createReference(this.getClass().getName(), this);
+    }
+
+    /**
+     * @param in
+     * @throws IOException
+     * @throws ClassNotFoundException
+     * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+     */
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        Properties props = (Properties)in.readObject();
+        if (props != null) {
+            setProperties(props);
+        }
+
+    }
+
+    /**
+     * @param out
+     * @throws IOException
+     * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+     */
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(getProperties());
+
+    }
+
+}

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIReferenceFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIReferenceFactory.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIReferenceFactory.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIReferenceFactory.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,135 @@
+/**
+ * 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.activemq.jndi;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Converts objects implementing JNDIStorable into a property fields so they can
+ * be stored and regenerated from JNDI
+ */
+public class JNDIReferenceFactory implements ObjectFactory {
+
+    static Log log = LogFactory.getLog(JNDIReferenceFactory.class);
+
+    /**
+     * This will be called by a JNDIprovider when a Reference is retrieved from
+     * a JNDI store - and generates the orignal instance
+     * 
+     * @param object the Reference object
+     * @param name the JNDI name
+     * @param nameCtx the context
+     * @param environment the environment settings used by JNDI
+     * @return the instance built from the Reference object
+     * @throws Exception if building the instance from Reference fails (usually
+     *                 class not found)
+     */
+    public Object getObjectInstance(Object object, Name name, Context nameCtx, Hashtable environment) throws Exception {
+        Object result = null;
+        if (object instanceof Reference) {
+            Reference reference = (Reference)object;
+
+            if (log.isTraceEnabled()) {
+                log.trace("Getting instance of " + reference.getClassName());
+            }
+
+            Class theClass = loadClass(this, reference.getClassName());
+            if (JNDIStorableInterface.class.isAssignableFrom(theClass)) {
+
+                JNDIStorableInterface store = (JNDIStorableInterface)theClass.newInstance();
+                Properties properties = new Properties();
+                for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
+
+                    StringRefAddr addr = (StringRefAddr)iter.nextElement();
+                    properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
+
+                }
+                store.setProperties(properties);
+                result = store;
+            }
+        } else {
+            log.error("Object " + object + " is not a reference - cannot load");
+            throw new RuntimeException("Object " + object + " is not a reference");
+        }
+        return result;
+    }
+
+    /**
+     * Create a Reference instance from a JNDIStorable object
+     * 
+     * @param instanceClassName
+     * @param po
+     * @return
+     * @throws NamingException
+     */
+
+    public static Reference createReference(String instanceClassName, JNDIStorableInterface po) throws NamingException {
+        if (log.isTraceEnabled()) {
+            log.trace("Creating reference: " + instanceClassName + "," + po);
+        }
+        Reference result = new Reference(instanceClassName, JNDIReferenceFactory.class.getName(), null);
+        try {
+            Properties props = po.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);
+                result.add(addr);
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new NamingException(e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * Retrieve the class loader for a named class
+     * 
+     * @param thisObj
+     * @param className
+     * @return
+     * @throws ClassNotFoundException
+     */
+
+    public static Class loadClass(Object thisObj, String className) throws ClassNotFoundException {
+        // tryu local ClassLoader first.
+        ClassLoader loader = thisObj.getClass().getClassLoader();
+        Class theClass;
+        if (loader != null) {
+            theClass = loader.loadClass(className);
+        } else {
+            // Will be null in jdk1.1.8
+            // use default classLoader
+            theClass = Class.forName(className);
+        }
+        return theClass;
+    }
+
+}

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIStorableInterface.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIStorableInterface.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIStorableInterface.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/JNDIStorableInterface.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,45 @@
+/**
+ * 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.activemq.jndi;
+
+import java.util.Properties;
+
+import javax.naming.Referenceable;
+
+/**
+ * Faciliates objects to be stored in JNDI as properties
+ */
+
+public interface JNDIStorableInterface extends Referenceable {
+
+    /**
+     * set the properties for this instance as retrieved from JNDI
+     *
+     * @param properties
+     */
+
+    void setProperties(Properties properties);
+
+    /**
+     * Get the properties from this instance for storing in JNDI
+     *
+     * @return
+     */
+
+    Properties getProperties();
+
+}

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,42 @@
+/**
+ * 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.activemq.jndi;
+
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * Allows users to dynamically create items
+ * 
+ * @version $Revision: 1.2 $
+ */
+public abstract class LazyCreateContext extends ReadOnlyContext {
+    public Object lookup(String name) throws NamingException {
+        try {
+            return super.lookup(name);
+        } catch (NameNotFoundException e) {
+            Object answer = createEntry(name);
+            if (answer == null) {
+                throw e;
+            }
+            internalBind(name, answer);
+            return answer;
+        }
+    }
+
+    protected abstract Object createEntry(String name);
+}

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/NameParserImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/NameParserImpl.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/NameParserImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/NameParserImpl.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.activemq.jndi;
+
+import javax.naming.CompositeName;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+
+/**
+ * A default implementation of {@link NameParser}
+ *
+ * @version $Revision: 1.2 $
+ */
+public class NameParserImpl implements NameParser {
+    public Name parse(String name) throws NamingException {
+        return new CompositeName(name);
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/NameParserImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,421 @@
+/**
+ * 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.activemq.jndi;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.Binding;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.LinkRef;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.Reference;
+import javax.naming.spi.NamingManager;
+
+/**
+ * A read-only Context <p/> This version assumes it and all its subcontext are
+ * read-only and any attempt to modify (e.g. through bind) will result in an
+ * OperationNotSupportedException. Each Context in the tree builds a cache of
+ * the entries in all sub-contexts to optimise the performance of lookup.
+ * </p>
+ * <p>
+ * This implementation is intended to optimise the performance of lookup(String)
+ * to about the level of a HashMap get. It has been observed that the scheme
+ * resolution phase performed by the JVM takes considerably longer, so for
+ * optimum performance lookups should be coded like:
+ * </p>
+ * <code>
+ * Context componentContext = (Context)new InitialContext().lookup("java:comp");
+ * String envEntry = (String) componentContext.lookup("env/myEntry");
+ * String envEntry2 = (String) componentContext.lookup("env/myEntry2");
+ * </code>
+ * 
+ * @version $Revision: 1.2 $ $Date: 2005/08/27 03:52:39 $
+ */
+@SuppressWarnings("unchecked")
+public class ReadOnlyContext implements Context, Serializable {
+
+    public static final String SEPARATOR = "/";
+    protected static final NameParser NAME_PARSER = new NameParserImpl();
+    private static final long serialVersionUID = -5754338187296859149L;
+
+    protected final Hashtable<String, Object> environment; // environment for this context
+    protected final Map<String, Object> bindings; // bindings at my level
+    protected final Map<String, Object> treeBindings; // all bindings under me
+
+    private boolean frozen;
+    private String nameInNamespace = "";
+
+    public ReadOnlyContext() {
+        environment = new Hashtable<String, Object>();
+        bindings = new HashMap<String, Object>();
+        treeBindings = new HashMap<String, Object>();
+    }
+
+    public ReadOnlyContext(Hashtable env) {
+        if (env == null) {
+            this.environment = new Hashtable<String, Object>();
+        } else {
+            this.environment = new Hashtable<String, Object>(env);
+        }
+        this.bindings = Collections.EMPTY_MAP;
+        this.treeBindings = Collections.EMPTY_MAP;
+    }
+
+    public ReadOnlyContext(Hashtable environment, Map<String, Object> bindings) {
+        if (environment == null) {
+            this.environment = new Hashtable<String, Object>();
+        } else {
+            this.environment = new Hashtable<String, Object>(environment);
+        }
+        this.bindings = bindings;
+        treeBindings = new HashMap<String, Object>();
+        frozen = true;
+    }
+
+    public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace) {
+        this(environment, bindings);
+        this.nameInNamespace = nameInNamespace;
+    }
+
+    protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env) {
+        this.bindings = clone.bindings;
+        this.treeBindings = clone.treeBindings;
+        this.environment = new Hashtable<String, Object>(env);
+    }
+
+    protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String, Object> env, String nameInNamespace) {
+        this(clone, env);
+        this.nameInNamespace = nameInNamespace;
+    }
+
+    public void freeze() {
+        frozen = true;
+    }
+
+    boolean isFrozen() {
+        return frozen;
+    }
+
+    /**
+     * internalBind is intended for use only during setup or possibly by
+     * suitably synchronized superclasses. It binds every possible lookup into a
+     * map in each context. To do this, each context strips off one name segment
+     * and if necessary creates a new context for it. Then it asks that context
+     * to bind the remaining name. It returns a map containing all the bindings
+     * from the next context, plus the context it just created (if it in fact
+     * created it). (the names are suitably extended by the segment originally
+     * lopped off).
+     * 
+     * @param name
+     * @param value
+     * @return
+     * @throws javax.naming.NamingException
+     */
+    protected Map<String, Object> internalBind(String name, Object value) throws NamingException {
+        assert name != null && name.length() > 0;
+        assert !frozen;
+
+        Map<String, Object> newBindings = new HashMap<String, Object>();
+        int pos = name.indexOf('/');
+        if (pos == -1) {
+            if (treeBindings.put(name, value) != null) {
+                throw new NamingException("Something already bound at " + name);
+            }
+            bindings.put(name, value);
+            newBindings.put(name, value);
+        } else {
+            String segment = name.substring(0, pos);
+            assert segment != null;
+            assert !segment.equals("");
+            Object o = treeBindings.get(segment);
+            if (o == null) {
+                o = newContext();
+                treeBindings.put(segment, o);
+                bindings.put(segment, o);
+                newBindings.put(segment, o);
+            } else if (!(o instanceof ReadOnlyContext)) {
+                throw new NamingException("Something already bound where a subcontext should go");
+            }
+            ReadOnlyContext readOnlyContext = (ReadOnlyContext)o;
+            String remainder = name.substring(pos + 1);
+            Map<String, Object> subBindings = readOnlyContext.internalBind(remainder, value);
+            for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry)iterator.next();
+                String subName = segment + "/" + (String)entry.getKey();
+                Object bound = entry.getValue();
+                treeBindings.put(subName, bound);
+                newBindings.put(subName, bound);
+            }
+        }
+        return newBindings;
+    }
+
+    protected ReadOnlyContext newContext() {
+        return new ReadOnlyContext();
+    }
+
+    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+        return environment.put(propName, propVal);
+    }
+
+    public Hashtable<String, Object> getEnvironment() throws NamingException {
+        return (Hashtable<String, Object>)environment.clone();
+    }
+
+    public Object removeFromEnvironment(String propName) throws NamingException {
+        return environment.remove(propName);
+    }
+
+    public Object lookup(String name) throws NamingException {
+        if (name.length() == 0) {
+            return this;
+        }
+        Object result = treeBindings.get(name);
+        if (result == null) {
+            result = bindings.get(name);
+        }
+        if (result == null) {
+            int pos = name.indexOf(':');
+            if (pos > 0) {
+                String scheme = name.substring(0, pos);
+                Context ctx = NamingManager.getURLContext(scheme, environment);
+                if (ctx == null) {
+                    throw new NamingException("scheme " + scheme + " not recognized");
+                }
+                return ctx.lookup(name);
+            } else {
+                // Split out the first name of the path
+                // and look for it in the bindings map.
+                CompositeName path = new CompositeName(name);
+
+                if (path.size() == 0) {
+                    return this;
+                } else {
+                    String first = path.get(0);
+                    Object obj = bindings.get(first);
+                    if (obj == null) {
+                        throw new NameNotFoundException(name);
+                    } else if (obj instanceof Context && path.size() > 1) {
+                        Context subContext = (Context)obj;
+                        obj = subContext.lookup(path.getSuffix(1));
+                    }
+                    return obj;
+                }
+            }
+        }
+        if (result instanceof LinkRef) {
+            LinkRef ref = (LinkRef)result;
+            result = lookup(ref.getLinkName());
+        }
+        if (result instanceof Reference) {
+            try {
+                result = NamingManager.getObjectInstance(result, null, null, this.environment);
+            } catch (NamingException e) {
+                throw e;
+            } catch (Exception e) {
+                throw (NamingException)new NamingException("could not look up : " + name).initCause(e);
+            }
+        }
+        if (result instanceof ReadOnlyContext) {
+            String prefix = getNameInNamespace();
+            if (prefix.length() > 0) {
+                prefix = prefix + SEPARATOR;
+            }
+            result = new ReadOnlyContext((ReadOnlyContext)result, environment, prefix + name);
+        }
+        return result;
+    }
+
+    public Object lookup(Name name) throws NamingException {
+        return lookup(name.toString());
+    }
+
+    public Object lookupLink(String name) throws NamingException {
+        return lookup(name);
+    }
+
+    public Name composeName(Name name, Name prefix) throws NamingException {
+        Name result = (Name)prefix.clone();
+        result.addAll(name);
+        return result;
+    }
+
+    public String composeName(String name, String prefix) throws NamingException {
+        CompositeName result = new CompositeName(prefix);
+        result.addAll(new CompositeName(name));
+        return result.toString();
+    }
+
+    public NamingEnumeration list(String name) throws NamingException {
+        Object o = lookup(name);
+        if (o == this) {
+            return new ListEnumeration();
+        } else if (o instanceof Context) {
+            return ((Context)o).list("");
+        } else {
+            throw new NotContextException();
+        }
+    }
+
+    public NamingEnumeration listBindings(String name) throws NamingException {
+        Object o = lookup(name);
+        if (o == this) {
+            return new ListBindingEnumeration();
+        } else if (o instanceof Context) {
+            return ((Context)o).listBindings("");
+        } else {
+            throw new NotContextException();
+        }
+    }
+
+    public Object lookupLink(Name name) throws NamingException {
+        return lookupLink(name.toString());
+    }
+
+    public NamingEnumeration list(Name name) throws NamingException {
+        return list(name.toString());
+    }
+
+    public NamingEnumeration listBindings(Name name) throws NamingException {
+        return listBindings(name.toString());
+    }
+
+    public void bind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void bind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void close() throws NamingException {
+        // ignore
+    }
+
+    public Context createSubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Context createSubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public String getNameInNamespace() throws NamingException {
+        return nameInNamespace;
+    }
+
+    public NameParser getNameParser(Name name) throws NamingException {
+        return NAME_PARSER;
+    }
+
+    public NameParser getNameParser(String name) throws NamingException {
+        return NAME_PARSER;
+    }
+
+    public void rebind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rebind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(Name oldName, Name newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(String oldName, String newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    private abstract class LocalNamingEnumeration implements NamingEnumeration {
+        private Iterator i = bindings.entrySet().iterator();
+
+        public boolean hasMore() throws NamingException {
+            return i.hasNext();
+        }
+
+        public boolean hasMoreElements() {
+            return i.hasNext();
+        }
+
+        protected Map.Entry getNext() {
+            return (Map.Entry)i.next();
+        }
+
+        public void close() throws NamingException {
+        }
+    }
+
+    private class ListEnumeration extends LocalNamingEnumeration {
+        ListEnumeration() {
+        }
+
+        public Object next() throws NamingException {
+            return nextElement();
+        }
+
+        public Object nextElement() {
+            Map.Entry entry = getNext();
+            return new NameClassPair((String)entry.getKey(), entry.getValue().getClass().getName());
+        }
+    }
+
+    private class ListBindingEnumeration extends LocalNamingEnumeration {
+        ListBindingEnumeration() {
+        }
+
+        public Object next() throws NamingException {
+            return nextElement();
+        }
+
+        public Object nextElement() {
+            Map.Entry entry = getNext();
+            return new Binding((String)entry.getKey(), entry.getValue());
+        }
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/package.html
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/package.html?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/package.html (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/package.html Mon Jun  1 18:37:41 2009
@@ -0,0 +1,25 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+JNDI support classes
+
+</body>
+</html>

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/jndi/package.html
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,95 @@
+/**
+ * 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.activemq.util;
+
+/**
+ * Used to convert to hex from byte arrays and back.
+ * 
+ * @version $Revision: 1.2 $
+ */
+public final class HexSupport {
+    
+    private static final String[] HEX_TABLE = new String[]{
+        "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
+        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f",
+        "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f",
+        "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f",
+        "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f",
+        "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f",
+        "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f",
+        "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f",
+        "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f",
+        "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f",
+        "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af",
+        "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf",
+        "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf",
+        "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df",
+        "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef",
+        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff",
+    };
+    private static final int[] INT_OFFSETS = new int[]{
+    	24,16,8,0
+    };
+    
+    private HexSupport() {
+    }
+    
+    /**
+     * @param hex
+     * @return
+     */
+    public static byte[] toBytesFromHex(String hex) {
+        byte rc[] = new byte[hex.length() / 2];
+        for (int i = 0; i < rc.length; i++) {
+            String h = hex.substring(i * 2, i * 2 + 2);
+            int x = Integer.parseInt(h, 16);
+            rc[i] = (byte) x;
+        }
+        return rc;
+    }
+
+    /**
+     * @param bytes
+     * @return
+     */
+    public static String toHexFromBytes(byte[] bytes) {
+        StringBuffer rc = new StringBuffer(bytes.length * 2);
+        for (int i = 0; i < bytes.length; i++) {
+            rc.append(HEX_TABLE[0xFF & bytes[i]]);
+        }
+        return rc.toString();
+    }
+
+    /**
+     * 
+     * @param value 
+     * @param trim if the leading 0's should be trimmed off.
+     * @return
+     */
+    public static String toHexFromInt(int value, boolean trim) {
+        StringBuffer rc = new StringBuffer(INT_OFFSETS.length*2);
+        for (int i = 0; i < INT_OFFSETS.length; i++) {
+        	int b = 0xFF & (value>>INT_OFFSETS[i]);
+        	if( !(trim && b == 0) ) { 
+        		rc.append(HEX_TABLE[b]);
+        		trim=false;
+        	}
+        }
+        return rc.toString();
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java?rev=780773&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java (added)
+++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java Mon Jun  1 18:37:41 2009
@@ -0,0 +1,89 @@
+/**
+ * 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.activemq.util;
+
+import javax.jms.JMSException;
+import javax.jms.MessageEOFException;
+import javax.jms.MessageFormatException;
+
+public final class JMSExceptionSupport {
+
+    private JMSExceptionSupport() {
+    }
+
+    public static JMSException create(String msg, Throwable cause) {
+        JMSException exception = new JMSException(msg);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static JMSException create(String msg, Exception cause) {
+        JMSException exception = new JMSException(msg);
+        exception.setLinkedException(cause);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static JMSException create(Throwable cause) {
+        if (cause instanceof JMSException) {
+            return (JMSException)cause;
+        }
+        String msg = cause.getMessage();
+        if (msg == null || msg.length() == 0) {
+            msg = cause.toString();
+        }
+        JMSException exception = new JMSException(msg);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static JMSException create(Exception cause) {
+        if (cause instanceof JMSException) {
+            return (JMSException)cause;
+        }
+        String msg = cause.getMessage();
+        if (msg == null || msg.length() == 0) {
+            msg = cause.toString();
+        }
+        JMSException exception = new JMSException(msg);
+        exception.setLinkedException(cause);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static MessageEOFException createMessageEOFException(Exception cause) {
+        String msg = cause.getMessage();
+        if (msg == null || msg.length() == 0) {
+            msg = cause.toString();
+        }
+        MessageEOFException exception = new MessageEOFException(msg);
+        exception.setLinkedException(cause);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static MessageFormatException createMessageFormatException(Exception cause) {
+        String msg = cause.getMessage();
+        if (msg == null || msg.length() == 0) {
+            msg = cause.toString();
+        }
+        MessageFormatException exception = new MessageFormatException(msg);
+        exception.setLinkedException(cause);
+        exception.initCause(cause);
+        return exception;
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
------------------------------------------------------------------------------
    svn:executable = *