svn commit: r894325 - /camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java

2009-12-29 Thread ningjiang
Author: ningjiang
Date: Tue Dec 29 09:06:10 2009
New Revision: 894325

URL: http://svn.apache.org/viewvc?rev=894325view=rev
Log:
Remove the Log.info as Claus point out

Modified:

camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java

Modified: 
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java?rev=894325r1=894324r2=894325view=diff
==
--- 
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java
 (original)
+++ 
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiClassResolver.java
 Tue Dec 29 09:06:10 2009
@@ -83,7 +83,6 @@
 try {
 answer = loader.loadClass(name);
 } catch (ClassNotFoundException e) {
-LOG.info(Cannot load class:  + name +  using classloader:  
+ loader, e);
 if (LOG.isTraceEnabled()) {
 LOG.trace(Cannot load class:  + name +  using 
classloader:  + loader, e);
 }




svn commit: r894532 - in /camel/trunk/tests: camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsync

2009-12-29 Thread ningjiang
Author: ningjiang
Date: Wed Dec 30 02:17:57 2009
New Revision: 894532

URL: http://svn.apache.org/viewvc?rev=894532view=rev
Log:
Fixed the eclipses errors

Modified:

camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java

camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java

Modified: 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java?rev=894532r1=894531r2=894532view=diff
==
--- 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/protobuf/ProtobufRouteTest.java
 Wed Dec 30 02:17:57 2009
@@ -16,47 +16,27 @@
  */
 package org.apache.camel.itest.osgi.protobuf;
 
-import java.io.InputStream;
-import java.util.HashMap;
-
-import javax.mail.Address;
-import javax.mail.Message;
-import javax.mail.Message.RecipientType;
-
 
 import org.apache.camel.CamelException;
-import org.apache.camel.Exchange;
 import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.converter.IOConverter;
 import org.apache.camel.dataformat.protobuf.ProtobufDataFormat;
-
 import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
 import org.apache.camel.itest.osgi.protobuf.generated.AddressBookProtos;
 import org.apache.camel.itest.osgi.protobuf.generated.AddressBookProtos.Person;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.jvnet.mock_javamail.Mailbox;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
 
 import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.logProfile;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
 
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-
 
 @RunWith(JUnit4TestRunner.class)
 public class ProtobufRouteTest extends OSGiIntegrationTestSupport {
@@ -147,14 +127,6 @@
 scanFeatures(mavenBundle().groupId(org.apache.camel.karaf).
  
artifactId(apache-camel).versionAsInProject().type(xml/features),   
  
   camel-core, camel-spring-osgi, camel-test, 
camel-protobuf),
-// create a bundle that has the protobuf class
-/*provision(newBundle().add(AddressBookProtos.class)
-   .add(AddressBookProtos.AddressBook.class)
-   .add(AddressBookProtos.Person.class)
-   .set(Constants.BUNDLE_SYMBOLICNAME, 
CamelProtoBufTinyBundle)
-   .set(Constants.EXPORT_PACKAGE, 
org.apache.camel.itest.osgi.protobuf.generated)
-   .build()),*/
-
 
 felix());
 

Modified: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java?rev=894532r1=894531r2=894532view=diff
==
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
 Wed Dec 30 02:17:57 2009
@@ -27,7 +27,8 @@
  * @version $Revision$
  */
 public class HttpAsyncTest extends CamelTestSupport {
-
+ 
+@SuppressWarnings(unchecked)
 @Test
 public void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
 // START SNIPPET: e2
@@ -52,13 +53,13 @@
 // (waiting if needed) and then return a string body response.
 // This allows us to do this in a single code line instead of using the
 // JDK Future API to get hold of it, but you can also use that if you 
want
-String response = template.extractFutureBody(future, String.class);
+  

[CONF] Apache Camel Spring Java Config

2009-12-29 Thread confluence







 Spring Java Config
 Page edited by willem jiang

 
  
 
 Spring Java Config

Spring started life using XML Config to wire beans together. However some folks don't like using XML and would rather use Java code which led to the creation of Guice along with the Spring JavaConfig project.

You can use either the XML or Java config approachs with Camel; its your choice really on which you prefer.

NOTE: From Camel 2.2.0 camel-spring-javaconfig is moved to Spring 3.x, which means you can't run it with spring 2.x.

Using Spring Java Config

To use Spring Java Config in your Camel project the easiest thing to do is add the following to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
  version${camel-version}/version
/dependency



This will then add the dependencies on the Spring JavaConfig library along with some helper classes for configuring Camel inside Spring.

Note that this library is totally optional; you could just wire Camel together yourself with Java Config.

Example

The following example using Java Config is actually a Spring Testing based unit test.


@ContextConfiguration(
locations = "org.apache.camel.spring.javaconfig.patterns.FilterTest$ContextConfig",
loader = JavaConfigContextLoader.class)
public class FilterTest extends AbstractJUnit4SpringContextTests {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

@DirtiesContext
@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

@DirtiesContext
@Test
public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}
}



The @ContextConfiguration annotation tells the Spring Testing framework to load the ContextConfig class as the configuration to use. This class derives from SingleRouteCamelConfiguration which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.

If you wish to create a collection of RouteBuilder instances then derive from the CamelConfiguration helper class and implement the routes() method.
 
 
   
Change Notification Preferences
   

   View Online
   |
   View Change
  |
   Add Comment









[CONF] Apache Camel Spring Java Config Example

2009-12-29 Thread confluence







 Spring Java Config Example
 Page edited by willem jiang

 
  
 
 Spring Java Config Example 

The spring java config example is a simple refactor of the spring example since Camel 2.0 to show how to use the Spring JavaConfig approach to working with Camel. In this example we just write RouteBuilder implementations, then Camel will find it through your configuration.
NOTE From Camel 2.2.0, camel-example-spring-javaconfig can only work with Spring 3.x.

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work



cd examples/camel-example-spring-javaconfig
mvn camel:run



You need to add camel-spring-javaconfig dependency into pom.xml and also set the configure class or base package in the camel plugin configuration. 


dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring/artifactId
/dependency

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
/dependency



Here is the configuration for camel plugin.


plugins
  !-- Allows the routes to be run via 'mvn camel:run' --
  plugin
groupIdorg.apache.camel/groupId
artifactIdcamel-maven-plugin/artifactId
version${project.version}/version
configuration
duration5s/duration
configClassesorg.apache.camel.example.spring.javaconfig.MyRouteConfig/configClasses
!--You could set the base package directory and let spring to find the config classes for you 
basedPackagesorg.apache.camel.example.spring.javaconfig/basedPackages 
 --
/configuration
  /plugin
/plugins



What this does is boot up the Spring ApplicationContext defined in the file MyRouteConfig class on the classpath. This is a regular Java file which has the Spring JavaConfig annotation to configure a CamelContext.


/**
 * A simple example router from a file system to an ActiveMQ queue and then to a file system
 *
 * @version $Revision$
 */
@Configuration
public class MyRouteConfig extends SingleRouteCamelConfiguration implements InitializingBean, BundleContextAware {

private BundleContext bundleContext;

/**
 * Allow this route to be run as an application
 *
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
new Main().run(args);
}

public BundleContext getBundleContext() {
return bundleContext;
}

public void setBundleContext(BundleContext bundleContext) { 
this.bundleContext = bundleContext;
}


/**
 * Returns the CamelContext which support OSGi
 */
@Override
protected CamelContext createCamelContext() throws Exception {
SpringCamelContextFactory factory = new SpringCamelContextFactory();
factory.setApplicationContext(getApplicationContext());
factory.setBundleContext(getBundleContext());
return factory.createContext();
}

@Override
// setup the ActiveMQ component and register it into the camel context
protected void setupCamelContext(CamelContext camelContext) throws Exception {
JmsComponent answer = new JmsComponent();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm://localhost.spring.javaconfig?marshal=falsebroker.persistent=falsebroker.useJmx=false");
answer.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", answer);
}


public static class SomeBean {
public void someMethod(String body) {
System.out.println("Received: " + body);
}
}

@Bean
@Override
// you can confige the route rule with Java DSL here
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
// populate the message queue with some messages
from("file:src/data?noop=true").
to("jms:test.MyQueue");

from("jms:test.MyQueue").
to("file://target/test?noop=true");

// set up a listener on the file component
from("file://target/test?noop=true").
bean(new SomeBean());
}
};
}

