Repository: camel Updated Branches: refs/heads/master 3e194e048 -> 91c3dbb3e
CAMEL-7999: Lets include more core components documentation out of the box. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/799d4a0c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/799d4a0c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/799d4a0c Branch: refs/heads/master Commit: 799d4a0c27b1a45d6d2f01da51e51c64ec493ed3 Parents: 3e194e0 Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Nov 10 19:50:43 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Nov 10 19:50:43 2014 +0100 ---------------------------------------------------------------------- .../camel/component/bean/BeanComponent.java | 4 ++ .../camel/component/bean/ClassComponent.java | 11 +++-- .../camel/component/bean/ClassEndpoint.java | 32 +++++++++++++ .../camel/component/seda/SedaComponent.java | 17 ++++++- .../camel/component/seda/SedaEndpoint.java | 6 ++- .../camel/component/stub/StubComponent.java | 15 ++++++ .../camel/component/stub/StubEndpoint.java | 50 ++++++++++++++++++++ .../apache/camel/component/vm/StubConsumer.java | 27 +++++++++++ .../apache/camel/component/vm/VmComponent.java | 26 ++++++++-- .../apache/camel/component/vm/VmConsumer.java | 27 +++++++++++ .../apache/camel/component/vm/VmEndpoint.java | 48 +++++++++++++++++++ 11 files changed, 254 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java index e3da6e3..8516290 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java @@ -42,6 +42,10 @@ public class BeanComponent extends UriEndpointComponent { super(BeanEndpoint.class); } + public BeanComponent(Class<? extends Endpoint> endpointClass) { + super(endpointClass); + } + /** * A helper method to create a new endpoint from a bean with a generated URI */ http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java b/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java index ef6f4bb..05646de 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java @@ -22,15 +22,20 @@ import org.apache.camel.Endpoint; import org.apache.camel.Processor; /** - * The <a href="http://camel.apache.org/class.html">Class Component</a> - * will create an instance of the class from the {@link org.apache.camel.spi.Registry} and use that to handle message dispatching. + * The <a href="http://camel.apache.org/class.html">Class Component</a> is for invoking Java classes from Camel. + * <p/> + * This component is an extension to the {@link org.apache.camel.component.bean.BeanComponent}. * * @version */ public class ClassComponent extends BeanComponent { + public ClassComponent() { + super(ClassEndpoint.class); + } + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - BeanEndpoint endpoint = new BeanEndpoint(uri, this); + ClassEndpoint endpoint = new ClassEndpoint(uri, this); endpoint.setBeanName(remaining); // bean name is the FQN http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/bean/ClassEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/ClassEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/bean/ClassEndpoint.java new file mode 100644 index 0000000..63793b8 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/bean/ClassEndpoint.java @@ -0,0 +1,32 @@ +/** + * 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.bean; + +import org.apache.camel.Component; +import org.apache.camel.spi.UriEndpoint; + +/** + * Endpoint for the class component. + */ +@UriEndpoint(scheme = "class") +public class ClassEndpoint extends BeanEndpoint { + + public ClassEndpoint(String endpointUri, Component component) { + super(endpointUri, component); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java index ce08856d..bf8c420 100644 --- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaComponent.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.BlockingQueue; +import org.apache.camel.Component; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.impl.UriEndpointComponent; @@ -44,6 +45,10 @@ public class SedaComponent extends UriEndpointComponent { super(SedaEndpoint.class); } + public SedaComponent(Class<? extends Endpoint> endpointClass) { + super(endpointClass); + } + public void setQueueSize(int size) { queueSize = size; } @@ -164,14 +169,22 @@ public class SedaComponent extends UriEndpointComponent { if (queue == null) { BlockingQueueFactory<Exchange> queueFactory = resolveAndRemoveReferenceParameter(parameters, "queueFactory", BlockingQueueFactory.class); // defer creating queue till endpoint is started, so we pass the queue factory - answer = new SedaEndpoint(uri, this, queueFactory, consumers); + answer = createEndpoint(uri, this, queueFactory, consumers); } else { - answer = new SedaEndpoint(uri, this, queue, consumers); + answer = createEndpoint(uri, this, queue, consumers); } answer.configureProperties(parameters); return answer; } + protected SedaEndpoint createEndpoint(String endpointUri, Component component, BlockingQueueFactory<Exchange> queueFactory, int concurrentConsumers) { + return new SedaEndpoint(endpointUri, component, queueFactory, concurrentConsumers); + } + + protected SedaEndpoint createEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue, int concurrentConsumers) { + return new SedaEndpoint(endpointUri, component, queue, concurrentConsumers); + } + public String getQueueKey(String uri) { if (uri.contains("?")) { // strip parameters http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java index f5043fa..86a5321 100644 --- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java @@ -134,11 +134,15 @@ public class SedaEndpoint extends DefaultEndpoint implements BrowsableEndpoint, } } - Consumer answer = new SedaConsumer(this, processor); + Consumer answer = createNewConsumer(processor); configureConsumer(answer); return answer; } + protected SedaConsumer createNewConsumer(Processor processor) { + return new SedaConsumer(this, processor); + } + @Override public PollingConsumer createPollingConsumer() throws Exception { SedaPollingConsumer answer = new SedaPollingConsumer(this); http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java b/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java index 36cec51..d273b67 100644 --- a/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/stub/StubComponent.java @@ -17,7 +17,11 @@ package org.apache.camel.component.stub; import java.util.Map; +import java.util.concurrent.BlockingQueue; +import org.apache.camel.Component; +import org.apache.camel.Exchange; +import org.apache.camel.component.seda.BlockingQueueFactory; import org.apache.camel.component.vm.VmComponent; /** @@ -27,6 +31,7 @@ import org.apache.camel.component.vm.VmComponent; public class StubComponent extends VmComponent { public StubComponent() { + super(StubEndpoint.class); } @Override @@ -39,4 +44,14 @@ public class StubComponent extends VmComponent { // Don't validate so we can stub any URI } + @Override + protected StubEndpoint createEndpoint(String endpointUri, Component component, BlockingQueueFactory<Exchange> queueFactory, int concurrentConsumers) { + return new StubEndpoint(endpointUri, component, queueFactory, concurrentConsumers); + } + + @Override + protected StubEndpoint createEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue, int concurrentConsumers) { + return new StubEndpoint(endpointUri, component, queue, concurrentConsumers); + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/stub/StubEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/stub/StubEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/stub/StubEndpoint.java new file mode 100644 index 0000000..64d75ad --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/stub/StubEndpoint.java @@ -0,0 +1,50 @@ +/** + * 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.stub; + +import java.util.concurrent.BlockingQueue; + +import org.apache.camel.Component; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.component.seda.BlockingQueueFactory; +import org.apache.camel.component.vm.StubConsumer; +import org.apache.camel.component.vm.VmConsumer; +import org.apache.camel.component.vm.VmEndpoint; +import org.apache.camel.spi.UriEndpoint; + +@UriEndpoint(scheme = "stub", consumerClass = VmConsumer.class) +public class StubEndpoint extends VmEndpoint { + + public StubEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue) { + super(endpointUri, component, queue); + } + + public StubEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue, int concurrentConsumers) { + super(endpointUri, component, queue, concurrentConsumers); + } + + public StubEndpoint(String endpointUri, Component component, BlockingQueueFactory<Exchange> queueFactory, int concurrentConsumers) { + super(endpointUri, component, queueFactory, concurrentConsumers); + } + + @Override + protected StubConsumer createNewConsumer(Processor processor) { + return new StubConsumer(this, processor); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/vm/StubConsumer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/vm/StubConsumer.java b/camel-core/src/main/java/org/apache/camel/component/vm/StubConsumer.java new file mode 100644 index 0000000..92c477f --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/vm/StubConsumer.java @@ -0,0 +1,27 @@ +/** + * 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.vm; + +import org.apache.camel.Processor; + +public class StubConsumer extends VmConsumer { + + public StubConsumer(VmEndpoint endpoint, Processor processor) { + super(endpoint, processor); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java b/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java index ddbfa3b..9cf8030 100644 --- a/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/vm/VmComponent.java @@ -21,10 +21,12 @@ import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.camel.Component; import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.component.seda.BlockingQueueFactory; import org.apache.camel.component.seda.QueueReference; import org.apache.camel.component.seda.SedaComponent; -import org.apache.camel.component.seda.SedaEndpoint; /** * An implementation of the <a href="http://camel.apache.org/vm.html">VM components</a> @@ -36,9 +38,17 @@ import org.apache.camel.component.seda.SedaEndpoint; */ public class VmComponent extends SedaComponent { protected static final Map<String, QueueReference> QUEUES = new HashMap<String, QueueReference>(); - protected static final Map<String, SedaEndpoint> ENDPOINTS = new HashMap<String, SedaEndpoint>(); + protected static final Map<String, VmEndpoint> ENDPOINTS = new HashMap<String, VmEndpoint>(); private static final AtomicInteger START_COUNTER = new AtomicInteger(); + public VmComponent() { + super(VmEndpoint.class); + } + + public VmComponent(Class<? extends Endpoint> endpointClass) { + super(endpointClass); + } + @Override public Map<String, QueueReference> getQueues() { return QUEUES; @@ -71,9 +81,19 @@ public class VmComponent extends SedaComponent { return ENDPOINTS.get(uri); } - SedaEndpoint answer = (SedaEndpoint) super.createEndpoint(uri, remaining, parameters); + VmEndpoint answer = (VmEndpoint) super.createEndpoint(uri, remaining, parameters); ENDPOINTS.put(uri, answer); return answer; } + + @Override + protected VmEndpoint createEndpoint(String endpointUri, Component component, BlockingQueueFactory<Exchange> queueFactory, int concurrentConsumers) { + return new VmEndpoint(endpointUri, component, queueFactory, concurrentConsumers); + } + + @Override + protected VmEndpoint createEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue, int concurrentConsumers) { + return new VmEndpoint(endpointUri, component, queue, concurrentConsumers); + } } http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/vm/VmConsumer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/vm/VmConsumer.java b/camel-core/src/main/java/org/apache/camel/component/vm/VmConsumer.java new file mode 100644 index 0000000..a110ba4 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/vm/VmConsumer.java @@ -0,0 +1,27 @@ +/** + * 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.vm; + +import org.apache.camel.Processor; +import org.apache.camel.component.seda.SedaConsumer; + +public class VmConsumer extends SedaConsumer { + + public VmConsumer(VmEndpoint endpoint, Processor processor) { + super(endpoint, processor); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/799d4a0c/camel-core/src/main/java/org/apache/camel/component/vm/VmEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/vm/VmEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/vm/VmEndpoint.java new file mode 100644 index 0000000..fb94a80 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/vm/VmEndpoint.java @@ -0,0 +1,48 @@ +/** + * 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.vm; + +import java.util.concurrent.BlockingQueue; + +import org.apache.camel.Component; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.component.seda.BlockingQueueFactory; +import org.apache.camel.component.seda.SedaEndpoint; +import org.apache.camel.spi.UriEndpoint; + +@UriEndpoint(scheme = "vm", consumerClass = VmConsumer.class) +public class VmEndpoint extends SedaEndpoint { + + public VmEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue) { + super(endpointUri, component, queue); + } + + public VmEndpoint(String endpointUri, Component component, BlockingQueue<Exchange> queue, int concurrentConsumers) { + super(endpointUri, component, queue, concurrentConsumers); + } + + public VmEndpoint(String endpointUri, Component component, BlockingQueueFactory<Exchange> queueFactory, int concurrentConsumers) { + super(endpointUri, component, queueFactory, concurrentConsumers); + } + + @Override + protected VmConsumer createNewConsumer(Processor processor) { + return new VmConsumer(this, processor); + } + +}