[jboss-svn-commits] JBL Code SVN: r21525 - in labs/jbossesb/workspace/skeagh: api and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 13 17:30:22 EDT 2008
Author: tfennelly
Date: 2008-08-13 17:30:22 -0400 (Wed, 13 Aug 2008)
New Revision: 21525
Added:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationDigester.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DefaultConfigurationDigester.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/package.html
Removed:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ConfigurationUnit.java
Modified:
labs/jbossesb/workspace/skeagh/
labs/jbossesb/workspace/skeagh/api/
labs/jbossesb/workspace/skeagh/api/routing/
labs/jbossesb/workspace/skeagh/api/service/
labs/jbossesb/workspace/skeagh/commons/
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XMLParseUtils.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java
labs/jbossesb/workspace/skeagh/runtime/
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/Deployment.java
Log:
some config parts
Property changes on: labs/jbossesb/workspace/skeagh
___________________________________________________________________
Name: svn:ignore
+ jbossesb.iml
jbossesb.ipr
jbossesb.iws
Property changes on: labs/jbossesb/workspace/skeagh/api
___________________________________________________________________
Name: svn:ignore
+ api.iml
Property changes on: labs/jbossesb/workspace/skeagh/api/routing
___________________________________________________________________
Name: svn:ignore
+ jbossesb-api-routing.iml
jbossesb-routing-api.iml
Property changes on: labs/jbossesb/workspace/skeagh/api/service
___________________________________________________________________
Name: svn:ignore
+ jbossesb-api-service.iml
jbossesb-service-api.iml
Property changes on: labs/jbossesb/workspace/skeagh/commons
___________________________________________________________________
Name: svn:ignore
+ jbossesb-commons.iml
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XMLParseUtils.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XMLParseUtils.java 2008-08-13 19:01:18 UTC (rev 21524)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/xml/XMLParseUtils.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -21,12 +21,15 @@
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
/**
* XML Parsing utilities.
@@ -51,14 +54,29 @@
* @throws IOException Error reading document stream.
* @throws SAXException XML parse error.
*/
- public static Document parseStream(final InputStream stream) throws ParserConfigurationException, IOException, SAXException
+ public static Document parse(final InputStream stream) throws ParserConfigurationException, IOException, SAXException
{
+ Reader reader = new InputStreamReader(stream, "UTF-8");
+ return parse(reader);
+ }
+
+ /**
+ * Basic DOM namespace aware parse.
+ *
+ * @param reader Document stream.
+ * @return Document instance.
+ * @throws ParserConfigurationException Parser config error.
+ * @throws IOException Error reading document stream.
+ * @throws SAXException XML parse error.
+ */
+ public static Document parse(Reader reader) throws ParserConfigurationException, SAXException, IOException
+ {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder;
factory.setNamespaceAware(true);
docBuilder = factory.newDocumentBuilder();
- return docBuilder.parse(stream);
+ return docBuilder.parse(new InputSource(reader));
}
}
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-08-13 19:01:18 UTC (rev 21524)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/xml/XsdDOMValidatorTest.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -33,7 +33,7 @@
public class XsdDOMValidatorTest extends TestCase {
public void test_namespace_gathering() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parseStream(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
XsdDOMValidator validator = new XsdDOMValidator(document);
assertEquals("http://www.milyn.org/xsd/test-xsd-01.xsd", validator.getDefaultNamespace().toString());
@@ -41,14 +41,14 @@
}
public void test_validation_validdoc() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parseStream(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
XsdDOMValidator validator = new XsdDOMValidator(document);
validator.validate();
}
public void test_validation_invaliddoc() throws IOException, SAXException, ParserConfigurationException {
- Document document = XMLParseUtils.parseStream(getClass().getResourceAsStream("xsdDomValidator-test-02.xml"));
+ Document document = XMLParseUtils.parse(getClass().getResourceAsStream("xsdDomValidator-test-02.xml"));
XsdDOMValidator validator = new XsdDOMValidator(document);
try {
Property changes on: labs/jbossesb/workspace/skeagh/runtime
___________________________________________________________________
Name: svn:ignore
+ jbossesb-rt.iml
Deleted: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ConfigurationUnit.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ConfigurationUnit.java 2008-08-13 19:01:18 UTC (rev 21524)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ConfigurationUnit.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
- */
-package org.jboss.esb.deploy;
-
-import org.jboss.esb.routing.InboundRouter;
-import org.jboss.esb.routing.OutboundRouter;
-import org.jboss.esb.service.Service;
-import org.jboss.esb.service.ServiceName;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * JBoss ESB Configuration Unit.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class ConfigurationUnit
-{
- /**
- * List of Inbound routers defined in the configuration.
- */
- private List<InboundRouter> inboundRouters = new ArrayList<InboundRouter>();
- /**
- * List of Services defined in the configuration.
- */
- private Map<ServiceName, Service> services = new LinkedHashMap<ServiceName, Service>();
- /**
- * List of Outbound routers defined in the configuration.
- */
- private List<OutboundRouter> outboundRouters = new ArrayList<OutboundRouter>();
-
- /**
- * Public constructor.
- *
- * @param configStream Configuration stream.
- */
- public ConfigurationUnit(final Reader configStream)
- {
- // TODO digest the config stream into the list of routers and services...
- }
-
- /**
- * Get the List of Inbound routers defined in the configuration.
- *
- * @return The List of Inbound routers defined in the configuration.
- */
- public final List<InboundRouter> getInboundRouters()
- {
- return inboundRouters;
- }
-
- /**
- * Get the List of Services defined in the configuration (mapped by ServiceName).
- *
- * @return The List of Inbound routers defined in the configuration.
- */
- public final Map<ServiceName, Service> getServices()
- {
- return services;
- }
-
- /**
- * Get the List of Outbound routers defined in the configuration.
- *
- * @return The List of Outbound routers defined in the configuration.
- */
- public final List<OutboundRouter> getOutboundRouters()
- {
- return outboundRouters;
- }
-}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/Deployment.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/Deployment.java 2008-08-13 19:01:18 UTC (rev 21524)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/Deployment.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -21,6 +21,7 @@
import org.jboss.esb.context.DeploymentContext;
import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.deploy.config.ConfigurationUnit;
import java.util.ArrayList;
import java.util.List;
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationDigester.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationDigester.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationDigester.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.deploy.config;
+
+import org.jboss.esb.deploy.DeploymentException;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Configuration Digester.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface ConfigurationDigester
+{
+
+ /**
+ * JBoss ESB 5.0 Namespace URI.
+ */
+ public static final String XSD_v50 = "http://www.jboss.org/esb/jbossesb-5.0.xsd";
+
+ /**
+ * Digest the supplied configuration stream.
+ * <p/>
+ * Produces a {@link ConfigurationUnit} that can be added to a {@link org.jboss.esb.deploy.Deployment}.
+ *
+ * @param configStream The configuration Stream.
+ * @return A configuration unit.
+ * @throws IOException Error reading the configuration stream.
+ * @throws DeploymentException Error in the supplied configuration data.
+ */
+ ConfigurationUnit digest(final Reader configStream) throws IOException, DeploymentException;
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationDigester.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java (from rev 21523, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/ConfigurationUnit.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.deploy.config;
+
+import org.jboss.esb.routing.InboundRouter;
+import org.jboss.esb.routing.OutboundRouter;
+import org.jboss.esb.service.Service;
+import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.util.AssertArgument;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * JBoss ESB Configuration Unit.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ConfigurationUnit
+{
+ /**
+ * List of Inbound routers defined in the configuration.
+ */
+ private Map<ServiceName, InboundRouter> inboundRouters = new LinkedHashMap<ServiceName, InboundRouter>();
+ /**
+ * List of Services defined in the configuration.
+ */
+ private Map<ServiceName, Service> services = new LinkedHashMap<ServiceName, Service>();
+ /**
+ * List of Outbound routers defined in the configuration.
+ */
+ private Map<ServiceName, OutboundRouter> outboundRouters = new LinkedHashMap<ServiceName, OutboundRouter>();
+
+ /**
+ * Add an inbounder router for a service.
+ *
+ * @param inboundRouter The inbound router instance.
+ * @param serviceName The service that the inbound router is associated with.
+ */
+ public void add(InboundRouter inboundRouter, ServiceName serviceName)
+ {
+ AssertArgument.isNotNull(inboundRouter, "inboundRouter");
+ AssertArgument.isNotNull(serviceName, "serviceName");
+ inboundRouters.put(serviceName, inboundRouter);
+ }
+
+ /**
+ * Add a service instance for a given service name.
+ *
+ * @param service The Service instance.
+ * @param serviceName The Service name.
+ */
+ public void add(Service service, ServiceName serviceName)
+ {
+ AssertArgument.isNotNull(service, "service");
+ AssertArgument.isNotNull(serviceName, "serviceName");
+ services.put(serviceName, service);
+ }
+
+ /**
+ * Add an outbounder router for a service.
+ *
+ * @param outboundRouter The outbound router instance.
+ * @param serviceName The Service name.
+ */
+ public void add(OutboundRouter outboundRouter, ServiceName serviceName)
+ {
+ AssertArgument.isNotNull(outboundRouter, "outboundRouter");
+ AssertArgument.isNotNull(serviceName, "serviceName");
+ outboundRouters.put(serviceName, outboundRouter);
+ }
+
+ /**
+ * Get the List of Inbound routers defined in the configuration (mapped by ServiceName).
+ *
+ * @return The List of Inbound routers defined in the configuration.
+ */
+ public final Map<ServiceName, InboundRouter> getInboundRouters()
+ {
+ return inboundRouters;
+ }
+
+ /**
+ * Get the List of Services defined in the configuration (mapped by ServiceName).
+ *
+ * @return The List of Inbound routers defined in the configuration.
+ */
+ public final Map<ServiceName, Service> getServices()
+ {
+ return services;
+ }
+
+ /**
+ * Get the List of Outbound routers defined in the configuration (mapped by ServiceName).
+ *
+ * @return The List of Outbound routers defined in the configuration.
+ */
+ public final Map<ServiceName, OutboundRouter> getOutboundRouters()
+ {
+ return outboundRouters;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DefaultConfigurationDigester.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DefaultConfigurationDigester.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DefaultConfigurationDigester.java 2008-08-13 21:30:22 UTC (rev 21525)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.deploy.config;
+
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.xml.XMLParseUtils;
+import org.jboss.esb.xml.XsdDOMValidator;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Default Configuration Digester.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DefaultConfigurationDigester implements ConfigurationDigester
+{
+ /**
+ * Digest the supplied configuration stream.
+ * <p/>
+ * Produces a {@link ConfigurationUnit} that can be added to a {@link org.jboss.esb.deploy.Deployment}.
+ *
+ * @param configStream The configuration Stream.
+ * @return A configuration unit.
+ * @throws IOException Error reading the configuration stream.
+ * @throws DeploymentException Error in the supplied configuration data.
+ */
+ public final ConfigurationUnit digest(final Reader configStream) throws IOException, DeploymentException
+ {
+ AssertArgument.isNotNull(configStream, "configStream");
+
+ try
+ {
+ Document configDoc = XMLParseUtils.parse(configStream);
+ return digest(configDoc);
+ } catch (ParserConfigurationException e)
+ {
+ throw new DeploymentException("Parser configuration error parsing JBoss ESB Configuration.", e);
+ } catch (SAXException e)
+ {
+ throw new DeploymentException("Configuration format error parsing JBoss ESB Configuration..", e);
+ }
+ }
+
+ /**
+ * Digest the supplied configuration document.
+ *
+ * @param configDoc The configuration document.
+ * @return A configuration unit.
+ * @throws SAXException Error digesting document.
+ */
+ private ConfigurationUnit digest(Document configDoc) throws SAXException, DeploymentException
+ {
+ XsdDOMValidator validator = new XsdDOMValidator(configDoc);
+
+ // Make sure it's a valid configuration...
+ if(!ConfigurationDigester.XSD_v50.equals(validator.getDefaultNamespace())) {
+ throw new DeploymentException("Invalid JBoss ESB Configuration. Default Namespace expected to be '" + ConfigurationDigester.XSD_v50 + "'. Default Namespace was '" + validator.getDefaultNamespace() + "'.");
+ }
+ try
+ {
+ validator.validate();
+ } catch (IOException e)
+ {
+ throw new DeploymentException("Error reading configuration schemas.", e);
+ // The XsdDOMValidator.validate() method throws a SAXException if there's an actual config validation error!
+ }
+
+ // It's a valid configuration, so lets extract the router (in/out) and service instances from it
+ // and create a ConfigurationUnit ...
+ ConfigurationUnit configurationtUnit = new ConfigurationUnit();
+
+ // TODO....
+
+ return configurationtUnit;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/DefaultConfigurationDigester.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/package.html (from rev 21523, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/package.html)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/package.html 2008-08-13 21:30:22 UTC (rev 21525)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+ESB Deployment Configuration.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list