Polished

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

Branch: refs/heads/master
Commit: ff285e4e2d892610481b9405d0671c1531839c20
Parents: 61fc55f
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Nov 1 08:52:25 2016 -0400
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Nov 1 08:57:37 2016 -0400

----------------------------------------------------------------------
 components/camel-bonita/.gitignore              |   1 -
 components/camel-bonita/pom.xml                 | 198 +++++++++----------
 .../camel/component/bonita/BonitaComponent.java |  19 +-
 .../component/bonita/BonitaConfiguration.java   |  29 +--
 .../camel/component/bonita/BonitaEndpoint.java  |   9 +-
 .../bonita/consumer/BonitaConsumer.java         |  44 -----
 .../component/bonita/util/BonitaOperation.java  |   1 -
 .../bonita/BonitaConfigurationTest.java         |   3 +-
 8 files changed, 118 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/.gitignore
----------------------------------------------------------------------
diff --git a/components/camel-bonita/.gitignore 
b/components/camel-bonita/.gitignore
deleted file mode 100644
index b83d222..0000000
--- a/components/camel-bonita/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-bonita/pom.xml b/components/camel-bonita/pom.xml
index 86c5874..427b86d 100644
--- a/components/camel-bonita/pom.xml
+++ b/components/camel-bonita/pom.xml
@@ -1,112 +1,110 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- 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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-
-       <modelVersion>4.0.0</modelVersion>
+<!--
+  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
 
-       <parent>
-               <groupId>org.apache.camel</groupId>
-               <artifactId>components</artifactId>
-               <version>2.19.0-SNAPSHOT</version>
-       </parent>
+  http://www.apache.org/licenses/LICENSE-2.0
 
-       <artifactId>camel-bonita</artifactId>
-       <packaging>jar</packaging>
-       <name>Camel :: Bonita</name>
-       <description>Camel Bonita support</description>
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
 
-       <properties>
-               
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-               
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-               <jersey.version>2.23.2</jersey.version>
-               <wiremock.version>2.1.12</wiremock.version>
-       </properties>
+  <modelVersion>4.0.0</modelVersion>
 
-       <dependencies>
-               <dependency>
-                       <groupId>org.apache.camel</groupId>
-                       <artifactId>camel-core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>com.fasterxml.jackson.jaxrs</groupId>
-                       <artifactId>jackson-jaxrs-json-provider</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.glassfish.jersey.core</groupId>
-                       <artifactId>jersey-client</artifactId>
-                       <version>${jersey.version}</version>
-               </dependency>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.19.0-SNAPSHOT</version>
+  </parent>
 
-               <dependency>
-                       <groupId>org.glassfish.jersey.connectors</groupId>
-                       <artifactId>jersey-apache-connector</artifactId>
-                       <version>${jersey.version}</version>
-               </dependency>
+  <artifactId>camel-bonita</artifactId>
+  <packaging>jar</packaging>
+  <name>Camel :: Bonita</name>
+  <description>Camel Bonita support</description>
 
-<!--           <dependency> -->
-<!--                   <groupId>org.glassfish.jersey.core</groupId> -->
-<!--                   <artifactId>jersey-client</artifactId> -->
-<!--                   <version>${jersey.version}</version> -->
-<!--           </dependency> -->
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <jersey.version>2.23.2</jersey.version>
+    <wiremock.version>2.1.12</wiremock.version>
+  </properties>
 