public void afterPropertiesSet() throws Exception {
// just to make SpringDM happy do nothing here
}
}



In the method of setupCamelContext(CamelContext camelContext), we setup the JMS component's connection factory and register the component into the camelcontext. You can override this method if you want to setup the another connection factory or start up a JMS broker here.

You can write the route rule with Java DSL in the route() method.

This approach, of using Java code to write the routes in the DSL and Spring will help your configure the 

[CONF] Apache Camel Camel 2.2.0 Release

2009-12-29 Thread confluence







 Camel 2.2.0 Release
 Page edited by willem jiang

 
  
 
 Camel 2.2.0 release (currently in progress)




New and Noteworthy

Welcome to the 2.2.0 release which approx XXX issues resolved (new features, improvements and bug fixes such as...)


	Routing Slip now breaks when an exception occurred
	MINA now supports easier configuration of multiple custom codecs, which is needed when working with SSL.
	Improved TransactionErrorHandler two fold by reducing complexity of internal logic in Camel when working with transactions. And added better support for using multiple transactions in multiple routes. See more at section Using multiple routes with different propagation behaviors at Transactional Client.
	Recipient List now supports parallelProcessing, stopOnException and references for AggregationStrategy and thread pools. This applies to the @RecipientList annotation as well.
	Cleanup of spring jar dependencies.
	File Language is now merged directly into Simple language which among others makes Content Based Router in Spring XML using file language syntax easier.
	HTTP is now using CamelContext Properties instead of System Properties to set the http proxy configuration.
	Fixed Camel Proxy throwing exception if null was returned.
	Improved error handling with Recipient List and Multicast which now performs redelivery etc. on that output node instead of starting again from the scratch.
	Improved the ETL Example and BAM Example so they can be deployed into ServiceMix4(Karaf).
	SEDA now supports multipleConsumers which allows you to use it for pub-sub messaging where each consumer concurrently will receive a copy of the Exchange. This is done with the help from Multicast EIP.
	DefaultErrorHandler will now log a log line at ERROR level in case an Exception was thrown which could not be redelivered either. This aid to see that an Exception occurred instead of relying on the client logging it. You can customize this behavior on the Error Handler.
	Fixed groupedExchange not working properly on Aggregator.
	Graceful Shutdown which ensures Camel now shutdown in a more reliable and graceful manner. This also works with in memory components such as SEDA.
	Added new log in the DSL for dynamic human readable log messages.
	Camel now supports Spring 3.0.0 and camel-spring-javaconfig is moved to Spring 3.0.0
	Added methods for getting header and property (Exchange / Message API) which uses a default parameter.



