camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r582253 - in /activemq/camel/trunk: ./ components/ components/camel-groovy/src/main/java/groovy/ components/camel-groovy/src/main/java/org/apache/camel/language/groovy/ components/camel-groovy/src/main/resources/org/ components/camel-groovy...
Date Fri, 05 Oct 2007 13:24:54 GMT
Author: jstrachan
Date: Fri Oct  5 06:24:52 2007
New Revision: 582253

URL: http://svn.apache.org/viewvc?rev=582253&view=rev
Log:
re-enabled the groovy module and switched the implementation to use the ExpandoMetaClass

Added:
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/
    activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
Removed:
    activemq/camel/trunk/components/camel-groovy/src/main/java/groovy/
Modified:
    activemq/camel/trunk/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
    activemq/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
    activemq/camel/trunk/components/camel-groovy/src/test/resources/log4j.properties
    activemq/camel/trunk/components/pom.xml
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java?rev=582253&r1=582252&r2=582253&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
(original)
+++ activemq/camel/trunk/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyRouteBuilder.java
Fri Oct  5 06:24:52 2007
@@ -17,6 +17,7 @@
  */
 package org.apache.camel.language.groovy;
 
+import groovy.lang.GroovyShell;
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 
@@ -25,9 +26,20 @@
  */
 public abstract class GroovyRouteBuilder extends RouteBuilder {
     public GroovyRouteBuilder() {
+        init();
     }
 
     public GroovyRouteBuilder(CamelContext context) {
         super(context);
+        init();
+    }
+
+    private void init() {
+        ClassLoader loader = getClass().getClassLoader();
+        GroovyShell shell = new GroovyShell(loader);
+        shell.evaluate(loader.getResourceAsStream("org/apache/camel/language/groovy/ConfigureCamel.groovy"));
+
+        // TODO compile Groovy as part of build!
+        //new ConfigureCamel().run();
     }
 }

Added: activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy?rev=582253&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
(added)
+++ activemq/camel/trunk/components/camel-groovy/src/main/resources/org/apache/camel/language/groovy/ConfigureCamel.groovy
Fri Oct  5 06:24:52 2007
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.language.groovy
+
+import org.apache.camel.model.ChoiceType;
+import org.apache.camel.model.ProcessorType;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+class ConfigureCamel implements Runnable {
+
+    static void main(String[] args) {
+        new ConfigureCamel().run();
+    }
+
+    void run() {
+        ExpandoMetaClass.enableGlobally();
+
+        ProcessorType.metaClass.filter = { filter ->
+            if (filter instanceof Closure) {
+                filter = CamelGroovyMethods.toExpression(filter)
+            }
+            delegate.filter(filter);
+        }
+
+        ChoiceType.metaClass.when = { filter ->
+            if (filter instanceof Closure) {
+                filter = CamelGroovyMethods.toExpression(filter)
+            }
+            delegate.when(filter);
+        }
+    }
+}
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java?rev=582253&r1=582252&r2=582253&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
(original)
+++ activemq/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyTest.java
Fri Oct  5 06:24:52 2007
@@ -36,14 +36,14 @@
     protected String groovyBuilderClass = "org.apache.camel.language.groovy.example.GroovyRoutes";
 
     public void testSendMatchingMessage() throws Exception {
-        System.out.println(">>>>> " + ProcessorType.class.getName());
-        
         MockEndpoint resultEndpoint = getMockEndpoint("mock:results");
         resultEndpoint.expectedBodiesReceived(expected);
 
         template.sendBodyAndHeader("direct:a", expected, "foo", "bar");
 
         assertMockEndpointsSatisifed();
+
+        log.debug("Should have received one exchange: " + resultEndpoint.getReceivedExchanges());
     }
 
     public void testSendNotMatchingMessage() throws Exception {
@@ -53,20 +53,14 @@
         template.sendBodyAndHeader("direct:a", expected, "foo", "123");
 
         assertMockEndpointsSatisifed();
+
+        log.debug("Should not have received any messages: " + resultEndpoint.getReceivedExchanges());
     }
 
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext answer = super.createCamelContext();
-
-/*
-        MetaClassRegistry metaClassRegistry = MetaClassRegistry.getInstance(MetaClassRegistry.LOAD_DEFAULT);
-        MetaClass metaClass = metaClassRegistry.getMetaClass(ProcessorType.class);
-        metaClass = new ProxyMetaClass(metaClassRegistry, ProcessorType.class, metaClass);
-        metaClass.addNewInstanceMethod(CamelGroovyMethods.class.getMethod("filter", ProcessorType.class,
Closure.class));
-        metaClassRegistry.setMetaClass(ProcessorType.class, metaClass);
-*/
 
         GroovyClassLoader classLoader = new GroovyClassLoader();
         Class<?> type = classLoader.loadClass(groovyBuilderClass);

Modified: activemq/camel/trunk/components/camel-groovy/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-groovy/src/test/resources/log4j.properties?rev=582253&r1=582252&r2=582253&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-groovy/src/test/resources/log4j.properties (original)
+++ activemq/camel/trunk/components/camel-groovy/src/test/resources/log4j.properties Fri Oct
 5 06:24:52 2007
@@ -21,9 +21,9 @@
 log4j.rootLogger=INFO, out
 
 # uncomment the following to enable debug of Camel
-log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
 
-#log4j.logger.org.apache.activemq=DEBUG
+log4j.logger.org.springframework=WARN
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender

Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?rev=582253&r1=582252&r2=582253&view=diff
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Fri Oct  5 06:24:52 2007
@@ -34,11 +34,12 @@
   <packaging>pom</packaging>
 
   <modules>
+    <!--<module>camel-amqp</module>-->
     <module>camel-atom</module>
     <module>camel-bam</module>
     <module>camel-cxf</module>
     <module>camel-ftp</module>
-    <!--<module>camel-groovy</module>-->
+    <module>camel-groovy</module>
     <module>camel-http</module>
     <module>camel-ibatis</module>
     <module>camel-irc</module>

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=582253&r1=582252&r2=582253&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Fri Oct  5 06:24:52 2007
@@ -607,9 +607,7 @@
       <dependency>
         <groupId>org.codehaus.groovy</groupId>
         <artifactId>groovy-all</artifactId>
-        <!-- TODO upgrade to new version with patch when available -->
-        <!--<version>1.1-beta-3-SNAPSHOT</version>-->
-        <version>1.1-beta-2</version>
+        <version>1.1-beta-3</version>
       </dependency>
       <dependency>
         <groupId>com.sun.script</groupId>



Mime
View raw message