You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2007/06/12 20:20:19 UTC
svn commit: r546580 [2/3] - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/builder/
camel-core/src/main/java/org/apache/camel/component/direct/
camel-core/src/main/java/org/apache/camel/co...
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java Tue Jun 12 11:20:13 2007
@@ -1,90 +1,90 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.TestSupport;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.processor.DelegateProcessor;
-
-/**
- * @version $Revision: 530102 $
- */
-public class InterceptorBuilderTest extends TestSupport {
-
-
- /**
- * Validates that interceptors are executed in the right order.
- * @throws Exception
- */
- public void testRouteWithInterceptor() throws Exception {
-
- CamelContext container = new DefaultCamelContext();
- final ArrayList<String> order = new ArrayList<String>();
-
- final DelegateProcessor interceptor1 = new DelegateProcessor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- order.add("START:1");
- super.process(exchange);
- order.add("END:1");
- }
- };
- final DelegateProcessor interceptor2 = new DelegateProcessor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- order.add("START:2");
- super.process(exchange);
- order.add("END:2");
- }
- };
-
- RouteBuilder builder = new RouteBuilder() {
- public void configure() {
- from("direct:a")
- .intercept()
- .add(interceptor1)
- .add(interceptor2)
- .target().to("direct:d");
- }
- };
- container.addRoutes(builder);
- container.start();
-
- Endpoint<Exchange> endpoint = container.getEndpoint("direct:a");
- Exchange exchange = endpoint.createExchange();
- Producer<Exchange> producer = endpoint.createProducer();
- producer.process(exchange);
-
-
- ArrayList<String> expected = new ArrayList<String>();
- expected.add("START:1");
- expected.add("START:2");
- expected.add("END:2");
- expected.add("END:1");
-
- log.debug("Interceptor invocation order:"+order);
- assertEquals(expected, order);
-
- }
-
-}
+/*
+ * 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;
+
+import java.util.ArrayList;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.TestSupport;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.processor.DelegateProcessor;
+
+/**
+ * @version $Revision: 530102 $
+ */
+public class InterceptorBuilderTest extends TestSupport {
+
+
+ /**
+ * Validates that interceptors are executed in the right order.
+ * @throws Exception
+ */
+ public void testRouteWithInterceptor() throws Exception {
+
+ CamelContext container = new DefaultCamelContext();
+ final ArrayList<String> order = new ArrayList<String>();
+
+ final DelegateProcessor interceptor1 = new DelegateProcessor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ order.add("START:1");
+ super.process(exchange);
+ order.add("END:1");
+ }
+ };
+ final DelegateProcessor interceptor2 = new DelegateProcessor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ order.add("START:2");
+ super.process(exchange);
+ order.add("END:2");
+ }
+ };
+
+ RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ from("direct:a")
+ .intercept()
+ .add(interceptor1)
+ .add(interceptor2)
+ .target().to("direct:d");
+ }
+ };
+ container.addRoutes(builder);
+ container.start();
+
+ Endpoint<Exchange> endpoint = container.getEndpoint("direct:a");
+ Exchange exchange = endpoint.createExchange();
+ Producer<Exchange> producer = endpoint.createProducer();
+ producer.process(exchange);
+
+
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("START:1");
+ expected.add("START:2");
+ expected.add("END:2");
+ expected.add("END:1");
+
+ log.debug("Interceptor invocation order:"+order);
+ assertEquals(expected, order);
+
+ }
+
+}
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/MyInterceptorProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/MyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/DirectRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/ISay.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/PojoRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/SayService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/timer/TimerRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/queue/QueueRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java Tue Jun 12 11:20:13 2007
@@ -1,44 +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.impl;
-
-import junit.framework.TestCase;
-
-import org.apache.camel.Component;
-import org.apache.camel.component.pojo.PojoComponent;
-
-/**
- * @version $Revision: 525634 $
- */
-public class DefaultCamelContextTest extends TestCase {
-
- public void testAutoCreateComponentsOn() {
- DefaultCamelContext ctx = new DefaultCamelContext();
- Component component = ctx.getComponent("pojo");
- assertNotNull(component);
- assertEquals(component.getClass(), PojoComponent.class);
- }
-
- public void testAutoCreateComponentsOff() {
- DefaultCamelContext ctx = new DefaultCamelContext();
- ctx.setAutoCreateComponents(false);
- Component component = ctx.getComponent("pojo");
- assertNull(component);
- }
-
-}
+/**
+ *
+ * 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.impl;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.Component;
+import org.apache.camel.component.pojo.PojoComponent;
+
+/**
+ * @version $Revision: 525634 $
+ */
+public class DefaultCamelContextTest extends TestCase {
+
+ public void testAutoCreateComponentsOn() {
+ DefaultCamelContext ctx = new DefaultCamelContext();
+ Component component = ctx.getComponent("pojo");
+ assertNotNull(component);
+ assertEquals(component.getClass(), PojoComponent.class);
+ }
+
+ public void testAutoCreateComponentsOff() {
+ DefaultCamelContext ctx = new DefaultCamelContext();
+ ctx.setAutoCreateComponents(false);
+ Component component = ctx.getComponent("pojo");
+ assertNull(component);
+ }
+
+}
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/NoCorrelationKeyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/rules/ActivityRules.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/rules/ProcessRules.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/rules/TemporalRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/JettyHttpComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringAndJmsNameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringWithAutoWireTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java Tue Jun 12 11:20:13 2007
@@ -1,272 +1,272 @@
-/**
- *
- * 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.jms;
-
-import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-import static org.apache.camel.component.mock.MockEndpoint.assertWait;
-
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Session;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Processor;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.processor.DelegateProcessor;
-import org.apache.camel.spi.Policy;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.spring.SpringRouteBuilder;
-import org.apache.camel.spring.spi.SpringTransactionPolicy;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.support.TransactionTemplate;
-
-/**
- * @version $Revision: 529902 $
- */
-public class TransactedJmsRouteTest extends ContextTestSupport {
-
- private static final transient Log log = LogFactory.getLog(TransactedJmsRouteTest.class);
- private MockEndpoint mockEndpointA;
- private MockEndpoint mockEndpointB;
- private ClassPathXmlApplicationContext spring;
- private MockEndpoint mockEndpointC;
- private MockEndpoint mockEndpointD;
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new SpringRouteBuilder() {
- public void configure() {
-
- Policy requried = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_REQUIRED"));
- Policy notsupported = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_NOT_SUPPORTED"));
- Policy requirenew = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_REQUIRES_NEW"));
-
- Policy rollback = new Policy() {
- public Processor wrap(Processor processor) {
- return new DelegateProcessor(processor) {
- @Override
- public void process(Exchange exchange) throws Exception {
- processNext(exchange);
- throw new RuntimeException("rollback");
- }
-
- @Override
- public String toString() {
- return "rollback(" + next + ")";
- }
- };
- }
- };
-
- Policy catchRollback = new Policy() {
- public Processor wrap(Processor processor) {
- return new DelegateProcessor(processor) {
- @Override
- public void process(Exchange exchange) {
- try {
- processNext(exchange);
- } catch ( Throwable e ) {
- }
- }
- @Override
- public String toString() {
- return "catchRollback(" + next + ")";
- }
- };
- }
- };
-
- // NOTE: ErrorHandler has to be disabled since it operates within the failed transaction.
- inheritErrorHandler(false);
- // Used to validate messages are sent to the target.
- from("activemq:queue:mock.a").trace().to("mock:a");
- from("activemq:queue:mock.b").trace().to("mock:b");
- from("activemq:queue:mock.c").trace().to("mock:c");
- from("activemq:queue:mock.d").trace().to("mock:d");
-
- // Receive from a and send to target in 1 tx.
- from("activemq:queue:a").to("activemq:queue:mock.a");
-
- // Cause an error after processing the send. The send to activemq:queue:mock.a should rollback
- // since it is participating in the inbound transaction, but mock:b does not participate so we should see the message get
- // there. Also, expect multiple inbound retries as the message is rolled back.
- //transactionPolicy(requried);
- from("activemq:queue:b").policy(rollback).to("activemq:queue:mock.a", "mock:b");
-
- // Cause an error after processing the send in a new transaction. The send to activemq:queue:mock.a should rollback
- // since the rollback is within it's transaction, but mock:b does not participate so we should see the message get
- // there. Also, expect the message to be successfully consumed since the rollback error is not propagated.
- //transactionPolicy(requried);
- from("activemq:queue:c").policy(catchRollback).policy(requirenew).policy(rollback).to("activemq:queue:mock.a", "mock:b");
-
- // Cause an error after processing the send in without a transaction. The send to activemq:queue:mock.a should succeed.
- // Also, expect the message to be successfully consumed since the rollback error is not propagated.
- from("activemq:queue:d").policy(catchRollback).policy(notsupported).policy(rollback).to("activemq:queue:mock.a");
-
- // Receive message on a non transacted JMS endpoint, start a transaction, send and then rollback.
- // mock:a should never get the message (due to rollback) but mock:b should get only 1 since the
- // inbound was not transacted.
- JmsEndpoint endpoint = (JmsEndpoint)endpoint("activemq:queue:e");
- endpoint.getConfiguration().setTransacted(false);
- endpoint.getConfiguration().setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);
- from(endpoint).policy(requried).policy(rollback).to("activemq:queue:mock.a", "mock:b");
-
-
- //
- // Sets up 2 consumers on single topic, one being transacted the other not. Used to verify
- // That each consumer can have independently configured transaction settings.
- // Do a rollback, should cause the transacted consumer to re-deliver (since we are using a durable subscription) but not the un-transacted one.
- // TODO: find out why re-delivery is not working with a non durable transacted topic.
- JmsEndpoint endpoint1 = (JmsEndpoint) endpoint("activemq:topic:f");
- endpoint1.getConfiguration().setTransacted(true);
- endpoint1.getConfiguration().setSubscriptionDurable(true);
- endpoint1.getConfiguration().setClientId("client2");
- endpoint1.getConfiguration().setDurableSubscriptionName("sub");
- from(endpoint1).policy(requried).policy(rollback).to("activemq:queue:mock.a", "mock:b");
-
- JmsEndpoint endpoint2 = (JmsEndpoint) endpoint("activemq:topic:f");
- endpoint2.getConfiguration().setTransacted(false);
- endpoint2.getConfiguration().setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);
- endpoint2.getConfiguration().setSubscriptionDurable(true);
- endpoint2.getConfiguration().setClientId("client1");
- endpoint2.getConfiguration().setDurableSubscriptionName("sub");
- from(endpoint2).policy(requried).policy(rollback).to("activemq:queue:mock.c", "mock:d");
- }
- };
- }
-
- protected CamelContext createCamelContext() throws Exception {
- spring = new ClassPathXmlApplicationContext("org/apache/camel/component/jms/spring.xml");
- SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
- PlatformTransactionManager transactionManager = (PlatformTransactionManager) spring.getBean("jmsTransactionManager");
- ConnectionFactory connectionFactory = (ConnectionFactory) spring.getBean("jmsConnectionFactory");
- JmsComponent component = JmsComponent.jmsComponentTransacted(connectionFactory, transactionManager);
- component.getConfiguration().setConcurrentConsumers(1);
- ctx.addComponent("activemq", component);
- return ctx;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
-// for (Route route : this.context.getRoutes()) {
-// System.out.println(route);
-// }
-
- mockEndpointA = (MockEndpoint) resolveMandatoryEndpoint("mock:a");
- mockEndpointB = (MockEndpoint) resolveMandatoryEndpoint("mock:b");
- mockEndpointC = (MockEndpoint) resolveMandatoryEndpoint("mock:c");
- mockEndpointD = (MockEndpoint) resolveMandatoryEndpoint("mock:d");
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- spring.destroy();
- }
-
- /**
- * This test seems to be fail every other run.
- * @throws Exception
- */
- public void disabledtestSenarioF() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedMessageCount(0);
- mockEndpointB.expectedMinimumMessageCount(2);
- mockEndpointC.expectedMessageCount(0);
- mockEndpointD.expectedMessageCount(1);
- sendBody("activemq:topic:f", expected);
-
- // Wait till the endpoints get their messages.
- assertWait(10, TimeUnit.SECONDS, mockEndpointA,mockEndpointB,mockEndpointC,mockEndpointD);
-
- // Wait a little more to make sure extra messages are not received.
- Thread.sleep(1000);
-
- assertIsSatisfied(mockEndpointA,mockEndpointB,mockEndpointC,mockEndpointD);
- }
-
- public void testSenarioA() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedBodiesReceived(expected);
- sendBody("activemq:queue:a", expected);
- assertIsSatisfied(mockEndpointA);
- }
-
- public void testSenarioB() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedMessageCount(0);
- mockEndpointB.expectedMinimumMessageCount(2); // May be more since spring seems to go into tight loop re-delivering.
- sendBody("activemq:queue:b", expected);
- assertIsSatisfied(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
- }
-
- public void testSenarioC() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedMessageCount(0);
- mockEndpointB.expectedMessageCount(1); // Should only get 1 message the incoming transaction does not rollback.
- sendBody("activemq:queue:c", expected);
-
- // Wait till the endpoints get their messages.
- assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
-
- // Wait a little more to make sure extra messages are not received.
- Thread.sleep(1000);
-
- assertIsSatisfied(mockEndpointA,mockEndpointB);
- }
-
- public void testSenarioD() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedMessageCount(1);
- sendBody("activemq:queue:d", expected);
-
- // Wait till the endpoints get their messages.
- assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
-
- // Wait a little more to make sure extra messages are not received.
- Thread.sleep(1000);
-
- assertIsSatisfied(mockEndpointA);
- }
-
- public void testSenarioE() throws Exception {
- String expected = getName()+": "+System.currentTimeMillis();
- mockEndpointA.expectedMessageCount(0);
- mockEndpointB.expectedMessageCount(1);
- sendBody("activemq:queue:e", expected);
-
- // Wait till the endpoints get their messages.
- assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
-
- // Wait a little more to make sure extra messages are not received.
- Thread.sleep(1000);
-
- assertIsSatisfied(mockEndpointA, mockEndpointB);
- }
-
-
-}
+/**
+ *
+ * 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.jms;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.apache.camel.component.mock.MockEndpoint.assertWait;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.DelegateProcessor;
+import org.apache.camel.spi.Policy;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.spring.spi.SpringTransactionPolicy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
+
+/**
+ * @version $Revision: 529902 $
+ */
+public class TransactedJmsRouteTest extends ContextTestSupport {
+
+ private static final transient Log log = LogFactory.getLog(TransactedJmsRouteTest.class);
+ private MockEndpoint mockEndpointA;
+ private MockEndpoint mockEndpointB;
+ private ClassPathXmlApplicationContext spring;
+ private MockEndpoint mockEndpointC;
+ private MockEndpoint mockEndpointD;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new SpringRouteBuilder() {
+ public void configure() {
+
+ Policy requried = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_REQUIRED"));
+ Policy notsupported = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_NOT_SUPPORTED"));
+ Policy requirenew = new SpringTransactionPolicy(bean(TransactionTemplate.class, "PROPAGATION_REQUIRES_NEW"));
+
+ Policy rollback = new Policy() {
+ public Processor wrap(Processor processor) {
+ return new DelegateProcessor(processor) {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ processNext(exchange);
+ throw new RuntimeException("rollback");
+ }
+
+ @Override
+ public String toString() {
+ return "rollback(" + next + ")";
+ }
+ };
+ }
+ };
+
+ Policy catchRollback = new Policy() {
+ public Processor wrap(Processor processor) {
+ return new DelegateProcessor(processor) {
+ @Override
+ public void process(Exchange exchange) {
+ try {
+ processNext(exchange);
+ } catch ( Throwable e ) {
+ }
+ }
+ @Override
+ public String toString() {
+ return "catchRollback(" + next + ")";
+ }
+ };
+ }
+ };
+
+ // NOTE: ErrorHandler has to be disabled since it operates within the failed transaction.
+ inheritErrorHandler(false);
+ // Used to validate messages are sent to the target.
+ from("activemq:queue:mock.a").trace().to("mock:a");
+ from("activemq:queue:mock.b").trace().to("mock:b");
+ from("activemq:queue:mock.c").trace().to("mock:c");
+ from("activemq:queue:mock.d").trace().to("mock:d");
+
+ // Receive from a and send to target in 1 tx.
+ from("activemq:queue:a").to("activemq:queue:mock.a");
+
+ // Cause an error after processing the send. The send to activemq:queue:mock.a should rollback
+ // since it is participating in the inbound transaction, but mock:b does not participate so we should see the message get
+ // there. Also, expect multiple inbound retries as the message is rolled back.
+ //transactionPolicy(requried);
+ from("activemq:queue:b").policy(rollback).to("activemq:queue:mock.a", "mock:b");
+
+ // Cause an error after processing the send in a new transaction. The send to activemq:queue:mock.a should rollback
+ // since the rollback is within it's transaction, but mock:b does not participate so we should see the message get
+ // there. Also, expect the message to be successfully consumed since the rollback error is not propagated.
+ //transactionPolicy(requried);
+ from("activemq:queue:c").policy(catchRollback).policy(requirenew).policy(rollback).to("activemq:queue:mock.a", "mock:b");
+
+ // Cause an error after processing the send in without a transaction. The send to activemq:queue:mock.a should succeed.
+ // Also, expect the message to be successfully consumed since the rollback error is not propagated.
+ from("activemq:queue:d").policy(catchRollback).policy(notsupported).policy(rollback).to("activemq:queue:mock.a");
+
+ // Receive message on a non transacted JMS endpoint, start a transaction, send and then rollback.
+ // mock:a should never get the message (due to rollback) but mock:b should get only 1 since the
+ // inbound was not transacted.
+ JmsEndpoint endpoint = (JmsEndpoint)endpoint("activemq:queue:e");
+ endpoint.getConfiguration().setTransacted(false);
+ endpoint.getConfiguration().setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);
+ from(endpoint).policy(requried).policy(rollback).to("activemq:queue:mock.a", "mock:b");
+
+
+ //
+ // Sets up 2 consumers on single topic, one being transacted the other not. Used to verify
+ // That each consumer can have independently configured transaction settings.
+ // Do a rollback, should cause the transacted consumer to re-deliver (since we are using a durable subscription) but not the un-transacted one.
+ // TODO: find out why re-delivery is not working with a non durable transacted topic.
+ JmsEndpoint endpoint1 = (JmsEndpoint) endpoint("activemq:topic:f");
+ endpoint1.getConfiguration().setTransacted(true);
+ endpoint1.getConfiguration().setSubscriptionDurable(true);
+ endpoint1.getConfiguration().setClientId("client2");
+ endpoint1.getConfiguration().setDurableSubscriptionName("sub");
+ from(endpoint1).policy(requried).policy(rollback).to("activemq:queue:mock.a", "mock:b");
+
+ JmsEndpoint endpoint2 = (JmsEndpoint) endpoint("activemq:topic:f");
+ endpoint2.getConfiguration().setTransacted(false);
+ endpoint2.getConfiguration().setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);
+ endpoint2.getConfiguration().setSubscriptionDurable(true);
+ endpoint2.getConfiguration().setClientId("client1");
+ endpoint2.getConfiguration().setDurableSubscriptionName("sub");
+ from(endpoint2).policy(requried).policy(rollback).to("activemq:queue:mock.c", "mock:d");
+ }
+ };
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ spring = new ClassPathXmlApplicationContext("org/apache/camel/component/jms/spring.xml");
+ SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
+ PlatformTransactionManager transactionManager = (PlatformTransactionManager) spring.getBean("jmsTransactionManager");
+ ConnectionFactory connectionFactory = (ConnectionFactory) spring.getBean("jmsConnectionFactory");
+ JmsComponent component = JmsComponent.jmsComponentTransacted(connectionFactory, transactionManager);
+ component.getConfiguration().setConcurrentConsumers(1);
+ ctx.addComponent("activemq", component);
+ return ctx;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+// for (Route route : this.context.getRoutes()) {
+// System.out.println(route);
+// }
+
+ mockEndpointA = (MockEndpoint) resolveMandatoryEndpoint("mock:a");
+ mockEndpointB = (MockEndpoint) resolveMandatoryEndpoint("mock:b");
+ mockEndpointC = (MockEndpoint) resolveMandatoryEndpoint("mock:c");
+ mockEndpointD = (MockEndpoint) resolveMandatoryEndpoint("mock:d");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ spring.destroy();
+ }
+
+ /**
+ * This test seems to be fail every other run.
+ * @throws Exception
+ */
+ public void disabledtestSenarioF() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedMessageCount(0);
+ mockEndpointB.expectedMinimumMessageCount(2);
+ mockEndpointC.expectedMessageCount(0);
+ mockEndpointD.expectedMessageCount(1);
+ sendBody("activemq:topic:f", expected);
+
+ // Wait till the endpoints get their messages.
+ assertWait(10, TimeUnit.SECONDS, mockEndpointA,mockEndpointB,mockEndpointC,mockEndpointD);
+
+ // Wait a little more to make sure extra messages are not received.
+ Thread.sleep(1000);
+
+ assertIsSatisfied(mockEndpointA,mockEndpointB,mockEndpointC,mockEndpointD);
+ }
+
+ public void testSenarioA() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedBodiesReceived(expected);
+ sendBody("activemq:queue:a", expected);
+ assertIsSatisfied(mockEndpointA);
+ }
+
+ public void testSenarioB() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedMessageCount(0);
+ mockEndpointB.expectedMinimumMessageCount(2); // May be more since spring seems to go into tight loop re-delivering.
+ sendBody("activemq:queue:b", expected);
+ assertIsSatisfied(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
+ }
+
+ public void testSenarioC() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedMessageCount(0);
+ mockEndpointB.expectedMessageCount(1); // Should only get 1 message the incoming transaction does not rollback.
+ sendBody("activemq:queue:c", expected);
+
+ // Wait till the endpoints get their messages.
+ assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
+
+ // Wait a little more to make sure extra messages are not received.
+ Thread.sleep(1000);
+
+ assertIsSatisfied(mockEndpointA,mockEndpointB);
+ }
+
+ public void testSenarioD() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedMessageCount(1);
+ sendBody("activemq:queue:d", expected);
+
+ // Wait till the endpoints get their messages.
+ assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
+
+ // Wait a little more to make sure extra messages are not received.
+ Thread.sleep(1000);
+
+ assertIsSatisfied(mockEndpointA);
+ }
+
+ public void testSenarioE() throws Exception {
+ String expected = getName()+": "+System.currentTimeMillis();
+ mockEndpointA.expectedMessageCount(0);
+ mockEndpointB.expectedMessageCount(1);
+ sendBody("activemq:queue:e", expected);
+
+ // Wait till the endpoints get their messages.
+ assertWait(5, TimeUnit.SECONDS, mockEndpointA,mockEndpointB);
+
+ // Wait a little more to make sure extra messages are not received.
+ Thread.sleep(1000);
+
+ assertIsSatisfied(mockEndpointA, mockEndpointB);
+ }
+
+
+}
Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-josql/src/main/java/org/apache/camel/builder/sql/SqlBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-josql/src/test/java/org/apache/camel/builder/sql/Person.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-josql/src/test/java/org/apache/camel/builder/sql/SqlTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java (original)
+++ activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java Tue Jun 12 11:20:13 2007
@@ -1,45 +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.component.rmi;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.component.pojo.PojoExchange;
-import org.apache.camel.impl.DefaultComponent;
-
-/**
- * @version $Revision:520964 $
- */
-public class RmiComponent extends DefaultComponent<PojoExchange> {
-
- public RmiComponent() {
- }
-
- public RmiComponent(CamelContext context) {
- super(context);
- }
-
- @Override
- protected Endpoint<PojoExchange> createEndpoint(String uri,
- String remaining, Map parameters) throws Exception {
- return new RmiEndpoint(uri, this);
- }
-
-}
+/**
+ *
+ * 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.rmi;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class RmiComponent extends DefaultComponent<PojoExchange> {
+
+ public RmiComponent() {
+ }
+
+ public RmiComponent(CamelContext context) {
+ super(context);
+ }
+
+ @Override
+ protected Endpoint<PojoExchange> createEndpoint(String uri,
+ String remaining, Map parameters) throws Exception {
+ return new RmiEndpoint(uri, this);
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java (original)
+++ activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java Tue Jun 12 11:20:13 2007
@@ -1,107 +1,107 @@
-/**
- *
- * 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.rmi;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.rmi.Remote;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.component.pojo.PojoExchange;
-import org.apache.camel.component.pojo.PojoInvocation;
-import org.apache.camel.impl.DefaultConsumer;
-
-/**
- * A {@link Consumer} which uses RMI's {@see UnicastRemoteObject} to consume method invocations.
- *
- * @version $Revision: 533758 $
- */
-public class RmiConsumer extends DefaultConsumer<PojoExchange> implements InvocationHandler {
-
- private final RmiEndpoint endpoint;
- private Remote stub;
- private Remote proxy;
-
- public RmiConsumer(RmiEndpoint endpoint, Processor processor) {
- super(endpoint, processor);
- this.endpoint = endpoint;
-
- }
-
- @Override
- protected void doStart() throws Exception {
- Class[] interfaces = new Class[endpoint.getRemoteInterfaces().size()];
- endpoint.getRemoteInterfaces().toArray(interfaces);
- proxy = (Remote) Proxy.newProxyInstance(endpoint.getClassLoader(), interfaces, this);
- stub = UnicastRemoteObject.exportObject(proxy,endpoint.getPort());
-
- try {
- Registry registry = endpoint.getRegistry();
- String name = endpoint.getName();
- registry.bind(name, stub);
-
- } catch (Exception e) { // Registration might fail.. clean up..
- try {
- UnicastRemoteObject.unexportObject(stub, true);
- } catch (Throwable e1) {
- }
- stub=null;
- throw e;
- }
- super.doStart();
- }
-
- @Override
- protected void doStop() throws Exception {
- super.doStop();
- try {
- Registry registry = endpoint.getRegistry();
- registry.unbind(endpoint.getName());
- } catch( Throwable e ) { // do our best to unregister
- }
- UnicastRemoteObject.unexportObject(proxy, true);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (!isStarted()) {
- throw new IllegalStateException("The endpoint is not active: " + getEndpoint().getEndpointUri());
- }
- PojoInvocation invocation = new PojoInvocation(proxy, method, args);
- PojoExchange exchange = getEndpoint().createExchange();
- exchange.setInvocation(invocation);
- getProcessor().process(exchange);
- Throwable fault = exchange.getException();
- if (fault != null) {
- throw new InvocationTargetException(fault);
- }
- return exchange.getOut().getBody();
- }
-
- public Remote getProxy() {
- return proxy;
- }
-
- public Remote getStub() {
- return stub;
- }
-}
+/**
+ *
+ * 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.rmi;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.component.pojo.PojoInvocation;
+import org.apache.camel.impl.DefaultConsumer;
+
+/**
+ * A {@link Consumer} which uses RMI's {@see UnicastRemoteObject} to consume method invocations.
+ *
+ * @version $Revision: 533758 $
+ */
+public class RmiConsumer extends DefaultConsumer<PojoExchange> implements InvocationHandler {
+
+ private final RmiEndpoint endpoint;
+ private Remote stub;
+ private Remote proxy;
+
+ public RmiConsumer(RmiEndpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ Class[] interfaces = new Class[endpoint.getRemoteInterfaces().size()];
+ endpoint.getRemoteInterfaces().toArray(interfaces);
+ proxy = (Remote) Proxy.newProxyInstance(endpoint.getClassLoader(), interfaces, this);
+ stub = UnicastRemoteObject.exportObject(proxy,endpoint.getPort());
+
+ try {
+ Registry registry = endpoint.getRegistry();
+ String name = endpoint.getName();
+ registry.bind(name, stub);
+
+ } catch (Exception e) { // Registration might fail.. clean up..
+ try {
+ UnicastRemoteObject.unexportObject(stub, true);
+ } catch (Throwable e1) {
+ }
+ stub=null;
+ throw e;
+ }
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
+ try {
+ Registry registry = endpoint.getRegistry();
+ registry.unbind(endpoint.getName());
+ } catch( Throwable e ) { // do our best to unregister
+ }
+ UnicastRemoteObject.unexportObject(proxy, true);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (!isStarted()) {
+ throw new IllegalStateException("The endpoint is not active: " + getEndpoint().getEndpointUri());
+ }
+ PojoInvocation invocation = new PojoInvocation(proxy, method, args);
+ PojoExchange exchange = getEndpoint().createExchange();
+ exchange.setInvocation(invocation);
+ getProcessor().process(exchange);
+ Throwable fault = exchange.getException();
+ if (fault != null) {
+ throw new InvocationTargetException(fault);
+ }
+ return exchange.getOut().getBody();
+ }
+
+ public Remote getProxy() {
+ return proxy;
+ }
+
+ public Remote getStub() {
+ return stub;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java Tue Jun 12 11:20:13 2007
@@ -1,116 +1,116 @@
-/*
- * 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.rmi;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.pojo.PojoExchange;
-import org.apache.camel.impl.DefaultEndpoint;
-
-/**
- * @version $Revision:520964 $
- */
-public class RmiEndpoint extends DefaultEndpoint<PojoExchange> {
-
- private List<Class> remoteInterfaces;
- private ClassLoader classLoader;
- private URI uri;
- private int port;
-
- protected RmiEndpoint(String endpointUri, RmiComponent component) throws URISyntaxException {
- super(endpointUri, component);
- this.uri = new URI(endpointUri);
- }
-
- public boolean isSingleton() {
- return false;
- }
-
- public PojoExchange createExchange() {
- return new PojoExchange(getContext());
- }
-
- public Consumer<PojoExchange> createConsumer(Processor processor) throws Exception {
- if( remoteInterfaces == null || remoteInterfaces.size()==0 )
- throw new RuntimeCamelException("To create an RMI consumer, the RMI endpoint's remoteInterfaces property must be be configured.");
- return new RmiConsumer(this, processor);
- }
-
- public Producer<PojoExchange> createProducer() throws Exception {
- return new RmiProducer(this);
- }
-
- public String getName() {
- String path = uri.getPath();
- if( path == null )
- path = uri.getSchemeSpecificPart();
- return path;
- }
-
- public Registry getRegistry() throws RemoteException {
- if( uri.getHost()!=null ) {
- if( uri.getPort() == -1 ) {
- return LocateRegistry.getRegistry(uri.getHost());
- } else {
- return LocateRegistry.getRegistry(uri.getHost(), uri.getPort());
- }
- } else {
- return LocateRegistry.getRegistry();
- }
- }
-
- public List<Class> getRemoteInterfaces() {
- return remoteInterfaces;
- }
-
- public void setRemoteInterfaces(List<Class> remoteInterfaces) {
- this.remoteInterfaces = remoteInterfaces;
- if( classLoader== null && !remoteInterfaces.isEmpty() ) {
- classLoader = remoteInterfaces.get(0).getClassLoader();
- }
- }
- public void setRemoteInterfaces(Class... remoteInterfaces) {
- setRemoteInterfaces(Arrays.asList(remoteInterfaces));
- }
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
- public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
-
-}
+/*
+ * 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.rmi;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class RmiEndpoint extends DefaultEndpoint<PojoExchange> {
+
+ private List<Class> remoteInterfaces;
+ private ClassLoader classLoader;
+ private URI uri;
+ private int port;
+
+ protected RmiEndpoint(String endpointUri, RmiComponent component) throws URISyntaxException {
+ super(endpointUri, component);
+ this.uri = new URI(endpointUri);
+ }
+
+ public boolean isSingleton() {
+ return false;
+ }
+
+ public PojoExchange createExchange() {
+ return new PojoExchange(getContext());
+ }
+
+ public Consumer<PojoExchange> createConsumer(Processor processor) throws Exception {
+ if( remoteInterfaces == null || remoteInterfaces.size()==0 )
+ throw new RuntimeCamelException("To create an RMI consumer, the RMI endpoint's remoteInterfaces property must be be configured.");
+ return new RmiConsumer(this, processor);
+ }
+
+ public Producer<PojoExchange> createProducer() throws Exception {
+ return new RmiProducer(this);
+ }
+
+ public String getName() {
+ String path = uri.getPath();
+ if( path == null )
+ path = uri.getSchemeSpecificPart();
+ return path;
+ }
+
+ public Registry getRegistry() throws RemoteException {
+ if( uri.getHost()!=null ) {
+ if( uri.getPort() == -1 ) {
+ return LocateRegistry.getRegistry(uri.getHost());
+ } else {
+ return LocateRegistry.getRegistry(uri.getHost(), uri.getPort());
+ }
+ } else {
+ return LocateRegistry.getRegistry();
+ }
+ }
+
+ public List<Class> getRemoteInterfaces() {
+ return remoteInterfaces;
+ }
+
+ public void setRemoteInterfaces(List<Class> remoteInterfaces) {
+ this.remoteInterfaces = remoteInterfaces;
+ if( classLoader== null && !remoteInterfaces.isEmpty() ) {
+ classLoader = remoteInterfaces.get(0).getClassLoader();
+ }
+ }
+ public void setRemoteInterfaces(Class... remoteInterfaces) {
+ setRemoteInterfaces(Arrays.asList(remoteInterfaces));
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+
+}
Propchange: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java (original)
+++ activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java Tue Jun 12 11:20:13 2007
@@ -1,58 +1,58 @@
-/**
- *
- * 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.rmi;
-
-import java.rmi.AccessException;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.Registry;
-
-import org.apache.camel.component.pojo.PojoEndpoint;
-import org.apache.camel.component.pojo.PojoExchange;
-import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.Exchange;
-
-/**
- * @version $Revision: 533076 $
- */
-public class RmiProducer extends DefaultProducer {
-
- private final RmiEndpoint endpoint;
- private Remote remote;
-
- public RmiProducer(RmiEndpoint endpoint) throws AccessException, RemoteException, NotBoundException {
- super(endpoint);
- this.endpoint = endpoint;
- }
-
- public void process(Exchange exchange) throws AccessException, RemoteException, NotBoundException {
- PojoExchange pojoExchange = endpoint.toExchangeType(exchange);
- PojoEndpoint.invoke(getRemote(), pojoExchange);
- exchange.copyFrom(pojoExchange);
- }
-
- public Remote getRemote() throws AccessException, RemoteException, NotBoundException {
- if( remote == null ) {
- Registry registry = endpoint.getRegistry();
- remote = registry.lookup(endpoint.getName());
- }
- return remote;
- }
-
-}
+/**
+ *
+ * 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.rmi;
+
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
+import org.apache.camel.component.pojo.PojoEndpoint;
+import org.apache.camel.component.pojo.PojoExchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.Exchange;
+
+/**
+ * @version $Revision: 533076 $
+ */
+public class RmiProducer extends DefaultProducer {
+
+ private final RmiEndpoint endpoint;
+ private Remote remote;
+
+ public RmiProducer(RmiEndpoint endpoint) throws AccessException, RemoteException, NotBoundException {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ public void process(Exchange exchange) throws AccessException, RemoteException, NotBoundException {
+ PojoExchange pojoExchange = endpoint.toExchangeType(exchange);
+ PojoEndpoint.invoke(getRemote(), pojoExchange);
+ exchange.copyFrom(pojoExchange);
+ }
+
+ public Remote getRemote() throws AccessException, RemoteException, NotBoundException {
+ if( remote == null ) {
+ Registry registry = endpoint.getRegistry();
+ remote = registry.lookup(endpoint.getName());
+ }
+ return remote;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java Tue Jun 12 11:20:13 2007
@@ -1,86 +1,86 @@
-/**
- *
- * 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.remoting;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.component.pojo.PojoComponent;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.remoting.support.UrlBasedRemoteAccessor;
-
-/**
- * Creates a Proxy to Camel Pojo Endpoint.
- *
- * @author chirino
- */
-public class CamelProxyFactoryBean extends UrlBasedRemoteAccessor implements FactoryBean {
-
- private CamelContext camelContext;
- private Endpoint endpoint;
- private Object serviceProxy;
-
- @Override
- public void afterPropertiesSet() {
- super.afterPropertiesSet();
- try {
- if( endpoint == null ) {
- if( getServiceUrl() == null || camelContext==null ) {
- throw new IllegalArgumentException("If endpoint is not specified, the serviceUrl and camelContext must be specified.");
- }
-
- endpoint = camelContext.getEndpoint(getServiceUrl());
- if( endpoint == null ) {
- throw new IllegalArgumentException("Could not resolve endpoint: "+getServiceUrl());
- }
- }
-
- this.serviceProxy = PojoComponent.createProxy(endpoint, getServiceInterface());
- } catch (Exception e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public Object getObject() throws Exception {
- return serviceProxy;
- }
-
- public Class getObjectType() {
- return getServiceInterface();
- }
-
- public boolean isSingleton() {
- return true;
- }
-
- public Endpoint getEndpoint() {
- return endpoint;
- }
-
- public void setEndpoint(Endpoint endpoint) {
- this.endpoint = endpoint;
- }
-
- public CamelContext getCamelContext() {
- return camelContext;
- }
-
- public void setCamelContext(CamelContext camelContext) {
- this.camelContext = camelContext;
- }
-
-}
+/**
+ *
+ * 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.remoting;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.pojo.PojoComponent;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.remoting.support.UrlBasedRemoteAccessor;
+
+/**
+ * Creates a Proxy to Camel Pojo Endpoint.
+ *
+ * @author chirino
+ */
+public class CamelProxyFactoryBean extends UrlBasedRemoteAccessor implements FactoryBean {
+
+ private CamelContext camelContext;
+ private Endpoint endpoint;
+ private Object serviceProxy;
+
+ @Override
+ public void afterPropertiesSet() {
+ super.afterPropertiesSet();
+ try {
+ if( endpoint == null ) {
+ if( getServiceUrl() == null || camelContext==null ) {
+ throw new IllegalArgumentException("If endpoint is not specified, the serviceUrl and camelContext must be specified.");
+ }
+
+ endpoint = camelContext.getEndpoint(getServiceUrl());
+ if( endpoint == null ) {
+ throw new IllegalArgumentException("Could not resolve endpoint: "+getServiceUrl());
+ }
+ }
+
+ this.serviceProxy = PojoComponent.createProxy(endpoint, getServiceInterface());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Object getObject() throws Exception {
+ return serviceProxy;
+ }
+
+ public Class getObjectType() {
+ return getServiceInterface();
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java?view=diff&rev=546580&r1=546579&r2=546580
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java Tue Jun 12 11:20:13 2007
@@ -1,81 +1,81 @@
-/**
- *
- * 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.remoting;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.component.pojo.PojoComponent;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.remoting.support.RemoteExporter;
-
-/**
- * Exports a Spring defined service to Camel as a Pojo endpoint.
- *
- * @author chirino
- */
-public class CamelServiceExporter extends RemoteExporter implements InitializingBean, DisposableBean {
-
- CamelContext camelContext;
- PojoComponent pojoComponent;
- String serviceName;
-
- public void afterPropertiesSet() throws Exception {
- if( serviceName == null ) {
- throw new IllegalArgumentException("The serviceName must be configured.");
- }
- if( pojoComponent == null ) {
- if( camelContext == null ) {
- throw new IllegalArgumentException("A pojoComponent or camelContext must be configured.");
- }
- pojoComponent = (PojoComponent) camelContext.getComponent("pojo");
- if( pojoComponent == null ) {
- throw new IllegalArgumentException("The pojoComponent could not be found.");
- }
- }
- pojoComponent.addService(serviceName, getProxyForService());
- }
-
- public void destroy() throws Exception {
- if( serviceName!=null ) {
- pojoComponent.removeService(serviceName);
- }
- }
-
-
- public PojoComponent getPojoComponent() {
- return pojoComponent;
- }
- public void setPojoComponent(PojoComponent pojoComponent) {
- this.pojoComponent = pojoComponent;
- }
-
- public CamelContext getCamelContext() {
- return camelContext;
- }
- public void setCamelContext(CamelContext camelContext) {
- this.camelContext = camelContext;
- }
-
- public String getServiceName() {
- return serviceName;
- }
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
-}
+/**
+ *
+ * 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.remoting;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.pojo.PojoComponent;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.remoting.support.RemoteExporter;
+
+/**
+ * Exports a Spring defined service to Camel as a Pojo endpoint.
+ *
+ * @author chirino
+ */
+public class CamelServiceExporter extends RemoteExporter implements InitializingBean, DisposableBean {
+
+ CamelContext camelContext;
+ PojoComponent pojoComponent;
+ String serviceName;
+
+ public void afterPropertiesSet() throws Exception {
+ if( serviceName == null ) {
+ throw new IllegalArgumentException("The serviceName must be configured.");
+ }
+ if( pojoComponent == null ) {
+ if( camelContext == null ) {
+ throw new IllegalArgumentException("A pojoComponent or camelContext must be configured.");
+ }
+ pojoComponent = (PojoComponent) camelContext.getComponent("pojo");
+ if( pojoComponent == null ) {
+ throw new IllegalArgumentException("The pojoComponent could not be found.");
+ }
+ }
+ pojoComponent.addService(serviceName, getProxyForService());
+ }
+
+ public void destroy() throws Exception {
+ if( serviceName!=null ) {
+ pojoComponent.removeService(serviceName);
+ }
+ }
+
+
+ public PojoComponent getPojoComponent() {
+ return pojoComponent;
+ }
+ public void setPojoComponent(PojoComponent pojoComponent) {
+ this.pojoComponent = pojoComponent;
+ }
+
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
------------------------------------------------------------------------------
svn:eol-style = native