[jboss-svn-commits] JBL Code SVN: r33055 - in labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product: rosetta/src/org/jboss/soa/esb/listeners/config/mappers130 and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon May 24 14:25:50 EDT 2010
Author: dward
Date: 2010-05-24 14:25:49 -0400 (Mon, 24 May 2010)
New Revision: 33055
Modified:
labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/etc/schemas/xml/jbossesb-1.3.0.xsd
labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers130/CamelGatewayMapper.java
labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/camel/CamelGateway.java
labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/build.xml
labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/jboss-esb-unfiltered.xml
Log:
Reduced functionality to only allow "from" URIs.
Modified: labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/etc/schemas/xml/jbossesb-1.3.0.xsd
===================================================================
--- labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/etc/schemas/xml/jbossesb-1.3.0.xsd 2010-05-24 18:25:05 UTC (rev 33054)
+++ labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/etc/schemas/xml/jbossesb-1.3.0.xsd 2010-05-24 18:25:49 UTC (rev 33055)
@@ -2049,13 +2049,22 @@
<!-- 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
Camel Type Implementations.
88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888-->
- <xsd:element name="route" type="xsd:anyType">
+ <xsd:element name="from">
<xsd:annotation>
<xsd:documentation xml:lang="en">
- Camel "route", loosely allowing for Camel XML
- config without being dependent on it here.
+ Camel "from" element.
</xsd:documentation>
</xsd:annotation>
+ <xsd:complexType>
+ <xsd:attribute name="uri" type="xsd:string"
+ use="required">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ Camel "uri" attribute.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
</xsd:element>
<xsd:element name="camel-bus" substitutionGroup="jesb:bus">
<xsd:annotation>
@@ -2068,16 +2077,32 @@
<xsd:extension base="jesb:bus">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
- ref="jesb:route" />
+ ref="jesb:from" />
</xsd:sequence>
- <xsd:attribute name="route-from-uri" type="xsd:string"
+ <xsd:attribute name="from-uri" type="xsd:string"
use="optional">
<xsd:annotation>
<xsd:documentation xml:lang="en">
- Camel Route "from" URI.
+ Camel "from" URI.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute name="async" type="xsd:boolean"
+ use="optional">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ Should the Service be invoked asynchronously?
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="timeout" type="xsd:long"
+ use="optional">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ Synchronous Service invocation timeout.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
@@ -2107,18 +2132,18 @@
<xsd:extension base="jesb:gateway-only-listener">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
- ref="jesb:route" />
+ ref="jesb:from" />
</xsd:sequence>
- <xsd:attribute name="route-from-uri" type="xsd:string"
+ <xsd:attribute name="from-uri" type="xsd:string"
use="optional">
<xsd:annotation>
<xsd:documentation xml:lang="en">
- Camel Route "from" URI.
+ Camel "from" URI.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="async" type="xsd:boolean"
- use="optional" default="true">
+ use="optional">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Should the Service be invoked asynchronously?
@@ -2126,7 +2151,7 @@
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="timeout" type="xsd:long"
- use="optional" default="30000">
+ use="optional">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Synchronous Service invocation timeout.
Modified: labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers130/CamelGatewayMapper.java
===================================================================
--- labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers130/CamelGatewayMapper.java 2010-05-24 18:25:05 UTC (rev 33054)
+++ labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers130/CamelGatewayMapper.java 2010-05-24 18:25:49 UTC (rev 33055)
@@ -26,12 +26,11 @@
import java.util.List;
import java.util.Map;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.dom.YADOMUtil;
import org.jboss.soa.esb.listeners.config.xbeanmodel130.CamelGatewayDocument;
import org.jboss.soa.esb.listeners.config.xbeanmodel130.CamelBusDocument.CamelBus;
+import org.jboss.soa.esb.listeners.config.xbeanmodel130.FromDocument.From;
import org.jboss.soa.esb.listeners.config.xbeanmodel130.ServiceDocument.Service;
import org.jboss.soa.esb.listeners.gateway.camel.CamelGateway;
import org.jboss.soa.esb.listeners.gateway.camel.JBossESBComponent;
@@ -49,13 +48,6 @@
gatewayNode.setAttribute("name", gateway.getName());
- URI routeToURI = createRouteToURI(gateway, model);
-
- List<String> routeXMLs = new ArrayList<String>();
-
- // <camel-gateway route-from-uri="">
- URI gatewayRouteFromURI = createURI(gateway.getRouteFromUri());
-
final CamelBus bus;
try {
bus = (CamelBus)model.getOptionalBus(gateway.getBusidref());
@@ -63,28 +55,42 @@
throw new ConfigurationException("Invalid busid reference [" + gateway.getBusidref() + "] on gateway [" + gateway.getName() + "]. A <camel-gateway> must reference a <camel-bus>.");
}
+ List<String> routeXMLs = new ArrayList<String>();
+
+ URI toURI = createToURI(gateway, bus, model);
+
+ // <camel-gateway from-uri="">
+ URI gatewayFromURI;
+ if (gateway.isSetFromUri()) {
+ gatewayFromURI = createURI(gateway.getFromUri());
+ } else {
+ gatewayFromURI = null;
+ }
+
if (bus != null) {
try {
- if (gatewayRouteFromURI == null) {
- // <camel-bus route-from-uri="">
- URI busRouteFromURI = createURI(bus.getRouteFromUri());
- addRouteXML(busRouteFromURI, routeToURI, routeXMLs);
+ if (gatewayFromURI == null && bus.isSetFromUri()) {
+ // <camel-bus from-uri="">
+ URI busFromURI = createURI(bus.getFromUri());
+ addRouteXML(busFromURI, toURI, routeXMLs);
}
- // <camel-bus><route>*
- for (XmlObject busRoute : bus.getRouteList()) {
- addRouteXML(busRoute, routeToURI, routeXMLs);
+ // <camel-bus><from uri="">*
+ for (From busFrom : bus.getFromList()) {
+ URI fromURI = createURI(busFrom.getUri());
+ addRouteXML(fromURI, toURI, routeXMLs);
}
} catch (ClassCastException e) {
throw new ConfigurationException("Invalid bus config [" + gateway.getBusidref() + "]. Should be contained within a <camel-provider> instance. Unexpected exception - this should have caused a validation error!");
}
}
- if (gatewayRouteFromURI != null) {
- addRouteXML(gatewayRouteFromURI, routeToURI, routeXMLs);
+ if (gatewayFromURI != null) {
+ addRouteXML(gatewayFromURI, toURI, routeXMLs);
}
- // <camel-gateway><route>*
- for (XmlObject gatewayRoute : gateway.getRouteList()) {
- addRouteXML(gatewayRoute, routeToURI, routeXMLs);
+ // <camel-gateway><from uri="">*
+ for (From gatewayFrom : gateway.getFromList()) {
+ URI fromURI = createURI(gatewayFrom.getUri());
+ addRouteXML(fromURI, toURI, routeXMLs);
}
// Map the standard listener attributes - common across all listener types...
@@ -106,15 +112,30 @@
return gatewayNode;
}
- private static URI createRouteToURI(final CamelGatewayDocument.CamelGateway listener, final XMLBeansModel model) throws ConfigurationException {
- Service service = model.getService(listener);
+ private static URI createToURI(final CamelGatewayDocument.CamelGateway gateway, CamelBus bus, final XMLBeansModel model) throws ConfigurationException {
Map<String,Object> toParams = new LinkedHashMap<String,Object>();
+ Service service = model.getService(gateway);
toParams.put(JBossESBComponent.CATEGORY, service.getCategory());
toParams.put(JBossESBComponent.NAME, service.getName());
- boolean async = Boolean.valueOf(listener.getAsync()).booleanValue();
+ boolean async;
+ if (gateway.isSetAsync()) {
+ async = gateway.getAsync();
+ } else if (bus != null && bus.isSetAsync()) {
+ async = bus.getAsync();
+ } else {
+ async = true;
+ }
toParams.put(JBossESBComponent.ASYNC, String.valueOf(async));
if (!async) {
- toParams.put(JBossESBComponent.TIMEOUT, String.valueOf(listener.getTimeout()));
+ long timeout;
+ if (gateway.isSetTimeout()) {
+ timeout = gateway.getTimeout();
+ } else if (bus != null && bus.isSetTimeout()) {
+ timeout = bus.getTimeout();
+ } else {
+ timeout = 30000L;
+ }
+ toParams.put(JBossESBComponent.TIMEOUT, String.valueOf(timeout));
}
try {
return JBossESBComponent.createEndpointURI(JBossESBComponent.SERVICE, toParams);
@@ -137,34 +158,16 @@
return null;
}
- private static void addRouteXML(URI routeFromURI, URI routeToURI, List<String> routeXMLs) throws ConfigurationException {
- if (routeFromURI != null) {
+ private static void addRouteXML(URI fromURI, URI toURI, List<String> routeXMLs) throws ConfigurationException {
+ if (fromURI != null) {
StringBuilder sb = new StringBuilder();
sb.append("<route><from uri=\"");
- sb.append(routeFromURI);
+ sb.append(fromURI);
sb.append("\"/><to uri=\"");
- sb.append(routeToURI);
+ sb.append(toURI);
sb.append("\"/></route>");
routeXMLs.add(sb.toString());
}
}
-
- private static void addRouteXML(XmlObject route, URI routeToURI, List<String> routeXMLs) {
- if (route != null) {
- XmlOptions xo = new XmlOptions();
- xo.setSaveOuter();
- xo.setSavePrettyPrint();
- String routeXML = route.xmlText(xo);
- routeXML = routeXML.replaceAll(" xmlns=\".*\"", "");
- routeXML = routeXML.replaceAll(" ", "");
- routeXML = routeXML.replaceAll("\\n", "");
- StringBuilder sb = new StringBuilder();
- sb.append("<to uri=\"");
- sb.append(routeToURI);
- sb.append("\"/></route>");
- routeXML = routeXML.replaceAll("</route>", sb.toString());
- routeXMLs.add(routeXML);
- }
- }
}
Modified: labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/camel/CamelGateway.java
===================================================================
--- labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/camel/CamelGateway.java 2010-05-24 18:25:05 UTC (rev 33054)
+++ labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/camel/CamelGateway.java 2010-05-24 18:25:49 UTC (rev 33055)
@@ -20,6 +20,7 @@
package org.jboss.soa.esb.listeners.gateway.camel;
import java.io.StringReader;
+import java.io.StringWriter;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
@@ -30,6 +31,9 @@
import org.apache.camel.model.Constants;
import org.apache.camel.model.RoutesDefinition;
import org.apache.log4j.Logger;
+import org.dom4j.DocumentHelper;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
@@ -52,7 +56,8 @@
public CamelGateway(ConfigTree config) throws ConfigurationException {
super(config);
StringBuilder sb = new StringBuilder();
- sb.append("<routes>");
+ // Don't let the namespace fool you; there's no dependency on Spring at this level!
+ sb.append("<routes xmlns=\"http://camel.apache.org/schema/spring\">");
boolean routesDefined = false;
for (ConfigTree property: config.getChildren("property")) {
if (ROUTE.equals(property.getRequiredAttribute("name"))) {
@@ -70,7 +75,7 @@
throw new ConfigurationException("no routes defined; add at least one route");
}
sb.append("</routes>");
- routesXML = sb.toString().replaceAll("&", "&");
+ routesXML = sb.toString().replaceAll("&", "&");
}
@Override
@@ -78,13 +83,22 @@
camelContext = new DefaultCamelContext(new SimpleRegistry());
camelContext.disableJMX();
camelContext.addComponent(JBossESBComponent.JBOSSESB, new JBossESBComponent());
- logger.info("adding routes [" + routesXML + "]");
- // Don't let the namespace fool you; there's no dependency on Spring at this level!
- String jaxbRoutesXML = routesXML.replaceFirst("<routes>", "<routes xmlns=\"http://camel.apache.org/schema/spring\">").replaceAll("&", "&");
+ if (logger.isInfoEnabled()) {
+ try {
+ StringWriter sw = new StringWriter();
+ OutputFormat of = OutputFormat.createPrettyPrint();
+ of.setSuppressDeclaration(true);
+ new XMLWriter(sw, of).write(DocumentHelper.parseText(routesXML));
+ logger.info("adding routes [" + sw.toString().replaceAll("&", "&") + "]");
+ } catch (Exception e) {
+ logger.warn("problem pretty-printing routes: " + e.getMessage());
+ logger.info("adding routes [" + routesXML + "]");
+ }
+ }
try {
JAXBContext jc = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
Unmarshaller um = jc.createUnmarshaller();
- RoutesDefinition rd = (RoutesDefinition)um.unmarshal(new StringReader(jaxbRoutesXML));
+ RoutesDefinition rd = (RoutesDefinition)um.unmarshal(new StringReader(routesXML));
camelContext.addRouteDefinitions(rd.getRoutes());
} catch (Exception e) {
throw new ManagedLifecycleException("problem adding routes", e);
Modified: labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/build.xml
===================================================================
--- labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/build.xml 2010-05-24 18:25:05 UTC (rev 33054)
+++ labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/build.xml 2010-05-24 18:25:49 UTC (rev 33055)
@@ -8,22 +8,29 @@
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
- <property name="jbossesb.inputdir" location="${build.dir}/input"/>
+ <property name="jbossesb.inputdir1" location="${build.dir}/input1"/>
+ <property name="jbossesb.inputdir2" location="${build.dir}/input2"/>
<target name="filter_jboss-esb.xml">
- <pathconvert targetos="unix" property="jbossesb.inputdir.unix">
- <path location="${jbossesb.inputdir}"/>
+ <pathconvert targetos="unix" property="jbossesb.inputdir1.unix">
+ <path location="${jbossesb.inputdir1}"/>
</pathconvert>
+ <pathconvert targetos="unix" property="jbossesb.inputdir2.unix">
+ <path location="${jbossesb.inputdir2}"/>
+ </pathconvert>
<copy file="${basedir}/jboss-esb-unfiltered.xml" tofile="${basedir}/jboss-esb.xml" overwrite="true" filtering="true">
<filterset>
- <filter token="INPUTDIR" value="${jbossesb.inputdir.unix}"/>
+ <filter token="INPUTDIR1" value="${jbossesb.inputdir1.unix}"/>
+ <filter token="INPUTDIR2" value="${jbossesb.inputdir2.unix}"/>
</filterset>
</copy>
</target>
<target name="config">
- <delete dir="${jbossesb.inputdir}" quiet="true"/>
- <mkdir dir="${jbossesb.inputdir}"/>
+ <delete dir="${jbossesb.inputdir1}" quiet="true"/>
+ <delete dir="${jbossesb.inputdir2}" quiet="true"/>
+ <mkdir dir="${jbossesb.inputdir1}"/>
+ <mkdir dir="${jbossesb.inputdir2}"/>
<antcall target="filter_jboss-esb.xml"/>
<copy file="log4j.xml" tofile="build/log4j.xml"/>
</target>
@@ -33,7 +40,8 @@
</target>
<target name="runtest" depends="compile" description="Runs test">
- <echo message="Hello ${user.name}!" file="${jbossesb.inputdir}/test.txt"/>
+ <echo message="Hello ${user.name}! (1)" file="${jbossesb.inputdir1}/test.txt"/>
+ <echo message="Hello ${user.name}! (2)" file="${jbossesb.inputdir2}/test.txt"/>
</target>
</project>
Modified: labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/jboss-esb-unfiltered.xml
===================================================================
--- labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/jboss-esb-unfiltered.xml 2010-05-24 18:25:05 UTC (rev 33054)
+++ labs/jbossesb/workspace/dward/JBESB_4_8_Camel_Gateway/product/samples/quickstarts/camel_helloworld/jboss-esb-unfiltered.xml 2010-05-24 18:25:49 UTC (rev 33055)
@@ -1,35 +1,30 @@
<?xml version = "1.0" encoding = "UTF-8"?>
<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.3.0.xsd" parameterReloadSecs="5">
- <!--
<providers>
<camel-provider name="provider1">
- <camel-bus busid="bus1" route-from-uri="file://@INPUTDIR@?delete=true"/>
- <camel-bus busid="bus2">
- <route>
- <from uri="file://@INPUTDIR@?delete=true"/>
- <to uri="log://camel_helloworld?level=INFO"/>
- </route>
+ <camel-bus busid="bus1">
+ <from uri="file://@INPUTDIR1@?delete=true"/>
+ <from uri="file://@INPUTDIR2@?delete=true"/>
</camel-bus>
+ <!--
+ <camel-bus busid="bus2" from-uri="file://@INPUTDIR1@?delete=true"/>
+ -->
</camel-provider>
</providers>
- -->
<services>
<service category="camel_helloworld" name="service1" description="Hello World" invmScope="GLOBAL">
<listeners>
+ <camel-gateway name="gateway1" busidref="bus1"/>
<!--
- <camel-gateway name="gateway1" route-from-uri="file://@INPUTDIR@?delete=true"/>
- <camel-gateway name="gateway2">
- <route>
- <from uri="file://@INPUTDIR@?delete=true"/>
- <to uri="log://camel_helloworld?level=INFO"/>
- </route>
+ <camel-gateway name="gateway2" busidref="bus2"/>
+ <camel-gateway name="gateway3">
+ <from uri="file://@INPUTDIR1@?delete=true"/>
+ <from uri="file://@INPUTDIR2@?delete=true"/>
</camel-gateway>
- <camel-gateway name="gateway3" busidref="bus1"/>
- <camel-gateway name="gateway4" busidref="bus2"/>
+ <camel-gateway name="gateway4" from-uri="file://@INPUTDIR1@?delete=true"/>
-->
- <camel-gateway name="gateway1" route-from-uri="file://@INPUTDIR@?delete=true"/>
</listeners>
<actions mep="OneWay">
<action name="action1" class="org.jboss.soa.esb.actions.SystemPrintln"/>
More information about the jboss-svn-commits
mailing list