[jboss-svn-commits] JBL Code SVN: r23409 - in labs/jbossesb/workspace/skeagh: api/routing/src/main/java/org/jboss/esb/routing and 28 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 9 16:28:16 EDT 2008
Author: beve
Date: 2008-10-09 16:28:16 -0400 (Thu, 09 Oct 2008)
New Revision: 23409
Added:
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/JBossESBException.java
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/package.html
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/routing/jms/src/main/resources/log4j.xml
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/DeploymentRegistry.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/resources/jndi.properties
Removed:
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/JBossESBException.java
labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/HelloworldActivator.java
labs/jbossesb/workspace/skeagh/examples/helloworld/src/test/java/org/jboss/esb/examples/helloworld/HelloworldActivatorTest.java
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/deploy/ResourceLocator.java
Modified:
labs/jbossesb/workspace/skeagh/api/routing/pom.xml
labs/jbossesb/workspace/skeagh/api/routing/src/main/java/org/jboss/esb/routing/RoutingException.java
labs/jbossesb/workspace/skeagh/api/service/osgi.bnd
labs/jbossesb/workspace/skeagh/api/service/pom.xml
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/message/MessageProcessingException.java
labs/jbossesb/workspace/skeagh/commons/osgi.bnd
labs/jbossesb/workspace/skeagh/commons/pom.xml
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/examples/helloworld/README.TXT
labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/MyTestService.java
labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jboss-esb.xml
labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jndi.properties
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/osgi.bnd
labs/jbossesb/workspace/skeagh/runtime/pom.xml
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentException.java
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/DeploymentUnit.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/DeploymentCoordinator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SchedulingException.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/serialization/SerializationException.java
labs/jbossesb/workspace/skeagh/runtime/src/main/resources/log4j.xml
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/FilterConfigTest.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/ConfigUtilTest.java
Log:
Updated for osgi bundling and example
Modified: labs/jbossesb/workspace/skeagh/api/routing/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/api/routing/pom.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/routing/pom.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -12,7 +12,7 @@
<artifactId>jbossesb-api-routing</artifactId>
<version>${jboss.esb.version}</version>
<url>http://www.jboss.org/jbossesb/</url>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<dependencies>
<dependency>
Modified: labs/jbossesb/workspace/skeagh/api/routing/src/main/java/org/jboss/esb/routing/RoutingException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/routing/src/main/java/org/jboss/esb/routing/RoutingException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/routing/src/main/java/org/jboss/esb/routing/RoutingException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.routing;
-import org.jboss.esb.JBossESBException;
+import org.jboss.esb.exception.JBossESBException;
/**
* Routing exception.
Modified: labs/jbossesb/workspace/skeagh/api/service/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/osgi.bnd 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/service/osgi.bnd 2008-10-09 20:28:16 UTC (rev 23409)
@@ -5,5 +5,5 @@
Export-Package: org.jboss.esb.annotations.*, \
org.jboss.esb.context.*, \
org.jboss.esb.message.*, \
-org.jboss.esb.service.*, \
-org.jboss.esb;include:="JBossESBException"
+org.jboss.esb.exception.*, \
+org.jboss.esb.service.*
Modified: labs/jbossesb/workspace/skeagh/api/service/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/pom.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/service/pom.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -12,7 +12,7 @@
<artifactId>jbossesb-api-service</artifactId>
<version>${jboss.esb.version}</version>
<url>http://www.jboss.org/jbossesb/</url>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<dependencies>
<dependency>
Deleted: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/JBossESBException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/JBossESBException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/JBossESBException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,49 +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;
-
-/**
- * Base JBossESB Exception.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class JBossESBException extends Exception
-{
- /**
- * Public Constructor.
- *
- * @param message Exception message.
- */
- public JBossESBException(final String message)
- {
- super(message);
- }
-
- /**
- * Public Constructor.
- *
- * @param message Exception message.
- * @param cause Exception cause.
- */
- public JBossESBException(final String message, final Throwable cause)
- {
- super(message, cause);
- }
-}
Copied: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/JBossESBException.java (from rev 23356, labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/JBossESBException.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/JBossESBException.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/JBossESBException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,54 @@
+/*
+ * 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.exception;
+
+/**
+ * Base JBossESB Exception.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBossESBException extends Exception
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Public Constructor.
+ *
+ * @param message Exception message.
+ */
+ public JBossESBException(final String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Public Constructor.
+ *
+ * @param message Exception message.
+ * @param cause Exception cause.
+ */
+ public JBossESBException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/JBossESBException.java
___________________________________________________________________
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/exception/package.html 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+ESB Service Exception classes.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/message/MessageProcessingException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/message/MessageProcessingException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/message/MessageProcessingException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.message;
-import org.jboss.esb.JBossESBException;
+import org.jboss.esb.exception.JBossESBException;
/**
* Message Processing Exception.
Modified: labs/jbossesb/workspace/skeagh/commons/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/osgi.bnd 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/commons/osgi.bnd 2008-10-09 20:28:16 UTC (rev 23409)
@@ -9,6 +9,3 @@
org.jboss.esb.util,\
org.jboss.esb.xml
-#Fragment-Host: jboss.jbossesb.jbossesb-rt
-DynamicImport-Package: *
-
Modified: labs/jbossesb/workspace/skeagh/commons/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/pom.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/commons/pom.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -12,7 +12,7 @@
<artifactId>jbossesb-commons</artifactId>
<version>${jboss.esb.version}</version>
<url>http://www.jboss.org/jbossesb/</url>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<dependencies>
Copied: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java (from rev 23356, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,78 @@
+/*
+ * 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);
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/DefaultResourceLocator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java (from rev 23356, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ResourceLocator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,64 @@
+/*
+ * 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);
+}
Property changes on: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ResourceLocator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: 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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XsdDOMValidator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,10 +19,12 @@
*/
package org.jboss.esb.xml;
-import org.jboss.esb.classpath.ClassUtil;
-import org.jboss.esb.util.AssertArgument;
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
+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;
@@ -31,13 +33,15 @@
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;
+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/>
@@ -117,17 +121,18 @@
/**
* 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() throws SAXException, IOException
+ 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));
+ xsdSources[i] = getNamespaceSource(namespaces.get(i), resourceLocator);
}
// Create the merged Schema instance and from that, create the Validator instance...
@@ -140,37 +145,6 @@
}
/**
- * Duplicate of validate but takes a class that is the caller that should
- * be used to retrieve the xsd.
- * This was added to force our current impl to work with OSGi
- *
- * TODO: Revist this solution and remove duplicated code after our
- * OSGi strategy is set. /Dan
- *
- * @param caller - the class that should be used for searching the classpath
- * @throws SAXException Validation error.
- * @throws java.io.IOException Error reading the XSD Sources.
- */
- public final void validate(final Class<?> caller) 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), caller);
- }
-
- // 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.
@@ -202,13 +176,14 @@
* 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) throws SAXException
+ private Source getNamespaceSource(final URI namespace, final ResourceLocator resourceLocator) throws SAXException
{
String resourcePath = "/META-INF" + namespace.getPath();
- InputStream xsdStream = ClassUtil.getResourceAsStream(resourcePath, getClass());
+ InputStream xsdStream = resourceLocator.getResourceAsStream(resourcePath, getClass());
if (xsdStream == null)
{
@@ -218,28 +193,4 @@
return new StreamSource(xsdStream);
}
- /**
- * Duplicate of getNamespaceSource with the addition of the ability to specify
- * a caller class. This class will be used to for searching the classpath
- *
- * TODO: Revist this solution and remove duplicated code after our
- * OSGi strategy is set. /Dan
- *
- * @param namespace The namespace URI.
- * @param caller - the class that should be used for searching the classpath
- * @return The XSD Schema Source.
- * @throws SAXException Unable to get XSD Schema Source.
- */
- private Source getNamespaceSource(final URI namespace, final Class<?> caller) throws SAXException
- {
- String resourcePath = "/META-INF" + namespace.getPath();
- InputStream xsdStream = ClassUtil.getResourceAsStream(resourcePath, caller);
-
- 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/xml/XsdDOMValidatorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -20,6 +20,9 @@
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;
@@ -31,6 +34,7 @@
* @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"));
@@ -44,7 +48,7 @@
Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
XsdDOMValidator validator = new XsdDOMValidator(document);
- validator.validate();
+ validator.validate(resourceLocator);
}
public void test_validation_invaliddoc() throws IOException, SAXException, ParserConfigurationException {
@@ -52,7 +56,7 @@
XsdDOMValidator validator = new XsdDOMValidator(document);
try {
- validator.validate();
+ validator.validate(resourceLocator);
fail("Expected SAXParseException");
} catch(SAXParseException e) {
assertEquals("cvc-complex-type.4: Attribute 'myName' must appear on element 'a:myNVP'.", e.getMessage());
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/README.TXT 2008-10-09 20:28:16 UTC (rev 23409)
@@ -16,3 +16,12 @@
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:
+ >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)
+
+ Notice how the esb undeploy and deploys the bundle.
+
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,11 +1,29 @@
#-----------------------------------------------------------------
# Use this file to add customized Bnd instructions for the bundle
#-----------------------------------------------------------------
-Export-Package: org.jboss.esb.examples.*,org.apache.activemq.*, org.apache.log4j.*, javax.jms.*
-Import-Package: *;resolution:=optional,*
-Bundle-Activator: org.jboss.esb.examples.helloworld.HelloworldActivator
-Embed-Dependency: log4j;scope=compile|runtime, activemq-core;scope=compile|runtime, jms;scope=compile|runtime, mx4j;scope=compile|runtime, mx4j-tools, backport-util-concurrent, commons-logging, geronimo-j2ee-management_1.1_spec
+# Need to export all classes that this bundle uses
+Export-Package: org.jboss.esb.examples.helloworld.*, org.apache.activemq.*, org.apache.log4j.*, javax.jms.*, edu.emory.*, org.apache.commons.logging.*, javax.management.j2ee.*
+
+# 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, \
+activemq-core;scope=compile|runtime, \
+jms;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-Transitive: true
-DynamicImport-Package: *
+# This property can be used to override the
+# default configuration file name.
+JBossESB-ConfigFile = /jboss-esb.xml
+
+
+
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -89,21 +89,32 @@
<artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
<version>1.0-M1</version>
</dependency>
+
<dependency>
<groupId>jboss.jbossesb</groupId>
<artifactId>jbossesb-routing-jms</artifactId>
<version>${jboss.esb.version}</version>
</dependency>
+
<dependency>
<groupId>jboss.jbossesb</groupId>
<artifactId>jbossesb-api-service</artifactId>
<version>${jboss.esb.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-api-routing</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+
+ <!--
<dependency>
<groupId>jboss.jbossesb</groupId>
- <artifactId>jbossesb-commons</artifactId>
+ <artifactId>jbossesb-osgi</artifactId>
<version>${jboss.esb.version}</version>
</dependency>
+ -->
</dependencies>
</project>
Deleted: labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/HelloworldActivator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/HelloworldActivator.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/HelloworldActivator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,89 +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.examples.helloworld;
-
-import java.io.InputStream;
-
-import org.jboss.esb.deploy.DeploymentRuntime;
-import org.jboss.esb.deploy.DeploymentUtil;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * OSGI Activator.
- * <p/>
- *
- * This is a simple attempt to test the new JBossESB 5.0 architecture.
- * Usage:
- *
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- *
- */
-public class HelloworldActivator implements BundleActivator
-{
- /**
- * The ESB Deployment Runtime.
- */
- private DeploymentRuntime runtime;
-
- /**
- * Bundle start method. Deploys the ESB configuration.
- *
- * @param context - the OSGi BundleContext
- * @throws Exception - is an exception occurs.
- */
- public final void start(final BundleContext context) throws Exception
- {
- runtime = DeploymentUtil.createRuntime(getConfiguration("/jboss-esb.xml"));
- runtime.deploy();
- }
-
- /**
- * Bundle stop method. Deploys the ESB configuration.
- *
- * @param context - the OSGi BundleContext
- * @throws Exception - is an exception occurs.
- */
- public final void stop(final BundleContext context) throws Exception
- {
- if (runtime != null)
- {
- runtime.undeploy();
- }
- }
-
- /**
- * Retrieves the esb confuration file as an InputStream.
- *
- * @param fileName - the configuration file.
- * @return InputStream - inputstream to the configuration file.
- */
- private InputStream getConfiguration(final String fileName)
- {
- InputStream in = getClass().getResourceAsStream(fileName);
- if (in == null)
- {
- throw new IllegalStateException("Could not locate 'jboss-esb.xml'. Make sure that it exists on the classpath");
- }
- return in;
- }
-
-}
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/MyTestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/MyTestService.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/java/org/jboss/esb/examples/helloworld/MyTestService.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.examples.helloworld;
+import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.message.Message;
import org.jboss.esb.service.Service;
import org.jboss.esb.service.ServiceException;
@@ -28,12 +29,16 @@
*
* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
-public class MyTestService implements Service
+public final class MyTestService implements Service
{
/**
- * ESB Message object. Only used for testing.
+ * Just an example of an initialize method.
*/
- private static Message message;
+ @Initialize
+ public void init()
+ {
+ System.out.println("Init in MyTestService");
+ }
/**
* Processes the message.
@@ -41,22 +46,10 @@
* @return Messsage - the esb message object instance.
* @throws ServiceException - if an exception occurs during processing.
*/
- public final Message process(final Message msg) throws ServiceException
+ public Message process(final Message msg) throws ServiceException
{
System.out.println("MyTestService message payload : " + msg.getPayload());
- MyTestService.message = msg;
return msg;
}
- /**
- * Simple get the static message object instance.
- * This is only intended for unit testing.
- *
- * @return Message - the ESB Message object that was last seen by the process method.
- */
- public static Message getMessage()
- {
- return message;
- }
-
}
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jboss-esb.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jboss-esb.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,19 +1,12 @@
<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
-
- <routing>
- <inRouters serviceCategory="examples" serviceName="helloworld">
+ <services>
+ <service serviceCategory="examples" serviceName="helloworld" serviceDescription="First Example" class="org.jboss.esb.examples.helloworld.MyTestService">
<inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
- <property name="java.naming.provider.url">tcp://danbev-laptop:61717</property>
+ <property name="java.naming.provider.url">tcp://localhost:61717</property>
<property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
<property name="jmsDestination">jbossesb.TestQueue</property>
- <property name="queue.jbossesb.TestQueue">jbossesb.TestQueue</property>
+ <!--property name="queue.jbossesb.TestQueue">jbossesb.TestQueue</property-->
</inRouter>
- </inRouters>
- </routing>
-
- <services>
- <service serviceCategory="examples" serviceName="helloworld" serviceDescription="TestService" class="org.jboss.esb.examples.helloworld.MyTestService"/>
- </services>
-
-
+ </service>
+ </services>
</jbossesb>
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jndi.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jndi.properties 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/src/main/resources/jndi.properties 2008-10-09 20:28:16 UTC (rev 23409)
@@ -3,13 +3,12 @@
# use the following property to specify the JNDI name the connection factory
# should appear as.
-#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = connectionFactory, ConnectionFactory, queueConnectionFactory, topicConnectionFactory
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.jbossesb.TestQueue = jbossesb.TestQueue
-
queue.jbossesb.jms.bus = jbossesb.jms.bus
# register some topics in JNDI using the form
Deleted: labs/jbossesb/workspace/skeagh/examples/helloworld/src/test/java/org/jboss/esb/examples/helloworld/HelloworldActivatorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/src/test/java/org/jboss/esb/examples/helloworld/HelloworldActivatorTest.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/src/test/java/org/jboss/esb/examples/helloworld/HelloworldActivatorTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,137 +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.examples.helloworld;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Dictionary;
-
-import org.jboss.esb.examples.helloworld.HelloworldActivator;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Test for {@link HelloworldActivator}.
- *
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- *
- */
-public class HelloworldActivatorTest
-{
- @Test
- @Ignore
- public void startStop() throws Exception
- {
- HelloworldActivator helloworldActivator = new HelloworldActivator();
- MockBundleContext bundleContext = new MockBundleContext();
- helloworldActivator.start(bundleContext);
- helloworldActivator.stop(bundleContext);
- }
-
- private class MockBundleContext implements BundleContext
- {
- public void addBundleListener(BundleListener listener) { }
- public void addFrameworkListener(FrameworkListener listener) { }
- public void addServiceListener(ServiceListener listener) { }
- public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { }
- public Filter createFilter(String filter) throws InvalidSyntaxException
- {
- return null;
- }
- public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- return null;
- }
- public Bundle getBundle()
- {
- return null;
- }
- public Bundle getBundle(long id)
- {
- return null;
- }
- public Bundle[] getBundles()
- {
- return null;
- }
- public File getDataFile(String filename)
- {
- return null;
- }
- public String getProperty(String key)
- {
- return null;
- }
- public Object getService(ServiceReference reference)
- {
- return null;
- }
- public ServiceReference getServiceReference(String clazz)
- {
- return null;
- }
- public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- return null;
- }
- public Bundle installBundle(String location) throws BundleException
- {
- return null;
- }
- public Bundle installBundle(String location, InputStream input) throws BundleException
- {
-
- return null;
- }
- public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
- {
- return null;
- }
- public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
- {
- return null;
- }
- public void removeBundleListener(BundleListener listener)
- {
- }
- public void removeFrameworkListener(FrameworkListener listener)
- {
- }
- public void removeServiceListener(ServiceListener listener)
- {
- }
- public boolean ungetService(ServiceReference reference)
- {
-
- return false;
- }
- }
-}
Modified: labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/routing/jms/osgi.bnd 2008-10-09 20:28:16 UTC (rev 23409)
@@ -4,5 +4,3 @@
Export-Package: org.jboss.esb.jms.*
Import-Package: *;resolution:=optional
-
-DynamicImport-Package: *
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -110,12 +110,11 @@
@Initialize
public final void initialize() throws JMSException
{
- // add this class as a JMS message listener...
- final Destination jmsDestination = AbstractMessageHandler.lookupDestination(destination, jmsProperties);
- jmsSession = new JMSSession(jmsDestination.getClass(), jmsProperties);
- jmsSession.connect();
try
{
+ final Destination jmsDestination = AbstractMessageHandler.lookupDestination(destination, jmsProperties);
+ jmsSession = new JMSSession(jmsDestination.getClass(), jmsProperties);
+ jmsSession.connect();
messageListener = new JmsMessageListener(destination, jmsSession, jmsProperties, dispatcher);
messageListener.connect();
}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/resources/log4j.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,58 @@
+<?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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -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;
Modified: labs/jbossesb/workspace/skeagh/runtime/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/osgi.bnd 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/osgi.bnd 2008-10-09 20:28:16 UTC (rev 23409)
@@ -5,16 +5,27 @@
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.history.*,\
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.jms.*,\
+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.*
Import-Package: *;resolution:=optional
-Embed-Dependency: *;scope=compile|runtime;artifactId=!xercesImpl|jbossesb-api-service|jbossesb-api-routing|jbossesb-commons|log4j;inline=false
+Bundle-Activator: org.jboss.esb.osgi.EsbServiceDeploymentActivator
+
+Embed-Dependency: *;scope=compile|runtime;artifactId=!xercesImpl|log4j;inline=false
Embed-Transitive: true
-
-DynamicImport-Package: org.jboss.esb.examples.*, *
-
Modified: labs/jbossesb/workspace/skeagh/runtime/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -30,6 +30,7 @@
<artifactId>jbossesb-api-routing</artifactId>
<version>${jboss.esb.version}</version>
</dependency>
+
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-j2ee</artifactId>
@@ -51,6 +52,12 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi_R4_core</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
<!--
Test dependencies...
Deleted: 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/deploy/DefaultResourceLocator.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DefaultResourceLocator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,94 +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.deploy;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.jboss.esb.classpath.ClassUtil;
-
-/**
- * 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)} and passes this
- * classes class as the second argument.
- *
- * @param resourceName - the name of the resource to locate.
- * @return InputStream - the input stream for the resource.
- * @throws IOException - if the resource could not be located.
- */
- public final InputStream getResourceAsStream(final String resourceName) throws IOException
- {
- return ClassUtil.getResourceAsStream(resourceName, getClass());
- }
-
- /**
- * 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.
- * @throws IOException - if the resource could not be located.
- *
- */
- public final InputStream getResourceAsStream(final String resourceName, final Class<?> caller) throws IOException
- {
- return ClassUtil.getResourceAsStream(resourceName, caller);
- }
-
-}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,7 +19,7 @@
*/
package org.jboss.esb.deploy;
-import org.jboss.esb.JBossESBException;
+import org.jboss.esb.exception.JBossESBException;
/**
* ESB Deployment Exception.
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -23,6 +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.deploy.config.ConfigUtil;
import org.jboss.esb.deploy.config.DeploymentUnit;
@@ -138,7 +140,7 @@
/**
* ResourceLocator that will be used by this instance.
*/
- private ResourceLocator resourceLocator;
+ private final ResourceLocator resourceLocator;
/**
* Constructs a DeploymentRuntime and sets its {@link ResourceLocator}
@@ -272,8 +274,9 @@
context = new DeploymentContext();
context.setContextObject(DeploymentRuntime.class, this);
+ context.setContextObject(ResourceLocator.class, resourceLocator);
- deploymentProperties = PropertiesUtil.getDeploymentConfig(deploymentName);
+ deploymentProperties = PropertiesUtil.getDeploymentConfig(deploymentName, resourceLocator);
deploymentId = deploymentProperties.getProperty("deployment.id", deploymentId);
deploymentId += ":" + deploymentName;
@@ -344,6 +347,16 @@
}
/**
+ * Get the resource locator.
+ *
+ * @return ResourceLocator The resource locator in use by this instance.
+ */
+ public final ResourceLocator getResourceLocator()
+ {
+ return resourceLocator;
+ }
+
+ /**
* Undeploy all the inbound routers.
* <p/>
* This includes the {@link BusInboundRouter} instances.
@@ -426,7 +439,7 @@
{
new PropertiesIterator(deploymentProperties)
{
- private DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ private DefaultConfigurationDigester digester = new DefaultConfigurationDigester(resourceLocator);
@Override
public void processEntry(final String unitName, final String unitPath) throws DeploymentException
@@ -435,7 +448,7 @@
String defaultCheckPath = "preinstalled/" + unitPath;
// Try for a deployment specific configuration...
- InputStream configStream = ConfigUtil.getConfigStream(deploymentCheckPath);
+ InputStream configStream = ConfigUtil.getConfigStream(deploymentCheckPath, resourceLocator);
if (configStream != null)
{
try
@@ -450,7 +463,7 @@
}
// Try for a default configuration...
- configStream = ConfigUtil.getConfigStream(defaultCheckPath);
+ configStream = ConfigUtil.getConfigStream(defaultCheckPath, resourceLocator);
if (configStream != null)
{
try
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy;
+import org.jboss.esb.classpath.ResourceLocator;
import org.jboss.esb.deploy.config.DeploymentUnit;
import org.jboss.esb.deploy.config.InboundRouterConfig;
import org.jboss.esb.deploy.config.OutboundRouterConfig;
@@ -37,6 +38,7 @@
* Useful for testing etc.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
public abstract class DeploymentUtil
{
@@ -60,13 +62,24 @@
*/
public static DeploymentRuntime createRuntime(final InputStream deploymentConfig) throws DeploymentException, IOException
{
- DeploymentRuntime runtime = new DeploymentRuntime();
- DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
- DeploymentUnit deploymentUnit = digester.digest(deploymentConfig);
+ return createRuntime(deploymentConfig, new DeploymentRuntime());
+ }
- runtime.add(deploymentUnit);
-
- return runtime;
+ /**
+ * Digest the supplied config stream and create a DeploymentRuntime instance.
+ * <p/>
+ * Uses the {@link org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester}.
+ *
+ * @param deploymentConfig The config stream.
+ * @param resourceLocator The {@link ResourceLocator} to use.
+ * @return The DeploymentRuntime instance (undeployed).
+ * @throws org.jboss.esb.deploy.DeploymentException
+ * Error digesting configuration.
+ * @throws java.io.IOException Error reading configuration stream.
+ */
+ public static DeploymentRuntime createRuntime(final InputStream deploymentConfig, final ResourceLocator resourceLocator) throws DeploymentException, IOException
+ {
+ return createRuntime(deploymentConfig, new DeploymentRuntime(resourceLocator));
}
/**
@@ -145,4 +158,25 @@
return null;
}
+
+ /**
+ * Digest the supplied config stream and the deployment unit to the supplied DeploymentRuntime instance.
+ * <p/>
+ * Uses the {@link org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester}.
+ *
+ * @param deploymentConfig The config stream.
+ * @param runtime The deployment runtime to add the deployment to.
+ * @return The DeploymentRuntime instance (undeployed).
+ *
+ * @throws java.io.IOException Error reading configuration stream.
+ * @throws org.jboss.esb.deploy.DeploymentException
+ * Error digesting configuration.
+ */
+ private static DeploymentRuntime createRuntime(final InputStream deploymentConfig, final DeploymentRuntime runtime) throws DeploymentException, IOException
+ {
+ final DefaultConfigurationDigester digester = new DefaultConfigurationDigester(runtime.getResourceLocator());
+ final DeploymentUnit deploymentUnit = digester.digest(deploymentConfig);
+ runtime.add(deploymentUnit);
+ return runtime;
+ }
}
Deleted: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ResourceLocator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ResourceLocator.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ResourceLocator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -1,75 +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.deploy;
-
-import java.io.IOException;
-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 classpath.
- *
- * @param resourceName - the name of the resource to be retrieved.
- * @return InputStream - the InputStream for the resource.
- * @throws IOException - if an IOExcpetion occurs while trying to access the resource.
- */
- InputStream getResourceAsStream(final String resourceName) throws IOException;
-
- /**
- * 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.
- * @throws IOException - if an IOExcpetion occurs while trying to access the resource.
- */
- InputStream getResourceAsStream(final String resourceName, final Class<?> caller) throws IOException;
-}
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -22,7 +22,9 @@
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.deploy.DeploymentException;
+import org.jboss.esb.util.AssertArgument;
import org.milyn.javabean.DataDecoder;
import java.io.File;
@@ -74,7 +76,6 @@
{
String fileCheckPath = BUSCONFIG_FILE_DIR + configPath;
String cpCheckPath = ESBCONFIG_CP_DIR + configPath;
- InputStream configStream;
// 1st: Check for a config on the local file system...
File checkFile = new File(fileCheckPath);
@@ -95,6 +96,44 @@
}
/**
+ * Get the specified configuration stream using the passed in ResourceLocator.
+ * <p/>
+ * Checks in the following order:
+ * <ol>
+ * <li>File: "busconfig/<configPath>"</li>
+ * <li>Classpath: "/META-INF/jbossesb/<configPath>"</li>
+ * </ol>
+ *
+ * @param configPath The configuration file path.
+ * @param resourceLocator The {@link ResourceLocator} implementation to use.
+ * @return The configuration stream, or null if the specified configuration cannot be found.
+ * @throws org.jboss.esb.deploy.DeploymentException Unable to read configuration.
+ */
+ public static InputStream getConfigStream(final String configPath, final ResourceLocator resourceLocator) throws DeploymentException
+ {
+ AssertArgument.isNotNull(resourceLocator, "resourceLocator");
+ String fileCheckPath = BUSCONFIG_FILE_DIR + configPath;
+ String cpCheckPath = ESBCONFIG_CP_DIR + configPath;
+
+ // 1st: Check for a config on the local file system...
+ File checkFile = new File(fileCheckPath);
+ if (checkFile.exists() && !checkFile.isDirectory())
+ {
+ try
+ {
+ return new FileInputStream(checkFile);
+ }
+ catch (IOException e)
+ {
+ throw new DeploymentException("Error reading configuration file '" + checkFile.getAbsolutePath() + "'.", e);
+ }
+ }
+
+ // 2nd: Check for a config using the resource locator...
+ return resourceLocator.getResourceAsStream(cpCheckPath, ConfigUtil.class);
+ }
+
+ /**
* URL encode the supplied string.
*
* @param string The String.
@@ -124,7 +163,7 @@
*/
public static void configure(final Object component, final Properties properties) throws DeploymentException
{
- Class objectClass = component.getClass();
+ Class<?> objectClass = component.getClass();
configure(component, objectClass, properties);
}
@@ -136,7 +175,7 @@
* @param properties The properties set.
* @throws DeploymentException Error configuring component.
*/
- private static void configure(final Object component, final Class hierarchyClass, final Properties properties) throws DeploymentException
+ private static void configure(final Object component, final Class<?> hierarchyClass, final Properties properties) throws DeploymentException
{
final Class<?> superclass = hierarchyClass.getSuperclass();
@@ -153,11 +192,11 @@
String propertyName = AnnotationConstants.NULL_STRING.equals(propertyAnno.name()) ? field.getName() : propertyAnno.name();
String propertyValue = properties.getProperty(propertyName);
- if(propertyValue == null)
+ if (propertyValue == null)
{
- if(!Property.Assert.isDefaultAssigned(propertyAnno))
+ if (!Property.Assert.isDefaultAssigned(propertyAnno))
{
- if(propertyAnno.use() == Property.Use.REQUIRED)
+ if (propertyAnno.use() == Property.Use.REQUIRED)
{
throw new DeploymentException("Required property '" + propertyName + "' is not configured on class '" + component.getClass() + ".");
}
@@ -191,6 +230,7 @@
* @param choices the choices available
* @param name the name of the paramter
* @param paramValue the property value
+ * @throws DeploymentException If an invalid choice was passed to this method.
*/
private static void assertValidChoice(final String[] choices, final String name, final String paramValue) throws DeploymentException
{
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DeploymentUnit.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DeploymentUnit.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DeploymentUnit.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -243,7 +243,7 @@
Collection<InboundRouterConfig> inrouters = inboundRouters.values();
for (InboundRouterConfig inrouter : inrouters)
{
- for(InboundRouterFilterConfig filterConfig : inrouter.getFilters())
+ for (InboundRouterFilterConfig filterConfig : inrouter.getFilters())
{
if (!outboundRouters.containsKey(filterConfig.getTo()))
{
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,13 +19,13 @@
*/
package org.jboss.esb.deploy.config;
-import org.apache.log4j.Logger;
-import org.jboss.esb.deploy.DeploymentException;
-import org.jboss.esb.properties.ApplicationProperties;
-
import java.io.IOException;
import java.io.InputStream;
+import org.jboss.esb.classpath.ResourceLocator;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.properties.ApplicationProperties;
+
/**
* Deployment properties configuration utility methods.
* <p/>
@@ -36,13 +36,7 @@
*/
public abstract class PropertiesUtil
{
-
/**
- * Logger.
- */
- private static Logger logger = Logger.getLogger(PropertiesUtil.class);
-
- /**
* Private constructor.
*/
private PropertiesUtil()
@@ -66,10 +60,11 @@
*
* @param protocol The protocol name e.g. "jms".
* @param deploymentName The deployment name e.g. "Order_Service".
+ * @param resourceLocator The {@link ResourceLocator} to use for looking up property files.
* @return The bus configuration as a {@link java.util.Properties} instance.
* @throws DeploymentException Unable to read configuration.
*/
- public static ApplicationProperties getBusConfig(final String protocol, final String deploymentName) throws DeploymentException
+ public static ApplicationProperties getBusConfig(final String protocol, final String deploymentName, final ResourceLocator resourceLocator) throws DeploymentException
{
String defaultCheckPath = protocol + "/" + "default.properties";
String deploymentCheckPath = protocol + "/" + ConfigUtil.urlEncode(deploymentName) + ".properties";
@@ -77,14 +72,14 @@
ApplicationProperties deploymentProperties;
// Get the default ...
- properties = getConfig(defaultCheckPath);
+ properties = getConfig(defaultCheckPath, resourceLocator);
if (properties == null)
{
throw new DeploymentException("Unable to find the default Bus configuration for protocol '" + protocol + "''.");
}
// Check for a deployment specific config ...
- deploymentProperties = getConfig(deploymentCheckPath);
+ deploymentProperties = getConfig(deploymentCheckPath, resourceLocator);
if (deploymentProperties != null)
{
// Overlay the deault properties with the deployment specific properties....
@@ -109,10 +104,11 @@
* <b><u>NOTE:</u></b> The deployment name is URL encoded (application/x-www-form-urlencoded).
*
* @param deploymentName The deployment name.
+ * @param resourceLocator The {@link ResourceLocator} to use for looking up property files.
* @return The main Deployment properties.
* @throws DeploymentException Error reading properties.
*/
- public static ApplicationProperties getDeploymentConfig(final String deploymentName) throws DeploymentException
+ public static ApplicationProperties getDeploymentConfig(final String deploymentName, final ResourceLocator resourceLocator) throws DeploymentException
{
String defaultCheckPath = "jbossesb-default.properties";
String deploymentCheckPath = ConfigUtil.urlEncode(deploymentName) + ".properties";
@@ -120,14 +116,14 @@
ApplicationProperties deploymentProperties;
// Get the default ...
- properties = getConfig(defaultCheckPath);
+ properties = getConfig(defaultCheckPath, resourceLocator);
if (properties == null)
{
throw new DeploymentException("Unable to find the default JBoss ESB Deployment configuration '" + defaultCheckPath + "' for deployment '" + deploymentName + "'.");
}
// Check for a deployment specific config ...
- deploymentProperties = getConfig(deploymentCheckPath);
+ deploymentProperties = getConfig(deploymentCheckPath, resourceLocator);
if (deploymentProperties != null)
{
// Overlay the deault properties with the deployment specific properties....
@@ -147,13 +143,14 @@
* </ol>
*
* @param configPath The configuration file path.
+ * @param resourceLocator The {@link ResourceLocator} to use for looking up property files.
* @return The bus configuration as a {@link java.util.Properties} instance, or null if
* the specified configuration cannot be found.
* @throws DeploymentException Unable to read configuration.
*/
- public static ApplicationProperties getConfig(final String configPath) throws DeploymentException
+ public static ApplicationProperties getConfig(final String configPath, final ResourceLocator resourceLocator) throws DeploymentException
{
- InputStream configStream = ConfigUtil.getConfigStream(configPath);
+ InputStream configStream = ConfigUtil.getConfigStream(configPath, resourceLocator);
if (configStream != null)
{
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/CreateObject.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -20,14 +20,20 @@
package org.jboss.esb.deploy.config.digest;
import static org.jboss.esb.annotations.AnnotationConstants.UNASSIGNED;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
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.milyn.SmooksException;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.cdr.annotation.ConfigParam;
import org.milyn.container.ExecutionContext;
-import org.milyn.delivery.annotation.Initialize;
import org.milyn.delivery.dom.DOMVisitAfter;
import org.milyn.delivery.dom.DOMVisitBefore;
import org.milyn.javabean.DataDecoder;
@@ -35,11 +41,6 @@
import org.milyn.xml.DomUtils;
import org.w3c.dom.Element;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.ArrayList;
-
/**
* Create an object and set it in the Smooks bean repository.
*
@@ -77,16 +78,17 @@
/**
* Initialize the visitor.
*
+ * @param resourceLocator The {@link ResourceLocator} to use.
* @throws SmooksConfigurationException Unable to load the expected type class.
*/
- @Initialize
- public final void initialize() throws SmooksConfigurationException
+ //@Initialize
+ public final void initialize(final ResourceLocator resourceLocator) throws SmooksConfigurationException
{
if (expectedTypeName != null)
{
try
{
- expectedType = ClassUtil.forName(expectedTypeName, CreateObject.class);
+ expectedType = resourceLocator.forName(expectedTypeName, CreateObject.class);
}
catch (ClassNotFoundException e)
{
@@ -104,6 +106,9 @@
*/
public final void visitBefore(final Element element, final ExecutionContext executionContext) throws SmooksException
{
+ final ResourceLocator resourceLocator = (ResourceLocator) executionContext.getAttribute(ResourceLocator.class);
+ initialize(resourceLocator);
+
String objectClassName = null;
if (className != null)
@@ -123,7 +128,7 @@
throw new SmooksException("One of the attributes 'className' or 'classAttrib' must be defined on the '" + CreateObject.class.getName() + "' resource.");
}
- Object objectInstance = createObject(objectClassName, expectedType);
+ Object objectInstance = createObject(objectClassName, expectedType, resourceLocator);
// Store the bean in the Smooks bean repository...
BeanRepositoryManager.getBeanRepository(executionContext).addBean(beanId, objectInstance);
@@ -158,14 +163,15 @@
* 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.
* @return Object The created object.
* @throws SmooksException if an exception occurs while trying to create the object.
*/
- public static Object createObject(final String objectClassName, final Class expectedType) throws SmooksException
+ public static Object createObject(final String objectClassName, final Class expectedType, final ResourceLocator resourceLocator) throws SmooksException
{
try
{
- Class objectClass = ClassUtil.forName(objectClassName, CreateObject.class);
+ Class objectClass = resourceLocator.forName(objectClassName, CreateObject.class);
Constructor defaultConstructor;
if (expectedType != null && !expectedType.isAssignableFrom(objectClass))
@@ -198,6 +204,7 @@
}
catch (Exception e)
{
+ e.printStackTrace();
throw new SmooksException("Unable to create class instance for class '" + objectClassName + "'.", e);
}
}
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DefaultConfigurationDigester.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
+import org.jboss.esb.classpath.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.DeploymentResource;
import org.jboss.esb.deploy.config.DeploymentUnit;
@@ -52,10 +53,25 @@
* namespace based configuration extensions.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
public class DefaultConfigurationDigester implements ConfigurationDigester
{
/**
+ * ResourceLocator used to search for resources.
+ */
+ private final ResourceLocator resourceLocator;
+
+ /**
+ * Constructs an instance and store the passed in ResourceLocator.
+ *
+ * @param resourceLocator The resource locator to be used by this instance.
+ */
+ public DefaultConfigurationDigester(final ResourceLocator resourceLocator)
+ {
+ this.resourceLocator = resourceLocator;
+ }
+ /**
* Digest the supplied configuration stream.
* <p/>
* Produces a {@link org.jboss.esb.deploy.config.DeploymentUnit} that can be added to a {@link org.jboss.esb.deploy.DeploymentRuntime}.
@@ -111,7 +127,6 @@
private DeploymentUnit digest(final Document configDoc) throws SAXException, DeploymentException
{
XsdDOMValidator validator = new XsdDOMValidator(configDoc);
-
// Make sure it's a valid configuration...
if (!ConfigurationDigester.XSD_V50.equals(validator.getDefaultNamespace().toString()))
{
@@ -119,12 +134,7 @@
}
try
{
- /*
- * Modified to use this class as the caller to force this to work
- * as an osgi bundle.
- * TODO: revisit this and our osgi strategy as a whole.
- */
- validator.validate(getClass());
+ validator.validate(resourceLocator);
}
catch (IOException e)
{
@@ -159,7 +169,7 @@
Element resources = (Element) resourcesNodeList.item(0);
try
{
- List<Object> resourceObjects = DigestUtil.digestChildElements(resources);
+ List<Object> resourceObjects = DigestUtil.digestChildElements(resources, resourceLocator);
for (Object resourceObject : resourceObjects)
{
@@ -227,7 +237,7 @@
Element inRoutersElement = (Element) inRoutersNodeList.item(i);
try
{
- Map<String, Object> inRoutersObjects = DigestUtil.digestElement(inRoutersElement);
+ Map<String, Object> inRoutersObjects = DigestUtil.digestElement(inRoutersElement, resourceLocator);
List<InboundRouterConfig> inRouters = (List<InboundRouterConfig>) inRoutersObjects.get("inRouters");
List<InboundRouterFilterConfig> inRouterFilters = (List<InboundRouterFilterConfig>) inRoutersObjects.get("inRouterFilters");
@@ -280,7 +290,7 @@
Element outRoutersElement = (Element) outRoutersNodeList.item(i);
try
{
- Map<String, Object> outRoutersObjects = DigestUtil.digestElement(outRoutersElement);
+ Map<String, Object> outRoutersObjects = DigestUtil.digestElement(outRoutersElement, resourceLocator);
List<OutboundRouterConfig> outRouters = (List<OutboundRouterConfig>) outRoutersObjects.get("outRouters");
if(!outRouters.isEmpty())
@@ -321,7 +331,24 @@
Element services = (Element) servicesNodeList.item(0);
try
{
- Map<String, Object> servicesObjects = DigestUtil.digestElement(services);
+ Map<String, Object> servicesObjects;
+
+ /*
+ * This storing/setting/restoring of the context classloader is done to enable Smooks to
+ * find classes and resources.
+ * This is a temporary solution. /Daniel 2008-10-09
+ */
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ servicesObjects = DigestUtil.digestElement(services, resourceLocator);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+
List<ServiceConfig> serviceConfigList = (List<ServiceConfig>) servicesObjects.get("services");
List<InboundRouterConfig> inRouters = (List<InboundRouterConfig>) servicesObjects.get("inRouters");
List<OutboundRouterConfig> outRouters = (List<OutboundRouterConfig>) servicesObjects.get("outRouters");
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/DigestUtil.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
+import org.jboss.esb.classpath.ResourceLocator;
import org.jboss.esb.xml.XMLParseUtils;
import org.milyn.Smooks;
import org.milyn.cdr.SmooksResourceConfigurationList;
@@ -26,7 +27,6 @@
import org.milyn.container.ExecutionContext;
import org.milyn.event.report.HtmlReportGenerator;
import org.milyn.payload.JavaResult;
-import org.milyn.util.ClassUtil;
import org.milyn.xml.DomUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -78,14 +78,15 @@
* The caller needs to sort out and validate the returned list.
*
* @param configurationElement The configuration element.
+ * @param resourceLocator The {@link ResourceLocator} to use.
* @return List of configuration "objects". Returns an empty
* list if there are no child elements.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
*/
- public static List<Object> digestChildElements(final Element configurationElement) throws IOException, SAXException
+ public static List<Object> digestChildElements(final Element configurationElement, final ResourceLocator resourceLocator) throws IOException, SAXException
{
- return digestChildElements(configurationElement, null);
+ return digestChildElements(configurationElement, null, resourceLocator);
}
/**
@@ -96,12 +97,13 @@
*
* @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.
* @return List of configuration "objects". Returns an empty
* list if there are no child elements.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
*/
- public static List<Object> digestChildElements(final Element configurationElement, final String matchElementName) throws IOException, SAXException
+ public static List<Object> digestChildElements(final Element configurationElement, final String matchElementName, final ResourceLocator resourceLocator) throws IOException, SAXException
{
List<Object> configObjects = new ArrayList<Object>();
NodeList children = configurationElement.getChildNodes();
@@ -117,7 +119,7 @@
if (matchElementName == null || DomUtils.getName(subElement).equals(matchElementName))
{
- configObjects.addAll(digestElement(subElement).values());
+ configObjects.addAll(digestElement(subElement, resourceLocator).values());
}
}
}
@@ -142,30 +144,34 @@
* Digest a configuration element and from it produce a list of configuration objects.
*
* @param configurationElement The configuration element.
+ * @param resourceLocator The {@link ResourceLocator} to use.
* @return Digest configuration objects.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
*/
- public static Map<String, Object> digestElement(final Element configurationElement) throws IOException, SAXException
+ public static Map<String, Object> digestElement(final Element configurationElement, final ResourceLocator resourceLocator) throws IOException, SAXException
{
- Smooks smooks = getSmooksInstance(configurationElement);
+ Smooks smooks = getSmooksInstance(configurationElement, resourceLocator);
JavaResult result = new JavaResult();
if (smooks != null)
{
+ ExecutionContext execContext = smooks.createExecutionContext();
+
if (reportPath != null)
{
- ExecutionContext execContext = smooks.createExecutionContext();
+
File reportPathFile = new File(reportPath);
File tsReportPathFile = new File(reportPathFile.getParentFile(), Long.toString(System.currentTimeMillis()) + "-" + reportPathFile.getName());
execContext.setEventListener(new HtmlReportGenerator(new FileWriter(tsReportPathFile)));
- smooks.filter(new DOMSource(configurationElement), result, execContext);
}
- else
- {
- smooks.filter(new DOMSource(configurationElement), result);
- }
+
+ // store the resource locator in the Smooks execution context so that it
+ // can be used by the visitor methods.
+ execContext.setAttribute(ResourceLocator.class, resourceLocator);
+
+ smooks.filter(new DOMSource(configurationElement), result, execContext);
}
return result.getResultMap();
@@ -175,40 +181,42 @@
* Get the Smooks instance for the supplied namespaced element.
*
* @param element The namespaced element.
+ * @param resourceLocator The {@link 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.
*/
- private static Smooks getSmooksInstance(final Element element) throws IOException, SAXException
+ private static Smooks getSmooksInstance(final Element element, final ResourceLocator resourceLocator) throws IOException, SAXException
{
Smooks smooks = new Smooks();
- /*
- * Storing the context classloader which will be reset after usage.
- * This was needed to force our current impl to work nicely with OSGi.
- * TODO: Revisit and update when our OSGi strategy has been set/Dan
- */
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(DigestUtil.class.getClassLoader());
- Set<URI> namespaces = new LinkedHashSet<URI>();
+ Set<URI> namespaces = new LinkedHashSet<URI>();
- XMLParseUtils.gatherElementNamespaces(element, namespaces);
+ XMLParseUtils.gatherElementNamespaces(element, namespaces);
- for (URI namespace : namespaces)
+ for (URI namespace : namespaces)
+ {
+ SmooksResourceConfigurationList configList = null;
+ /*
+ * This storing/setting/restoring of the context classloader is done to enable Smooks to
+ * find classes and resources.
+ * This is a temporary solution. /Daniel 2008-10-09
+ */
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try
{
- SmooksResourceConfigurationList configList = getNamespaceConfig(namespace);
+ Thread.currentThread().setContextClassLoader(Smooks.class.getClassLoader());
+ configList = getNamespaceConfig(namespace, resourceLocator);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
- if (configList != null)
- {
- smooks.getApplicationContext().getStore().addSmooksResourceConfigurationList(configList);
- }
+ if (configList != null)
+ {
+ smooks.getApplicationContext().getStore().addSmooksResourceConfigurationList(configList);
}
}
- finally
- {
- Thread.currentThread().setContextClassLoader(loader);
- }
return smooks;
}
@@ -217,11 +225,12 @@
* Get the namespace configuration for the specified namespace URI.
*
* @param namespace The namespace URI.
+ * @param resourceLocator The {@link ResourceLocator} to use.
* @return The SmooksResourceConfigurationList instance.
* @throws IOException Error reading digests configuration.
* @throws SAXException Error parsing digest configuration.
*/
- private static SmooksResourceConfigurationList getNamespaceConfig(final URI namespace) throws IOException, SAXException
+ private static SmooksResourceConfigurationList getNamespaceConfig(final URI namespace, final ResourceLocator resourceLocator) throws IOException, SAXException
{
SmooksResourceConfigurationList list = null;
@@ -233,13 +242,13 @@
String resPathString = "/META-INF" + namespace.getPath() + "-smooks.xml";
File resPath = new File(resPathString);
String baseURI = resPath.getParent().replace('\\', '/');
- InputStream configStream = ClassUtil.getResourceAsStream(resPathString, DigestUtil.class);
+ InputStream configStream = resourceLocator.getResourceAsStream(resPathString, DigestUtil.class);
if (configStream != null)
{
try
{
- list = XMLConfigDigester.digestConfig(ClassUtil.getResourceAsStream(resPathString, DigestUtil.class), baseURI);
+ list = XMLConfigDigester.digestConfig(resourceLocator.getResourceAsStream(resPathString, DigestUtil.class), baseURI);
}
catch (URISyntaxException e)
{
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/FilterDecisionTreeBuilder.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
+import org.jboss.esb.classpath.ResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.config.ConfigUtil;
import org.jboss.esb.filter.FilterDecisionNode;
@@ -79,7 +80,7 @@
nodeStack.peek().getSubFilters().add(node);
}
- node.setFilterEvaluator(createEvaluator(evaluatorElement));
+ node.setFilterEvaluator(createEvaluator(evaluatorElement, (ResourceLocator) executionContext.getAttribute(ResourceLocator.class)));
nodeStack.push(node);
}
@@ -104,17 +105,18 @@
/**
* Create the evaluator instance from the configuration element.
* @param element The element.
+ * @param resourceLocator The {@link ResourceLocator} to use.
* @return The FilterEvaluator instance.
* @throws SmooksException Error creating {@link FilterEvaluator}.
*/
- private FilterEvaluator createEvaluator(final Element element) throws SmooksException
+ private FilterEvaluator createEvaluator(final Element element, final ResourceLocator resourceLocator) throws SmooksException
{
FilterEvaluator evaluator = null;
String className = DomUtils.getAttributeValue(element, "class");
if (className != null)
{
- evaluator = (FilterEvaluator) CreateObject.createObject(className.trim(), FilterEvaluator.class);
+ evaluator = (FilterEvaluator) CreateObject.createObject(className.trim(), FilterEvaluator.class, resourceLocator);
Properties properties = getProperties(element);
try
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -131,7 +131,7 @@
@Initialize
public final void initialize() throws DeploymentException
{
- ApplicationProperties deploymentProperties = PropertiesUtil.getDeploymentConfig(runtime.getDeploymentName());
+ ApplicationProperties deploymentProperties = PropertiesUtil.getDeploymentConfig(runtime.getDeploymentName(), runtime.getResourceLocator());
// Set the deploymnt monitor timeout - 3 missed heartbeats...
monitorTimeout = (deploymentProperties.getLongProperty(COORDINATOR_HEARTBEAT_FREQUENCY_KEY, COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY) * 3);
@@ -146,10 +146,11 @@
{
new PropertiesIterator(deploymentProperties)
{
- public void processEntry(String busProtocol, String busClassName) throws DeploymentException
+ @Override
+ public void processEntry(final String busProtocol, final String busClassName) throws DeploymentException
{
Bus bus = Bus.Factory.newInstance(busClassName);
- ApplicationProperties busProperties = PropertiesUtil.getBusConfig(busProtocol, runtime.getDeploymentName());
+ ApplicationProperties busProperties = PropertiesUtil.getBusConfig(busProtocol, runtime.getDeploymentName(), runtime.getResourceLocator());
bus.setDeploymentName(runtime.getDeploymentName());
bus.setDeploymentId(runtime.getDeploymentId());
@@ -173,7 +174,7 @@
}
}
}
- }.iterate("bus.");
+ } .iterate("bus.");
}
catch (DeploymentException e)
{
@@ -222,6 +223,7 @@
*
* @throws SchedulingException Exception processing schedule event.
*/
+ @Override
public final void onSchedule() throws SchedulingException
{
if (!busDeployments.isEmpty())
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java (from rev 23356, labs/jbossesb/workspace/skeagh/osgi/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,116 @@
+/*
+ * 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.osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+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/>
+ * This locator will look for and load resources by first looking in
+ * the bundles classpath. Does this violate the OSGi classloading?
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class BundleResourceLocator implements ResourceLocator
+{
+ /**
+ * The OSGi BundleContext instance.
+ */
+ private final Bundle bundle;
+
+ /**
+ * Creates and instance and stores the passed-in BundleContext.
+ *
+ * @param bundle - the OSGi Bundle.
+ */
+ public BundleResourceLocator(final Bundle bundle)
+ {
+ this.bundle = bundle;
+ }
+
+ /**
+ * Load the specified class. Ignores the callers classloader.
+ *
+ * @param className The name of the class to load.
+ * @param caller The class of the caller. Ignored
+ * @return Class The specified class.
+ * @throws ClassNotFoundException If the class cannot be found.
+ */
+ public final Class<?> forName(final String className, final Class<?> caller) throws ClassNotFoundException
+ {
+ try
+ {
+ return forName(className);
+ }
+ catch (final ClassNotFoundException e)
+ {
+ // fallback to normal classloading
+ return ClassUtil.forName(className, caller);
+ }
+ }
+
+ /**
+ * Load the specified class.
+ *
+ * @param className The name of the class to load.
+ * @return Class The specified class.
+ * @throws ClassNotFoundException If the class cannot be found.
+ */
+ public final Class<?> forName(final String className) throws ClassNotFoundException
+ {
+ return bundle.loadClass(className);
+ }
+
+ /**
+ * 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.
+ */
+ public final InputStream getResourceAsStream(final String resourceName, final Class<?> caller)
+ {
+ final URL entry = bundle.getEntry(resourceName);
+ if (entry != null)
+ {
+ try
+ {
+ return entry.openStream();
+ }
+ catch (final IOException ignore)
+ {
+ ignore.printStackTrace();
+ // ignore. Will fallback to normal classloading
+ }
+ }
+ return ClassUtil.getResourceAsStream(resourceName, caller);
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/BundleResourceLocator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/DeploymentRegistry.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/DeploymentRegistry.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/DeploymentRegistry.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,143 @@
+package org.jboss.esb.osgi;
+
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.osgi.framework.Bundle;
+
+/**
+ * DeploymentRegistry keeps tracks of deployed runtimes.
+ * <p/>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class DeploymentRegistry
+{
+ /**
+ * Default name of the config file.
+ */
+ private static final String DEFAULT_CONFIG_FILENAME = "/jboss-esb.xml";
+
+ /**
+ * Header that can be placed in the MANIFEST.MF file to
+ * specify a different config file name then the default one.
+ */
+ private static final String CONFIG_FILE_HEADER = "JBossESB-ConfigFile";
+
+ /**
+ * Set of activated deployments.
+ */
+ private HashMap<Bundle,DeploymentRuntime> activated = new HashMap<Bundle,DeploymentRuntime>();
+
+ /**
+ * Unregisters the DeploymentRuntime.
+ *
+ * @param bundle The bundle to register.
+ */
+ public final void register(final Bundle bundle)
+ {
+ synchronized (activated)
+ {
+ if (activated.containsKey(bundle))
+ {
+ // already registered. Don't need to do anything
+ return;
+ }
+ }
+
+ final URL configUrl = getEsbConfigFile(bundle);
+ if (configUrl == null)
+ {
+ return;
+ }
+
+ try
+ {
+ //TODO: Use logging service
+ System.out.println("Found config : " + configUrl + " for bundle : " + bundle);
+ DeploymentRuntime runtime = DeploymentUtil.createRuntime(configUrl.openStream(), new BundleResourceLocator(bundle));
+ runtime.deploy();
+
+ synchronized (activated)
+ {
+ activated.put(bundle, runtime);
+ }
+ }
+ catch (final Throwable t)
+ {
+ //TODO: add exception handling.
+ t.printStackTrace();
+ }
+ }
+
+ /**
+ * Unregisters the DeploymentRuntime.
+ *
+ * @param bundle the bundle.
+ */
+ public final void unregister(final Bundle bundle)
+ {
+ //TODO: Use logging service
+ System.out.println("unregister bundle: " + bundle);
+ synchronized (activated)
+ {
+ if (!activated.containsKey(bundle))
+ {
+ return;
+ }
+
+ final DeploymentRuntime deploymentRuntime = activated.get(bundle);
+ try
+ {
+ deploymentRuntime.undeploy();
+ }
+ catch (DeploymentException e)
+ {
+ //TODO: Handle exception.
+ e.printStackTrace();
+ }
+ finally
+ {
+ activated.remove(bundle);
+ }
+ }
+ }
+
+ /**
+ * Gets the Esb configuration file from the bundle.
+ *
+ * @param bundle The Bundle being activated.
+ * @return URL URL to the configuration file.
+ *
+ */
+ private URL getEsbConfigFile(final Bundle bundle)
+ {
+ final Dictionary headers = bundle.getHeaders();
+ String configFileName = (String)headers.get(CONFIG_FILE_HEADER);
+ if (configFileName == null)
+ {
+ configFileName = DEFAULT_CONFIG_FILENAME;
+ }
+ return bundle.getEntry(configFileName);
+ }
+
+ /**
+ * Close this registry.
+ */
+ public final void close()
+ {
+ Set<Bundle> keySet = activated.keySet();
+ for (Bundle bundle : keySet)
+ {
+ unregister(bundle);
+ }
+ }
+}
+
+
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/DeploymentRegistry.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java (from rev 23356, labs/jbossesb/workspace/skeagh/osgi/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,141 @@
+/*
+ * 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.osgi;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * EsbServiceDeploymentActivator is an OSGi Activator that takes care
+ * registering the EsbServiceDeployer service.
+ * <p>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class EsbServiceDeploymentActivator implements BundleActivator, BundleListener
+{
+ /**
+ * The BundleContext for this listener.
+ */
+ private BundleContext bundleContext;
+
+ /**
+ * Registry that hold the DeploymentRuntimes.
+ */
+ private DeploymentRegistry registry = new DeploymentRegistry();
+
+ /**
+ * Log service.
+ */
+ private LogService log;
+
+ /**
+ * Activation method that will be called by the Service Component Runtime.
+ * @param cc The ComponentContext.
+ */
+ public final void activate(final ComponentContext cc)
+ {
+ System.out.println("activate...");
+ this.bundleContext = cc.getBundleContext();
+ log.log(LogService.LOG_DEBUG, "activate....");
+
+ bundleContext.addBundleListener(this);
+
+ // get all the currently installed bundles.
+ final Bundle[] bundles = bundleContext.getBundles();
+ for (Bundle bundle : bundles)
+ {
+ if ((bundle.getState() & (Bundle.STARTING | Bundle.ACTIVE)) != 0)
+ {
+ // register the bundles that are esb bundles.
+ registry.register(bundle);
+ }
+ }
+ }
+
+ /**
+ * Called when the OSGi Component Runtime notifies about
+ * changed bundles.
+ *
+ * @param event The event that occured. This method only handles STARTED and STOPPED events.
+ */
+ public final void bundleChanged(final BundleEvent event)
+ {
+ switch (event.getType())
+ {
+ case BundleEvent.STARTED:
+ registry.register(event.getBundle());
+ break;
+
+ case BundleEvent.STOPPED:
+ registry.unregister(event.getBundle());
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Starts the bundle.
+ * Will add this instance as a bundle listener, and register any bundles
+ * containing an esb configuration file.
+ *
+ * @param context The bundle context.
+ * @throws Exception If an exception occurs during startup.
+ */
+ public final void start(final BundleContext context) throws Exception
+ {
+ System.out.println("activate...");
+ this.bundleContext = context;
+
+ context.addBundleListener(this);
+
+ // get all the currently installed bundles.
+ final Bundle[] bundles = context.getBundles();
+ for (final Bundle bundle : bundles)
+ {
+ if ((bundle.getState() & (Bundle.STARTING | Bundle.ACTIVE)) != 0)
+ {
+ // register and deploy the bundles that are esb bundles.
+ registry.register(bundle);
+ }
+ }
+ }
+
+ /**
+ * Stops this bundle.
+ * Will close the underlying registry of DeploymentRuntime, going
+ * through them and undeploying them.
+ *
+ * @param unused The bundle context.
+ * @throws Exception If an exception occurs during startup.
+ */
+ public final void stop(final BundleContext unused) throws Exception
+ {
+ registry.close();
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/EsbServiceDeploymentActivator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SchedulingException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SchedulingException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SchedulingException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,8 +19,9 @@
*/
package org.jboss.esb.schedule;
-import org.jboss.esb.JBossESBException;
+import org.jboss.esb.exception.JBossESBException;
+
/**
* Scheduling Exception.
*
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/serialization/SerializationException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/serialization/SerializationException.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/serialization/SerializationException.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,8 +19,9 @@
*/
package org.jboss.esb.serialization;
-import org.jboss.esb.JBossESBException;
+import org.jboss.esb.exception.JBossESBException;
+
/**
* Serialization/Deserialization Exception.
*
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/resources/jndi.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/resources/jndi.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/resources/jndi.properties 2008-10-09 20:28:16 UTC (rev 23409)
@@ -0,0 +1,16 @@
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.jbossesb.TestQueue = jbossesb.TestQueue
+
+queue.jbossesb.jms.bus = jbossesb.jms.bus
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+topic.jbossesb.deployment.coordintation.topic = jbossesb.deployment.coordintation.topic
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/resources/log4j.xml 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/resources/log4j.xml 2008-10-09 20:28:16 UTC (rev 23409)
@@ -39,7 +39,7 @@
</category>
<category name="org.jboss">
- <priority value="error"/>
+ <priority value="debug"/>
</category>
<category name="org.apache.activemq">
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-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/DefaultConfigurationDigesterTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy.config;
+import org.jboss.esb.classpath.DefaultResourceLocator;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester;
import org.jboss.esb.deploy.config.digest.DigestUtil;
@@ -501,7 +502,7 @@
private DeploymentUnit digest(String config) throws IOException, DeploymentException
{
- DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester(new DefaultResourceLocator());
return digester.digest(getClass().getResourceAsStream(config));
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/FilterConfigTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/FilterConfigTest.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/FilterConfigTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -24,6 +24,7 @@
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;
@@ -88,7 +89,7 @@
evaluator = filters.get(1).getEvaluator();
assertFalse(evaluator.filterMessage(new Message("hello")));
- assertTrue(evaluator.filterMessage(new Message("goodbye")));
+ assertTrue(evaluator.filterMessage(new Message("goodbye")));
}
finally
{
@@ -179,7 +180,7 @@
private DeploymentUnit digest(String config) throws IOException, DeploymentException
{
- DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester(new DefaultResourceLocator());
return digester.digest(getClass().getResourceAsStream(config));
}
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/ConfigUtilTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/ConfigUtilTest.java 2008-10-09 19:55:48 UTC (rev 23408)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/ConfigUtilTest.java 2008-10-09 20:28:16 UTC (rev 23409)
@@ -19,13 +19,14 @@
*/
package org.jboss.esb.deploy.config.digest;
+import java.util.Properties;
+
import junit.framework.TestCase;
+
import org.jboss.esb.annotations.Property;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.config.ConfigUtil;
-import java.util.Properties;
-
/**
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
More information about the jboss-svn-commits
mailing list