-               <dependency>
-                       <groupId>org.glassfish.jersey.media</groupId>
-                       <artifactId>jersey-media-json-jackson</artifactId>
-                       <version>${jersey.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       
<groupId>com.fasterxml.jackson.core</groupId>
-                                       
<artifactId>jackson-annotations</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.jaxrs</groupId>
+      <artifactId>jackson-jaxrs-json-provider</artifactId>
+    </dependency>
 
-               <dependency>
-                       <groupId>org.glassfish.jersey.media</groupId>
-                       <artifactId>jersey-media-multipart</artifactId>
-                       <version>${jersey.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       
<groupId>com.fasterxml.jackson.core</groupId>
-                                       
<artifactId>jackson-annotations</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.core</groupId>
+      <artifactId>jersey-client</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.connectors</groupId>
+      <artifactId>jersey-apache-connector</artifactId>
+      <version>${jersey.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.media</groupId>
+      <artifactId>jersey-media-json-jackson</artifactId>
+      <version>${jersey.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>com.fasterxml.jackson.core</groupId>
+          <artifactId>jackson-annotations</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.media</groupId>
+      <artifactId>jersey-media-multipart</artifactId>
+      <version>${jersey.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>com.fasterxml.jackson.core</groupId>
+          <artifactId>jackson-annotations</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
 
-               <!-- testing -->
-               <dependency>
-                       <groupId>org.apache.camel</groupId>
-                       <artifactId>camel-test</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.powermock</groupId>
-                       <artifactId>powermock-module-junit4</artifactId>
-                       <version>${powermock-version}</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.powermock</groupId>
-                       <artifactId>powermock-api-mockito</artifactId>
-                       <version>${powermock-version}</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>com.github.tomakehurst</groupId>
-                       <artifactId>wiremock-standalone</artifactId>
-                       <version>${wiremock.version}</version>
-                       <scope>test</scope>
-               </dependency>
-       </dependencies>
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.powermock</groupId>
+      <artifactId>powermock-module-junit4</artifactId>
+      <version>${powermock-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.powermock</groupId>
+      <artifactId>powermock-api-mockito</artifactId>
+      <version>${powermock-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.github.tomakehurst</groupId>
+      <artifactId>wiremock-standalone</artifactId>
+      <version>${wiremock.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaComponent.java
 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaComponent.java
index e22f183..02b40a4 100644
--- 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaComponent.java
+++ 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaComponent.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.bonita;
 
 import java.util.Map;
@@ -24,9 +23,6 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.component.bonita.util.BonitaOperation;
 import org.apache.camel.impl.UriEndpointComponent;
 
-/**
- * Represents the component that manages {@link BonitaEndpoint}.
- */
 public class BonitaComponent extends UriEndpointComponent {
 
     public BonitaComponent() {
@@ -37,13 +33,16 @@ public class BonitaComponent extends UriEndpointComponent {
         super(context, BonitaEndpoint.class);
     }
 
-    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters)
-            throws Exception {
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
         BonitaConfiguration configuration = new BonitaConfiguration();
-        // configuration.setParameters(parameters);
         setProperties(configuration, parameters);
-        configuration.setOperation(BonitaOperation.valueOf(remaining));
-        Endpoint endpoint = new BonitaEndpoint(uri, this, configuration);
-        return endpoint;
+
+        BonitaOperation op = 
getCamelContext().getTypeConverter().tryConvertTo(BonitaOperation.class, 
remaining);
+        if (op == null) {
+            throw new IllegalArgumentException("Invalid operation " + 
remaining);
+        }
+        configuration.setOperation(op);
+
+        return new BonitaEndpoint(uri, this, configuration);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaConfiguration.java
 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaConfiguration.java
index 70b615f..7343e2c 100644
--- 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaConfiguration.java
+++ 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaConfiguration.java
@@ -5,16 +5,15 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.bonita;
 
 import java.util.Map;
@@ -28,29 +27,17 @@ import org.apache.camel.spi.UriPath;
 @UriParams
 public class BonitaConfiguration implements Cloneable {
 
-    @UriPath(
-            enums = "startCase")
-    @Metadata(
-            required = "true")
+    @UriPath @Metadata(required = "true")
     private BonitaOperation operation;
-
-    @UriParam(
-            defaultValue = "localhost")
+    @UriParam(defaultValue = "localhost")
     private String hostname = "localhost";
-
-    @UriParam(
-            defaultValue = "8080")
+    @UriParam(defaultValue = "8080")
     private String port = "8080";
-
     @UriParam
     private String processName;
-
-    @UriParam(
-            label = "security")
+    @UriParam(label = "security", secret = true)
     private String username;
-
-    @UriParam(
-            label = "security")
+    @UriParam(label = "security", secret = true)
     private String password;
 
     public String getHostname() {

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaEndpoint.java
 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaEndpoint.java
index b3ca00b..f76622c 100644
--- 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaEndpoint.java
+++ 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/BonitaEndpoint.java
@@ -14,13 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.bonita;
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.component.bonita.consumer.BonitaConsumer;
 import org.apache.camel.component.bonita.exception.BonitaException;
 import org.apache.camel.component.bonita.producer.BonitaStartProducer;
 import org.apache.camel.component.bonita.util.BonitaOperation;
@@ -30,14 +28,11 @@ import org.apache.camel.spi.UriParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Represents a bonita endpoint.
- */
 @UriEndpoint(
         scheme = "bonita",
         title = "bonita",
         syntax = "bonita:operation",
-        consumerClass = BonitaConsumer.class,
+        consumerOnly = true,
         label = "bonita")
 public class BonitaEndpoint extends DefaultEndpoint {
 
@@ -68,7 +63,7 @@ public class BonitaEndpoint extends DefaultEndpoint {
     }
 
     public Consumer createConsumer(Processor processor) throws Exception {
-        return new BonitaConsumer(this, processor);
+        throw new UnsupportedOperationException("Consumer not supported");
     }
 
     public boolean isSingleton() {

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/consumer/BonitaConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/consumer/BonitaConsumer.java
 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/consumer/BonitaConsumer.java
deleted file mode 100644
index a6cd712..0000000
--- 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/consumer/BonitaConsumer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.bonita.consumer;
-
-import org.apache.camel.Processor;
-import org.apache.camel.component.bonita.BonitaEndpoint;
-import org.apache.camel.impl.ScheduledPollConsumer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The bonita consumer.
- */
-public class BonitaConsumer extends ScheduledPollConsumer {
-
-    protected static final transient Logger LOG = 
LoggerFactory.getLogger(BonitaConsumer.class);
-
-    protected BonitaEndpoint endpoint;
-
-    public BonitaConsumer(BonitaEndpoint endpoint, Processor processor) {
-        super(endpoint, processor);
-        this.endpoint = endpoint;
-    }
-
-    @Override
-    protected int poll() throws Exception {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/util/BonitaOperation.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/util/BonitaOperation.java
 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/util/BonitaOperation.java
index 0dd3fdd..07bcb25 100644
--- 
a/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/util/BonitaOperation.java
+++ 
b/components/camel-bonita/src/main/java/org/apache/camel/component/bonita/util/BonitaOperation.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.bonita.util;
 
 public enum BonitaOperation {

http://git-wip-us.apache.org/repos/asf/camel/blob/ff285e4e/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/BonitaConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/BonitaConfigurationTest.java
 
b/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/BonitaConfigurationTest.java
index 7539edd..c6b06f6 100644
--- 
a/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/BonitaConfigurationTest.java
+++ 
b/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/BonitaConfigurationTest.java
@@ -49,8 +49,7 @@ public class BonitaConfigurationTest extends CamelTestSupport 
{
         assertEquals(0, 
configuration.getOperation().compareTo(BonitaOperation.startCase));
     }
 
-    @Test(
-            expected = ResolveEndpointFailedException.class)
+    @Test(expected = ResolveEndpointFailedException.class)
     public void testBonitaConfigurationWrongOperation() {
         BonitaEndpoint bonitaEndpoint =
                 context.getEndpoint("bonita:wrongOperation", 
BonitaEndpoint.class);

Reply via email to