Repository: camel
Updated Branches:
  refs/heads/master ea915bc8f -> 80d1937cb


Polished


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

Branch: refs/heads/master
Commit: 80d1937cb0dec2b490e0e14e18a541d2352da59d
Parents: ea915bc
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Sep 22 08:33:26 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Sep 22 08:33:26 2016 +0200

----------------------------------------------------------------------
 components/camel-asterisk/pom.xml               |  2 +-
 .../src/main/docs/asterisk-component.adoc       | 10 ++---
 .../component/asterisk/AsteriskConnection.java  |  2 +-
 .../component/asterisk/AsteriskConstants.java   |  7 +--
 .../component/asterisk/AsteriskEndpoint.java    | 45 +++++++-------------
 .../component/asterisk/AsteriskProducer.java    |  5 +--
 .../component/asterisk/AsteriskConfigTest.java  |  4 +-
 7 files changed, 30 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-asterisk/pom.xml 
b/components/camel-asterisk/pom.xml
index 4bcc8f8..8e1aefa 100644
--- a/components/camel-asterisk/pom.xml
+++ b/components/camel-asterisk/pom.xml
@@ -27,7 +27,7 @@
   <artifactId>camel-asterisk</artifactId>
   <packaging>jar</packaging>
   <name>Camel :: Asterisk</name>
-  <description>Camel Asterisk to interact with an Asterisk PBX 
Server.</description>
+  <description>Camel Asterisk to interact with an Asterisk PBX 
Server</description>
 
   <properties>
     <camel.osgi.import.before.defaults>

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/main/docs/asterisk-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-asterisk/src/main/docs/asterisk-component.adoc 
b/components/camel-asterisk/src/main/docs/asterisk-component.adoc
index 898f8e6..a8288e3 100644
--- a/components/camel-asterisk/src/main/docs/asterisk-component.adoc
+++ b/components/camel-asterisk/src/main/docs/asterisk-component.adoc
@@ -45,14 +45,14 @@ The Asterisk component supports 9 endpoint options which 
are listed below:
 [width="100%",cols="2,1,1m,1m,5",options="header"]
 |=======================================================================
 | Name | Group | Default | Java Type | Description
-| name | common |  | String | *Required* name
-| action | common |  | String | action
-| hostname | common |  | String | Hostname
-| password | common |  | String | AsteriskServer password
-| username | common |  | String | AsteriskServer username
+| name | common |  | String | *Required* Logical name
+| hostname | common |  | String | The hostname of the asterix server
+| password | common |  | String | Login password
+| username | common |  | String | Login username
 | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the 
consumer to the Camel routing Error Handler which mean any exceptions occurred 
while the consumer is trying to pickup incoming messages or the likes will now 
be processed as a message and handled by the routing Error Handler. By default 
the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with 
exceptions that will be logged at WARN/ERROR level and ignored.
 | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the 
consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler 
is enabled then this options is not in use. By default the consumer will deal 
with exceptions that will be logged at WARN/ERROR level and ignored.
 | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the 
exchange pattern when the consumer creates an exchange.
+| action | producer |  | AsteriskActionEnum | What action to perform such as 
getting queue status sip peers or extension state.
 | synchronous | advanced | false | boolean | Sets whether synchronous 
processing should be strictly used or Camel is allowed to use asynchronous 
processing (if supported).
 |=======================================================================
 {% endraw %}

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConnection.java
----------------------------------------------------------------------
diff --git 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConnection.java
 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConnection.java
index 9d36153..468d7e8 100644
--- 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConnection.java
+++ 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConnection.java
@@ -53,7 +53,7 @@ public class AsteriskConnection {
             ManagerConnectionFactory factory = new 
ManagerConnectionFactory(host, username, password);
             managerConnection = factory.createManagerConnection();
             
-            LOG.debug("asterisk connection estabilished!");
+            LOG.debug("asterisk connection established!");
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConstants.java
----------------------------------------------------------------------
diff --git 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConstants.java
 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConstants.java
index 9666753..f49a00b 100644
--- 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConstants.java
+++ 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskConstants.java
@@ -17,9 +17,10 @@
 package org.apache.camel.component.asterisk;
 
 public final class AsteriskConstants {
-    public static final String EVENT_NAME = "AsteriskEventName";
-    public static final String EXTEN = "AsteriskExtension";
-    public static final String CONTEXT = "AsteriskContext";
+
+    public static final String EVENT_NAME = "CamelAsteriskEventName";
+    public static final String EXTENSION = "CamelAsteriskExtension";
+    public static final String CONTEXT = "CamelAsteriskContext";
 
     private AsteriskConstants() {
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskEndpoint.java
 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskEndpoint.java
index 629a24d..8d25b5f 100644
--- 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskEndpoint.java
+++ 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskEndpoint.java
@@ -44,23 +44,19 @@ public class AsteriskEndpoint extends DefaultEndpoint {
     @SuppressWarnings("unused")
     private static final Logger LOG = 
LoggerFactory.getLogger(AsteriskProducer.class);
 
+    private AsteriskConnection asteriskConnection;
+
     @UriPath(description = "Name of component") @Metadata(required = "true")
     private String name;
-    
     @UriParam
     private String hostname;
-
-    @UriParam
-    private String action;
-
-    @UriParam
+    @UriParam(label = "producer")
+    private AsteriskActionEnum action;
+    @UriParam(secret = true)
     private String username;
-
-    @UriParam
+    @UriParam(secret = true)
     private String password;
 
-    private AsteriskConnection asteriskConnection;
-
     public AsteriskEndpoint(String uri, AsteriskComponent component) {
         super(uri, component);
     }
@@ -84,9 +80,6 @@ public class AsteriskEndpoint extends DefaultEndpoint {
             throw new IllegalArgumentException("Missing required action 
parameter");
         }
         
-        // validate action value
-        AsteriskActionEnum.valueOf(action);
-
         return new AsteriskProducer(this);
     }
 
@@ -95,6 +88,8 @@ public class AsteriskEndpoint extends DefaultEndpoint {
     }
 
     public boolean isSingleton() {
+        // TODO: prefer to be singleton and do not have state on the endpoint
+        // the asteriskConnection should be createed on the consumer / 
producer instance and be private there
         return false;
     }
 
@@ -126,9 +121,7 @@ public class AsteriskEndpoint extends DefaultEndpoint {
     }
 
     /**
-     * AsteriskServer username
-     * 
-     * @param host
+     * Login username
      */
     public void setUsername(String username) {
         this.username = username;
@@ -139,24 +132,20 @@ public class AsteriskEndpoint extends DefaultEndpoint {
     }
 
     /**
-     * AsteriskServer password
-     * 
-     * @param host
+     * Login password
      */
     public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getAction() {
+    public AsteriskActionEnum getAction() {
         return action;
     }
 
     /**
-     * action
-     * 
-     * @param host
+     * What action to perform such as getting queue status, sip peers or 
extension state.
      */
-    public void setAction(String action) {
+    public void setAction(AsteriskActionEnum action) {
         this.action = action;
     }
 
@@ -165,18 +154,14 @@ public class AsteriskEndpoint extends DefaultEndpoint {
     }
 
     /**
-     * Hostname 
-     * 
-     * @param hostname
+     * The hostname of the asterix server
      */
     public void setHostname(String hostname) {
         this.hostname = hostname;
     }
 
     /**
-     * name 
-     * 
-     * @return
+     * Logical name
      */
     public String getName() {
         return name;

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskProducer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskProducer.java
 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskProducer.java
index bea860c..f7ea5ee 100644
--- 
a/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskProducer.java
+++ 
b/components/camel-asterisk/src/main/java/org/apache/camel/component/asterisk/AsteriskProducer.java
@@ -55,7 +55,7 @@ public class AsteriskProducer extends DefaultProducer {
 
     public void process(Exchange exchange) throws Exception {
         ManagerAction action;
-        switch (AsteriskActionEnum.valueOf(endpoint.getAction())) {
+        switch (endpoint.getAction()) {
         case QUEUE_STATUS:
             action = new QueueStatusAction();
             break;
@@ -63,9 +63,8 @@ public class AsteriskProducer extends DefaultProducer {
             action = new SipPeersAction();
             break;
         case EXTENSION_STATE:
-            action = new 
ExtensionStateAction((String)exchange.getIn().getHeader(AsteriskConstants.EXTEN),
 (String)exchange.getIn().getHeader(AsteriskConstants.CONTEXT));
+            action = new 
ExtensionStateAction((String)exchange.getIn().getHeader(AsteriskConstants.EXTENSION),
 (String)exchange.getIn().getHeader(AsteriskConstants.CONTEXT));
             break;
-
         default:
             throw new IllegalStateException("Unknown action");
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/80d1937c/components/camel-asterisk/src/test/java/org/apache/camel/component/asterisk/AsteriskConfigTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-asterisk/src/test/java/org/apache/camel/component/asterisk/AsteriskConfigTest.java
 
b/components/camel-asterisk/src/test/java/org/apache/camel/component/asterisk/AsteriskConfigTest.java
index 738f87a..32a1091 100644
--- 
a/components/camel-asterisk/src/test/java/org/apache/camel/component/asterisk/AsteriskConfigTest.java
+++ 
b/components/camel-asterisk/src/test/java/org/apache/camel/component/asterisk/AsteriskConfigTest.java
@@ -25,7 +25,7 @@ public class AsteriskConfigTest extends CamelTestSupport {
     private String hostname = "192.168.0.254";
     private String username = "username";
     private String password = "password";
-    private String action = "action";
+    private String action = "QUEUE_STATUS";
 
     @Test
     public void asteriskEndpointData() throws Exception {
@@ -36,6 +36,6 @@ public class AsteriskConfigTest extends CamelTestSupport {
         assertEquals(hostname, asteriskEndpoint.getHostname());
         assertEquals(username, asteriskEndpoint.getUsername());
         assertEquals(password, asteriskEndpoint.getPassword());
-        assertEquals(action, asteriskEndpoint.getAction());
+        assertEquals(action, asteriskEndpoint.getAction().name());
     }
 }

Reply via email to