Repository: camel Updated Branches: refs/heads/master 91c3dbb3e -> 247fe5507
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/247fe550 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/247fe550 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/247fe550 Branch: refs/heads/master Commit: 247fe550721d78f6432754f23c12a6325730a0b6 Parents: 91c3dbb Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Nov 10 20:34:31 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Nov 10 20:34:31 2014 +0100 ---------------------------------------------------------------------- .../camel/component/bean/ClassComponent.java | 60 ------------------- .../camel/component/bean/ClassEndpoint.java | 32 ---------- .../component/beanclass/ClassComponent.java | 63 ++++++++++++++++++++ .../component/beanclass/ClassEndpoint.java | 33 ++++++++++ .../camel/component/beanclass/package.html | 25 ++++++++ .../apache/camel/impl/DefaultCamelContext.java | 2 + .../services/org/apache/camel/component/class | 2 +- 7 files changed, 124 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/247fe550/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 deleted file mode 100644 index 05646de..0000000 --- a/camel-core/src/main/java/org/apache/camel/component/bean/ClassComponent.java +++ /dev/null @@ -1,60 +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.bean; - -import java.util.Map; - -import org.apache.camel.Endpoint; -import org.apache.camel.Processor; - -/** - * 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 { - ClassEndpoint endpoint = new ClassEndpoint(uri, this); - endpoint.setBeanName(remaining); - - // bean name is the FQN - String name = endpoint.getBeanName(); - Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(name); - // create bean - Object bean = getCamelContext().getInjector().newInstance(clazz); - - // now set additional properties on it - setProperties(bean, parameters); - - // and register the bean as a holder on the endpoint - BeanHolder holder = new ConstantBeanHolder(bean, getCamelContext()); - endpoint.setBeanHolder(holder); - - // create processor - Processor processor = endpoint.getProcessor(); - setProperties(processor, parameters); - return endpoint; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/247fe550/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 deleted file mode 100644 index 63793b8..0000000 --- a/camel-core/src/main/java/org/apache/camel/component/bean/ClassEndpoint.java +++ /dev/null @@ -1,32 +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.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/247fe550/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java new file mode 100644 index 0000000..af5e7bc --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java @@ -0,0 +1,63 @@ +/** + * 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.beanclass; + +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.Processor; +import org.apache.camel.component.bean.BeanComponent; +import org.apache.camel.component.bean.BeanHolder; +import org.apache.camel.component.bean.ConstantBeanHolder; + +/** + * 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 { + ClassEndpoint endpoint = new ClassEndpoint(uri, this); + endpoint.setBeanName(remaining); + + // bean name is the FQN + String name = endpoint.getBeanName(); + Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(name); + // create bean + Object bean = getCamelContext().getInjector().newInstance(clazz); + + // now set additional properties on it + setProperties(bean, parameters); + + // and register the bean as a holder on the endpoint + BeanHolder holder = new ConstantBeanHolder(bean, getCamelContext()); + endpoint.setBeanHolder(holder); + + // create processor + Processor processor = endpoint.getProcessor(); + setProperties(processor, parameters); + return endpoint; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/247fe550/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java new file mode 100644 index 0000000..dd4783b --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java @@ -0,0 +1,33 @@ +/** + * 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.beanclass; + +import org.apache.camel.Component; +import org.apache.camel.component.bean.BeanEndpoint; +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/247fe550/camel-core/src/main/java/org/apache/camel/component/beanclass/package.html ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/beanclass/package.html b/camel-core/src/main/java/org/apache/camel/component/beanclass/package.html new file mode 100644 index 0000000..64c584f --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/beanclass/package.html @@ -0,0 +1,25 @@ +<!-- + 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. +--> +<html> +<head> +</head> +<body> + +The <a href="http://activemq.apache.org/class.html">Class Component</a> for invoking Java classes from Camel + +</body> +</html> http://git-wip-us.apache.org/repos/asf/camel/blob/247fe550/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index 32da83f..4d48355 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -1172,6 +1172,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon return "netty4/http"; } else if ("spring-event".equals(componentName)) { return "event"; + } else if ("class".equals(componentName)) { + return "beanclass"; } return componentName.replaceAll("-", ""); } http://git-wip-us.apache.org/repos/asf/camel/blob/247fe550/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/class ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/class b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/class index 69cf5be..4a47193 100644 --- a/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/class +++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/class @@ -15,4 +15,4 @@ # limitations under the License. # -class=org.apache.camel.component.bean.ClassComponent \ No newline at end of file +class=org.apache.camel.component.beanclass.ClassComponent \ No newline at end of file