New Enterprise Integration Patterns

New Components


	camel-ftp now supports FTPS (FTP over SSL/TLS)
	camel-smpp



New DSL


	markRollbackOnlyLast
	log



New Annotations

New Data Formats


	camel-protobuff



New Languages

New Examples

API breaking

DefaultComponent
The methods DefaultComponent.resolveAndRemoveReferenceParameter and DefaultComponent.resolveAndRemoveReferenceParameterList have been changed to make the leading # sign for bean references optional and to throw an IllegalArgumentException if a referenced bean is not in the registry. For details see CAMEL-2248.

Exchange
The property Exchange.FILTETED have been removed as part of CAMEL-2288.

Added two new methods for getProperty to accept a defaultValue as parameter to be used when the property does not exists.

Message
Added two new methods for getHeader to accept a defaultValue as parameter to be used when the header does not exists.

ExceptionHandler
The class org.apache.camel.spi.ExceptionHandler now have two additional methods which accepts more details when an Exception occurred such as a message and the current Exchange.

@EndpointInject
The name attribute in @EndpointInject has been renamed to ref to be consistent with the other annotations. Its a reference for an Endpoint to be looked up in the Registry.

BatchConsumer
The BatchConsumer have a new method isBatchAllowed which should be used during processing the batch, to break out the batch loop in case its not allowed anymore. Also BatchConsumer should consider implement ShutdownAware to support fine grained control during shutdown. See for example the GenericFileConsumer for details.

