Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 82925 invoked from network); 14 May 2007 16:41:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 May 2007 16:41:32 -0000 Received: (qmail 35172 invoked by uid 500); 14 May 2007 16:41:37 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 35148 invoked by uid 500); 14 May 2007 16:41:37 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 35130 invoked by uid 99); 14 May 2007 16:41:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 May 2007 09:41:37 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 May 2007 09:41:30 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 0F7281A983A; Mon, 14 May 2007 09:41:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r537904 - in /activemq/camel/trunk/camel-spring/src: main/java/org/apache/camel/spring/remoting/ test/java/org/apache/camel/spring/remoting/ test/resources/org/apache/camel/spring/remoting/ Date: Mon, 14 May 2007 16:41:09 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070514164110.0F7281A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Mon May 14 09:41:07 2007 New Revision: 537904 URL: http://svn.apache.org/viewvc?view=rev&rev=537904 Log: Added a testcase that shows spring remoting in action using camel as the transport. Added: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SayService.java activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/ activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml Modified: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java Modified: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java?view=diff&rev=537904&r1=537903&r2=537904 ============================================================================== --- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java (original) +++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java Mon May 14 09:41:07 2007 @@ -17,6 +17,7 @@ */ 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; @@ -29,6 +30,7 @@ */ public class CamelProxyFactoryBean extends UrlBasedRemoteAccessor implements FactoryBean { + private CamelContext camelContext; private Endpoint endpoint; private Object serviceProxy; @@ -36,6 +38,17 @@ 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); @@ -60,6 +73,14 @@ public void setEndpoint(Endpoint endpoint) { this.endpoint = endpoint; + } + + public CamelContext getCamelContext() { + return camelContext; + } + + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; } } Added: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java?view=auto&rev=537904 ============================================================================== --- activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java (added) +++ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java Mon May 14 09:41:07 2007 @@ -0,0 +1,24 @@ +/* + * 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 java.rmi.Remote; +import java.rmi.RemoteException; + +public interface ISay extends Remote { + public String say() throws RemoteException; +} Added: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SayService.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SayService.java?view=auto&rev=537904 ============================================================================== --- activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SayService.java (added) +++ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SayService.java Mon May 14 09:41:07 2007 @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.remoting; + +public class SayService implements ISay { + String message = "Hello"; + + public SayService() { + } + public SayService(String message) { + this.message = message; + } + + public String say() { + return message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} Added: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java?view=auto&rev=537904 ============================================================================== --- activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java (added) +++ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java Mon May 14 09:41:07 2007 @@ -0,0 +1,47 @@ +/** + * + * 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 junit.framework.TestCase; + +import org.apache.camel.CamelContext; +import org.apache.camel.spring.SpringCamelContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision: 520220 $ + */ +public class SpringRemotingRouteTest extends TestCase { + + public void testPojoRoutes() throws Exception { + + ClassPathXmlApplicationContext spring = new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/spring.xml"); + CamelContext camelContext = SpringCamelContext.springCamelContext(spring); + camelContext.start(); + + // START SNIPPET: invoke + ISay proxy = (ISay) spring.getBean("sayProxy"); + String rc = proxy.say(); + assertEquals("Hello", rc); + // END SNIPPET: invoke + + camelContext.stop(); + spring.destroy(); + } + +} Added: activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml?view=auto&rev=537904 ============================================================================== --- activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml (added) +++ activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml Mon May 14 09:41:07 2007 @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +