[jboss-svn-commits] JBL Code SVN: r8460 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Dec 20 16:47:36 EST 2006
Author: kurt.stam at jboss.com
Date: 2006-12-20 16:47:35 -0500 (Wed, 20 Dec 2006)
New Revision: 8460
Added:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FsListenerMapper.java
Log:
Adding
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FsListenerMapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FsListenerMapper.java 2006-12-20 21:46:57 UTC (rev 8459)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FsListenerMapper.java 2006-12-20 21:47:35 UTC (rev 8460)
@@ -0,0 +1,118 @@
+/*
+ * 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,
+ */
+
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+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.FsBusDocument.FsBus;
+import org.jboss.soa.esb.listeners.config.FsListenerDocument.FsListener;
+import org.jboss.soa.esb.listeners.config.FsMessageFilterDocument.FsMessageFilter;
+import org.jboss.soa.esb.listeners.config.FsProviderDocument.FsProvider;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.gateway.JmsGatewayListener;
+import org.w3c.dom.Element;
+
+/**
+ * Performs the mapping of a <fs-listener> XSD based configuration to the "ConfigTree"
+ * style configuration, adding the "ConfigTree" listener config to the "root" node.
+ *
+ * @author <a href="mailto:kurt.stam at jboss.com">kurt.stam at jboss.com</a>
+ */
+public class FsListenerMapper {
+
+ /**
+ * Perform the mapping.
+ * @param root The "ConfigTree" configuration root node.
+ * @param listener The Jmslistener to be mapped into the ConfigTree.
+ * @param model The configuration model from which the mapping is being performed.
+ * @return The ConfigTree listener configuration node.
+ * @throws ConfigurationException Invalid listener configuration.
+ */
+ public static Element map(Element root, FsListener listener, XMLBeansModel model) throws ConfigurationException {
+ Element listenerNode = YADOMUtil.addElement(root, listener.getName());
+ FsBus bus;
+ FsProvider provider;
+
+ try {
+ bus = (FsBus) 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>.");
+ }
+ try {
+ provider = (FsProvider) model.getProvider(bus);
+ } catch (ClassCastException e) {
+ throw new ConfigurationException("Invalid bus config [" + listener.getBusidref() + "]. Should be contained within a <jms-provider> instance. Unexpected exception - this should have caused a validation error!");
+ }
+
+ FsMessageFilter messageFilter = listener.getFsMessageFilter();
+ if(messageFilter == null) {
+ messageFilter = bus.getFsMessageFilter();
+ if(messageFilter == null) {
+ throw new ConfigurationException("No <fs-detination> defined on either <fs-listener> [" + listener.getName() + "] or <fs-bus> [" + bus.getBusid() + "].");
+ }
+ }
+
+ // Map the standard listener attributes - common across all listener types...
+ MapperUtil.mapDefaultAttributes(listener, listenerNode, model);
+ // Map the <property> elements targeted at the listener - from the listener itself.
+ MapperUtil.mapProperties(listener.getPropertyArray(), listenerNode);
+
+ if(model.getService(listener).getIsGateway()) {
+ listenerNode.setAttribute("gatewayClass", JmsGatewayListener.class.getName());
+ // Map EPR related attributes onto the listener - from the bus and provider and listener.
+ // Note: This will change - the Gateways will also support the EPR element...
+ mapFsEprProperties(listenerNode, provider, messageFilter);
+ MapperUtil.mapEPRProperties(listener, listenerNode, model);
+ } else {
+ Element eprNode = YADOMUtil.addElement(listenerNode, ListenerTagNames.EPR_TAG);
+
+ // Map EPR related attributes onto the EPR - from the bus and provider and listener...
+ mapFsEprProperties(eprNode, provider, messageFilter);
+ MapperUtil.mapEPRProperties(listener, eprNode, model);
+ // Remove any empty attributes set on the EPR config...
+ YADOMUtil.removeEmptyAttributes(eprNode);
+ }
+
+ // Remove any empty attributes set on the listener config...
+ YADOMUtil.removeEmptyAttributes(listenerNode);
+
+ return listenerNode;
+ }
+
+ private static void mapFsEprProperties(Element toElement, FsProvider provider, FsMessageFilter messageFilter) {
+ toElement.setAttribute(ListenerTagNames.URL_TAG, "file:///" + messageFilter.getDirectory());
+ toElement.setAttribute(FileEpr.INPUT_SUFFIX_TAG, messageFilter.getInputSuffix());
+ toElement.setAttribute(FileEpr.WORK_SUFFIX_TAG, messageFilter.getWorkSuffix());
+ toElement.setAttribute(FileEpr.POST_DEL_TAG, String.valueOf(messageFilter.getPostDelete()));
+ if (!messageFilter.getPostDelete()) {
+ toElement.setAttribute(FileEpr.POST_DIR_TAG, messageFilter.getPostDirectory());
+ toElement.setAttribute(FileEpr.POST_SUFFIX_TAG, messageFilter.getPostSuffix());
+ }
+ toElement.setAttribute(FileEpr.ERROR_DEL_TAG, String.valueOf(messageFilter.getErrorDelete()));
+ if (!messageFilter.getErrorDelete()) {
+ toElement.setAttribute(FileEpr.ERROR_DIR_TAG, messageFilter.getErrorDirectory());
+ toElement.setAttribute(FileEpr.ERROR_SUFFIX_TAG, messageFilter.getErrorSuffix());
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list