Known Issues

See known issues from previous releases.

Important changes to consider when upgrading

Spring jar dependencies have been cut down in camel-core.
The pom.xml file for camel-core have cut down number of spring jar dependencies to allow Camel to easily run without any Spring .jars at all. However this affects you if you use maven and use camel-core without camel-spring or spring at all. If you want to use JMX with Camel then you need to add the following 4 spring jars required: spring-core.jar, spring-beans.jar, spring-context.jar, spring-aop.jar. With maven you only need to depend on spring-context and spring-aop as they will bring in the other two jars.

See also Camel jar dependencies and Camel JMX.

Using filter in Splitter
The filter no long influence the split and its AggregationStrategy as it was just too confusing why it did that. 

[CONF] Apache Camel Camel 2.2.0 Release

2009-12-29 Thread confluence







 Camel 2.2.0 Release
 Page edited by willem jiang

 
  
 
 Camel 2.2.0 release (currently in progress)




New and Noteworthy

Welcome to the 2.2.0 release which approx XXX issues resolved (new features, improvements and bug fixes such as...)


	Routing Slip now breaks when an exception occurred
	MINA now supports easier configuration of multiple custom codecs, which is needed when working with SSL.
	Improved TransactionErrorHandler two fold by reducing complexity of internal logic in Camel when working with transactions. And added better support for using multiple transactions in multiple routes. See more at section Using multiple routes with different propagation behaviors at Transactional Client.
	Recipient List now supports parallelProcessing, stopOnException and references for AggregationStrategy and thread pools. This applies to the @RecipientList annotation as well.
	Cleanup of spring jar dependencies.
	File Language is now merged directly into Simple language which among others makes Content Based Router in Spring XML using file language syntax easier.
	HTTP is now using CamelContext Properties instead of System Properties to set the http proxy configuration.
	Fixed Camel Proxy throwing exception if null was returned.
	Improved error handling with Recipient List and Multicast which now performs redelivery etc. on that output node instead of starting again from the scratch.
	Improved the ETL Example and BAM Example so they can be deployed into ServiceMix4(Karaf).
	SEDA now supports multipleConsumers which allows you to use it for pub-sub messaging where each consumer concurrently will receive a copy of the Exchange. This is done with the help from Multicast EIP.
	DefaultErrorHandler will now log a log line at ERROR level in case an Exception was thrown which could not be redelivered either. This aid to see that an Exception occurred instead of relying on the client logging it. You can customize this behavior on the Error Handler.
	Fixed groupedExchange not working properly on Aggregator.
	Graceful Shutdown which ensures Camel now shutdown in a more reliable and graceful manner. This also works with in memory components such as SEDA.
	Added new log in the DSL for dynamic human readable log messages.
	Camel now supports Spring 3.0.0 and camel-spring-javaconfig is moved to Spring 3.0.0
	Added methods for getting header and property (Exchange / Message API) which uses a default parameter.
	Added OsgiClassResolver which supports to load the class or resources within OSGi platform.



New Enterprise Integration Patterns

New Components


	camel-ftp now supports FTPS (FTP over SSL/TLS)
	camel-smpp



New DSL


	markRollbackOnlyLast
	log



New Annotations

New Data Formats


	camel-protobuff



New Languages

New Examples

API breaking

DefaultComponent
The methods DefaultComponent.resolveAndRemoveReferenceParameter and DefaultComponent.resolveAndRemoveReferenceParameterList have been changed to make the leading # sign for bean references optional and to throw an IllegalArgumentException if a referenced bean is not in the registry. For details see CAMEL-2248.

Exchange
The property Exchange.FILTETED have been removed as part of CAMEL-2288.

Added two new methods for getProperty to accept a defaultValue as parameter to be used when the property does not exists.

Message
Added two new methods for getHeader to accept a defaultValue as parameter to be used when the header does not exists.

ExceptionHandler
The class org.apache.camel.spi.ExceptionHandler now have two additional methods which accepts more details when an Exception occurred such as a message and the current Exchange.

