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/77afa958 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/77afa958 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/77afa958 Branch: refs/heads/master Commit: 77afa958cb26fecb6f8ebcc7e92603356dde4e22 Parents: a430ee5 Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Dec 18 10:40:08 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Dec 18 10:58:55 2014 +0100 ---------------------------------------------------------------------- .../camel/component/stax/StAXComponent.java | 26 ++++---- .../camel/component/stax/StAXEndpoint.java | 62 ++++++++++++++++++++ 2 files changed, 72 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/77afa958/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXComponent.java b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXComponent.java index 94bfb2e..3d596f5 100644 --- a/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXComponent.java +++ b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXComponent.java @@ -18,27 +18,21 @@ package org.apache.camel.component.stax; import java.util.Map; -import org.xml.sax.ContentHandler; - import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultComponent; -import org.apache.camel.impl.ProcessorEndpoint; -import org.apache.camel.util.EndpointHelper; +import org.apache.camel.impl.UriEndpointComponent; + +public class StAXComponent extends UriEndpointComponent { -public class StAXComponent extends DefaultComponent { + public StAXComponent() { + super(StAXEndpoint.class); + } @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - StAXProcessor processor; - if (EndpointHelper.isReferenceParameter(remaining)) { - ContentHandler handler = EndpointHelper.resolveReferenceParameter(getCamelContext(), remaining.substring(1), ContentHandler.class, true); - processor = new StAXProcessor(handler); - } else { - Class clazz = getCamelContext().getClassResolver().resolveMandatoryClass(remaining, ContentHandler.class); - processor = new StAXProcessor(clazz); - } - setProperties(processor, parameters); - return new ProcessorEndpoint(uri, this, processor); + StAXEndpoint answer = new StAXEndpoint(uri, getCamelContext()); + answer.setContentHandlerClass(remaining); + setProperties(answer, parameters); + return answer; } } http://git-wip-us.apache.org/repos/asf/camel/blob/77afa958/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXEndpoint.java b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXEndpoint.java new file mode 100644 index 0000000..12c751e --- /dev/null +++ b/components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXEndpoint.java @@ -0,0 +1,62 @@ +/** + * 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.stax; + +import org.xml.sax.ContentHandler; + +import org.apache.camel.CamelContext; +import org.apache.camel.Processor; +import org.apache.camel.impl.ProcessorEndpoint; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriPath; +import org.apache.camel.util.EndpointHelper; + +@UriEndpoint(scheme = "stax", label = "transformation") +public class StAXEndpoint extends ProcessorEndpoint { + + @UriPath + private String contentHandlerClass; + + public StAXEndpoint(String endpointUri, CamelContext context) { + super(endpointUri, context, null); + } + + public String getContentHandlerClass() { + return contentHandlerClass; + } + + public void setContentHandlerClass(String contentHandlerClass) { + this.contentHandlerClass = contentHandlerClass; + } + + @Override + protected void doStart() throws Exception { + super.doStart(); + + Processor target; + if (EndpointHelper.isReferenceParameter(contentHandlerClass)) { + ContentHandler handler = EndpointHelper.resolveReferenceParameter(getCamelContext(), contentHandlerClass.substring(1), ContentHandler.class, true); + target = new StAXProcessor(handler); + } else { + Class<ContentHandler> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(contentHandlerClass, ContentHandler.class); + target = new StAXProcessor(clazz); + } + + setProcessor(target); + } + +}