[jboss-svn-commits] JBL Code SVN: r8325 - in labs/jbossesb/trunk/product/core/listeners: src/org/jboss/soa/esb/listeners/config src/org/jboss/soa/esb/listeners/config/mappers tests/src/org/jboss/soa/esb/listeners/config
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 14 13:48:04 EST 2006
Author: tfennelly
Date: 2006-12-14 13:47:51 -0500 (Thu, 14 Dec 2006)
New Revision: 8325
Added:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/NotificationMapper.java
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/Generator.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/YADOMUtil.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java
Log:
more xsd mods
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -21,8 +21,14 @@
package org.jboss.soa.esb.listeners.config;
+import java.util.List;
+
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.config.JmsListenerDocument.JmsListener;
+import org.jboss.soa.esb.listeners.config.mappers.ActionMapper;
+import org.jboss.soa.esb.listeners.config.mappers.JmsListenerMapper;
+import org.jboss.soa.esb.listeners.config.mappers.NotificationMapper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -56,11 +62,35 @@
*/
protected Document generate() throws ConfigurationException {
Document doc = YADOMUtil.createDocument();
- @SuppressWarnings("unused")
Element root = YADOMUtil.addElement(doc, "jbossesb");
-
+ // Iterate over all the ESB Aware listner configs and map them to the listener configuration...
+ List<Listener> listeners = model.getESBAwareListeners();
+ for(Listener listener : listeners) {
+ addESBAwareConfig(root, listener);
+ }
+
return doc;
}
+ /**
+ * Add a single ESB Aware Listener configuration node to configuration root.
+ * @param root Configuration root node.
+ * @param listener The ESB Aware Listener configuration to be added.
+ * @throws ConfigurationException Invalid listener configuration.
+ */
+ private void addESBAwareConfig(Element root, Listener listener) throws ConfigurationException {
+ Element configTree;
+
+ // Of course we could do the following reflectively if we really want to - TODO perhaps!!
+ if(listener instanceof JmsListener) {
+ configTree = JmsListenerMapper.map(root, (JmsListener)listener, model);
+ } else {
+ throw new ConfigurationException("Unsupported ESB Aware listener type [" + listener.getClass().getName() + "]. No mapper class configured.");
+ }
+
+ // Map the actions and notiications...
+ ActionMapper.map(configTree, listener, model);
+ NotificationMapper.map(configTree, listener, model);
+ }
}
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -21,8 +21,12 @@
package org.jboss.soa.esb.listeners.config;
+import java.util.List;
+
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.config.JmsListenerDocument.JmsListener;
+import org.jboss.soa.esb.listeners.config.mappers.JmsListenerMapper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -56,13 +60,30 @@
*/
protected Document generate() throws ConfigurationException {
Document doc = YADOMUtil.createDocument();
-
- @SuppressWarnings("unused")
- Element element = YADOMUtil.addElement(doc, "esb-config");
+ Element root = YADOMUtil.addElement(doc, "esb-config");
- // TODO: Add the listener configuration nodes....
+ // Iterate over all the gateway configs and map them to the gateway configuration...
+ List<Listener> gateways = model.getGatewayListeners();
+ for(Listener gateway : gateways) {
+ addGatewayConfig(root, gateway);
+ }
return doc;
}
+ /**
+ * Add a single gateway configuration node to configuration root.
+ * @param root Configuration root node.
+ * @param gateway The Gateway Listener configuration to be added.
+ * @throws ConfigurationException Invalid listener configuration.
+ */
+ private void addGatewayConfig(Element root, Listener gateway) throws ConfigurationException {
+
+ // Of course we could do the following reflectively if we really want to - TODO perhaps!!
+ if(gateway instanceof JmsListener) {
+ JmsListenerMapper.map(root, (JmsListener)gateway, model);
+ } else {
+ throw new ConfigurationException("Unsupported Gateway listener type [" + gateway.getClass().getName() + "]. No mapper class configured.");
+ }
+ }
}
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/Generator.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/Generator.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/Generator.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -24,12 +24,15 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.xmlbeans.XmlException;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.listeners.config.JbossesbDocument;
//import org.jboss.soa.esb.listeners.config.BusDocument.Bus;
import org.jboss.soa.esb.listeners.config.JbossesbDocument.Jbossesb;
+import org.jboss.soa.esb.listeners.config.ServiceDocument.Service;
//import org.jboss.soa.esb.listeners.config.ListenerDocument.Listener;
//import org.jboss.soa.esb.listeners.config.ServerDocument.Server;
import org.w3c.dom.Document;
@@ -117,14 +120,21 @@
Document awareConfig = awareGenerator.generate();
YADOMUtil.serialize(awareConfig, outdir, ESB_CONFIG_XML_FILE);
}
+
+ /**
+ * Get the model instance associate with the configuration used to create this Generator instance.
+ * @return Returns the model.
+ */
+ protected XMLBeansModel getModel() {
+ return model;
+ }
-
/**
* XMLBeans based model implementation.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
- protected class XMLBeansModel {
+ public class XMLBeansModel {
/**
* XMLBeans config model instance.
@@ -139,5 +149,77 @@
private XMLBeansModel(JbossesbDocument xmlBeansDoc) {
this.jbossesb = xmlBeansDoc.getJbossesb();
}
+
+ /**
+ * Get the list of ESB Gateway Listeners from the configuration.
+ * @return The list of ESB Gateway Listeners from the configuration.
+ */
+ public List<Listener> getGatewayListeners() {
+ return getListeners(true);
+ }
+
+ /**
+ * Get the list of ESB Aware Listeners from the configuration.
+ * @return The list of ESB Aware Listeners from the configuration.
+ */
+ public List<Listener> getESBAwareListeners() {
+ return getListeners(false);
+ }
+
+ /**
+ * Get the Service to which the supplied {@link Listener} configuration instance is bound.
+ * @param listener The listener instance (Gateway or ESB Aware).
+ * @return The Service to which the
+ */
+ public Service getService(Listener listener) {
+ Service[] services = jbossesb.getServices().getServiceArray();
+
+ for(Service service : services) {
+ for(Listener serviceListener : service.getListeners().getListenerArray()) {
+ if(serviceListener == listener) {
+ return service;
+ }
+ }
+ }
+
+ throw new IllegalStateException("No Service instance found for the supplied Listener instance. This should not be possible if the Listener instance was provided by this configuration. Where has this Listener instance come from?");
+ }
+
+ /**
+ * Get the <bus> configuration matching the supplied busid reference value.
+ * @param busid The required <bus> configuration reference value.
+ * @return The Bus configuration instance.
+ * @throws ConfigurationException Unknown busid reference value.
+ */
+ public Bus getBus(String busid) throws ConfigurationException {
+ Bus[] buses = jbossesb.getBuses().getBusArray();
+
+ for(Bus bus : buses) {
+ if(bus.getBusid().equals(busid)) {
+ return bus;
+ }
+ }
+
+ throw new ConfigurationException("Invalid ESB Configuration: No <bus> configuration matching busid reference value [" + busid + "].");
+ }
+
+ /**
+ * Get the list of ESB Listeners based on their Gateway flag.
+ * @return The list of ESB Aware or Gateway Listeners from the configuration.
+ */
+ private List<Listener> getListeners(boolean isGateway) {
+ List<Listener> gateways = new ArrayList<Listener>();
+ Service[] services = jbossesb.getServices().getServiceArray();
+
+ for(Service service : services) {
+ for(Listener listener : service.getListeners().getListenerArray()) {
+ if(listener.getIsGateway() == isGateway) {
+ gateways.add(listener);
+ }
+ }
+ }
+
+ return gateways;
+ }
}
}
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/YADOMUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/YADOMUtil.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/YADOMUtil.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -36,95 +36,71 @@
/**
* Yet another set of DOM utility methods.
+ * <p/>
+ * PLEASE DO NOT USE THIS CLASS OUTSIDE THIS PACKAGE. It will be removed as soon as we find
+ * equivalent DOM support methods somewhere else, or find a more appropriate home for these.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @deprecated Do not reuse this class outside this package.
*/
-class YADOMUtil
-{
+public class YADOMUtil {
- // If there are another set of the same utilities somewhere, or another
- // DOMUtil type class
+ // If there are another set of the same utilities somewhere, or another DOMUtil type class
// that we can add them too, we should do that :-)
-
+
/**
- * Create a new W3C Document. <p/> Handles exceptions etc.
- *
+ * Create a new W3C Document.
+ * <p/>
+ * Handles exceptions etc.
* @return The new Document instance.
- * @throws ConfigurationException
+ * @throws ConfigurationException
*/
- protected static Document createDocument() throws ConfigurationException
- {
+ public static Document createDocument() throws ConfigurationException {
Document doc = null;
-
- try
- {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
- .newDocument();
+
+ try {
+ doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new ConfigurationException("Failed to create ESB Configuration Document instance.", e);
}
- catch (ParserConfigurationException e)
- {
- throw new ConfigurationException(
- "Failed to create ESB Configuration Document instance.", e);
- }
-
+
return doc;
}
/**
* Add an Element node to the supplied parent name.
- *
- * @param parent
- * The parent to to which the new Element node is to be added.
- * @param elementName
- * The name of the Element to be added.
+ * @param parent The parent to to which the new Element node is to be added.
+ * @param elementName The name of the Element to be added.
* @return The new Element.
*/
- protected static Element addElement(Node parent, String elementName)
- {
+ public static Element addElement(Node parent, String elementName) {
Element element = null;
-
- if (parent instanceof Document)
- {
- element = ((Document) parent).createElement(elementName);
- }
- else
- {
+
+ if(parent instanceof Document) {
+ element = ((Document)parent).createElement(elementName);
+ } else {
element = parent.getOwnerDocument().createElement(elementName);
}
parent.appendChild(element);
-
+
return element;
}
/**
- * Serialize the supplied Document to the specified file in the specified
- * output directory.
- *
- * @param doc
- * The document to be serialised.
- * @param outdir
- * The directory into which the file is to be serialised.
- * @param fileName
- * The name of the file.
- * @throws ConfigurationException
- * Unable to serialise the document.
+ * Serialize the supplied Document to the specified file in the specified output directory.
+ * @param doc The document to be serialised.
+ * @param outdir The directory into which the file is to be serialised.
+ * @param fileName The name of the file.
+ * @throws ConfigurationException Unable to serialise the document.
*/
- protected static void serialize(Document doc, File outdir, String fileName)
- throws ConfigurationException
- {
+ public static void serialize(Document doc, File outdir, String fileName) throws ConfigurationException {
DOMSource domSource = new DOMSource(doc);
StreamResult streamRes = new StreamResult(new File(outdir, fileName));
-
- try
- {
- TransformerFactory.newInstance().newTransformer().transform(
- domSource, streamRes);
+
+ try {
+ TransformerFactory.newInstance().newTransformer().transform(domSource, streamRes);
+ } catch (Exception e) {
+ throw new ConfigurationException("Failed to serialize ESB Configuration Document instance.", e);
}
- catch (Exception e)
- {
- throw new ConfigurationException(
- "Failed to serialize ESB Configuration Document instance.",
- e);
- }
}
}
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -0,0 +1,44 @@
+/*
+ * 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,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.listeners.config.Listener;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ActionMapper {
+
+ /**
+ * @param configTree
+ * @param listener
+ * @param model
+ */
+ public static void map(Element configTree, Listener listener, XMLBeansModel model) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -0,0 +1,84 @@
+/*
+ * 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,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.config.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.config.JmsBusDocument.JmsBus;
+import org.jboss.soa.esb.listeners.config.JmsListenerDocument.JmsListener;
+import org.jboss.soa.esb.listeners.config.ServiceDocument.Service;
+import org.jboss.soa.esb.listeners.gateway.JmsGatewayListener;
+import org.jboss.soa.esb.listeners.message.JmsQueueListener;
+import org.w3c.dom.Element;
+
+/**
+ * Performs the mapping of a <jms-listener> XSD based configuration to the "ConfigTree"
+ * style configuration, adding the "ConfigTree" listener config to the "root" node.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JmsListenerMapper {
+
+ /**
+ * Perform the mapping.
+ * @param root The "ConfigTree" configuration root node.
+ * @param listener The Jmslistener to be mapped into the ConfigTree.
+ * @param model The model from which the Listener instance belongs.
+ * @param The ConfigTree listener configuration node.
+ * @throws ConfigurationException Invalid listener configuration.
+ */
+ public static Element map(Element root, JmsListener listener, XMLBeansModel model) throws ConfigurationException {
+ Element listenerNode = YADOMUtil.addElement(root, "listener-config");
+ Service service = model.getService(listener);
+ JmsBus bus;
+
+ try {
+ bus = (JmsBus) model.getBus(listener.getBusidref());
+ }catch (ClassCastException e) {
+ throw new ConfigurationException("Invalid busid reference [" + listener.getBusidref() + "] on listener [" + listener.getName() + "]. A <jms-listener> must reference a <jms-bus>.");
+ }
+
+ if(listener.getIsGateway()) {
+ listenerNode.setAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, service.getCategory());
+ listenerNode.setAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG, service.getName());
+ listenerNode.setAttribute("gatewayClass", JmsGatewayListener.class.getName());
+ } else {
+ listenerNode.setAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, service.getCategory());
+ listenerNode.setAttribute(ListenerTagNames.SERVICE_NAME_TAG, service.getName());
+ listenerNode.setAttribute(ListenerTagNames.SERVICE_DESCRIPTION_TAG, service.getDescription());
+ listenerNode.setAttribute("listenerClass", JmsQueueListener.class.getName());
+ listenerNode.setAttribute(ListenerTagNames.EPR_DESCRIPTION_TAG, listener.getName());
+ }
+
+ listenerNode.setAttribute(JMSEpr.DESTINATION_TYPE_TAG, listener.getDestinationType().toString().toLowerCase());
+ listenerNode.setAttribute(JMSEpr.DESTINATION_TYPE_TAG, listener.getDestinationName());
+ listenerNode.setAttribute(JMSEpr.CONNECTION_FACTORY_TAG, bus.getConnectionFactory());
+ listenerNode.setAttribute(JMSEpr.JNDI_CONTEXT_FACTORY, bus.getJndiContextFactory());
+ listenerNode.setAttribute(JMSEpr.JNDI_PKG_PREFIX_TAG, bus.getJndiPkgPrefix());
+ listenerNode.setAttribute(JMSEpr.JNDI_URL_TAG, bus.getJndiURL());
+
+ return listenerNode;
+ }
+}
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/NotificationMapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/NotificationMapper.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/NotificationMapper.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -0,0 +1,44 @@
+/*
+ * 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,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.listeners.config.Listener;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class NotificationMapper {
+
+ /**
+ * @param configTree
+ * @param listener
+ * @param model
+ */
+ public static void map(Element configTree, Listener listener, XMLBeansModel model) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java 2006-12-14 18:32:33 UTC (rev 8324)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java 2006-12-14 18:47:51 UTC (rev 8325)
@@ -23,12 +23,14 @@
import java.io.File;
import java.io.IOException;
+import java.util.List;
import org.apache.xmlbeans.XmlException;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.listeners.config.Generator;
import org.jboss.soa.esb.listeners.config.ActionDocument.Action;
import org.jboss.soa.esb.listeners.config.BusesDocument.Buses;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
import org.jboss.soa.esb.listeners.config.JbossesbDocument.Jbossesb;
import org.jboss.soa.esb.listeners.config.JmsBusDocument.JmsBus;
import org.jboss.soa.esb.listeners.config.JmsListenerDocument.JmsListener;
@@ -47,48 +49,6 @@
private File gatewayConfig;
private File awareConfig;
- public void test_xmlbeansmodel() throws XmlException, IOException {
- JbossesbDocument doc = JbossesbDocument.Factory.parse(getClass().getResourceAsStream("jbossesb_config_01.xml"));
- Jbossesb jbossesb = doc.getJbossesb();
- Buses buses = jbossesb.getBuses();
- Service service;
-
- // Check the bus..
- assertEquals(1, buses.getBusArray().length);
- JmsBus bus = (JmsBus)buses.getBusArray(0);
- assertEquals("server1-jms", bus.getBusid());
- assertEquals("ConnectionFactory", bus.getConnectionFactory());
- assertEquals("org.jnp.interfaces.NamingContextFactory", bus.getJndiContextFactory());
- assertEquals("localhost", bus.getJndiURL());
-
- assertEquals(1, jbossesb.getServices().getServiceArray().length);
- service = jbossesb.getServices().getServiceArray(0);
- assertEquals("Bank", service.getCategory());
- assertEquals("Reconciliation", service.getName());
- assertEquals("Bank Reconciliation Service", service.getDescription());
-
- assertEquals(2, service.getListeners().getListenerArray().length);
- JmsListener listener = (JmsListener)service.getListeners().getListenerArray(0);
- assertEquals("Bank-JMS-Gateway", listener.getName());
- assertEquals("server1-jms", listener.getBusidref());
- assertTrue(listener.getIsGateway());
- assertEquals("queue/A", listener.getDestinationName());
- assertEquals(JmsListener.DestinationType.QUEUE, listener.getDestinationType());
- assertEquals("service='Reconciliation'", listener.getMessageSelector());
- assertEquals(1, listener.getMaxThreads());
-
- Action[] actions = service.getActions().getActionArray();
- assertEquals(1, actions.length);
- assertEquals("TestDefaultRouteAction", actions[0].getName());
- assertEquals("org.jboss.soa.esb.actions.CbrProxyAction", actions[0].getClass1());
- assertEquals("route", actions[0].getProcess());
-
- assertEquals(1, actions[0].getPropertyArray().length);
- Property property = actions[0].getPropertyArray(0);
- assertEquals("propName", property.getName());
- assertEquals("propValue", property.getValue());
-}
-
public void test_constructor() throws ConfigurationException, IOException {
try {
new Generator(null);
@@ -114,6 +74,46 @@
assertTrue(awareConfig.exists());
}
+ public void test_model() throws ConfigurationException, IOException {
+ Generator generator = new Generator(getClass().getResourceAsStream("jbossesb_config_01.xml"));
+ XMLBeansModel model = generator.getModel();
+
+ JmsBus bus = (JmsBus)model.getBus("server1-jms");
+ assertEquals("server1-jms", bus.getBusid());
+ assertEquals("ConnectionFactory", bus.getConnectionFactory());
+ assertEquals("org.jnp.interfaces.NamingContextFactory", bus.getJndiContextFactory());
+ assertEquals("localhost", bus.getJndiURL());
+
+ List<Listener> gateways = model.getGatewayListeners();
+ assertEquals(1, gateways.size());
+ JmsListener gatewayListener = (JmsListener)gateways.get(0);
+ assertEquals("Bank-JMS-Gateway", gatewayListener.getName());
+ assertEquals("server1-jms", gatewayListener.getBusidref());
+ assertTrue(gatewayListener.getIsGateway());
+ assertEquals("queue/A", gatewayListener.getDestinationName());
+ assertEquals(JmsListener.DestinationType.QUEUE, gatewayListener.getDestinationType());
+ assertEquals("service='Reconciliation'", gatewayListener.getMessageSelector());
+ assertEquals(1, gatewayListener.getMaxThreads());
+
+ List<Listener> awareListeners = model.getESBAwareListeners();
+ assertEquals(1, awareListeners.size());
+ JmsListener awareListener = (JmsListener)awareListeners.get(0);
+ assertEquals("Bank-Listener", awareListener.getName());
+ assertEquals("server1-jms", awareListener.getBusidref());
+ assertTrue(!awareListener.getIsGateway());
+ assertEquals("queue/B", awareListener.getDestinationName());
+ assertEquals(JmsListener.DestinationType.TOPIC, awareListener.getDestinationType());
+ assertEquals("service='Reconciliation'", awareListener.getMessageSelector());
+ assertEquals(2, awareListener.getMaxThreads());
+
+ Service gatewayService = model.getService(gatewayListener);
+ Service awareService = model.getService(awareListener);
+ assertEquals(gatewayService, awareService);
+ assertEquals("Bank", gatewayService.getCategory());
+ assertEquals("Reconciliation", gatewayService.getName());
+ assertEquals("Bank Reconciliation Service", gatewayService.getDescription());
+ }
+
private void test_generate_badargs(File outdir, String expectedMessage) throws ConfigurationException, IOException {
Generator generator = new Generator(getClass().getResourceAsStream("jbossesb_config_01.xml"));
More information about the jboss-svn-commits
mailing list