@EndpointInject
The name attribute in @EndpointInject has been renamed to ref to be consistent with the other annotations. Its a reference for an Endpoint to be looked up in the Registry.

BatchConsumer
The BatchConsumer have a new method isBatchAllowed which should be used during processing the batch, to break out the batch loop in case its not allowed anymore. Also BatchConsumer should consider implement ShutdownAware to support fine grained control during shutdown. See for example the GenericFileConsumer for details.

Known Issues

See known issues from previous releases.

Important changes to consider when upgrading

Spring jar dependencies have been cut down in camel-core.
The pom.xml file for camel-core have cut down number of spring jar dependencies to allow Camel to easily run without any Spring .jars at all. However this affects you if you use maven and use camel-core without camel-spring or spring at all. If you want to use JMX with Camel then you need to add the following 4 spring jars required: spring-core.jar, spring-beans.jar, spring-context.jar, spring-aop.jar. With maven you only need to depend on spring-context and spring-aop as they will bring in the other two jars.

See also Camel jar dependencies and Camel JMX.

Using filter in Splitter
The filter no long 

svn commit: r894550 - in /camel/trunk/components/camel-quartz/src: main/java/org/apache/camel/component/quartz/QuartzComponent.java test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.j

2009-12-29 Thread ningjiang
Author: ningjiang
Date: Wed Dec 30 07:01:04 2009
New Revision: 894550

URL: http://svn.apache.org/viewvc?rev=894550view=rev
Log:
CAMEL-2324 Implemented fireNow option on camel-quartz component

Added:

camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.java
   (with props)
Modified:

camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java

Modified: 
camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java?rev=894550r1=894549r2=894550view=diff
==
--- 
camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
 (original)
+++ 
camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
 Wed Dec 30 07:01:04 2009
@@ -18,6 +18,7 @@
 
 import java.net.URI;
 import java.text.ParseException;
+import java.util.Date;
 import java.util.Map;
 
 import org.apache.camel.CamelContext;
@@ -63,6 +64,7 @@
 String path = ObjectHelper.after(u.getPath(), /);
 String host = u.getHost();
 String cron = getAndRemoveParameter(parameters, cron, String.class);
+Boolean fireNow = getAndRemoveParameter(parameters, fireNow, 
Boolean.class, Boolean.FALSE);
 
 // group can be optional, if so set it to Camel
 String name;
@@ -75,21 +77,28 @@
 name = host;
 }
 
+MapString, Object triggerParameters = 
IntrospectionSupport.extractProperties(parameters, trigger.);
+MapString, Object jobParameters = 
IntrospectionSupport.extractProperties(parameters, job.);
+
 // create the trigger either cron or simple
 Trigger trigger;
 if (ObjectHelper.isNotEmpty(cron)) {
 trigger = createCronTrigger(cron);
 } else {
 trigger = new SimpleTrigger();
+if (fireNow) {
+String intervalString = (String) 
triggerParameters.get(repeatInterval);
+if (intervalString != null) {
+long interval = Long.valueOf(intervalString);
+trigger.setStartTime(new Date(System.currentTimeMillis() - 
interval));
+}
+}
 }
 answer.setTrigger(trigger);
 
 trigger.setName(name);
 trigger.setGroup(group);
-
-MapString, Object triggerParameters = 
IntrospectionSupport.extractProperties(parameters, trigger.);
-MapString, Object jobParameters = 
IntrospectionSupport.extractProperties(parameters, job.);
-
+
 setProperties(trigger, triggerParameters);
 setProperties(answer.getJobDetail(), jobParameters);
 

Added: 
camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.java?rev=894550view=auto
==
--- 
camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.java
 (added)
+++ 
camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzRouteFireNowTest.java
 Wed Dec 30 07:01:04 2009
