You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2007/05/04 14:31:31 UTC
svn commit: r535206 - in /activemq/camel/trunk: camel-script/
camel-script/src/main/java/org/apache/camel/builder/script/
camel-script/src/test/java/org/apache/camel/builder/script/example/
camel-script/src/test/resources/ camel-script/src/test/resourc...
Author: jstrachan
Date: Fri May 4 05:31:29 2007
New Revision: 535206
URL: http://svn.apache.org/viewvc?view=rev&rev=535206
Log:
added a test case showing the use of the <groovy> predicates
Added:
activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/
activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java (with props)
activemq/camel/trunk/camel-script/src/test/resources/log4j.properties (with props)
activemq/camel/trunk/camel-script/src/test/resources/org/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/
activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml (with props)
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java (contents, props changed)
- copied, changed from r535115, activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParserSupport.java
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java (with props)
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java (with props)
Removed:
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParserSupport.java
Modified:
activemq/camel/trunk/camel-script/pom.xml
activemq/camel/trunk/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/CamelNamespaceHandler.java
activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd
Modified: activemq/camel/trunk/camel-script/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-script/pom.xml?view=diff&rev=535206&r1=535205&r2=535206
==============================================================================
--- activemq/camel/trunk/camel-script/pom.xml (original)
+++ activemq/camel/trunk/camel-script/pom.xml Fri May 4 05:31:29 2007
@@ -33,7 +33,6 @@
<description>Camel Script support</description>
<repositories>
- <!-- So we can download the jsr 233 stuff -->
<repository>
<id>logicblaze.all</id>
<name>LogicBlaze Repository</name>
@@ -47,6 +46,13 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </dependency>
+
+ <!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
@@ -54,34 +60,47 @@
<optional>true</optional>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
+ <groupId>javax.script</groupId>
+ <artifactId>groovy-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
+ <scope>test</scope>
</dependency>
- <!-- TODO is there a jsr223 jar anywhere else? -->
- <!-- TODO add this to a profile for Java 5 only -->
<dependency>
- <groupId>org.livetribe</groupId>
- <artifactId>livetribe-jsr223</artifactId>
- <version>2.0.1</version>
+ <groupId>javax.script</groupId>
+ <artifactId>js-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
+ <groupId>javax.script</groupId>
+ <artifactId>jython-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>groovy</groupId>
- <artifactId>groovy-all</artifactId>
+ <groupId>javax.script</groupId>
+ <artifactId>jruby-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>com.sun.script</groupId>
- <artifactId>groovy-engine</artifactId>
- <version>20070316</version>
+ <groupId>groovy</groupId>
+ <artifactId>groovy-all</artifactId>
<scope>test</scope>
</dependency>
@@ -92,6 +111,33 @@
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>jdk1.5</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ <dependencies>
+ <!-- required for the retrotranslated JSR-223 api & engines -->
+ <dependency>
+ <groupId>net.sf.retrotranslator</groupId>
+ <artifactId>retrotranslator-runtime</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+
+ <!-- these dependencies are only for Java 5, they are not required for Java 6 -->
+ <dependency>
+ <groupId>javax.script</groupId>
+ <artifactId>script-api</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+
<build>
<plugins>
<plugin>
@@ -103,9 +149,6 @@
<include>**/*Test.*</include>
</includes>
<excludes>
- <!-- TODO re-enable when we can find freely redistributable jars for Java 5! -->
- <exclude>**/Jsr223Test.*</exclude>
- <exclude>**/GroovyTest.*</exclude>
</excludes>
</configuration>
</plugin>
Modified: activemq/camel/trunk/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java?view=diff&rev=535206&r1=535205&r2=535206
==============================================================================
--- activemq/camel/trunk/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java (original)
+++ activemq/camel/trunk/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java Fri May 4 05:31:29 2007
@@ -17,11 +17,15 @@
*/
package org.apache.camel.builder.script;
+import static org.apache.camel.util.ObjectHelper.notNull;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
+import org.apache.camel.util.ObjectHelper;
import org.apache.camel.converter.ObjectConverter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
@@ -44,19 +48,25 @@
* @version $Revision$
*/
public class ScriptBuilder<E extends Exchange> implements Expression<E>, Predicate<E>, Processor {
+ private static final transient Log log = LogFactory.getLog(ScriptBuilder.class);
+
private String scriptEngineName;
private Resource scriptResource;
private String scriptText;
private ScriptEngine engine;
private CompiledScript compiledScript;
- public ScriptBuilder(String scriptEngineName, String scriptText) {
+ public ScriptBuilder(String scriptEngineName) {
this.scriptEngineName = scriptEngineName;
+ }
+
+ public ScriptBuilder(String scriptEngineName, String scriptText) {
+ this(scriptEngineName);
this.scriptText = scriptText;
}
public ScriptBuilder(String scriptEngineName, Resource scriptResource) {
- this.scriptEngineName = scriptEngineName;
+ this(scriptEngineName);
this.scriptResource = scriptResource;
}
@@ -343,6 +353,10 @@
return scriptText;
}
+ public void setScriptText(String scriptText) {
+ this.scriptText = scriptText;
+ }
+
public String getScriptEngineName() {
return scriptEngineName;
}
@@ -356,9 +370,12 @@
if (scriptText != null) {
return scriptEngineName + ": " + scriptText;
}
- else {
+ else if (scriptResource != null) {
return scriptEngineName + ": " + scriptResource.getDescription();
}
+ else {
+ return scriptEngineName + ": null script";
+ }
}
/**
@@ -375,10 +392,20 @@
getEngine().setContext(scriptContext);
}
+ public Resource getScriptResource() {
+ return scriptResource;
+ }
+
+ public void setScriptResource(Resource scriptResource) {
+ this.scriptResource = scriptResource;
+ }
// Implementation methods
//-------------------------------------------------------------------------
protected void checkInitialised() {
+ if (scriptText == null && scriptResource == null) {
+ throw new IllegalArgumentException("Neither scriptText or scriptResource are specified");
+ }
if (engine == null) {
engine = createScriptEngine();
}
@@ -408,6 +435,9 @@
}
}
catch (ScriptException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Script compile failed: " + e, e);
+ }
throw createScriptCompileException(e);
}
catch (IOException e) {
@@ -422,6 +452,9 @@
return runScript();
}
catch (ScriptException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Script evaluation failed: " + e, e);
+ }
throw createScriptEvaluationException(e.getCause());
}
catch (IOException e) {
Added: activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java?view=auto&rev=535206
==============================================================================
--- activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java (added)
+++ activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java Fri May 4 05:31:29 2007
@@ -0,0 +1,40 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder.script.example;
+
+import org.apache.camel.processor.XPathFilterTest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.impl.NoRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class GroovyFilterTest extends XPathFilterTest {
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return SpringCamelContext.springCamelContext(new ClassPathXmlApplicationContext("org/apache/camel/builder/script/example/groovyFilter.xml"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return NoRouteBuilder.getInstance();
+ }
+}
Propchange: activemq/camel/trunk/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/camel-script/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-script/src/test/resources/log4j.properties?view=auto&rev=535206
==============================================================================
--- activemq/camel/trunk/camel-script/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-script/src/test/resources/log4j.properties Fri May 4 05:31:29 2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.springframework=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
Propchange: activemq/camel/trunk/camel-script/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml?view=auto&rev=535206
==============================================================================
--- activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml (added)
+++ activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml Fri May 4 05:31:29 2007
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/camel-1.0.xsd http://activemq.apache.org/camel/schema/camel-1.0.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+ <route>
+ <from uri="direct:start"/>
+ <filter>
+ <groovy>exchange.in.headers.testCase == 'testSendMatchingMessage'</groovy>
+ </filter>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>
Propchange: activemq/camel/trunk/camel-script/src/test/resources/org/apache/camel/builder/script/example/groovyFilter.xml
------------------------------------------------------------------------------
svn:eol-style = native
Copied: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java (from r535115, activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParserSupport.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java?view=diff&rev=535206&p1=activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParserSupport.java&r1=535115&p2=activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java&r2=535206
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParserSupport.java (original)
+++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java Fri May 4 05:31:29 2007
@@ -25,15 +25,25 @@
*
* @version $Revision: 1.1 $
*/
-public class BeanDefinitionParserSupport extends AbstractSimpleBeanDefinitionParser {
+public class BeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
private Class type;
- public BeanDefinitionParserSupport(Class type) {
+ protected BeanDefinitionParser() {
+ }
+
+ public BeanDefinitionParser(Class type) {
this.type = type;
}
protected Class getBeanClass(Element element) {
+ if (type == null) {
+ type = loadType();
+ }
return type;
+ }
+
+ protected Class loadType() {
+ throw new IllegalArgumentException("No type specified!");
}
@Override
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/BeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/CamelNamespaceHandler.java?view=diff&rev=535206&r1=535205&r2=535206
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/CamelNamespaceHandler.java (original)
+++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/CamelNamespaceHandler.java Fri May 4 05:31:29 2007
@@ -10,7 +10,6 @@
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -21,15 +20,15 @@
public class CamelNamespaceHandler extends NamespaceHandlerSupport {
protected CamelBeanDefinitionParser routesParser = new CamelBeanDefinitionParser(this);
- protected BeanDefinitionParserSupport endpointParser = new BeanDefinitionParserSupport(EndpointFactoryBean.class);
- private Set<String> parserElementNames = new HashSet<String>();
+ protected BeanDefinitionParser endpointParser = new BeanDefinitionParser(EndpointFactoryBean.class);
+ protected Set<String> parserElementNames = new HashSet<String>();
public void init() {
registerParser("routes", routesParser);
registerParser("routeBuilder", routesParser);
registerParser("endpoint", endpointParser);
- registerParser("camelContext", new BeanDefinitionParserSupport(CamelContextFactoryBean.class) {
+ registerParser("camelContext", new BeanDefinitionParser(CamelContextFactoryBean.class) {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, parserContext, builder);
@@ -67,7 +66,7 @@
}
});
- registerParser("xpath", new BeanDefinitionParserSupport(XPathBuilder.class) {
+ registerParser("xpath", new BeanDefinitionParser(XPathBuilder.class) {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
// lets create a child context
@@ -77,9 +76,21 @@
builder.addPropertyValue("namespacesFromDom", element);
}
});
+
+
+ // scripting expressions
+ registerScriptParser("script", null);
+ registerScriptParser("groovy", "groovy");
+ registerScriptParser("ruby", "jruby");
+ registerScriptParser("javaScript", "js");
+ registerScriptParser("php", "php");
+ }
+
+ protected void registerScriptParser(String elementName, String engineName) {
+ registerParser(elementName, new ScriptDefinitionParser(engineName));
}
- protected void registerParser(String name, BeanDefinitionParser parser) {
+ protected void registerParser(String name, org.springframework.beans.factory.xml.BeanDefinitionParser parser) {
parserElementNames.add(name);
registerBeanDefinitionParser(name, parser);
}
Added: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java?view=auto&rev=535206
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java (added)
+++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java Fri May 4 05:31:29 2007
@@ -0,0 +1,45 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.xml;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * A {@link BeanDefinitionParser} which lazy loads the type on which it creates to allow the schema to be loosly coupled
+ * with the camel jars.
+ *
+ * @version $Revision: 1.1 $
+ */
+public class LazyLoadingBeanDefinitionParser extends BeanDefinitionParser {
+ private String className;
+ private String moduleName;
+
+ public LazyLoadingBeanDefinitionParser(String className, String moduleName) {
+ this.className = className;
+ this.moduleName = moduleName;
+ }
+
+ @Override
+ protected Class loadType() {
+ Class<?> answer = ObjectHelper.loadClass(className, getClass().getClassLoader());
+ if (answer == null) {
+ throw new IllegalArgumentException("Class: " + className + " could not be found. You need to add Camel module: " + moduleName + " to your classpath");
+ }
+ return answer;
+ }
+}
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/LazyLoadingBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java?view=auto&rev=535206
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java (added)
+++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java Fri May 4 05:31:29 2007
@@ -0,0 +1,52 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.xml;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+/**
+ * A parser of the various scripting language expressions
+ * @version $Revision: 1.1 $
+ */
+public class ScriptDefinitionParser extends LazyLoadingBeanDefinitionParser {
+ private final String scriptEngineName;
+
+ public ScriptDefinitionParser(String scriptEngineName) {
+ super("org.apache.camel.builder.script.ScriptBuilder", "camel-script");
+ this.scriptEngineName = scriptEngineName;
+ }
+
+ @Override
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ // lets create a child context
+ String engine = scriptEngineName;
+ if (engine == null) {
+ engine = element.getAttribute("language");
+ }
+ builder.addConstructorArg(engine);
+ super.doParse(element, parserContext, builder);
+ String scriptText = DomUtils.getTextValue(element).trim();
+ if (scriptText.length() > 0) {
+ builder.addPropertyValue("scriptText", scriptText);
+ }
+ }
+
+}
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/xml/ScriptDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd?view=diff&rev=535206&r1=535205&r2=535206
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd (original)
+++ activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd Fri May 4 05:31:29 2007
@@ -16,15 +16,15 @@
The Apache Camel Configuration Schema
</xs:documentation>
</xs:annotation>
-
+
<xs:element name="camelContext">
<xs:complexType>
<xs:complexContent>
<xs:extension base="s:identifiedType">
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element minOccurs="0" maxOccurs="1" ref="c:endpoint"/>
- <xs:element minOccurs="0" maxOccurs="1" ref="c:route"/>
- </xs:choice>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element minOccurs="0" maxOccurs="1" ref="c:endpoint"/>
+ <xs:element minOccurs="0" maxOccurs="1" ref="c:route"/>
+ </xs:choice>
<xs:attribute name="packages" type="xs:NMTOKEN"/>
</xs:extension>
</xs:complexContent>
@@ -145,6 +145,11 @@
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element ref="c:predicate"/>
<xs:element ref="c:xpath"/>
+ <xs:element ref="c:script"/>
+ <xs:element ref="c:javaScript"/>
+ <xs:element ref="c:groovy"/>
+ <xs:element ref="c:php"/>
+ <xs:element ref="c:ruby"/>
</xs:choice>
</xs:complexType>
@@ -167,6 +172,28 @@
<xs:element name="xpath">
</xs:element>
+ <xs:complexType name="scriptType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="resource" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="javaScript" type="c:scriptType"/>
+ <xs:element name="groovy" type="c:scriptType"/>
+ <xs:element name="php" type="c:scriptType"/>
+ <xs:element name="ruby" type="c:scriptType"/>
+
+ <xs:element name="script">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="c:scriptType">
+ <xs:attribute name="language" type="xs:string"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
<xs:element name="isEqualTo">
<xs:complexType>