camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/4] git commit: Fix for CAMEL-7512 Expose the component options for Camel Netty
Date Mon, 16 Jun 2014 18:42:18 GMT
Fix for CAMEL-7512 Expose the component options for Camel Netty


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3f8dcdde
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3f8dcdde
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3f8dcdde

Branch: refs/heads/master
Commit: 3f8dcdde56b3012667a047f7f3b52a6f3640c12c
Parents: 9f90b02
Author: Kevin Earls <kevin@kevinearls.com>
Authored: Mon Jun 16 17:48:09 2014 +0200
Committer: Kevin Earls <kevin@kevinearls.com>
Committed: Mon Jun 16 17:48:09 2014 +0200

----------------------------------------------------------------------
 .../camel/component/netty/NettyComponent.java   |  7 +--
 .../component/netty/NettyConfiguration.java     | 25 +++++++++
 .../camel/component/netty/NettyEndpoint.java    |  4 ++
 ...ponentConfigurationAndDocumentationTest.java | 57 ++++++++++++++++++++
 4 files changed, 90 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3f8dcdde/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
index a570df8..62028e6 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
@@ -24,24 +24,25 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.concurrent.CamelThreadFactory;
 import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
 import org.jboss.netty.util.HashedWheelTimer;
 import org.jboss.netty.util.Timer;
 
-public class NettyComponent extends DefaultComponent {
+public class NettyComponent extends UriEndpointComponent {
     // use a shared timer for Netty (see javadoc for HashedWheelTimer)
     private static volatile Timer timer;
     private NettyConfiguration configuration;
     private OrderedMemoryAwareThreadPoolExecutor executorService;
 
     public NettyComponent() {
+        super(NettyEndpoint.class);
     }
 
     public NettyComponent(CamelContext context) {
-        super(context);
+        super(context, NettyEndpoint.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/3f8dcdde/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
index 83ab62d..f61e12b 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
@@ -25,6 +25,8 @@ import java.util.Map;
 
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
@@ -36,33 +38,56 @@ import org.jboss.netty.util.CharsetUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@UriParams
 public class NettyConfiguration extends NettyServerBootstrapConfiguration implements Cloneable
{
     private static final Logger LOG = LoggerFactory.getLogger(NettyConfiguration.class);
 
+    @UriParam
     private long requestTimeout;
+    @UriParam
     private boolean sync = true;
+    @UriParam
     private boolean textline;
+    @UriParam
     private TextLineDelimiter delimiter = TextLineDelimiter.LINE;
+    @UriParam
     private boolean autoAppendDelimiter = true;
+    @UriParam
     private int decoderMaxLineLength = 1024;
+    @UriParam
     private String encoding;
     private List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
     private List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
+    @UriParam
     private boolean disconnect;
+    @UriParam
     private boolean lazyChannelCreation = true;
+    @UriParam
     private boolean transferExchange;
+    @UriParam
     private boolean disconnectOnNoReply = true;
+    @UriParam
     private LoggingLevel noReplyLogLevel = LoggingLevel.WARN;
+    @UriParam
     private LoggingLevel serverExceptionCaughtLogLevel = LoggingLevel.WARN;
+    @UriParam
     private LoggingLevel serverClosedChannelExceptionCaughtLogLevel = LoggingLevel.DEBUG;
+    @UriParam
     private boolean allowDefaultCodec = true;
     private ClientPipelineFactory clientPipelineFactory;
+    @UriParam
     private int maximumPoolSize = 16;
+    @UriParam
     private boolean orderedThreadPoolExecutor = true;
+    @UriParam
     private int producerPoolMaxActive = -1;
+    @UriParam
     private int producerPoolMinIdle;
+    @UriParam
     private int producerPoolMaxIdle = 100;
+    @UriParam
     private long producerPoolMinEvictableIdle = 5 * 60 * 1000L;
+    @UriParam
     private boolean producerPoolEnabled = true;
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/3f8dcdde/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyEndpoint.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyEndpoint.java
index 7b464fa..10c7aca 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyEndpoint.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyEndpoint.java
@@ -29,13 +29,17 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.SynchronousDelegateProducer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.ObjectHelper;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.handler.ssl.SslHandler;
 import org.jboss.netty.util.Timer;
 
+@UriEndpoint(scheme = "netty", consumerClass = NettyConsumer.class)
 public class NettyEndpoint extends DefaultEndpoint {
+    @UriParam
     private NettyConfiguration configuration;
     private Timer timer;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3f8dcdde/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyComponentConfigurationAndDocumentationTest.java
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..67b3ab0
--- /dev/null
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.netty;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class NettyComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        NettyComponent comp = context.getComponent("netty", NettyComponent.class);
+        EndpointConfiguration conf = comp.createConfiguration("netty:tcp://localhost:5150?sync=true"
+
+                "&maximumPoolSize=32&ssl=true&passphrase=#password");
+
+        assertEquals("true", conf.getParameter("sync"));
+        assertEquals("32", conf.getParameter("maximumPoolSize"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"producerPoolMinEvictableIdle\": { \"type\": \"long\"
}"));
+        assertTrue(json.contains("\"allowDefaultCodec\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("netty");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}


Mime
View raw message