@@ -0,0 +1,44 @@
+/**
+ * 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.component.quartz;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class QuartzRouteFireNowTest extends QuartzRouteTest {
+
+@Override
+protected RouteBuilder createRouteBuilder() {
+return new RouteBuilder() {
+

[CONF] Apache Camel Quartz

2009-12-29 Thread confluence







 Quartz
 Page edited by willem jiang

 CAMEL-2324
  
 CAMEL-2324
 
  
 
 Quartz Component

The quartz: component provides a scheduled delivery of messages using the Quartz scheduler. 
Each endpoint represents a different timer (in Quartz terms, a Trigger and JobDetail).

Using cron expressionsConfiguring the cron _expression_ in Camel 1.x is based on path separators. We changed this to an URI option in Camel 2.0, allowing a more elegant configuration.
Also it is not possible to use the / cron special character (for increments) in Camel 1.x, which Camel 2.0 also fixes.

URI format



quartz://timerName?options
quartz://groupName/timerName?options
quartz://groupName/timerName/cronExpression   (@deprecated)
quartz://groupName/timerName/?cron=_expression_ (Camel 2.0)
quartz://timerName?cron=_expression_(Camel 2.0)



The component uses either a CronTrigger or a SimpleTrigger. If no cron _expression_ is provided, the component uses a simple trigger. If no groupName is provided, the quartz component uses the Camel group name.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options



 Parameter 
 Default 
 Description 


 cron 
 None 
 Specifies a cron _expression_ (not compatible with the trigger. or job. options). 


 trigger.repeatCount 
 0 
 SimpleTrigger: How many times should the timer repeat? 


 trigger.repeatInterval 
 0 
 SimpleTrigger: The amount of time in milliseconds between repeated triggers. 


 job.name 
 null 
 Sets the job name. 


 job.XXX 
 null 
 Sets the job option with the XXX setter name. 


 trigger.XXX 
 null 
 Sets the trigger option with the XXX setter name. 


 stateful 
 false 
 Uses a Quartz StatefulJob instead of the default job. 


 fireNow 
 false 
 New to Camel 2.2.0, if it is true will fire the trigger when the route is start when using SimpleTrigger.



For example, the following routing rule will fire two timer events to the mock:results endpoint:


from("quartz://myGroup/myTimerName?trigger.repeatInterval=2trigger.repeatCount=1").to("mock:result");



When using a StatefulJob, the JobDataMap is re-persisted after every execution of the job, thus preserving state for the next execution.

Message Headers
Camel adds the getters from the Quartz Execution Context as header values. The following headers are added:
calendar, fireTime, jobDetail, jobInstance, jobRuntTime, mergedJobDataMap, nextFireTime, previousFireTime, refireCount, result, scheduledFireTime, scheduler, trigger, triggerName, triggerGroup.

The fireTime header contains the java.util.Date of when the exchange was fired.

Using Cron Triggers
Avaiable as of Camel 2.0
Quartz supports Cron-like expressions for specifying timers in a handy format. You can use these expressions in the cron URI parameter; though to preserve valid URI encoding we allow + to be used instead of spaces. Quartz provides a little tutorial on how to use cron expressions.

For example the following will fire a message at 12pm (noon) every day


from("quartz://myGroup/myTimerName?cron=0+0/5+12-18+?+*+MON-FRI").to("activemq:Totally.Rocks");



which is equivalent to using the cron _expression_


0 0/5 12-18 ? * MON-FRI



The following table shows the URI character encodings we use to preserve valid URI syntax:


URI Character
Cron character


  
 Space 



Using Cron Triggers in Camel 1.x
@deprecated
Quartz supports Cron-like expressions for specifying timers in a handy format. You can use these expressions in the URI; though to preserve valid URI encoding we allow / to be used instead of spaces and $ to be used instead of ?.

For example, the following endpoint URI will fire a message at 12pm (noon) every day



from("quartz://myGroup/myTimerName/0/0/12/*/*/$").to("activemq:Totally.Rocks");



which is equivalent to using the cron _expression_



0 0 12 * * ?



The following table shows the URI character encodings we use to preserve valid URI syntax:



URI Character
Cron character


 / 
 Space 


 $ 
 ? 



See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started



	Timer



 
 
   
Change Notification Preferences
   

   View Online
   |
   View Change
  |
   Add Comment









[CONF] Apache Camel Camel 2.2.0 Release

2009-12-29 Thread confluence







 Camel 2.2.0 Release
 Page edited by willem jiang

 
  
 
 Camel 2.2.0 release (currently in progress)




