Move parameter documentation from annotation to javadoc on setters

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

Branch: refs/heads/master
Commit: 9912647738ec0714ea5475c7a696b61ca405f5a2
Parents: e5a094d
Author: Quinn Stevenson <qu...@pronoia-solutions.com>
Authored: Tue Jan 5 13:20:36 2016 -0700
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jan 6 17:47:59 2016 +0100

----------------------------------------------------------------------
 .../camel/component/mllp/MllpComponent.java     |  24 ++-
 .../camel/component/mllp/MllpEndpoint.java      | 147 ++++++++++++-------
 .../component/mllp/MllpTcpClientProducer.java   |   2 +-
 .../component/mllp/MllpTcpServerConsumer.java   |  26 +++-
 .../mllp/MllpTcpClientProducerTest.java         |   2 +-
 .../mllp/MllpTcpServerConsumerTest.java         |   2 +-
 6 files changed, 142 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpComponent.java
 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpComponent.java
index 7a3fbb1..3a67dd3 100644
--- 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpComponent.java
+++ 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpComponent.java
@@ -37,8 +37,30 @@ public class MllpComponent extends UriEndpointComponent {
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
-        Endpoint endpoint = new MllpEndpoint(uri, this);
+        MllpEndpoint endpoint = new MllpEndpoint(uri, this);
         setProperties(endpoint, parameters);
+
+        // mllp://hostname:port
+        String hostPort;
+        // look for options
+        int optionsStartIndex = uri.indexOf('?');
+        if (-1 == optionsStartIndex) {
+            // No options - just get the host/port stuff
+            hostPort = uri.substring(7);
+        } else {
+            hostPort = uri.substring(7, optionsStartIndex);
+        }
+
+        // Make sure it has a host - may just be a port
+        int colonIndex = hostPort.indexOf(':');
+        if (-1 != colonIndex) {
+            endpoint.setHostname(hostPort.substring(0, colonIndex));
+            endpoint.setPort(Integer.parseInt(hostPort.substring(colonIndex + 
1)));
+        } else {
+            // No host specified - leave the default host and set the port
+            endpoint.setPort(Integer.parseInt(hostPort.substring(colonIndex + 
1)));
+        }
+
         return endpoint;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java
 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java
index 21740a6..e93e408 100644
--- 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java
+++ 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Represents a MLLP endpoint.
- *
+ * <p/>
  * NOTE: MLLP payloads are not logged unless the logging level is set to DEBUG 
or TRACE to avoid introducing PHI
  * into the log files.  Logging of PHI can be globally disabled by setting the 
org.apache.camel.mllp.logPHI system
  * property to false.
@@ -47,86 +47,55 @@ public class MllpEndpoint extends DefaultEndpoint {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(MllpEndpoint.class);
 
-    @UriPath(defaultValue = "0.0.0.0", description = "Hostname or IP for 
connection")
+    @UriPath(defaultValue = "0.0.0.0")
     String hostname = "0.0.0.0";
 
     @UriPath(description = "TCP Port for connection")
     int port = -1;
 
-    // TODO:  Move URI Params to a MllpConfiguration class
-    // TODO: Move the description documentation to javadoc in the setter method
-    @UriParam(defaultValue = "5", description = "TCP Server only - The maximum 
queue length for incoming connection indications (a request to connect) is set 
to the backlog parameter. If a "
-            + "connection indication arrives when the queue is full, the 
connection is refused.")
+    @UriParam(defaultValue = "5")
     int backlog = 5;
 
     @UriParam(defaultValue = "30000", description = "TCP Server only - timeout 
value while waiting for a TCP listener to start (milliseconds)")
     int bindTimeout = 30000;
 
-    @UriParam(defaultValue = "30000", description = "TCP Server only - timeout 
value while waiting for a TCP connection (milliseconds)")
-    int acceptTimeout = 30000;
+    @UriParam(defaultValue = "60000")
+    int acceptTimeout = 60000;
 
-    @UriParam(defaultValue = "30000", description = "TCP Client only - timeout 
value while establishing for a TCP connection (milliseconds)")
+    @UriParam(defaultValue = "30000")
     int connectTimeout = 30000;
 
-    @UriParam(defaultValue = "5000", description = "Timeout value 
(milliseconds) used when reading a message from an external")
-    int responseTimeout = 5000;
+    @UriParam(defaultValue = "10000")
+    int receiveTimeout = 10000;
 
-    @UriParam(defaultValue = "true", description = "Enable/disable the 
SO_KEEPALIVE socket option.")
+    @UriParam(defaultValue = "true")
     boolean keepAlive = true;
 
-    @UriParam(defaultValue = "true", description = "Enable/disable the 
TCP_NODELAY socket option.")
+    @UriParam(defaultValue = "true")
     boolean tcpNoDelay = true;
 
-    @UriParam(defaultValue = "false", description = "Enable/disable the 
SO_REUSEADDR socket option.")
+    @UriParam(defaultValue = "false")
     boolean reuseAddress;
 
-    @UriParam(description = "Sets the SO_RCVBUF option to the specified value")
+    @UriParam(defaultValue = "System Default")
     Integer receiveBufferSize;
 
-    @UriParam(description = "Sets the SO_SNDBUF option to the specified value")
+    @UriParam(defaultValue = "System Default")
     Integer sendBufferSize;
 
-    @UriParam(defaultValue = "0", description = "The amount of time a TCP 
connection can remain idle before it is closed")
-    int idleTimeout;
-
     @UriParam(description = "The TCP mode of the endpoint (client or server).  
Defaults to client for Producers and server for Consumers")
     String tcpMode;
 
-    @UriParam(defaultValue = "true", description = "MLLP Consumers only - 
Automatically generate and send an MLLP Acknowledgement")
+    @UriParam(defaultValue = "true")
     boolean autoAck = true;
 
-    @UriParam(description = "Set the CamelCharsetName property on the 
exchange")
+    @UriParam(defaultValue = "System Default")
     String charsetName;
 
     public MllpEndpoint(String uri, MllpComponent component) {
         super(uri, component);
-
-        // TODO: this logic should be in component class
-        // TODO: all the options in the endpoint should be getter/setter so 
you can configure them as plain Java
-
-        // mllp://hostname:port
-        String hostPort;
-        // look for options
-        int optionsStartIndex = uri.indexOf('?');
-        if (-1 == optionsStartIndex) {
-            // No options - just get the host/port stuff
-            hostPort = uri.substring(7);
-        } else {
-            hostPort = uri.substring(7, optionsStartIndex);
-        }
-
-        // Make sure it has a host - may just be a port
-        int colonIndex = hostPort.indexOf(':');
-        if (-1 != colonIndex) {
-            hostname = hostPort.substring(0, colonIndex);
-            port = Integer.parseInt(hostPort.substring(colonIndex + 1));
-        } else {
-            // No host specified - leave the default host and set the port
-            port = Integer.parseInt(hostPort);
-        }
     }
 
-
     @Override
     public ExchangePattern getExchangePattern() {
         return ExchangePattern.InOut;
@@ -177,6 +146,11 @@ public class MllpEndpoint extends DefaultEndpoint {
         return charsetName;
     }
 
+    /**
+     * Set the CamelCharsetName property on the exchange
+     *
+     * @param charsetName
+     */
     public void setCharsetName(String charsetName) {
         this.charsetName = charsetName;
     }
@@ -185,14 +159,28 @@ public class MllpEndpoint extends DefaultEndpoint {
         return hostname;
     }
 
+    /**
+     * Hostname or IP for connection for the TCP connection
+     *
+     * @param hostname Hostname or IP
+     */
+    public void setHostname(String hostname) {
+        this.hostname = hostname;
+    }
+
     public int getPort() {
         return port;
     }
 
     /**
-     * The maximum queue length for incoming connection indications (a request 
to connect) is set to the backlog parameter. If a connection indication arrives 
when the queue is full, the connection
-     * is refused.
+     * Port number for the TCP connection
+     *
+     * @param port TCP port
      */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
     public int getBacklog() {
         return backlog;
     }
@@ -209,6 +197,13 @@ public class MllpEndpoint extends DefaultEndpoint {
         return acceptTimeout;
     }
 
+    /**
+     * Timeout value while waiting for a TCP connection
+     * <p/>
+     * TCP Server Only
+     *
+     * @param acceptTimeout timeout in milliseconds
+     */
     public void setAcceptTimeout(int acceptTimeout) {
         this.acceptTimeout = acceptTimeout;
     }
@@ -217,22 +212,39 @@ public class MllpEndpoint extends DefaultEndpoint {
         return connectTimeout;
     }
 
+    /**
+     * Timeout value for establishing for a TCP connection
+     * <p/>
+     * TCP Client only
+     *
+     * @param connectTimeout timeout in milliseconds
+     */
     public void setConnectTimeout(int connectTimeout) {
         this.connectTimeout = connectTimeout;
     }
 
-    public int getResponseTimeout() {
-        return responseTimeout;
+    public int getReceiveTimeout() {
+        return receiveTimeout;
     }
 
-    public void setResponseTimeout(int responseTimeout) {
-        this.responseTimeout = responseTimeout;
+    /**
+     * The SO_TIMEOUT value used when waiting for the start of an MLLP frame
+     *
+     * @param receiveTimeout timeout in milliseconds
+     */
+    public void setReceiveTimeout(int receiveTimeout) {
+        this.receiveTimeout = receiveTimeout;
     }
 
     public boolean isKeepAlive() {
         return keepAlive;
     }
 
+    /**
+     * Enable/disable the SO_KEEPALIVE socket option.
+     *
+     * @param keepAlive enable SO_KEEPALIVE when true; otherwise disable 
SO_KEEPALIVE
+     */
     public void setKeepAlive(boolean keepAlive) {
         this.keepAlive = keepAlive;
     }
@@ -241,6 +253,11 @@ public class MllpEndpoint extends DefaultEndpoint {
         return tcpNoDelay;
     }
 
+    /**
+     * Enable/disable the TCP_NODELAY socket option.
+     *
+     * @param tcpNoDelay enable TCP_NODELAY when true; otherwise disable 
TCP_NODELAY
+     */
     public void setTcpNoDelay(boolean tcpNoDelay) {
         this.tcpNoDelay = tcpNoDelay;
     }
@@ -249,6 +266,11 @@ public class MllpEndpoint extends DefaultEndpoint {
         return reuseAddress;
     }
 
+    /**
+     * Enable/disable the SO_REUSEADDR socket option.
+     *
+     * @param reuseAddress enable SO_REUSEADDR when true; otherwise disable 
SO_REUSEADDR
+     */
     public void setReuseAddress(boolean reuseAddress) {
         this.reuseAddress = reuseAddress;
     }
@@ -257,7 +279,12 @@ public class MllpEndpoint extends DefaultEndpoint {
         return receiveBufferSize;
     }
 
-    public void setReceiveBufferSize(int receiveBufferSize) {
+    /**
+     * Sets the SO_RCVBUF option to the specified value
+     *
+     * @param receiveBufferSize the SO_RCVBUF option value.  If null, the 
system default is used
+     */
+    public void setReceiveBufferSize(Integer receiveBufferSize) {
         this.receiveBufferSize = receiveBufferSize;
     }
 
@@ -265,7 +292,12 @@ public class MllpEndpoint extends DefaultEndpoint {
         return sendBufferSize;
     }
 
-    public void setSendBufferSize(int sendBufferSize) {
+    /**
+     * Sets the SO_SNDBUF option to the specified value
+     *
+     * @param sendBufferSize the SO_SNDBUF option value.  If null, the system 
default is used
+     */
+    public void setSendBufferSize(Integer sendBufferSize) {
         this.sendBufferSize = sendBufferSize;
     }
 
@@ -273,6 +305,13 @@ public class MllpEndpoint extends DefaultEndpoint {
         return autoAck;
     }
 
+    /**
+     * Enable/Disable the automatic generation of a MLLP Acknowledgement
+     *
+     * MLLP Consumers only
+     *
+     * @param autoAck enabled if true, otherwise disabled
+     */
     public void setAutoAck(boolean autoAck) {
         this.autoAck = autoAck;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
index fdff64b..4a313ef 100644
--- 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
+++ 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
@@ -208,7 +208,7 @@ public class MllpTcpClientProducer extends DefaultProducer {
                 socket.setSoLinger(false, -1);
 
                 // Read Timeout
-                socket.setSoTimeout(endpoint.responseTimeout);
+                socket.setSoTimeout(endpoint.receiveTimeout);
             } catch (SocketException e) {
                 return e;
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
index d74468c..186a462 100644
--- 
a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
+++ 
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
@@ -38,7 +38,27 @@ import 
org.apache.camel.processor.mllp.Hl7AcknowledgementGenerationException;
 import org.apache.camel.processor.mllp.Hl7AcknowledgementGenerator;
 import org.apache.camel.util.IOHelper;
 
-import static org.apache.camel.component.mllp.MllpConstants.*;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_ACKNOWLEDGEMENT;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_ACKNOWLEDGEMENT_TYPE;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_CHARSET;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_EVENT_TYPE;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_LOCAL_ADDRESS;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_MESSAGE_CONTROL;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_MESSAGE_TYPE;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_PROCESSING_ID;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_RECEIVING_APPLICATION;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_RECEIVING_FACILITY;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_REMOTE_ADDRESS;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_RESET_CONNECTION_AFTER_SEND;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_RESET_CONNECTION_BEFORE_SEND;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_SECURITY;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_SENDING_APPLICATION;
+import static 
org.apache.camel.component.mllp.MllpConstants.MLLP_SENDING_FACILITY;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_TIMESTAMP;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_TRIGGER_EVENT;
+import static org.apache.camel.component.mllp.MllpConstants.MLLP_VERSION_ID;
 import static org.apache.camel.component.mllp.MllpEndpoint.SEGMENT_DELIMITER;
 import static org.apache.camel.component.mllp.MllpEndpoint.START_OF_BLOCK;
 
@@ -208,7 +228,7 @@ public class MllpTcpServerConsumer extends DefaultConsumer {
                         socket.setSoTimeout(100);
                         try {
                             int tmpByte = inputStream.read();
-                            socket.setSoTimeout(endpoint.responseTimeout);
+                            socket.setSoTimeout(endpoint.receiveTimeout);
                             if (-1 == tmpByte) {
                                 log.debug("Socket.read() returned 
END_OF_STREAM - resetting connection");
                                 MllpUtil.resetConnection(socket);
@@ -272,7 +292,7 @@ public class MllpTcpServerConsumer extends DefaultConsumer {
             this.clientSocket.setSoLinger(false, -1);
 
             // Read Timeout
-            this.clientSocket.setSoTimeout(endpoint.responseTimeout);
+            this.clientSocket.setSoTimeout(endpoint.receiveTimeout);
 
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerTest.java
 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerTest.java
index 616e2d9..dc8d594 100644
--- 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerTest.java
+++ 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerTest.java
@@ -93,7 +93,7 @@ public class MllpTcpClientProducerTest extends 
CamelTestSupport {
                 from(source.getDefaultEndpoint())
                         .routeId("mllp-sender-test-route")
                         .log(LoggingLevel.INFO, "Sending Message: 
$simple{header[CamelHL7MessageControl]}")
-                        
.toF("mllp://%s:%d?connectTimeout=%d&responseTimeout=%d",
+                        
.toF("mllp://%s:%d?connectTimeout=%d&receiveTimeout=%d",
                                 "0.0.0.0", mllpServer.getListenPort(), 
connectTimeout, responseTimeout)
                         .to(acknowledged);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/99126477/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTest.java
 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTest.java
index 2ddd25c..c77c35f 100644
--- 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTest.java
+++ 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTest.java
@@ -69,7 +69,7 @@ public class MllpTcpServerConsumerTest extends 
CamelTestSupport {
                         .toF("log:%s?level=INFO&showAll=true", routeId)
                         .log(LoggingLevel.INFO, routeId, "Test route 
complete");
 
-                
fromF("mllp://%s:%d?autoAck=true&connectTimeout=%d&responseTimeout=%d",
+                
fromF("mllp://%s:%d?autoAck=true&connectTimeout=%d&receiveTimeout=%d",
                         mllpClient.getMllpHost(), mllpClient.getMllpPort(), 
connectTimeout, responseTimeout)
                         .routeId(routeId)
                         .log(LoggingLevel.INFO, routeId, "Test route received 
message")

Reply via email to