camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r750401 - in /camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/MinaComponent.java test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
Date Thu, 05 Mar 2009 09:45:21 GMT
Author: davsclaus
Date: Thu Mar  5 09:45:20 2009
New Revision: 750401

URL: http://svn.apache.org/viewvc?rev=750401&view=rev
Log:
MinaEndpoint codec option is now the real object and not string. Improved spring bean style
config of mina endpoints. Added missing requestBody to producer template.

Modified:
    camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
    camel/trunk/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml

Modified: camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java?rev=750401&r1=750400&r2=750401&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
(original)
+++ camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
Thu Mar  5 09:45:20 2009
@@ -29,6 +29,7 @@
 import org.apache.camel.Endpoint;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -94,23 +95,25 @@
         config.setProtocol(u.getScheme());
         setProperties(config, parameters);
 
-        return createEndpoint(getCamelContext(), uri, config);
+        return createEndpoint(uri, config);
     }
 
-    public Endpoint createEndpoint(CamelContext context, MinaConfiguration config) throws
Exception {
-        return createEndpoint(context, null, config);
+    public Endpoint createEndpoint(MinaConfiguration config) throws Exception {
+        return createEndpoint(null, config);
     }
 
-    private Endpoint createEndpoint(CamelContext context, String uri, MinaConfiguration config)
throws Exception {
+    private Endpoint createEndpoint(String uri, MinaConfiguration config) throws Exception
{
+        ObjectHelper.notNull(getCamelContext(), "camelContext");
+
         String protocol = config.getProtocol();
         // if mistyped uri then protocol can be null
         if (protocol != null) {
             if (protocol.equals("tcp")) {
-                return createSocketEndpoint(context, uri, config);
+                return createSocketEndpoint(uri, config);
             } else if (protocol.equals("udp") || protocol.equals("mcast") || protocol.equals("multicast"))
{
-                return createDatagramEndpoint(context, uri, config);
+                return createDatagramEndpoint(uri, config);
             } else if (protocol.equals("vm")) {
-                return createVmEndpoint(context, uri, config);
+                return createVmEndpoint(uri, config);
             }
         }
         // protocol not resolved so error
@@ -121,7 +124,7 @@
     // Implementation methods
     //-------------------------------------------------------------------------
 
-    protected MinaEndpoint createVmEndpoint(CamelContext context, String uri, MinaConfiguration
configuration) {
+    protected MinaEndpoint createVmEndpoint(String uri, MinaConfiguration configuration)
{
         boolean minaLogger = configuration.isMinaLogger();
         boolean sync = configuration.isSync();
         List<IoFilter> filters = configuration.getFilters();
@@ -145,7 +148,6 @@
         appendIoFiltersToChain(filters, acceptor.getFilterChain());
 
         MinaEndpoint endpoint = new MinaEndpoint(uri, this);
-        endpoint.setCamelContext(context);
         endpoint.setAddress(address);
         endpoint.setAcceptor(acceptor);
         endpoint.setConnector(connector);
@@ -161,7 +163,7 @@
         return endpoint;
     }
 
-    protected MinaEndpoint createSocketEndpoint(CamelContext context, String uri, MinaConfiguration
configuration) {
+    protected MinaEndpoint createSocketEndpoint(String uri, MinaConfiguration configuration)
{
         boolean minaLogger = configuration.isMinaLogger();
         long timeout = configuration.getTimeout();
         boolean sync = configuration.isSync();
@@ -193,7 +195,6 @@
         appendIoFiltersToChain(filters, acceptorConfig.getFilterChain());
 
         MinaEndpoint endpoint = new MinaEndpoint(uri, this);
-        endpoint.setCamelContext(context);
         endpoint.setAddress(address);
         endpoint.setAcceptor(acceptor);
         endpoint.setAcceptorConfig(acceptorConfig);
@@ -235,7 +236,7 @@
         addCodecFactory(config, codecFactory);
     }
 
-    protected MinaEndpoint createDatagramEndpoint(CamelContext context, String uri, MinaConfiguration
configuration) {
+    protected MinaEndpoint createDatagramEndpoint(String uri, MinaConfiguration configuration)
{
         boolean minaLogger = configuration.isMinaLogger();
         long timeout = configuration.getTimeout();
         boolean transferExchange = configuration.isTransferExchange();
@@ -269,7 +270,6 @@
         appendIoFiltersToChain(filters, acceptorConfig.getFilterChain());
 
         MinaEndpoint endpoint = new MinaEndpoint(uri, this);
-        endpoint.setCamelContext(context);
         endpoint.setAddress(address);
         endpoint.setAcceptor(acceptor);
         endpoint.setAcceptorConfig(acceptorConfig);

Modified: camel/trunk/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml?rev=750401&r1=750400&r2=750401&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
(original)
+++ camel/trunk/components/camel-mina/src/test/resources/org/apache/camel/component/mina/SpringMinaEndpointTest-context.xml
Thu Mar  5 09:45:20 2009
@@ -24,7 +24,10 @@
     <!-- START SNIPPET: e1 -->
     <!-- Creating mina endpoints is a bit complex so we reuse MinaComponnet
          as a factory bean to create our endpoint, this is the easiest to do -->
-    <bean id="myMinaFactory" class="org.apache.camel.component.mina.MinaComponent"/>
+    <bean id="myMinaFactory" class="org.apache.camel.component.mina.MinaComponent">
+        <!-- we must provide a camel context so we refer to it by its id -->
+        <constructor-arg index="0" ref="myCamel"/>
+    </bean>
 
     <!-- This is our mina endpoint configured with spring, we will use the factory above
          to create it for us. The goal is to invoke the createEndpoint method with the
@@ -32,8 +35,8 @@
     <bean id="myMinaEndpoint"
           factory-bean="myMinaFactory"
           factory-method="createEndpoint">
-        <constructor-arg index="0" ref="myCamel"/>
-        <constructor-arg index="1" ref="myMinaConfig"/>
+        <!-- and here we can pass it our configuration -->
+        <constructor-arg index="0" ref="myMinaConfig"/>
     </bean>
 
     <!-- this is our mina configuration with plain properties -->



Mime
View raw message