New and Noteworthy

Welcome to the 2.2.0 release which approx XXX issues resolved (new features, improvements and bug fixes such as...)


	Routing Slip now breaks when an exception occurred
	MINA now supports easier configuration of multiple custom codecs, which is needed when working with SSL.
	Improved TransactionErrorHandler two fold by reducing complexity of internal logic in Camel when working with transactions. And added better support for using multiple transactions in multiple routes. See more at section Using multiple routes with different propagation behaviors at Transactional Client.
	Recipient List now supports parallelProcessing, stopOnException and references for AggregationStrategy and thread pools. This applies to the @RecipientList annotation as well.
	Cleanup of spring jar dependencies.
	File Language is now merged directly into Simple language which among others makes Content Based Router in Spring XML using file language syntax easier.
	HTTP is now using CamelContext Properties instead of System Properties to set the http proxy configuration.
	Fixed Camel Proxy throwing exception if null was returned.
	Improved error handling with Recipient List and Multicast which now performs redelivery etc. on that output node instead of starting again from the scratch.
	Improved the ETL Example and BAM Example so they can be deployed into ServiceMix4(Karaf).
	SEDA now supports multipleConsumers which allows you to use it for pub-sub messaging where each consumer concurrently will receive a copy of the Exchange. This is done with the help from Multicast EIP.
	DefaultErrorHandler will now log a log line at ERROR level in case an Exception was thrown which could not be redelivered either. This aid to see that an Exception occurred instead of relying on the client logging it. You can customize this behavior on the Error Handler.
	Fixed groupedExchange not working properly on Aggregator.
	Graceful Shutdown which ensures Camel now shutdown in a more reliable and graceful manner. This also works with in memory components such as SEDA.
	Added new log in the DSL for dynamic human readable log messages.
	Camel now supports Spring 3.0.0 and camel-spring-javaconfig is moved to Spring 3.0.0
	Added methods for getting header and property (Exchange / Message API) which uses a default parameter.
	Added OsgiClassResolver which supports to load the class or resources within OSGi platform.
	Added fireNow option to camel-quartz component to fire the trigger when the route is started.



New Enterprise Integration Patterns

New Components


	camel-ftp now supports FTPS (FTP over SSL/TLS)
	camel-smpp



New DSL


	markRollbackOnlyLast
	log



New Annotations

New Data Formats


	camel-protobuff



New Languages

New Examples

API breaking

DefaultComponent
The methods DefaultComponent.resolveAndRemoveReferenceParameter and DefaultComponent.resolveAndRemoveReferenceParameterList have been changed to make the leading # sign for bean references optional and to throw an IllegalArgumentException if a referenced bean is not in the registry. For details see CAMEL-2248.

Exchange
The property Exchange.FILTETED have been removed as part of CAMEL-2288.

Added two new methods for getProperty to accept a defaultValue as parameter to be used when the property does not exists.

Message
Added two new methods for getHeader to accept a defaultValue as parameter to be used when the header does not exists.

ExceptionHandler
The class org.apache.camel.spi.ExceptionHandler now have two additional methods which accepts more details when an Exception occurred such as a message and the current Exchange.

@EndpointInject
The name attribute in @EndpointInject has been renamed to ref to be consistent with the other annotations. Its a reference for an Endpoint to be looked up in the Registry.

BatchConsumer
The BatchConsumer have a new method isBatchAllowed which should be used during processing the batch, to break out the batch loop in case its not allowed anymore. Also BatchConsumer should consider implement ShutdownAware to support fine grained control during shutdown. See for example the GenericFileConsumer for details.

Known Issues

See known issues from previous releases.

Important changes to consider when upgrading

Spring jar dependencies have been cut down in camel-core.
The pom.xml file for camel-core have cut down number of spring jar dependencies to allow Camel to easily run without any Spring .jars at all. However this affects you if you use maven and use camel-core without camel-spring or spring at all. If you want to use JMX with Camel then you need to add the following 4 spring jars required: spring-core.jar, spring-beans.jar, spring-context.jar, spring-aop.jar. With maven you only need to depend on spring-context and spring-aop as they will bring in the other two jars.