[jboss-svn-commits] JBL Code SVN: r23458 - in labs/jbossesb/workspace/skeagh: commons and 26 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 15 03:12:27 EDT 2008
Author: tfennelly
Date: 2008-10-15 03:12:26 -0400 (Wed, 15 Oct 2008)
New Revision: 23458
Added:
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/context/ResourceLocator.java
labs/jbossesb/workspace/skeagh/examples/helloworld/run.bat
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/XsdDOMValidator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/package.html
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/XsdDOMValidatorTest.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-01.xml
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-02.xml
labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/
labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-01.xsd
labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-02.xsd
Removed:
labs/jbossesb/workspace/skeagh/commons/osgi.bnd
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-01.xml
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-02.xml
labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-01.xsd
labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-02.xsd
labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml
labs/jbossesb/workspace/skeagh/runtime/osgi.bnd
Modified:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java
labs/jbossesb/workspace/skeagh/container/osgi/osgi.bnd
labs/jbossesb/workspace/skeagh/container/osgi/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java
labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT
labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
labs/jbossesb/workspace/skeagh/runtime/pom.xml
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/CreateObject.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DefaultConfigurationDigester.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DigestUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/FilterDecisionTreeBuilder.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/DefaultConfigurationDigesterTest.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/InboundFilterConfigTest.java
Log:
OSGi modes... still not working re JNDI lookups
Copied: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/context/ResourceLocator.java (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/context/ResourceLocator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/context/ResourceLocator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.esb.context;
+
+import java.io.InputStream;
+
+/**
+ * A ResourceLocator is intended to be used by any code in the ESB
+ * that needs to access resources from a deployment.
+ * <p/>
+ * Different implementations can use different means to retreive
+ * the resources.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public interface ResourceLocator
+{
+ /**
+ * Load the specified class.
+ *
+ * @param className The name of the class to load.
+ * @return The specified class.
+ * @throws ClassNotFoundException If the class cannot be found.
+ */
+ Class<?> forName(final String className) throws ClassNotFoundException;
+
+ /**
+ * Load the specified class using the passed in class's classloader.
+ *
+ * @param className The name of the class to load.
+ * @param caller The class of the caller.
+ * @return The specified class.
+ * @throws ClassNotFoundException If the class cannot be found.
+ */
+ Class<?> forName(final String className, final Class<?> caller) throws ClassNotFoundException;
+
+ /**
+ * Get a resource from the callers classpath.
+ *
+ * @param resourceName - the name of the resource to be retrieved.
+ * @param caller - the class of the caller. The classes classloader will be used to search for the resource.
+ * @return InputStream - the InputStream for the resource.
+ */
+ InputStream getResourceAsStream(final String resourceName, final Class<?> caller);
+
+ /**
+ * Get the underlying classloader.
+ * @return The underlying ClassLoader.
+ */
+ ClassLoader getClassLoader();
+}
Property changes on: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/context/ResourceLocator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossesb/workspace/skeagh/commons/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/osgi.bnd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/osgi.bnd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,14 +0,0 @@
-
-# Use this file to add customized Bnd instructions for the bundle
-#-----------------------------------------------------------------
-# This file is currently not in use as commons is not a bundle.
-# This might change and I'm keeping the file in svn for the time being. /Daniel
-#
-
-#Export-Package: org.jboss.esb.classpath,\
-#org.jboss.esb.jms;include:="AbstractMessageHandler,AbstractMessageListener,JMSSession,MessageSender,MockMessageListener,StreamMessageInputStream",\
-#org.jboss.esb.lifecycle,\
-#org.jboss.esb.properties,\
-#org.jboss.esb.util,\
-#org.jboss.esb.xml
-
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -22,12 +22,15 @@
package org.jboss.esb.classpath;
import java.io.InputStream;
+import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.Enumeration;
/**
* Utility methods to aid in class/resource loading.
@@ -133,6 +136,74 @@
}
/**
+ * Get the specified resource.
+ *
+ * @param resourceName The resource name.
+ * @param caller The caller class.
+ * @return The resource URL.
+ */
+ public static URL getResource(final String resourceName, final Class<?> caller)
+ {
+ final String resource = resolveResourceName(resourceName, caller);
+ final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
+
+ if (threadClassLoader != null)
+ {
+ final URL url = threadClassLoader.getResource(resource);
+ if (url != null)
+ {
+ return url;
+ }
+ }
+
+ final ClassLoader classLoader = caller.getClassLoader();
+ if (classLoader != null)
+ {
+ final URL url = classLoader.getResource(resource);
+ if (url != null)
+ {
+ return url;
+ }
+ }
+
+ return ClassLoader.getSystemResource(resource);
+ }
+
+ /**
+ * Get the specified resources.
+ *
+ * @param resourceName The resource name.
+ * @param caller The caller class.
+ * @return The resource URLs.
+ */
+ public static Enumeration<URL> getResources(final String resourceName, final Class<?> caller) throws IOException
+ {
+ final String resource = resolveResourceName(resourceName, caller);
+ final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
+
+ if (threadClassLoader != null)
+ {
+ final Enumeration<URL> resources = threadClassLoader.getResources(resource);
+ if (resources != null)
+ {
+ return resources;
+ }
+ }
+
+ final ClassLoader classLoader = caller.getClassLoader();
+ if (classLoader != null)
+ {
+ final Enumeration<URL> resources = classLoader.getResources(resource);
+ if (resources != null)
+ {
+ return resources;
+ }
+ }
+
+ return ClassLoader.getSystemResources(resource);
+ }
+
+ /**
* Get the specified resource as a stream.
*
* @param resourceName The name of the class to load.
@@ -141,22 +212,9 @@
*/
public static InputStream getResourceAsStream(final String resourceName, final Class<?> caller)
{
- final String resource;
- if (resourceName.startsWith("/"))
- {
- resource = resourceName.substring(1);
- } else
- {
- final Package callerPackage = caller.getPackage();
- if (callerPackage != null)
- {
- resource = callerPackage.getName().replace('.', '/') + '/' + resourceName;
- } else
- {
- resource = resourceName;
- }
- }
+ final String resource = resolveResourceName(resourceName, caller);
final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
+
if (threadClassLoader != null)
{
final InputStream is = threadClassLoader.getResourceAsStream(resource);
@@ -180,6 +238,33 @@
}
/**
+ * Resolve the supplied resource name against the caller class.
+ * @param resourceName The resource name.
+ * @param caller The calling class.
+ * @return The resolved resource name.
+ */
+ private static String resolveResourceName(final String resourceName, final Class<?> caller)
+ {
+ final String resource;
+
+ if (resourceName.startsWith("/"))
+ {
+ resource = resourceName.substring(1);
+ } else
+ {
+ final Package callerPackage = caller.getPackage();
+ if (callerPackage != null)
+ {
+ resource = callerPackage.getName().replace('.', '/') + '/' + resourceName;
+ } else
+ {
+ resource = resourceName;
+ }
+ }
+ return resource;
+ }
+
+ /**
* Get a package name and convert it to a path value, so it can be used
* in calls to methods like {@link #getResourceAsStream}.
* <p/>
@@ -405,7 +490,7 @@
Field[] fields = hierarchyClass.getDeclaredFields();
for (Field field : fields)
{
- if (field.getType() == value.getClass() && field.getName().equals(fieldName))
+ if (field.getType().isAssignableFrom(value.getClass()) && field.getName().equals(fieldName))
{
setFieldValue(field, targetObject, value);
}
Deleted: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.esb.classpath;
-
-import java.io.InputStream;
-
-
-/**
- * Default resource locator works like you would expect a traditional
- * Java resource locator.
- * <p/>
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class DefaultResourceLocator implements ResourceLocator
-{
-
- /**
- * Simply delegates to {@link ClassUtil#forName(String, Class)} and passes this
- * classes class as the second argument.
- *
- * @param className - the class to load.
- * @return Class - the loaded class.
- * @throws ClassNotFoundException - if the class could not be found.
- */
- public final Class<?> forName(final String className) throws ClassNotFoundException
- {
- return ClassUtil.forName(className, getClass());
- }
-
- /**
- * Simply delegates to {@link ClassUtil#forName(String, Class)} and passes this
- * classes class as the second argument.
- *
- * @param className - the class to load.
- * @return Class - the loaded class.
- * @param caller - the class which should be used as the callers class.
- * @throws ClassNotFoundException - if the class could not be found.
- */
- public final Class<?> forName(final String className, final Class<?> caller) throws ClassNotFoundException
- {
- return ClassUtil.forName(className, caller);
- }
-
- /**
- * Simply delegates to {@link ClassUtil#getResourceAsStream(String, Class)}.
- * classes class as the second argument.
- *
- * @param resourceName - the name of the resource to locate.
- * @param caller - the class which should be used as the callers class.
- * @return InputStream - the input stream for the resource.
- *
- */
- public final InputStream getResourceAsStream(final String resourceName, final Class<?> caller)
- {
- return ClassUtil.getResourceAsStream(resourceName, caller);
- }
-
-}
Deleted: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.esb.classpath;
-
-import java.io.InputStream;
-
-/**
- * A ResourceLocator is intended to be used by any code in the ESB
- * that needs to access resources from a deployment.
- * <p/>
- * Different implementations can use different means to retreive
- * the resources.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public interface ResourceLocator
-{
- /**
- * Load the specified class.
- *
- * @param className The name of the class to load.
- * @return The specified class.
- * @throws ClassNotFoundException If the class cannot be found.
- */
- Class<?> forName(final String className) throws ClassNotFoundException;
-
- /**
- * Load the specified class using the passed in class's classloader.
- *
- * @param className The name of the class to load.
- * @param caller The class of the caller.
- * @return The specified class.
- * @throws ClassNotFoundException If the class cannot be found.
- */
- Class<?> forName(final String className, final Class<?> caller) throws ClassNotFoundException;
-
- /**
- * Get a resource from the callers classpath.
- *
- * @param resourceName - the name of the resource to be retrieved.
- * @param caller - the class of the caller. The classes classloader will be used to search for the resource.
- * @return InputStream - the InputStream for the resource.
- */
- InputStream getResourceAsStream(final String resourceName, final Class<?> caller);
-}
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -21,15 +21,13 @@
import org.apache.log4j.Logger;
import org.jboss.esb.util.AssertArgument;
-import org.jboss.esb.util.JNDIUtil;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
+import javax.jms.Queue;
import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.util.Properties;
+import javax.jms.Topic;
/**
* Abstract Message Handler.
@@ -108,16 +106,20 @@
*/
public final void connect() throws JMSException
{
- destination = lookupDestination(destinationName, jmsSession.getProperties());
- if (!jmsSession.getDestinationType().isAssignableFrom(destination.getClass()))
+ destination = jmsSession.lookupDestination(destinationName);
+ if(jmsSession.getSessionType() == JMSSession.Type.QUEUE && !(destination instanceof Queue))
{
- throw new JMSException("Handler '" + getClass().getName() + "' destination '" + destinationName + "' cannot be created. The destination type does not match that of the associate JMSSession instance. Session type is '" + jmsSession.getDestinationType().getName() + "'.");
+ throw new JMSException("Handler '" + getClass().getName() + "' destination '" + destinationName + "' cannot be created. Must be a JMS Queue Destination for this Session type.");
}
+ else if(jmsSession.getSessionType() == JMSSession.Type.TOPIC && !(destination instanceof Topic))
+ {
+ throw new JMSException("Handler '" + getClass().getName() + "' destination '" + destinationName + "' cannot be created. Must be a JMS Topic Destination for this Session type.");
+ }
// Listen for exceptions on the session connection...
if (this instanceof ExceptionListener)
{
- jmsSession.registerExceptionListener((ExceptionListener) this);
+ jmsSession.registerExceptionListener(this);
}
// And perform the handler specific connection ops...
@@ -193,33 +195,4 @@
* @return True if the connector is connected, otherwise false.
*/
public abstract boolean isConnected();
-
- /**
- * Lookup the destination.
- *
- * @param destinationName Destination name.
- * @param jndiProperties JNDI properties.
- * @return The JMS Destination.
- * @throws JMSException Error looking up destination.
- */
- public static Destination lookupDestination(final String destinationName, final Properties jndiProperties) throws JMSException
- {
- // Lookup the destination...
- try
- {
- Context context = JNDIUtil.getNamingContext(jndiProperties);
- try
- {
- return (Destination) context.lookup(destinationName);
- }
- finally
- {
- context.close();
- }
- }
- catch (NamingException e)
- {
- throw (JMSException) (new JMSException("Destination lookup failed. Destination name '" + destinationName + "'.").initCause(e));
- }
- }
}
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -32,11 +32,9 @@
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
import javax.jms.Session;
-import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicSession;
-import javax.naming.Context;
import javax.naming.NamingException;
import java.util.HashSet;
import java.util.Properties;
@@ -68,41 +66,84 @@
*/
private Session session = null;
/**
- * JMS Destination Type.
+ * JMS Session Type.
*/
- private Class<? extends Destination> destinationType = null;
+ private Type sessionType = null;
/**
* Exception listener.
*/
private ConnectionExceptionListener exceptionListener = new ConnectionExceptionListener();
+ /**
+ * Provider classloader.
+ */
+ private ClassLoader classLoader;
/**
+ * Session Type enumeration.
+ */
+ public static enum Type {
+ /**
+ * Queue Session.
+ */
+ QUEUE,
+ /**
+ * Topic Session.
+ */
+ TOPIC
+ }
+
+ /**
* Public constructor.
*
- * @param destinationType The JMS destination type.
+ * @param sessionType The JMS session type.
* @param jndiProperties The JNDI properties for creating the JMS session.
*/
- public JMSSession(final Class<? extends Destination> destinationType, final Properties jndiProperties)
+ public JMSSession(final Type sessionType, final Properties jndiProperties)
{
- AssertArgument.isNotNull(destinationType, "destinationType");
+ AssertArgument.isNotNull(sessionType, "sessionType");
AssertArgument.isNotNull(jndiProperties, "jndiProperties");
logger = Logger.getLogger(getClass());
- this.destinationType = destinationType;
+ this.sessionType = sessionType;
this.jndiProperties = jndiProperties;
}
/**
- * Get the JMS Destination type associated with the session.
+ * Public constructor.
+ * <p/>
+ * When using this constructor, {@link #setSessionType(org.jboss.esb.jms.JMSSession.Type)} must be called before
+ * {@link #connect()} can be called.
*
- * @return The JMS Destination type.
+ * @param jndiProperties The JNDI properties for creating the JMS session.
*/
- public final Class<? extends Destination> getDestinationType()
+ public JMSSession(final Properties jndiProperties)
{
- return destinationType;
+ AssertArgument.isNotNull(jndiProperties, "jndiProperties");
+
+ logger = Logger.getLogger(getClass());
+ this.jndiProperties = jndiProperties;
}
/**
+ * Get the JMS Session type associated with the instance.
+ *
+ * @return The JMS Session type.
+ */
+ public final Type getSessionType()
+ {
+ return sessionType;
+ }
+
+ /**
+ * Set the session type.
+ * @param sessionType The session type.
+ */
+ public final void setSessionType(final Type sessionType)
+ {
+ this.sessionType = sessionType;
+ }
+
+ /**
* Get the JNDI Properties in use by this session instance.
*
* @return The JNDI Properties in use by this session instance.
@@ -123,6 +164,24 @@
}
/**
+ * Get the ClassLoader used by the session instance.
+ * @return The ClassLoader.
+ */
+ public final ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /**
+ * Set the ClassLoader used by the session instance.
+ * @param classLoader The ClassLoader.
+ */
+ public final void setClassLoader(final ClassLoader classLoader)
+ {
+ this.classLoader = classLoader;
+ }
+
+ /**
* Connect to the configured destination.
*
* @throws javax.jms.JMSException Failed to connect.
@@ -131,6 +190,8 @@
{
ConnectionFactory connectionFactory;
+ assertSessionTypeConfigured();
+
try
{
// Get the Destination ConnectionFactory...
@@ -143,8 +204,8 @@
throw (JMSException) (new JMSException("Invalid JMS ConnectionFactory config. ConnectionFactory doesn't implement " + TopicConnectionFactory.class.getName() + ".").initCause(e));
}
- // Create the destination connection...
- if (destinationType == Topic.class)
+ // Create the Session Connection...
+ if (sessionType == Type.TOPIC)
{
conn = ((TopicConnectionFactory) connectionFactory).createTopicConnection();
}
@@ -153,8 +214,8 @@
conn = ((QueueConnectionFactory) connectionFactory).createQueueConnection();
}
- // Create the Destination Session...
- if (destinationType == Topic.class)
+ // Create the Session...
+ if (sessionType == Type.TOPIC)
{
session = ((TopicConnection) conn).createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
}
@@ -182,6 +243,17 @@
}
/**
+ * Assert that the session type has been configured.
+ */
+ private void assertSessionTypeConfigured()
+ {
+ if(sessionType == null)
+ {
+ throw new IllegalStateException("JMS Session type not configured.");
+ }
+ }
+
+ /**
* Close out the session and all it's resources.
*/
public final void close()
@@ -241,14 +313,18 @@
*/
private ConnectionFactory getJmsConnectionFactory() throws JMSException
{
- ConnectionFactory factory = null;
- Context context;
String connectionFactoryRuntime = jndiProperties.getProperty(ConnectionFactory.class.getName(), "ConnectionFactory");
+ ConnectionFactory factory;
+ ClassLoader tcClassLoader = Thread.currentThread().getContextClassLoader();
- context = JNDIUtil.getNamingContext(jndiProperties);
+ if(classLoader != null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
try
{
- factory = (ConnectionFactory) context.lookup(connectionFactoryRuntime);
+ factory = (ConnectionFactory) JNDIUtil.lookup(connectionFactoryRuntime, jndiProperties);
}
catch (NamingException e)
{
@@ -260,23 +336,45 @@
}
finally
{
- if (context != null)
- {
- try
- {
- context.close();
- }
- catch (NamingException ne)
- {
- logger.error("Failed to close Naming Context.", ne);
- }
- }
+ Thread.currentThread().setContextClassLoader(tcClassLoader);
}
return factory;
}
+
/**
+ * Lookup the destination.
+ *
+ * @param destinationName Destination name.
+ * @return The JMS Destination.
+ * @throws JMSException Error looking up destination.
+ */
+ public final Destination lookupDestination(final String destinationName) throws JMSException
+ {
+ ClassLoader tcClassLoader = Thread.currentThread().getContextClassLoader();
+
+ if(classLoader != null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ // Lookup the destination...
+ try
+ {
+ return (Destination) JNDIUtil.lookup(destinationName, jndiProperties);
+ }
+ catch (NamingException e)
+ {
+ throw (JMSException) (new JMSException("Destination lookup failed. Destination name '" + destinationName + "'.").initCause(e));
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(tcClassLoader);
+ }
+ }
+
+ /**
* Register an exception listener.
*
* @param listener The listener instance.
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,13 +19,11 @@
*/
package org.jboss.esb.util;
-import javax.jms.JMSException;
+import org.apache.log4j.Logger;
+
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-
import java.util.Properties;
/**
@@ -38,7 +36,7 @@
/**
* Logger instance.
*/
- private static Logger log = Logger.getLogger(JNDIUtil.class);
+ private static Logger logger = Logger.getLogger(JNDIUtil.class);
/**
* Private default constructor.
@@ -54,9 +52,9 @@
*
* @param jndiProperties JNDI properties.
* @return The context.
- * @throws javax.jms.JMSException Error getting context.
+ * @throws NamingException Error getting context.
*/
- public static Context getNamingContext(final Properties jndiProperties) throws JMSException
+ public static Context getNamingContext(final Properties jndiProperties) throws NamingException
{
Context context;
try
@@ -65,14 +63,47 @@
}
catch (NamingException e)
{
- log.error("NamingException while try to create initialContext. jndiProperties are " + jndiProperties, e);
- throw new JMSException("Failed to load InitialContext: " + jndiProperties);
+ logger.error("NamingException while try to create initialContext. jndiProperties are " + jndiProperties, e);
+ throw ((NamingException) new NamingException("Failed to load InitialContext: " + jndiProperties).initCause(e));
}
if (context == null)
{
- throw new JMSException("Failed to create JNDI context. Check that '" + Context.PROVIDER_URL + "', '" + Context.INITIAL_CONTEXT_FACTORY + "', '" + Context.URL_PKG_PREFIXES + "' are correctly configured in the supplied JNDI properties.");
+ throw new NamingException("Failed to create JNDI context. Check that '" + Context.PROVIDER_URL + "', '" + Context.INITIAL_CONTEXT_FACTORY + "', '" + Context.URL_PKG_PREFIXES + "' are correctly configured in the supplied JNDI properties.");
}
return context;
}
+
+ /**
+ * Lookup an object through the JNDI context.
+ *
+ * @param objectName The name of the object to be looked up.
+ * @param jndiProperties JNDI properties.
+ * @return The object.
+ * @throws NamingException Error getting object.
+ */
+ public static Object lookup(final String objectName, final Properties jndiProperties) throws NamingException
+ {
+ Object object = null;
+ Context context;
+
+ context = JNDIUtil.getNamingContext(jndiProperties);
+ try
+ {
+ object = context.lookup(objectName);
+ }
+ finally
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ logger.error("Failed to close Naming Context.", ne);
+ }
+ }
+
+ return object;
+ }
}
Deleted: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,197 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2008, JBoss Inc.
- */
-package org.jboss.esb.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import org.jboss.esb.classpath.ResourceLocator;
-import org.jboss.esb.util.AssertArgument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.xml.sax.SAXException;
-
-/**
- * XSD DOM Validator.
- * <p/>
- * <b><i>Donated by the <a href="http://milyn.codehaus.org">Milyn Project</a>.</i></b>
- * <p/>
- * Iterates through the document (DOM) gathering the namespaces. It validates
- * based on the convention that the gathered namespace XSDs are provided on the
- * classpath. It uses the namespace path (URI.getPath()), prepending it with "/META-INF"
- * to perform a classpath resource lookup for the XSD i.e. the XSDs must be provided on
- * the classpath below the "META-INF" package.
- *
- * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
- */
-public class XsdDOMValidator
-{
- /**
- * The document being validated.
- */
- private Document document;
- /**
- * Docuent default namespace.
- */
- private URI defaultNamespace;
- /**
- * Full namespace list.
- */
- private List<URI> namespaces = new ArrayList<URI>();
-
- /**
- * Public vonstructor.
- *
- * @param document The document to be validated.
- * @throws SAXException Unable to preprocess document for validation.
- */
- public XsdDOMValidator(final Document document) throws SAXException
- {
- AssertArgument.isNotNull(document, "document");
- this.document = document;
-
- // Get the default namespace...
- String defaultNamespaceString = getDefaultNamespace(document.getDocumentElement());
- if (defaultNamespaceString != null)
- {
- try
- {
- defaultNamespace = new URI(defaultNamespaceString);
- } catch (URISyntaxException e)
- {
- throw new SAXException("Cannot validate this document with this class. Namespaces must be valid URIs. Default Namespace: '" + defaultNamespaceString + "'.", e);
- }
- }
-
- // Get the full namespace list...
- XMLParseUtils.gatherNamespaceDeclarations(document.getDocumentElement(), namespaces);
- }
-
- /**
- * Get the default namespace.
- *
- * @return The default namespace.
- */
- public final URI getDefaultNamespace()
- {
- return defaultNamespace;
- }
-
- /**
- * Get the full namespace list.
- *
- * @return The namespace list.
- */
- public final List<URI> getNamespaces()
- {
- return namespaces;
- }
-
- /**
- * Validate the document against the namespaces referenced in it.
- *
- * @param resourceLocator The {@link ResourceLocator} to use.
- * @throws SAXException Validation error.
- * @throws java.io.IOException Error reading the XSD Sources.
- */
- public final void validate(final ResourceLocator resourceLocator) throws SAXException, IOException
- {
- // Using the namespace URI list, create the XSD Source array used to
- // create the merged Schema instance...
- Source[] xsdSources = new Source[namespaces.size()];
- for (int i = 0; i < namespaces.size(); i++)
- {
- xsdSources[i] = getNamespaceSource(namespaces.get(i), resourceLocator);
- }
-
- // Create the merged Schema instance and from that, create the Validator instance...
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(xsdSources);
- Validator validator = schema.newValidator();
-
- // Validate the document...
- validator.validate(new DOMSource(document));
- }
-
- /**
- * Get the default namespace associated with the supplied element.
- *
- * @param element The element to be checked.
- * @return The default namespace, or null if none was found.
- */
- public static String getDefaultNamespace(final Element element)
- {
- NamedNodeMap attributes = element.getAttributes();
- int attributeCount = attributes.getLength();
-
- for (int i = 0; i < attributeCount; i++)
- {
- Attr attribute = (Attr) attributes.item(i);
-
- if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getName()) && XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getLocalName()))
- {
- return attribute.getValue();
- }
- }
-
- return null;
- }
-
- /**
- * Get the namespace XSD for the specified namespace.
- * <p/>
- * Extracts the path element from the supplied namespace URI, prefixes
- * it with "/META-INF" and uses the result to check the classpath for the
- * XSD Source.
- *
- * @param namespace The namespace URI.
- * @param resourceLocator The {@link ResourceLocator} to use.
- * @return The XSD Schema Source.
- * @throws SAXException Unable to get XSD Schema Source.
- */
- private Source getNamespaceSource(final URI namespace, final ResourceLocator resourceLocator) throws SAXException
- {
- String resourcePath = "/META-INF" + namespace.getPath();
- InputStream xsdStream = resourceLocator.getResourceAsStream(resourcePath, getClass());
-
-
- if (xsdStream == null)
- {
- throw new SAXException("Failed to locate XSD resource '" + resourcePath + "' on classpath. Namespace: '" + namespace + "'.");
- }
-
- return new StreamSource(xsdStream);
- }
-
-}
Modified: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -21,10 +21,14 @@
import junit.framework.TestCase;
-import javax.jms.*;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import java.util.Arrays;
+import java.util.List;
import java.util.Properties;
-import java.util.List;
-import java.util.Arrays;
/**
* JMS Send and listen tests.
@@ -35,25 +39,25 @@
{
public void test_Topic_noselector() throws Exception
{
- test_Destination_noselector(Topic.class, "jbossesb.testTopic");
+ test_Destination_noselector(JMSSession.Type.TOPIC, "jbossesb.testTopic");
}
public void test_Queue_noselector() throws Exception
{
- test_Destination_noselector(Queue.class, "jbossesb.testQueue");
+ test_Destination_noselector(JMSSession.Type.QUEUE, "jbossesb.testQueue");
}
public void test_Topic_withselector() throws Exception
{
- test_Destination_withselector(Topic.class, "jbossesb.testTopic");
+ test_Destination_withselector(JMSSession.Type.TOPIC, "jbossesb.testTopic");
}
public void test_Queue_withselector() throws Exception
{
- test_Destination_withselector(Queue.class, "jbossesb.testQueue");
+ test_Destination_withselector(JMSSession.Type.QUEUE, "jbossesb.testQueue");
}
- private void test_Destination_noselector(final Class<? extends Destination> destType, final String destName) throws Exception
+ private void test_Destination_noselector(final JMSSession.Type destType, final String destName) throws Exception
{
JmsProvider jmsProvider = new JmsProvider();
jmsProvider.start();
@@ -67,7 +71,7 @@
jmsSession2.connect();
try
{
- if(destType == Topic.class) {
+ if(destType == JMSSession.Type.TOPIC) {
jndiProperties.setProperty("topic." + destName, destName);
} else {
jndiProperties.setProperty("queue." + destName, destName);
@@ -76,13 +80,13 @@
MockMessageListener<TextMessage> listener = new MockMessageListener<TextMessage>(destName, jmsSession1, null);
listener.connect();
- assertTrue(destType.isAssignableFrom(listener.getDestination().getClass()));
+ assertTypeOK(destType, listener.getDestination());
try {
MessageSender sender = new MessageSender(destName, jmsSession2);
List<String> messagesSent = Arrays.asList(new String[] {"message 1", "message 2", "message 3"});
sender.connect();
- assertTrue(destType.isAssignableFrom(sender.getDestination().getClass()));
+ assertTypeOK(destType, sender.getDestination());
try {
for (String message : messagesSent)
{
@@ -109,8 +113,17 @@
}
}
- private void test_Destination_withselector(final Class<? extends Destination> destType, final String destName) throws Exception
+ private void assertTypeOK(JMSSession.Type expectedType, Destination destination)
{
+ if(expectedType == JMSSession.Type.TOPIC) {
+ assertTrue(destination instanceof Topic);
+ } else {
+ assertTrue(destination instanceof Queue);
+ }
+ }
+
+ private void test_Destination_withselector(final JMSSession.Type destType, final String destName) throws Exception
+ {
JmsProvider jmsProvider = new JmsProvider();
jmsProvider.start();
@@ -123,7 +136,7 @@
jmsSession2.connect();
try
{
- if(destType == Topic.class) {
+ if(destType == JMSSession.Type.TOPIC) {
jndiProperties.setProperty("topic." + destName, destName);
} else {
jndiProperties.setProperty("queue." + destName, destName);
Deleted: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2008, JBoss Inc.
- */
-package org.jboss.esb.xml;
-
-import junit.framework.TestCase;
-
-import org.jboss.esb.classpath.DefaultResourceLocator;
-import org.jboss.esb.classpath.ResourceLocator;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
- */
-public class XsdDOMValidatorTest extends TestCase {
- private ResourceLocator resourceLocator = new DefaultResourceLocator();
-
- public void test_namespace_gathering() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
- XsdDOMValidator validator = new XsdDOMValidator(document);
-
- assertEquals("http://www.milyn.org/xsd/test-xsd-01.xsd", validator.getDefaultNamespace().toString());
- assertEquals("[http://www.milyn.org/xsd/test-xsd-01.xsd, http://www.milyn.org/xsd/test-xsd-02.xsd]", validator.getNamespaces().toString());
- }
-
- public void test_validation_validdoc() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
- XsdDOMValidator validator = new XsdDOMValidator(document);
-
- validator.validate(resourceLocator);
- }
-
- public void test_validation_invaliddoc() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-02.xml"));
- XsdDOMValidator validator = new XsdDOMValidator(document);
-
- try {
- validator.validate(resourceLocator);
- fail("Expected SAXParseException");
- } catch(SAXParseException e) {
- assertEquals("cvc-complex-type.4: Attribute 'myName' must appear on element 'a:myNVP'.", e.getMessage());
- }
- }
-}
Deleted: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-01.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-01.xml 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-01.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<nameValuePairs xmlns="http://www.milyn.org/xsd/test-xsd-01.xsd" xmlns:a="http://www.milyn.org/xsd/test-xsd-02.xsd">
- <nameValuePair name="a" value="1" />
- <a:myNVP myName="xxx" myValue="blah" />
-</nameValuePairs>
\ No newline at end of file
Deleted: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-02.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-02.xml 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-02.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<nameValuePairs xmlns="http://www.milyn.org/xsd/test-xsd-01.xsd" xmlns:a="http://www.milyn.org/xsd/test-xsd-02.xsd">
- <nameValuePair name="a" value="1" />
- <a:myNVP />
-</nameValuePairs>
\ No newline at end of file
Deleted: labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-01.xsd
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-01.xsd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-01.xsd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:yyy="http://www.milyn.org/xsd/test-xsd-01.xsd"
- targetNamespace="http://www.milyn.org/xsd/test-xsd-01.xsd"
- elementFormDefault="qualified">
-
- <xs:element name="nameValuePairs">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="yyy:abstractNVP" minOccurs="1" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="abstractNVP" type="yyy:abstractNVP" abstract="true" />
- <xs:complexType name="abstractNVP" abstract="true" />
-
- <xs:element name="nameValuePair" substitutionGroup="yyy:abstractNVP">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="yyy:abstractNVP">
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="value" type="xs:string" use="required"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
\ No newline at end of file
Deleted: labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-02.xsd
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-02.xsd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-02.xsd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:yyy="http://www.milyn.org/xsd/test-xsd-01.xsd"
- xmlns:zzz="http://www.milyn.org/xsd/test-xsd-02.xsd"
- targetNamespace="http://www.milyn.org/xsd/test-xsd-02.xsd"
- elementFormDefault="qualified">
-
- <xs:import namespace="http://www.milyn.org/xsd/test-xsd-01.xsd" />
-
- <xs:element name="myNVP" substitutionGroup="yyy:abstractNVP">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="yyy:abstractNVP">
- <xs:attribute name="myName" type="xs:string" use="required"/>
- <xs:attribute name="myValue" type="xs:string" use="required"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/container/osgi/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/osgi.bnd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/container/osgi/osgi.bnd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,46 +1,40 @@
#-----------------------------------------------------------------
# Use this file to add customized Bnd instructions for the bundle
+#
+# We need to sort out a package clash with the routing package. It's
+# in both the api and runtime modules. Rename the runtime package
+# to "invoke".
+#
#-----------------------------------------------------------------
-Export-Package: org.jboss.esb.deploy.*,\
-org.jboss.esb.dispatch.*,\
-org.jboss.esb.failure.*,\
-org.jboss.esb.federate.*,\
-org.jboss.esb.filter.*,\
-org.jboss.esb.history.*,\
-org.jboss.esb.routing.*,\
-org.jboss.esb.schedule.*,\
-org.jboss.esb.serialization.*,\
-org.jboss.esb.test.*,\
-org.jboss.esb.osgi.*,\
-org.jboss.esb.util.*,\
-org.jboss.esb.classpath.*,\
-org.jboss.esb.xml.*,\
-org.jboss.esb.properties.*,\
-org.jboss.esb.annotations.*,\
-org.jboss.esb.context.*,\
-org.jboss.esb.exception.*,\
-org.jboss.esb.service.*,\
-org.jboss.esb.message.*
+Export-Package: org.jboss.esb.test,\
+ org.jboss.esb.annotations, \
+ org.jboss.esb.context, \
+ org.jboss.esb.routing, \
+ org.jboss.esb.exception, \
+ org.jboss.esb.service, \
+ org.jboss.esb.message
+Private-Package: org.jboss.esb.osgi
+Import-Package: *;resolution:=optional
-Import-Package: *;resolution:=optional, javax.jms;version="1.1.0", org.apache.activemq.*;version="0.0.0";resolution:=optional, *;resolution:=optional
-
Bundle-Activator: org.jboss.esb.osgi.EsbServiceDeploymentActivator
Embed-Dependency: quartz,\
-xpp3_min, \
-xstream, \
-freemarker,\
-hsqldb, \
-jbossesb-rt, \
-mvel, \
-milyn-commons, \
-milyn-smooks-core, \
-milyn-smooks-javabean, \
-backport, \
-commons-lang, \
-commons-logging, \
-geronimo-j2ee-management, \
-geronimo-jms_1.1_spec-1.1.1.jar;scope=compile|runtime;artifactId=!xercesImpl|log4j|jbossesb-api-routing|jbossesb-api-service|jbossesb-routing|jbossesb-routing-jms|jbossesb-commons|activemq-core;inline=false
+ xpp3_min, \
+ xstream, \
+ freemarker,\
+ hsqldb, \
+ jbossesb-commons, \
+ jbossesb-api-service, \
+ jbossesb-api-routing, \
+ jbossesb-rt, \
+ mvel, \
+ milyn-commons, \
+ milyn-smooks-core, \
+ milyn-smooks-javabean, \
+ backport, \
+ commons-lang, \
+ commons-logging, \
+ log4j
Embed-Transitive: true
Modified: labs/jbossesb/workspace/skeagh/container/osgi/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/container/osgi/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -20,14 +20,15 @@
*/
package org.jboss.esb.osgi;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.context.ResourceLocator;
+import org.osgi.framework.Bundle;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Enumeration;
-import org.jboss.esb.classpath.ClassUtil;
-import org.jboss.esb.classpath.ResourceLocator;
-import org.osgi.framework.Bundle;
-
/**
* BundleResourceLocator is an OSGi implementation of ResourceLocator.
* <p/>
@@ -43,6 +44,10 @@
* The OSGi BundleContext instance.
*/
private final Bundle bundle;
+ /**
+ * Bundle ClassLoader.
+ */
+ private BundleClassLoader classLoader;
/**
* Creates and instance and stores the passed-in BundleContext.
@@ -52,6 +57,7 @@
public BundleResourceLocator(final Bundle bundle)
{
this.bundle = bundle;
+ classLoader = new BundleClassLoader(bundle, getClass().getClassLoader());
}
/**
@@ -113,4 +119,42 @@
return ClassUtil.getResourceAsStream(resourceName, caller);
}
+ /**
+ * Get the underlying classloader.
+ * @return The underlying ClassLoader.
+ */
+ public final ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /**
+ * Bundle ClassLoader.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+ public class BundleClassLoader extends ClassLoader
+ {
+ private Bundle bundle;
+
+ public BundleClassLoader(final Bundle bundle, final ClassLoader parent)
+ {
+ super(parent);
+ this.bundle = bundle;
+ }
+
+ protected Class<?> findClass(String name) throws ClassNotFoundException
+ {
+ return bundle.loadClass(name);
+ }
+
+ protected URL findResource(String name)
+ {
+ return bundle.getResource(name);
+ }
+
+ protected Enumeration<URL> findResources(String name) throws IOException
+ {
+ return bundle.getResources(name);
+ }
+ }
}
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,24 +1,24 @@
-About This Example:
-===================
+About This Example:
+===================
This example illustrates a simple JBossESB 5.0 helloworld example.
-
-
-How to Run?
-===========
- Requirements:
- 1. JDK 1.5
- 2. Maven 2.x (http://maven.apache.org/download.html)
-
- Running:
- 1. run "mvn activemq:run". This starts the JMS Provider.
- 2. Open a new console window ("Window 2")
- 3. run "mvn clean install pax:provision". This starts the OSGi container and deploy the ESB.
- 4. Open a new console window ("Window 3")
- 3. run "mvn exec:java". This publishes a JMS Message to the JMS Queue that will trigger the ESB process.
-Things to try
-=============
- At the felix commmand prompt:
+
+How to Run?
+===========
+ Requirements:
+ 1. JDK 1.5
+ 2. Maven 2.x (http://maven.apache.org/download.html)
+
+ Running:
+ 1. run "mvn activemq:run". This starts the JMS Provider.
+ 2. Open a new console window ("Window 2")
+ 3. run "mvn clean install pax:provision". This starts the OSGi container (Felix) and deploys the ESB.
+ 4. Open a new console window ("Window 3")
+ 3. run "mvn exec:java". This publishes a JMS Message to the JMS Queue that will trigger the ESB process.
+
+Things to try
+=============
+ At the felix commmand prompt ("Window 2"):
>ps // will list all bundles
>stop <id> // use the id of the JBoss ESB - Helloworld Example (5.0.0.SNAPSHOT)
>start <id> // use the id of the JBoss ESB - Helloworld Example (5.0.0.SNAPSHOT)
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -2,20 +2,12 @@
# Use this file to add customized Bnd instructions for the bundle
#-----------------------------------------------------------------
-# Need to export all classes that this bundle uses
-Export-Package: org.jboss.esb.examples.helloworld.*, org.apache.log4j.*, edu.emory.*, org.apache.commons.logging.*, javax.management.j2ee.*
+Export-Package: org.jboss.esb.examples.helloworld, org.apache.activemq.jndi
+Import-Package: org.jboss.esb.jms, *;resolution:=optional
-# Explicit imports
-Import-Package: org.jboss.esb.*, *;resolution:=optional
-
# Dependencies that need to be included into the bundle.
# This can be any no-osgi bundle that your bundle needs.
-Embed-Dependency: log4j;scope=compile|runtime, \
-mx4j;scope=compile|runtime, \
-mx4j-tools, \
-backport-util-concurrent;scope=compile|runtime, \
-commons-logging, \
-geronimo-j2ee-management_1.1_spec;scope=compile|runtime
+Embed-Dependency: log4j, activemq-core
Embed-Transitive: true
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -44,11 +44,16 @@
</build>
<dependencies>
- <dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.main</artifactId>
+ <version>1.2.1</version>
+ </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
@@ -64,6 +69,16 @@
<artifactId>mx4j</artifactId>
<version>3.0.2</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
@@ -84,11 +99,6 @@
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
- <version>1.0-M1</version>
- </dependency>
<!-- JBossESB OSGi bundle -->
<dependency>
Added: labs/jbossesb/workspace/skeagh/examples/helloworld/run.bat
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/run.bat (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/run.bat 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,11 @@
+ at echo off
+
+set JAVA_OPTS=
+
+if "%1" == "-debug" (
+ set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
+)
+
+set FELIX_JAR="%HOME%\.m2\repository\org\apache\felix\org.apache.felix.main\1.2.1\org.apache.felix.main-1.2.1.jar"
+
+"%JAVA_HOME%\bin\java" %JAVA_OPTS% -jar %FELIX_JAR%
Modified: labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -2,21 +2,9 @@
# Use this file to add customized Bnd instructions for the bundle
#-----------------------------------------------------------------
-# * Need to make javax.jms available as it is needed by our runtime. As we are using a JMSBus the bus impl
-# exits in the runtime and not in the jms routing module. The JMSBus will configure a queue and a topic for
-# internal bus communication and needs to be able to have access the javax.jms package and also the jms providers
-# classess(which are loaded via jndi). The provider in this case is activemq.
-#
-# As I see it have have the following options of packaging this bundle:
-# 1. Include the JMSProviders jars in this bundle and make them accessible by exporting them.
-# 2. Installing the jms provider as a bundle and importing it in this bundle. This would mean that
-# this bundles manifest must be updated with the providers packages as users will have different jms
-# providers.
-# 3. Using dynamic imports for the jms provider classes.
-#
-Export-Package: org.jboss.esb.jms.*, javax.jms;version="1.1", org.apache.activemq.*
+Export-Package: org.jboss.esb.jms
Import-Package: *;resolution:=optional
-Embed-Dependency: jms;scope=compile|runtime,jbossesb-commons;scope=compile|runtime;inline=false, activemq-core
+Embed-Dependency: jbossesb-commons, log4j
Embed-Transitive: true
Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -20,23 +20,24 @@
*/
package org.jboss.esb.jms;
-import java.util.Properties;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.naming.Context;
-
import org.apache.log4j.Logger;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Property;
+import org.jboss.esb.annotations.Property.Use;
import org.jboss.esb.annotations.Uninitialize;
-import org.jboss.esb.annotations.Property.Use;
import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.message.Message;
import org.jboss.esb.routing.InboundRouter;
import org.jboss.esb.routing.MessageDispatcher;
import org.jboss.esb.routing.RoutingException;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.naming.Context;
+import java.util.Properties;
+
/**
* Inbound router for JMS.
* <br><br>
@@ -73,6 +74,10 @@
* MessageDispatcher used to dipatch the message to the ESB.
*/
private MessageDispatcher dispatcher;
+ /**
+ * Resource locator
+ */
+ private ResourceLocator resourceLocator;
/**
* JMS destination name. The destination that this router listenes to.
@@ -110,7 +115,11 @@
@Initialize
public final void initialize() throws JMSException
{
- Destination jmsDestination = null;
+ Destination jmsDestination;
+
+ jmsSession = new JMSSession(jmsProperties);
+ jmsSession.setClassLoader(resourceLocator.getClassLoader());
+
/*
* Need to set the context classloader due to the current OSGi packaging.
* The jbossesb-routing-jms bundle needs to set the context classloader as
@@ -123,35 +132,37 @@
* that this bundle imports the packages needed. All we are saying is that the
* bundles classloader will have access to the classes. /Daniel 2008-10-13
*/
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ jmsSession.setClassLoader(getClass().getClassLoader());
+
+ // set the context class loader to this classes classloader.
+ jmsDestination = jmsSession.lookupDestination(destination);
+
+ // Configure the session type based on the destination type, before we try to connect...
+ if(jmsDestination instanceof Queue)
+ {
+ jmsSession.setSessionType(JMSSession.Type.QUEUE);
+ }
+ else
+ {
+ jmsSession.setSessionType(JMSSession.Type.TOPIC);
+ }
+
+ jmsSession.connect();
try
{
- // set the context class loader to this classes classloader.
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- jmsDestination = AbstractMessageHandler.lookupDestination(destination, jmsProperties);
-
- jmsSession = new JMSSession(jmsDestination.getClass(), jmsProperties);
- jmsSession.connect();
- try
- {
- messageListener = new JmsMessageListener(destination, jmsSession, jmsProperties, dispatcher);
- messageListener.connect();
- }
- catch (final JMSException e)
- {
- jmsSession.close();
- throw e;
- }
- catch (final Throwable t)
- {
- jmsSession.close();
- throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
- }
+ messageListener = new JmsMessageListener(destination, jmsSession, jmsProperties, dispatcher);
+ messageListener.connect();
}
- finally
+ catch (final JMSException e)
{
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ jmsSession.close();
+ throw e;
}
+ catch (final Throwable t)
+ {
+ jmsSession.close();
+ throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
+ }
}
/**
Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Log4j Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<!--
- | For more configuration infromation and examples see the Jakarta Log4j
- | owebsite: http://jakarta.apache.org/log4j
- -->
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
- <!-- ============================== -->
- <!-- Append messages to the console -->
- <!-- ============================== -->
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
- </layout>
- </appender>
-
- <!-- ================ -->
- <!-- Limit categories -->
-
- <category name="org.milyn">
- <priority value="error"/>
- </category>
-
- <category name="org.quartz">
- <priority value="error"/>
- </category>
-
- <category name="org.jboss">
- <priority value="debug"/>
- </category>
-
- <category name="org.apache.activemq">
- <priority value="ERROR"/>
- </category>
-
- <!-- ======================= -->
- <!-- Setup the Root category -->
- <!-- ======================= -->
-
- <root>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
-
Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -20,8 +20,8 @@
*/
package org.jboss.esb.jms;
-import org.jboss.esb.deploy.DeploymentUtil;
import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
import org.jboss.esb.test.JmsTestBusProvider;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
@@ -30,7 +30,6 @@
import org.junit.Test;
import javax.jms.JMSException;
-import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.Properties;
@@ -106,7 +105,7 @@
{
Properties jndiProperties = jmsProvider.getJndiProperties();
jndiProperties.setProperty("queue." + destination, destination);
- JMSSession jmsSession = new JMSSession(Queue.class, jndiProperties);
+ JMSSession jmsSession = new JMSSession(JMSSession.Type.QUEUE, jndiProperties);
jmsSession.connect();
try
Deleted: labs/jbossesb/workspace/skeagh/runtime/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/osgi.bnd 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/osgi.bnd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -1,24 +0,0 @@
-#-----------------------------------------------------------------
-# Use this file to add customized Bnd instructions for the bundle
-#-----------------------------------------------------------------
-Export-Package: org.jboss.esb.deploy.*,\
-org.jboss.esb.dispatch.*,\
-org.jboss.esb.failure.*,\
-org.jboss.esb.federate.*,\
-org.jboss.esb.filter.*,\
-org.jboss.esb.history.*,\
-org.jboss.esb.routing.*,\
-org.jboss.esb.schedule.*,\
-org.jboss.esb.serialization.*,\
-org.jboss.esb.test.*,\
-org.jboss.esb.annotations.*,\
-org.jboss.esb.context.*,\
-org.jboss.esb.exception.*,\
-org.jboss.esb.service.*,\
-org.jboss.esb.message.*
-
-#Import-Package: *;resolution:=optional,javax.jms.*;resolution:=optional
-#Import-Package: *;resolution:=optional
-
-Embed-Dependency: jbossesb-commons,jbossesb-api-services,jbossesb-api-routing,*;scope=compile|runtime;artifactId=!xercesImpl|log4j;inline=false,
-Embed-Transitive: true
Modified: labs/jbossesb/workspace/skeagh/runtime/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -12,7 +12,7 @@
<artifactId>jbossesb-rt</artifactId>
<version>${jboss.esb.version}</version>
<url>http://www.jboss.org/jbossesb/</url>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<dependencies>
<dependency>
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.esb.deploy;
+
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.context.ResourceLocator;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+
+/**
+ * Default resource locator works like you would expect a traditional
+ * Java resource locator.
+ * <p/>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class DefaultResourceLocator implements ResourceLocator
+{
+ /**
+ * Default ClassLoader.
+ */
+ private ClassLoader classLoader = new DefaultClassLoader(getClass().getClassLoader());
+
+ /**
+ * Simply delegates to {@link org.jboss.esb.classpath.ClassUtil#forName(String, Class)} and passes this
+ * classes class as the second argument.
+ *
+ * @param className - the class to load.
+ * @return Class - the loaded class.
+ * @throws ClassNotFoundException - if the class could not be found.
+ */
+ public final Class<?> forName(final String className) throws ClassNotFoundException
+ {
+ return ClassUtil.forName(className, getClass());
+ }
+
+ /**
+ * Simply delegates to {@link ClassUtil#forName(String, Class)} and passes this
+ * classes class as the second argument.
+ *
+ * @param className - the class to load.
+ * @return Class - the loaded class.
+ * @param caller - the class which should be used as the callers class.
+ * @throws ClassNotFoundException - if the class could not be found.
+ */
+ public final Class<?> forName(final String className, final Class<?> caller) throws ClassNotFoundException
+ {
+ return ClassUtil.forName(className, caller);
+ }
+
+ /**
+ * Simply delegates to {@link ClassUtil#getResourceAsStream(String, Class)}.
+ * classes class as the second argument.
+ *
+ * @param resourceName - the name of the resource to locate.
+ * @param caller - the class which should be used as the callers class.
+ * @return InputStream - the input stream for the resource.
+ *
+ */
+ public final InputStream getResourceAsStream(final String resourceName, final Class<?> caller)
+ {
+ return ClassUtil.getResourceAsStream(resourceName, caller);
+ }
+
+ /**
+ * Get the underlying classloader.
+ * @return The underlying ClassLoader.
+ */
+ public final ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /**
+ * Default ClassLoader.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+ public class DefaultClassLoader extends ClassLoader
+ {
+ public DefaultClassLoader(final ClassLoader parent)
+ {
+ super(parent);
+ }
+
+ protected Class<?> findClass(String name) throws ClassNotFoundException
+ {
+ return ClassUtil.forName(name, getClass());
+ }
+
+ protected URL findResource(String name)
+ {
+ return ClassUtil.getResource(name, getClass());
+ }
+
+ protected Enumeration<URL> findResources(String name) throws IOException
+ {
+ return ClassUtil.getResources(name, getClass());
+ }
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -23,9 +23,8 @@
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Uninitialize;
import org.jboss.esb.classpath.ClassUtil;
-import org.jboss.esb.classpath.DefaultResourceLocator;
-import org.jboss.esb.classpath.ResourceLocator;
import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.config.ConfigUtil;
import org.jboss.esb.deploy.config.DeploymentUnit;
import org.jboss.esb.deploy.config.InboundRouterConfig;
@@ -143,7 +142,7 @@
private final ResourceLocator resourceLocator;
/**
- * Constructs a DeploymentRuntime and sets its {@link ResourceLocator}
+ * Constructs a DeploymentRuntime and sets its {@link org.jboss.esb.context.ResourceLocator}
* to {@link DefaultResourceLocator}.
*/
public DeploymentRuntime()
@@ -258,6 +257,18 @@
}
/**
+ * Get the ResourceLocator instance associated with the supplied
+ * DeploymentContext.
+ *
+ * @param deploymentContext The deployment context.
+ * @return The Resource Locator.
+ */
+ public static ResourceLocator getResourceLocator(final DeploymentContext deploymentContext)
+ {
+ return (ResourceLocator) deploymentContext.getContextObject(ResourceLocator.class);
+ }
+
+ /**
* Deploy the Runtime.
*
* @throws org.jboss.esb.deploy.DeploymentException
@@ -273,40 +284,49 @@
}
context = new DeploymentContext();
- context.setContextObject(DeploymentRuntime.class, this);
- context.setContextObject(ResourceLocator.class, resourceLocator);
- deploymentProperties = PropertiesUtil.getDeploymentConfig(deploymentName, resourceLocator);
- deploymentId = deploymentProperties.getProperty("deployment.id", deploymentId);
- deploymentId += ":" + deploymentName;
+ DeploymentContext.setContext(context);
+ try
+ {
+ context.setContextObject(DeploymentRuntime.class, this);
+ context.setContextObject(ResourceLocator.class, resourceLocator);
- logger.info("Starting JBoss ESB deployment: '" + deploymentName + "'.");
+ deploymentProperties = PropertiesUtil.getDeploymentConfig(deploymentName, resourceLocator);
+ deploymentId = deploymentProperties.getProperty("deployment.id", deploymentId);
+ deploymentId += ":" + deploymentName;
- // Add the pre-installed deployment units e.g. for the "Dead Letter" Service
- // and any other that the deployment may have...
- addPreinstalledDeploymentUnits();
+ logger.info("Starting JBoss ESB deployment: '" + deploymentName + "'.");
- try
- {
- // Deploy everything in order...
- deployResources();
- deployOutboundRouters();
- deployServices();
- assembleDispatchChainMap();
- deployInboundRouters();
- deployDeploymentCoordinator();
+ // Add the pre-installed deployment units e.g. for the "Dead Letter" Service
+ // and any other that the deployment may have...
+ addPreinstalledDeploymentUnits();
+
+ try
+ {
+ // Deploy everything in order...
+ deployResources();
+ deployOutboundRouters();
+ deployServices();
+ assembleDispatchChainMap();
+ deployInboundRouters();
+ deployDeploymentCoordinator();
+ }
+ catch (DeploymentException e)
+ {
+ undeploy();
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ undeploy();
+ throw new DeploymentException("Unexpected deployment error.", t);
+ }
+ logger.info("JBoss ESB deployment completed successfully: '" + deploymentName + "'.");
}
- catch (DeploymentException e)
+ finally
{
- undeploy();
- throw e;
+ DeploymentContext.setContext(null);
}
- catch (Throwable t)
- {
- undeploy();
- throw new DeploymentException("Unexpected deployment error.", t);
- }
- logger.info("JBoss ESB deployment completed successfully: '" + deploymentName + "'.");
}
/**
@@ -979,6 +999,7 @@
// If supplied, set the ServiceName on the object...
ClassUtil.setFieldValue(object, "serviceName", serviceName);
}
+ ClassUtil.setFieldValue(object, "resourceLocator", resourceLocator);
ClassUtil.execAnnotatedMethod(object, Initialize.class);
deployedObjects.put((objectName != null ? objectName : object), object);
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.config.DeploymentUnit;
import org.jboss.esb.deploy.config.InboundRouterConfig;
import org.jboss.esb.deploy.config.OutboundRouterConfig;
@@ -71,7 +71,7 @@
* Uses the {@link org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester}.
*
* @param deploymentConfig The config stream.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return The DeploymentRuntime instance (undeployed).
* @throws org.jboss.esb.deploy.DeploymentException
* Error digesting configuration.
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -22,7 +22,7 @@
import org.jboss.esb.annotations.AnnotationConstants;
import org.jboss.esb.annotations.Property;
import org.jboss.esb.classpath.ClassUtil;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.util.AssertArgument;
import org.milyn.javabean.DataDecoder;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -22,7 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.properties.ApplicationProperties;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/CreateObject.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/CreateObject.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/CreateObject.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -29,7 +29,7 @@
import org.jboss.esb.annotations.Property;
import org.jboss.esb.annotations.Property.Use;
import org.jboss.esb.classpath.ClassUtil;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.milyn.SmooksException;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.cdr.annotation.ConfigParam;
@@ -163,7 +163,7 @@
* Create the specified object and check it's type.
* @param objectClassName The object class name.
* @param expectedType The expected type.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return Object The created object.
* @throws SmooksException if an exception occurs while trying to create the object.
*/
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DefaultConfigurationDigester.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DefaultConfigurationDigester.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DefaultConfigurationDigester.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.DeploymentResource;
import org.jboss.esb.deploy.config.DeploymentUnit;
@@ -29,8 +29,8 @@
import org.jboss.esb.deploy.config.ServiceConfig;
import org.jboss.esb.service.ServiceName;
import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.util.XsdDOMValidator;
import org.jboss.esb.xml.XMLParseUtils;
-import org.jboss.esb.xml.XsdDOMValidator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DigestUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DigestUtil.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DigestUtil.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.xml.XMLParseUtils;
import org.milyn.Smooks;
import org.milyn.cdr.SmooksResourceConfigurationList;
@@ -78,7 +78,7 @@
* The caller needs to sort out and validate the returned list.
*
* @param configurationElement The configuration element.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return List of configuration "objects". Returns an empty
* list if there are no child elements.
* @throws IOException Error reading digests configuration.
@@ -97,7 +97,7 @@
*
* @param configurationElement The configuration element.
* @param matchElementName The name of the elements to be digested. <code>null</code> to digest all elements.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return List of configuration "objects". Returns an empty
* list if there are no child elements.
* @throws IOException Error reading digests configuration.
@@ -181,7 +181,7 @@
* Get the Smooks instance for the supplied namespaced element.
*
* @param element The namespaced element.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return The Smooks instance for the element namespace, otherwise null.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
@@ -225,7 +225,7 @@
* Get the namespace configuration for the specified namespace URI.
*
* @param namespace The namespace URI.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return The SmooksResourceConfigurationList instance.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/FilterDecisionTreeBuilder.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/FilterDecisionTreeBuilder.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/FilterDecisionTreeBuilder.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
-import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.context.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.config.ConfigUtil;
import org.jboss.esb.filter.FilterDecisionNode;
@@ -105,7 +105,7 @@
/**
* Create the evaluator instance from the configuration element.
* @param element The element.
- * @param resourceLocator The {@link ResourceLocator} to use.
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
* @return The FilterEvaluator instance.
* @throws SmooksException Error creating {@link FilterEvaluator}.
*/
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -20,7 +20,10 @@
package org.jboss.esb.federate.bus.jms;
import org.apache.log4j.Logger;
+import org.jboss.esb.context.ResourceLocator;
+import org.jboss.esb.context.DeploymentContext;
import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
import org.jboss.esb.federate.bus.Bus;
import org.jboss.esb.federate.bus.BusMessage;
import org.jboss.esb.federate.bus.BusMessageListener;
@@ -35,8 +38,6 @@
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Topic;
import java.util.Properties;
/**
@@ -187,7 +188,7 @@
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ //Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
connectJMSSessions(properties);
if (topicSession != null && queueSession != null)
@@ -448,7 +449,10 @@
*/
private void connectJMSSessions(final ApplicationProperties localBusProperties)
{
- topicSession = new JMSSession(Topic.class, localBusProperties);
+ ResourceLocator resourceLocator = DeploymentRuntime.getResourceLocator(DeploymentContext.getContext());
+
+ topicSession = new JMSSession(JMSSession.Type.TOPIC, localBusProperties);
+ topicSession.setClassLoader(resourceLocator.getClassLoader());
try
{
topicSession.connect();
@@ -459,7 +463,8 @@
logger.debug("Failed to connect shared deployment JMS Topic Session.", t);
return;
}
- queueSession = new JMSSession(Queue.class, localBusProperties);
+ queueSession = new JMSSession(JMSSession.Type.QUEUE, localBusProperties);
+ queueSession.setClassLoader(resourceLocator.getClassLoader());
try
{
queueSession.connect();
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/XsdDOMValidator.java (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/XsdDOMValidator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/XsdDOMValidator.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.util;
+
+import org.jboss.esb.context.ResourceLocator;
+import org.jboss.esb.xml.XMLParseUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.SAXException;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * XSD DOM Validator.
+ * <p/>
+ * <b><i>Donated by the <a href="http://milyn.codehaus.org">Milyn Project</a>.</i></b>
+ * <p/>
+ * Iterates through the document (DOM) gathering the namespaces. It validates
+ * based on the convention that the gathered namespace XSDs are provided on the
+ * classpath. It uses the namespace path (URI.getPath()), prepending it with "/META-INF"
+ * to perform a classpath resource lookup for the XSD i.e. the XSDs must be provided on
+ * the classpath below the "META-INF" package.
+ *
+ * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+ */
+public class XsdDOMValidator
+{
+ /**
+ * The document being validated.
+ */
+ private Document document;
+ /**
+ * Docuent default namespace.
+ */
+ private URI defaultNamespace;
+ /**
+ * Full namespace list.
+ */
+ private List<URI> namespaces = new ArrayList<URI>();
+
+ /**
+ * Public vonstructor.
+ *
+ * @param document The document to be validated.
+ * @throws SAXException Unable to preprocess document for validation.
+ */
+ public XsdDOMValidator(final Document document) throws SAXException
+ {
+ AssertArgument.isNotNull(document, "document");
+ this.document = document;
+
+ // Get the default namespace...
+ String defaultNamespaceString = getDefaultNamespace(document.getDocumentElement());
+ if (defaultNamespaceString != null)
+ {
+ try
+ {
+ defaultNamespace = new URI(defaultNamespaceString);
+ } catch (URISyntaxException e)
+ {
+ throw new SAXException("Cannot validate this document with this class. Namespaces must be valid URIs. Default Namespace: '" + defaultNamespaceString + "'.", e);
+ }
+ }
+
+ // Get the full namespace list...
+ XMLParseUtils.gatherNamespaceDeclarations(document.getDocumentElement(), namespaces);
+ }
+
+ /**
+ * Get the default namespace.
+ *
+ * @return The default namespace.
+ */
+ public final URI getDefaultNamespace()
+ {
+ return defaultNamespace;
+ }
+
+ /**
+ * Get the full namespace list.
+ *
+ * @return The namespace list.
+ */
+ public final List<URI> getNamespaces()
+ {
+ return namespaces;
+ }
+
+ /**
+ * Validate the document against the namespaces referenced in it.
+ *
+ * @param resourceLocator The {@link org.jboss.esb.context.ResourceLocator} to use.
+ * @throws SAXException Validation error.
+ * @throws java.io.IOException Error reading the XSD Sources.
+ */
+ public final void validate(final ResourceLocator resourceLocator) throws SAXException, IOException
+ {
+ // Using the namespace URI list, create the XSD Source array used to
+ // create the merged Schema instance...
+ Source[] xsdSources = new Source[namespaces.size()];
+ for (int i = 0; i < namespaces.size(); i++)
+ {
+ xsdSources[i] = getNamespaceSource(namespaces.get(i), resourceLocator);
+ }
+
+ // Create the merged Schema instance and from that, create the Validator instance...
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(xsdSources);
+ Validator validator = schema.newValidator();
+
+ // Validate the document...
+ validator.validate(new DOMSource(document));
+ }
+
+ /**
+ * Get the default namespace associated with the supplied element.
+ *
+ * @param element The element to be checked.
+ * @return The default namespace, or null if none was found.
+ */
+ public static String getDefaultNamespace(final Element element)
+ {
+ NamedNodeMap attributes = element.getAttributes();
+ int attributeCount = attributes.getLength();
+
+ for (int i = 0; i < attributeCount; i++)
+ {
+ Attr attribute = (Attr) attributes.item(i);
+
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getName()) && XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getLocalName()))
+ {
+ return attribute.getValue();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the namespace XSD for the specified namespace.
+ * <p/>
+ * Extracts the path element from the supplied namespace URI, prefixes
+ * it with "/META-INF" and uses the result to check the classpath for the
+ * XSD Source.
+ *
+ * @param namespace The namespace URI.
+ * @param resourceLocator The {@link ResourceLocator} to use.
+ * @return The XSD Schema Source.
+ * @throws SAXException Unable to get XSD Schema Source.
+ */
+ private Source getNamespaceSource(final URI namespace, final ResourceLocator resourceLocator) throws SAXException
+ {
+ String resourcePath = "/META-INF" + namespace.getPath();
+ InputStream xsdStream = resourceLocator.getResourceAsStream(resourcePath, getClass());
+
+
+ if (xsdStream == null)
+ {
+ throw new SAXException("Failed to locate XSD resource '" + resourcePath + "' on classpath. Namespace: '" + namespace + "'.");
+ }
+
+ return new StreamSource(xsdStream);
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/XsdDOMValidator.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/package.html (from rev 23455, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/test/package.html)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/package.html 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+Runtime utilities.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/util/package.html
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/DefaultConfigurationDigesterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/DefaultConfigurationDigesterTest.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/DefaultConfigurationDigesterTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy.config;
-import org.jboss.esb.classpath.DefaultResourceLocator;
+import org.jboss.esb.deploy.DefaultResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester;
import org.jboss.esb.deploy.config.digest.DigestUtil;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/InboundFilterConfigTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/InboundFilterConfigTest.java 2008-10-15 05:22:10 UTC (rev 23457)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/InboundFilterConfigTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -21,10 +21,10 @@
import junit.framework.TestCase;
import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DefaultResourceLocator;
import org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester;
import org.jboss.esb.message.Message;
import org.jboss.esb.routing.FilterEvaluator;
-import org.jboss.esb.classpath.DefaultResourceLocator;
import org.jboss.esb.context.InvocationContext;
import java.io.IOException;
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/XsdDOMValidatorTest.java (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/XsdDOMValidatorTest.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/XsdDOMValidatorTest.java 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.util;
+
+import junit.framework.TestCase;
+import org.jboss.esb.context.ResourceLocator;
+import org.jboss.esb.deploy.DefaultResourceLocator;
+import org.jboss.esb.xml.XMLParseUtils;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+ */
+public class XsdDOMValidatorTest extends TestCase {
+ private ResourceLocator resourceLocator = new DefaultResourceLocator();
+
+ public void test_namespace_gathering() throws IOException, SAXException, ParserConfigurationException {
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
+ XsdDOMValidator validator = new XsdDOMValidator(document);
+
+ assertEquals("http://www.milyn.org/xsd/test-xsd-01.xsd", validator.getDefaultNamespace().toString());
+ assertEquals("[http://www.milyn.org/xsd/test-xsd-01.xsd, http://www.milyn.org/xsd/test-xsd-02.xsd]", validator.getNamespaces().toString());
+ }
+
+ public void test_validation_validdoc() throws IOException, SAXException, ParserConfigurationException {
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
+ XsdDOMValidator validator = new XsdDOMValidator(document);
+
+ validator.validate(resourceLocator);
+ }
+
+ public void test_validation_invaliddoc() throws IOException, SAXException, ParserConfigurationException {
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-02.xml"));
+ XsdDOMValidator validator = new XsdDOMValidator(document);
+
+ try {
+ validator.validate(resourceLocator);
+ fail("Expected SAXParseException");
+ } catch(SAXParseException e) {
+ assertEquals("cvc-complex-type.4: Attribute 'myName' must appear on element 'a:myNVP'.", e.getMessage());
+ }
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/XsdDOMValidatorTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-01.xml (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-01.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-01.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-01.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<nameValuePairs xmlns="http://www.milyn.org/xsd/test-xsd-01.xsd" xmlns:a="http://www.milyn.org/xsd/test-xsd-02.xsd">
+ <nameValuePair name="a" value="1" />
+ <a:myNVP myName="xxx" myValue="blah" />
+</nameValuePairs>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-02.xml (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/xsdDomValidator-test-02.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-02.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-02.xml 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<nameValuePairs xmlns="http://www.milyn.org/xsd/test-xsd-01.xsd" xmlns:a="http://www.milyn.org/xsd/test-xsd-02.xsd">
+ <nameValuePair name="a" value="1" />
+ <a:myNVP />
+</nameValuePairs>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/util/xsdDomValidator-test-02.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-01.xsd (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-01.xsd)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-01.xsd (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-01.xsd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:yyy="http://www.milyn.org/xsd/test-xsd-01.xsd"
+ targetNamespace="http://www.milyn.org/xsd/test-xsd-01.xsd"
+ elementFormDefault="qualified">
+
+ <xs:element name="nameValuePairs">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="yyy:abstractNVP" minOccurs="1" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="abstractNVP" type="yyy:abstractNVP" abstract="true" />
+ <xs:complexType name="abstractNVP" abstract="true" />
+
+ <xs:element name="nameValuePair" substitutionGroup="yyy:abstractNVP">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="yyy:abstractNVP">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="value" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-01.xsd
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-02.xsd (from rev 23455, labs/jbossesb/workspace/skeagh/commons/src/test/resources/META-INF/xsd/test-xsd-02.xsd)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-02.xsd (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-02.xsd 2008-10-15 07:12:26 UTC (rev 23458)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:yyy="http://www.milyn.org/xsd/test-xsd-01.xsd"
+ xmlns:zzz="http://www.milyn.org/xsd/test-xsd-02.xsd"
+ targetNamespace="http://www.milyn.org/xsd/test-xsd-02.xsd"
+ elementFormDefault="qualified">
+
+ <xs:import namespace="http://www.milyn.org/xsd/test-xsd-01.xsd" />
+
+ <xs:element name="myNVP" substitutionGroup="yyy:abstractNVP">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="yyy:abstractNVP">
+ <xs:attribute name="myName" type="xs:string" use="required"/>
+ <xs:attribute name="myValue" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/xsd/test-xsd-02.xsd
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list