CAMEL-7999: More components include documentation
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e49c560a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e49c560a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e49c560a Branch: refs/heads/master Commit: e49c560a62d5473d0b7f4e88bb23cebf741b4fb2 Parents: d726ae0 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Jan 4 15:21:57 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Jan 4 15:21:57 2015 +0100 ---------------------------------------------------------------------- .../camel/component/avro/AvroComponent.java | 8 ++--- .../camel/component/avro/AvroConfiguration.java | 34 ++++++++++++++------ .../camel/component/avro/AvroEndpoint.java | 4 +++ .../camel/component/avro/AvroListener.java | 4 +-- .../camel/component/avro/AvroTransport.java | 22 +++++++++++++ 5 files changed, 56 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e49c560a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java index 84c90e6..94ed038 100644 --- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java +++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java @@ -25,22 +25,22 @@ import java.util.concurrent.ConcurrentMap; import org.apache.avro.Protocol; import org.apache.avro.reflect.ReflectData; - 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.URISupport; -public class AvroComponent extends DefaultComponent { +public class AvroComponent extends UriEndpointComponent { private AvroConfiguration configuration; private ConcurrentMap<String, AvroListener> listenerRegistry = new ConcurrentHashMap<String, AvroListener>(); public AvroComponent() { + super(AvroEndpoint.class); } public AvroComponent(CamelContext context) { - super(context); + super(context, AvroEndpoint.class); } http://git-wip-us.apache.org/repos/asf/camel/blob/e49c560a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java index 6b5b24b..d9d4f2e 100644 --- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java +++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java @@ -20,22 +20,36 @@ import java.net.URI; import java.util.Map; import org.apache.avro.Protocol; - import org.apache.camel.RuntimeCamelException; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; +import org.apache.camel.spi.UriPath; import org.apache.commons.lang.StringUtils; -import static org.apache.camel.component.avro.AvroConstants.*; +import static org.apache.camel.component.avro.AvroConstants.AVRO_MESSAGE_NAME_SEPARATOR; + +@UriParams public class AvroConfiguration implements Cloneable { + @UriPath + private AvroTransport transport; + @UriPath private String host; + @UriPath private int port; - private Protocol protocol; + @UriParam private String protocolLocation; + @UriParam + private Protocol protocol; + @UriParam private String protocolClassName; - private String transport; + @UriParam private String messageName; + @UriParam private String uriAuthority; + @UriParam(defaultValue = "false") private boolean reflectionProtocol; + @UriParam(defaultValue = "false") private boolean singleParameter; public AvroConfiguration copy() { @@ -48,11 +62,7 @@ public class AvroConfiguration implements Cloneable { } public void parseURI(URI uri, Map<String, Object> parameters, AvroComponent component) throws Exception { - transport = uri.getScheme(); - - if ((!AVRO_HTTP_TRANSPORT.equalsIgnoreCase(transport)) && (!AVRO_NETTY_TRANSPORT.equalsIgnoreCase(transport))) { - throw new IllegalArgumentException("Unrecognized Avro IPC transport: " + protocol + " for uri: " + uri); - } + transport = AvroTransport.valueOf(uri.getScheme()); setHost(uri.getHost()); setPort(uri.getPort()); @@ -94,11 +104,15 @@ public class AvroConfiguration implements Cloneable { this.protocol = protocol; } - public String getTransport() { + public AvroTransport getTransport() { return transport; } public void setTransport(String transport) { + this.transport = AvroTransport.valueOf(transport); + } + + public void setTransport(AvroTransport transport) { this.transport = transport; } http://git-wip-us.apache.org/repos/asf/camel/blob/e49c560a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java index 0da6796..5db407c 100644 --- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java +++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java @@ -25,9 +25,13 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.Processor; import org.apache.camel.impl.DefaultEndpoint; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +@UriEndpoint(scheme = "avro", consumerClass = AvroConsumer.class, label = "messaging,transformation") public abstract class AvroEndpoint extends DefaultEndpoint { + @UriParam private AvroConfiguration configuration; /** http://git-wip-us.apache.org/repos/asf/camel/blob/e49c560a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java ---------------------------------------------------------------------- diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java index 60aedcf..9b040f7 100644 --- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java +++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java @@ -69,9 +69,9 @@ public class AvroListener { } - if (AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport())) { + if (AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) { server = new HttpServer(responder, configuration.getPort()); - } else if (AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport())) { + } else if (AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) { server = new NettyServer(responder, new InetSocketAddress(configuration.getHost(), configuration.getPort())); } else { throw new IllegalArgumentException("Unknown transport " + configuration.getTransport()); http://git-wip-us.apache.org/repos/asf/camel/blob/e49c560a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroTransport.java ---------------------------------------------------------------------- diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroTransport.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroTransport.java new file mode 100644 index 0000000..6205ed3 --- /dev/null +++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroTransport.java @@ -0,0 +1,22 @@ +/** + * 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.avro; + +public enum AvroTransport { + + http, netty +}