This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 87b1ebe4a59b23179d023471b91cd6977cecf814 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Jun 15 21:35:03 2019 +0200 CAMEL-13647: Allow to do autowrire by classpath. Quick and dirty prototype. --- catalog/camel-main-maven-plugin/pom.xml | 154 +++++++++ .../src/main/docs/camel-main-maven-plugin.adoc | 35 ++ .../java/org/apache/camel/maven/AutowireMojo.java | 372 +++++++++++++++++++++ .../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + catalog/pom.xml | 1 + .../camel/support/PropertyBindingSupport.java | 2 + examples/camel-example-main/pom.xml | 19 ++ 8 files changed, 797 insertions(+) diff --git a/catalog/camel-main-maven-plugin/pom.xml b/catalog/camel-main-maven-plugin/pom.xml new file mode 100644 index 0000000..f5e0d54 --- /dev/null +++ b/catalog/camel-main-maven-plugin/pom.xml @@ -0,0 +1,154 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <!-- NOTE parent need to point to camel maven plugins --> + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>maven-plugins</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../../tooling/maven</relativePath> + </parent> + + <artifactId>camel-main-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + <name>Camel :: Catalog :: Camel Main Maven Plugin</name> + <description>Maven plugin with tools for Camel Main support</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>tooling-parent</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + </dependency> + <!-- we extend the exec-maven-plugin for this camel maven plugin --> + <dependency> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-descriptor</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.collections</groupId> + <artifactId>google-collections</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-compat</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + </dependency> + + <!-- to scan classpath --> + <dependency> + <groupId>org.reflections</groupId> + <artifactId>reflections</artifactId> + <version>0.9.11</version> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>28.0-jre</version> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-main</artifactId> + </dependency> + + <!-- camel-catalog --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-catalog</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-catalog-maven</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- logging --> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <configuration> + <mojoDependencies> + <dep>org.codehaus.mojo:exec-maven-plugin</dep> + <dep>org.apache.maven:maven-plugin-api</dep> + </mojoDependencies> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc new file mode 100644 index 0000000..912ac3e --- /dev/null +++ b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc @@ -0,0 +1,35 @@ += Camel Main Maven Plugin + +The Camel Main Maven Plugin supports the following goals + + - camel-main:autowire - To pre-scan your project and prepare autowiring by classpath scanning + +== camel:autowire + +To pre-scan your project and prepare autowiring by classpath scanning. + +---- +mvn camel-main:autowire +---- + +You can also enable the plugin to automatic run as part of the build to catch these errors. + +[source,xml] +---- +<plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-main-maven-plugin</artifactId> + <executions> + <execution> + <phase>process-classes</phase> + <goals> + <goal>autowire</goal> + </goals> + </execution> + </executions> +</plugin> +---- + +The phase determines when the plugin runs. In the sample above the phase is `process-classes` which runs after +the compilation of the main source code. + diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java new file mode 100644 index 0000000..b57c8fd --- /dev/null +++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java @@ -0,0 +1,372 @@ +/* + * 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.maven; + +import java.io.File; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import org.apache.camel.catalog.CamelCatalog; +import org.apache.camel.catalog.DefaultCamelCatalog; +import org.apache.camel.catalog.JSonSchemaHelper; +import org.apache.camel.catalog.maven.MavenVersionManager; +import org.apache.camel.util.IOHelper; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.exec.AbstractExecMojo; +import org.reflections.Reflections; +import org.reflections.scanners.SubTypesScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; + +/** + * Pre scans your project and prepare autowiring by classpath scanning + */ +@Mojo(name = "autowire", threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE) +public class AutowireMojo extends AbstractExecMojo { + + /** + * Whether to allow downloading Camel catalog version from the internet. This is needed if the project + * uses a different Camel version than this plugin is using by default. + */ + @Parameter(property = "camel.downloadVersion", defaultValue = "true") + private boolean downloadVersion; + + /** + * Whether to log the classpath when starting + */ + @Parameter(property = "camel.logClasspath", defaultValue = "false") + protected boolean logClasspath; + + @Component + private ArtifactFactory artifactFactory; + + @Component + private ArtifactResolver artifactResolver; + + @Parameter(property = "localRepository") + private ArtifactRepository localRepository; + + @Parameter(property = "project.remoteArtifactRepositories") + private List remoteRepositories; + + private ClassLoader classLoader; + + // CHECKSTYLE:OFF + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + CamelCatalog catalog = new DefaultCamelCatalog(); + // add activemq as known component + catalog.addComponent("activemq", "org.apache.activemq.camel.component.ActiveMQComponent"); + // enable loading other catalog versions dynamically + catalog.setVersionManager(new MavenVersionManager()); + // enable caching + catalog.enableCache(); + + String detectedVersion = findCamelVersion(project); + if (detectedVersion != null) { + getLog().info("Detected Camel version used in project: " + detectedVersion); + } + + if (downloadVersion) { + String catalogVersion = catalog.getCatalogVersion(); + String version = findCamelVersion(project); + if (version != null && !version.equals(catalogVersion)) { + // the project uses a different Camel version so attempt to load it + getLog().info("Downloading Camel version: " + version); + boolean loaded = catalog.loadVersion(version); + if (!loaded) { + getLog().warn("Error downloading Camel version: " + version); + } + } + } + + if (catalog.getLoadedVersion() != null) { + getLog().info("Pre-scanning using downloaded Camel version: " + catalog.getLoadedVersion()); + } else { + getLog().info("Pre-scanning using Camel version: " + catalog.getCatalogVersion()); + } + + // find all Camel components on classpath and check in the camel-catalog for all component options + // then check each option if its a complex type and an interface + // and if so scan class-path and find the single class implementing this interface + // write this to META-INF/services/org/apache/camel/autowire-by-classpath + + // find all Camel components on classpath + Set<String> components = resolveCamelComponentsFromClasspath(); + if (components.isEmpty()) { + getLog().warn("No Camel components discovered in classpath"); + } else { + getLog().info("Discovered " + components.size() + " Camel components from classpath: " + components); + } + + Reflections reflections = new Reflections(new ConfigurationBuilder() + .addUrls(ClasspathHelper.forClassLoader(classLoader)) + .addClassLoader(classLoader) + .setScanners(new SubTypesScanner())); + + List<String> autowires = new ArrayList<>(); + + for (String componentName : components) { +getLog().info("Autowiring Camel component: " + componentName); + String json = catalog.componentJSonSchema(componentName); + if (json == null) { + getLog().warn("Cannot find component JSon metadata for component: " + componentName); + continue; + } + + + + List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true); + Set<String> names = JSonSchemaHelper.getNames(rows); + for (String name : names) { + Map<String, String> row = JSonSchemaHelper.getRow(rows, name); + String type = row.get("type"); + String javaType = safeJavaType(row.get("javaType")); + if ("object".equals(type)) { + // resolve javatype as class + try { + Class clazz = classLoader.loadClass(javaType); + if (clazz.isInterface()) { + Set<Class<?>> classes = reflections.getSubTypesOf(clazz); + // filter classes to not be interfaces or not a top level class + classes = classes.stream().filter(c -> !c.isInterface() && c.getEnclosingClass() == null).collect(Collectors.toSet()); + if (classes.size() == 1) { + Class cls = classes.iterator().next(); + if (isValidAutowireClass(cls)) { + String line = "camel.component." + componentName + "." + name + "=#class:" + cls; + getLog().debug(line); + autowires.add(line); + } + } else if (classes.size() > 1) { + getLog().debug("Found " + classes.size() + " for autowire: " + componentName + "." + name + " -> " + classes); + } + } + + } catch (Exception e) { + getLog().warn("Cannot load class: " + name, e); + // ignore + } + } + } + } + + if (!autowires.isEmpty()) { + // write the file + getLog().info("" + autowires); + } + } + + + protected boolean isValidAutowireClass(Class clazz) { + // skip all from Apache Camel as they would be default anyway + return !clazz.getName().startsWith("org.apache.camel"); + } + + protected String safeJavaType(String javaType) { + int pos = javaType.indexOf('<'); + if (pos > 0) { + return javaType.substring(0, pos); + } + return javaType; + } + + // autowire + // quartz2.xxxx=ddddd. + // + + protected Set<String> resolveCamelComponentsFromClasspath() throws MojoFailureException { + Set<String> components = new TreeSet<>(); + try { + classLoader = getClassLoader(); + Enumeration<URL> en = classLoader.getResources("META-INF/services/org/apache/camel/component.properties"); + while (en.hasMoreElements()) { + URL url = en.nextElement(); + InputStream is = (InputStream) url.getContent(); + Properties prop = new Properties(); + prop.load(is); + String comps = prop.getProperty("components"); + if (comps != null) { + String[] parts = comps.split("\\s+"); + components.addAll(Arrays.asList(parts)); + } + IOHelper.close(is); + } + } catch (Throwable e) { + // error + throw new MojoFailureException("Error during scanning", e); + } + return components; + } + + private static String findCamelVersion(MavenProject project) { + Dependency candidate = null; + + List list = project.getDependencies(); + for (Object obj : list) { + Dependency dep = (Dependency) obj; + if ("org.apache.camel".equals(dep.getGroupId())) { + if ("camel-core".equals(dep.getArtifactId())) { + // favor camel-core + candidate = dep; + break; + } else { + candidate = dep; + } + } + } + if (candidate != null) { + return candidate.getVersion(); + } + + return null; + } + + /** + * Set up a classloader for scanning + */ + private ClassLoader getClassLoader() throws MalformedURLException, MojoExecutionException { + Set<Artifact> deps = project.getArtifacts(); + deps.addAll(getAllNonTestScopedDependencies()); + + Set<URL> classpathURLs = new LinkedHashSet<>(); + for (Artifact dep : deps) { + File file = dep.getFile(); + if (file != null) { + classpathURLs.add(file.toURI().toURL()); + } + } + + if (logClasspath) { + getLog().info("Classpath:"); + for (URL url : classpathURLs) { + getLog().info(" " + url.getFile().toString()); + } + } + return new URLClassLoader(classpathURLs.toArray(new URL[classpathURLs.size()])); + } + + private Collection<Artifact> getAllNonTestScopedDependencies() throws MojoExecutionException { + List<Artifact> answer = new ArrayList<>(); + + for (Artifact artifact : getAllDependencies()) { + + // do not add test artifacts + if (!artifact.getScope().equals(Artifact.SCOPE_TEST)) { + + if ("google-collections".equals(artifact.getArtifactId())) { + // skip this as we conflict with guava + continue; + } + + if (!artifact.isResolved()) { + ArtifactResolutionRequest req = new ArtifactResolutionRequest(); + req.setArtifact(artifact); + req.setResolveTransitively(true); + req.setLocalRepository(localRepository); + req.setRemoteRepositories(remoteRepositories); + artifactResolver.resolve(req); + } + + answer.add(artifact); + } + } + return answer; + } + + // generic method to retrieve all the transitive dependencies + private Collection<Artifact> getAllDependencies() throws MojoExecutionException { + List<Artifact> artifacts = new ArrayList<>(); + + for (Iterator<?> dependencies = project.getDependencies().iterator(); dependencies.hasNext();) { + Dependency dependency = (Dependency)dependencies.next(); + + String groupId = dependency.getGroupId(); + String artifactId = dependency.getArtifactId(); + + VersionRange versionRange; + try { + versionRange = VersionRange.createFromVersionSpec(dependency.getVersion()); + } catch (InvalidVersionSpecificationException e) { + throw new MojoExecutionException("unable to parse version", e); + } + + String type = dependency.getType(); + if (type == null) { + type = "jar"; + } + String classifier = dependency.getClassifier(); + boolean optional = dependency.isOptional(); + String scope = dependency.getScope(); + if (scope == null) { + scope = Artifact.SCOPE_COMPILE; + } + + Artifact art = this.artifactFactory.createDependencyArtifact(groupId, artifactId, versionRange, + type, classifier, scope, null, optional); + + if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) { + art.setFile(new File(dependency.getSystemPath())); + } + + List<String> exclusions = new ArrayList<>(); + for (Exclusion exclusion : dependency.getExclusions()) { + exclusions.add(exclusion.getGroupId() + ":" + exclusion.getArtifactId()); + } + + ArtifactFilter newFilter = new ExcludesArtifactFilter(exclusions); + + art.setDependencyFilter(newFilter); + + artifacts.add(art); + } + + return artifacts; + } + + +} diff --git a/catalog/camel-main-maven-plugin/src/main/resources/META-INF/LICENSE.txt b/catalog/camel-main-maven-plugin/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/catalog/camel-main-maven-plugin/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/catalog/camel-main-maven-plugin/src/main/resources/META-INF/NOTICE.txt b/catalog/camel-main-maven-plugin/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000..2e215bf --- /dev/null +++ b/catalog/camel-main-maven-plugin/src/main/resources/META-INF/NOTICE.txt @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Apache Camel distribution. == + ========================================================================= + + This product includes software developed by + The Apache Software Foundation (http://www.apache.org/). + + Please read the different LICENSE files present in the licenses directory of + this distribution. diff --git a/catalog/pom.xml b/catalog/pom.xml index c5d77e5..d3178ac 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -46,6 +46,7 @@ <!-- tooling that depends on catalog --> <module>camel-route-parser</module> <module>camel-report-maven-plugin</module> + <module>camel-main-maven-plugin</module> </modules> </project> diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java index 9f84c43..7298242 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java @@ -298,6 +298,7 @@ public final class PropertyBindingSupport { * @param callback optional callback when a property was auto wired * @return true if one ore more properties was auto wired */ + @Deprecated public static boolean autowireInterfacePropertiesFromClasspath(CamelContext camelContext, Object target, boolean bindNullOnly, boolean deepNesting, OnAutowiring callback) { try { @@ -312,6 +313,7 @@ public final class PropertyBindingSupport { return false; } + @Deprecated private static boolean doAutowireInterfacePropertiesFromClasspath(CamelContext camelContext, Object target, Set<Object> parents, boolean bindNullOnly, boolean deepNesting, OnAutowiring callback) throws Exception { diff --git a/examples/camel-example-main/pom.xml b/examples/camel-example-main/pom.xml index 2d05078..384af5f 100644 --- a/examples/camel-example-main/pom.xml +++ b/examples/camel-example-main/pom.xml @@ -51,6 +51,15 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-quartz2</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jms</artifactId> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-jms-client</artifactId> + <version>2.9.0</version> + </dependency> <!-- logging --> <dependency> @@ -87,6 +96,16 @@ <mainClass>org.apache.camel.example.MyApplication</mainClass> </configuration> </plugin> + + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-main-maven-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <logClasspath>true</logClasspath> + </configuration> + </plugin> + </plugins> </build>