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 9924c1c35647104d2c9fc590ecc168052de3aa8d Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Jun 19 11:26:59 2019 +0200 CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files. --- catalog/{ => camel-main-parser}/pom.xml | 57 +- .../camel/main/parser/ConfigurationModel.java | 57 ++ .../camel/main/parser/MainConfigurationParser.java | 63 ++ .../src/main/resources/META-INF/LICENSE.txt | 203 +++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../apache/camel/main/parser/MyConfiguration.java | 642 +++++++++++++++++++++ .../main/parser/MyConfigurationParserTest.java | 45 ++ .../src/test/resources/log4j2.properties | 30 + catalog/pom.xml | 1 + 9 files changed, 1088 insertions(+), 21 deletions(-) diff --git a/catalog/pom.xml b/catalog/camel-main-parser/pom.xml similarity index 51% copy from catalog/pom.xml copy to catalog/camel-main-parser/pom.xml index d3178ac..55ac7e3 100644 --- a/catalog/pom.xml +++ b/catalog/camel-main-parser/pom.xml @@ -24,29 +24,44 @@ <parent> <groupId>org.apache.camel</groupId> - <artifactId>camel-parent</artifactId> + <artifactId>catalog</artifactId> <version>3.0.0-SNAPSHOT</version> - <relativePath>../parent</relativePath> </parent> - <artifactId>catalog</artifactId> - <name>Camel :: Catalog</name> - <description>Camel Catalog</description> - <packaging>pom</packaging> - - <modules> - <!-- dummy used for testing catalog --> - <module>dummy-component</module> - <!-- catalog --> - <module>camel-catalog</module> - <module>camel-catalog-provider-karaf</module> - <module>camel-catalog-provider-springboot</module> - <module>camel-catalog-lucene</module> - <module>camel-catalog-maven</module> - <!-- tooling that depends on catalog --> - <module>camel-route-parser</module> - <module>camel-report-maven-plugin</module> - <module>camel-main-maven-plugin</module> - </modules> + <artifactId>camel-main-parser</artifactId> + <name>Camel :: Camel Main Parser</name> + <description>Camel Main Java configuration source parser</description> + + <dependencies> + + <dependency> + <groupId>org.jboss.forge.roaster</groupId> + <artifactId>roaster-jdt</artifactId> + <version>${roaster-version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + <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> </project> diff --git a/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/ConfigurationModel.java b/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/ConfigurationModel.java new file mode 100644 index 0000000..e7755a6 --- /dev/null +++ b/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/ConfigurationModel.java @@ -0,0 +1,57 @@ +/* + * 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.main.parser; + +public class ConfigurationModel { + + private String name; + private String javaType; + private String defaultValue; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getJavaType() { + return javaType; + } + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/MainConfigurationParser.java b/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/MainConfigurationParser.java new file mode 100644 index 0000000..be0820c --- /dev/null +++ b/catalog/camel-main-parser/src/main/java/org/apache/camel/main/parser/MainConfigurationParser.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.main.parser; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.jboss.forge.roaster.Roaster; +import org.jboss.forge.roaster.model.source.FieldSource; +import org.jboss.forge.roaster.model.source.JavaClassSource; +import org.jboss.forge.roaster.model.source.MethodSource; + +public class MainConfigurationParser { + + /** + * Parses the Camel Main configuration java source file. + */ + public List<ConfigurationModel> parseConfigurationSource(String fileName) throws FileNotFoundException { + final List<ConfigurationModel> answer = new ArrayList<>(); + + JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File(fileName)); + List<FieldSource<JavaClassSource>> fields = clazz.getFields(); + // filter out final or static fields + fields = fields.stream().filter(f -> !f.isFinal() && !f.isStatic()).collect(Collectors.toList()); + fields.forEach(f -> { + String name = f.getName(); + String javaType = f.getType().getQualifiedName(); + String defaultValue = f.getStringInitializer(); + + // the field must have a setter + String setterName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1); + MethodSource setter = clazz.getMethod(setterName, javaType); + if (setter != null) { + String desc = setter.getJavaDoc().getFullText(); + ConfigurationModel model = new ConfigurationModel(); + model.setName(name); + model.setJavaType(javaType); + model.setDefaultValue(defaultValue); + model.setDescription(desc); + answer.add(model); + } + }); + + return answer; + } +} diff --git a/catalog/camel-main-parser/src/main/resources/META-INF/LICENSE.txt b/catalog/camel-main-parser/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/catalog/camel-main-parser/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-parser/src/main/resources/META-INF/NOTICE.txt b/catalog/camel-main-parser/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000..2e215bf --- /dev/null +++ b/catalog/camel-main-parser/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/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfiguration.java b/catalog/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfiguration.java new file mode 100644 index 0000000..55da275 --- /dev/null +++ b/catalog/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfiguration.java @@ -0,0 +1,642 @@ +/* + * 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.main.parser; + +import org.apache.camel.ManagementStatisticsLevel; +import org.apache.camel.support.PatternHelper; + +/** + * Common set of configuration options used by Camel Main, Camel Spring Boot and other runtimes. + */ +public class MyConfiguration { + + private String name; + private int durationMaxSeconds; + private int durationMaxIdleSeconds; + private int durationMaxMessages; + private int shutdownTimeout = 300; + private boolean shutdownSuppressLoggingOnTimeout; + private boolean shutdownNowOnTimeout = true; + private boolean shutdownRoutesInReverseOrder = true; + private boolean shutdownLogInflightExchangesOnTimeout = true; + private String fileConfigurations; + private boolean jmxEnabled = true; + private int producerTemplateCacheSize = 1000; + private int consumerTemplateCacheSize = 1000; + private boolean loadTypeConverters = true; + private int logDebugMaxChars; + private boolean streamCachingEnabled; + private String streamCachingSpoolDirectory; + private String streamCachingSpoolCipher; + private long streamCachingSpoolThreshold; + private int streamCachingSpoolUsedHeapMemoryThreshold; + private String streamCachingSpoolUsedHeapMemoryLimit; + private boolean streamCachingAnySpoolRules; + private int streamCachingBufferSize; + private boolean streamCachingRemoveSpoolDirectoryWhenStopping = true; + private boolean streamCachingStatisticsEnabled; + private boolean tracing; + private boolean messageHistory = true; + private boolean logMask; + private boolean logExhaustedMessageBody; + private boolean handleFault; + private boolean autoStartup = true; + private boolean allowUseOriginalMessage; + private boolean endpointRuntimeStatisticsEnabled; + private boolean useDataType; + private boolean useBreadcrumb; + private ManagementStatisticsLevel jmxManagementStatisticsLevel = ManagementStatisticsLevel.Default; + private String jmxManagementNamePattern = "#name#"; + private boolean jmxCreateConnector; + private boolean useMdcLogging; + private String threadNamePattern; + private String routeFilterIncludePattern; + private String routeFilterExcludePattern; + + // getter and setters + // -------------------------------------------------------------- + + public String getName() { + return name; + } + + /** + * Sets the name of the CamelContext. + */ + public void setName(String name) { + this.name = name; + } + + public int getDurationMaxSeconds() { + return durationMaxSeconds; + } + + /** + * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. + * You can use this to run Camel for a short while. + */ + public void setDurationMaxSeconds(int durationMaxSeconds) { + this.durationMaxSeconds = durationMaxSeconds; + } + + public int getDurationMaxIdleSeconds() { + return durationMaxIdleSeconds; + } + + /** + * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. + * You can use this to run Camel for a short while. + */ + public void setDurationMaxIdleSeconds(int durationMaxIdleSeconds) { + this.durationMaxIdleSeconds = durationMaxIdleSeconds; + } + + public int getDurationMaxMessages() { + return durationMaxMessages; + } + + /** + * To specify how many messages to process by Camel before automatic terminating the JVM. + * You can use this to run Camel for a short while. + */ + public void setDurationMaxMessages(int durationMaxMessages) { + this.durationMaxMessages = durationMaxMessages; + } + + public int getShutdownTimeout() { + return shutdownTimeout; + } + + /** + * Timeout in seconds to graceful shutdown Camel. + */ + public void setShutdownTimeout(int shutdownTimeout) { + this.shutdownTimeout = shutdownTimeout; + } + + public boolean isShutdownSuppressLoggingOnTimeout() { + return shutdownSuppressLoggingOnTimeout; + } + + /** + * Whether Camel should try to suppress logging during shutdown and timeout was triggered, + * meaning forced shutdown is happening. And during forced shutdown we want to avoid logging + * errors/warnings et all in the logs as a side-effect of the forced timeout. + * Notice the suppress is a best effort as there may still be some logs coming + * from 3rd party libraries and whatnot, which Camel cannot control. + * This option is default false. + */ + public void setShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { + this.shutdownSuppressLoggingOnTimeout = shutdownSuppressLoggingOnTimeout; + } + + public boolean isShutdownNowOnTimeout() { + return shutdownNowOnTimeout; + } + + /** + * Sets whether to force shutdown of all consumers when a timeout occurred and thus + * not all consumers was shutdown within that period. + * + * You should have good reasons to set this option to false as it means that the routes + * keep running and is halted abruptly when CamelContext has been shutdown. + */ + public void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { + this.shutdownNowOnTimeout = shutdownNowOnTimeout; + } + + public boolean isShutdownRoutesInReverseOrder() { + return shutdownRoutesInReverseOrder; + } + + /** + * Sets whether routes should be shutdown in reverse or the same order as they where started. + */ + public void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { + this.shutdownRoutesInReverseOrder = shutdownRoutesInReverseOrder; + } + + public boolean isShutdownLogInflightExchangesOnTimeout() { + return shutdownLogInflightExchangesOnTimeout; + } + + /** + * Sets whether to log information about the inflight Exchanges which are still running + * during a shutdown which didn't complete without the given timeout. + */ + public void setShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { + this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; + } + + public String getFileConfigurations() { + return fileConfigurations; + } + + /** + * Directory to load additional configuration files that contains + * configuration values that takes precedence over any other configuration. + * This can be used to refer to files that may have secret configuration that + * has been mounted on the file system for containers. + * + * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, + * multiple directories can be separated by comma. + */ + public void setFileConfigurations(String fileConfigurations) { + this.fileConfigurations = fileConfigurations; + } + + public boolean isJmxEnabled() { + return jmxEnabled; + } + + /** + * Enable JMX in your Camel application. + */ + public void setJmxEnabled(boolean jmxEnabled) { + this.jmxEnabled = jmxEnabled; + } + + public int getProducerTemplateCacheSize() { + return producerTemplateCacheSize; + } + + /** + * Producer template endpoints cache size. + */ + public void setProducerTemplateCacheSize(int producerTemplateCacheSize) { + this.producerTemplateCacheSize = producerTemplateCacheSize; + } + + public int getConsumerTemplateCacheSize() { + return consumerTemplateCacheSize; + } + + /** + * Consumer template endpoints cache size. + */ + public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) { + this.consumerTemplateCacheSize = consumerTemplateCacheSize; + } + + public boolean isLoadTypeConverters() { + return loadTypeConverters; + } + + /** + * Whether to load custom type converters by scanning classpath. + * This is used for backwards compatibility with Camel 2.x. + * Its recommended to migrate to use fast type converter loading + * by setting <tt>@Converter(loader = true)</tt> on your custom + * type converter classes. + */ + public void setLoadTypeConverters(boolean loadTypeConverters) { + this.loadTypeConverters = loadTypeConverters; + } + + public int getLogDebugMaxChars() { + return logDebugMaxChars; + } + + /** + * Is used to limit the maximum length of the logging Camel message bodies. If the message body + * is longer than the limit, the log message is clipped. Use -1 to have unlimited length. + * Use for example 1000 to log at most 1000 characters. + */ + public void setLogDebugMaxChars(int logDebugMaxChars) { + this.logDebugMaxChars = logDebugMaxChars; + } + + public boolean isStreamCachingEnabled() { + return streamCachingEnabled; + } + + /** + * Sets whether stream caching is enabled or not. + * + * Default is false. + */ + public void setStreamCachingEnabled(boolean streamCachingEnabled) { + this.streamCachingEnabled = streamCachingEnabled; + } + + public String getStreamCachingSpoolDirectory() { + return streamCachingSpoolDirectory; + } + + /** + * Sets the stream caching spool (temporary) directory to use for overflow and spooling to disk. + * + * If no spool directory has been explicit configured, then a temporary directory + * is created in the java.io.tmpdir directory. + */ + public void setStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { + this.streamCachingSpoolDirectory = streamCachingSpoolDirectory; + } + + public String getStreamCachingSpoolCipher() { + return streamCachingSpoolCipher; + } + + /** + * Sets a stream caching cipher name to use when spooling to disk to write with encryption. + * By default the data is not encrypted. + */ + public void setStreamCachingSpoolCipher(String streamCachingSpoolCipher) { + this.streamCachingSpoolCipher = streamCachingSpoolCipher; + } + + public long getStreamCachingSpoolThreshold() { + return streamCachingSpoolThreshold; + } + + /** + * Stream caching threshold in bytes when overflow to disk is activated. + * The default threshold is 128kb. + * Use -1 to disable overflow to disk. + */ + public void setStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { + this.streamCachingSpoolThreshold = streamCachingSpoolThreshold; + } + + public int getStreamCachingSpoolUsedHeapMemoryThreshold() { + return streamCachingSpoolUsedHeapMemoryThreshold; + } + + /** + * Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk. + */ + public void setStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { + this.streamCachingSpoolUsedHeapMemoryThreshold = streamCachingSpoolUsedHeapMemoryThreshold; + } + + public String getStreamCachingSpoolUsedHeapMemoryLimit() { + return streamCachingSpoolUsedHeapMemoryLimit; + } + + /** + * Sets what the upper bounds should be when streamCachingSpoolUsedHeapMemoryThreshold is in use. + */ + public void setStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { + this.streamCachingSpoolUsedHeapMemoryLimit = streamCachingSpoolUsedHeapMemoryLimit; + } + + public boolean isStreamCachingAnySpoolRules() { + return streamCachingAnySpoolRules; + } + + /** + * Sets whether if just any of the org.apache.camel.spi.StreamCachingStrategy.SpoolRule rules + * returns true then shouldSpoolCache(long) returns true, to allow spooling to disk. + * If this option is false, then all the org.apache.camel.spi.StreamCachingStrategy.SpoolRule must + * return true. + * + * The default value is false which means that all the rules must return true. + */ + public void setStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { + this.streamCachingAnySpoolRules = streamCachingAnySpoolRules; + } + + public int getStreamCachingBufferSize() { + return streamCachingBufferSize; + } + + /** + * Sets the stream caching buffer size to use when allocating in-memory buffers used for in-memory stream caches. + * + * The default size is 4096. + */ + public void setStreamCachingBufferSize(int streamCachingBufferSize) { + this.streamCachingBufferSize = streamCachingBufferSize; + } + + public boolean isStreamCachingRemoveSpoolDirectoryWhenStopping() { + return streamCachingRemoveSpoolDirectoryWhenStopping; + } + + /** + * Whether to remove stream caching temporary directory when stopping. + * This option is default true. + */ + public void setStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { + this.streamCachingRemoveSpoolDirectoryWhenStopping = streamCachingRemoveSpoolDirectoryWhenStopping; + } + + public boolean isStreamCachingStatisticsEnabled() { + return streamCachingStatisticsEnabled; + } + + /** + * Sets whether stream caching statistics is enabled. + */ + public void setStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { + this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled; + } + + public boolean isTracing() { + return tracing; + } + + /** + * Sets whether tracing is enabled or not. + * + * Default is false. + */ + public void setTracing(boolean tracing) { + this.tracing = tracing; + } + + public boolean isMessageHistory() { + return messageHistory; + } + + /** + * Sets whether message history is enabled or not. + * + * Default is true. + */ + public void setMessageHistory(boolean messageHistory) { + this.messageHistory = messageHistory; + } + + public boolean isLogMask() { + return logMask; + } + + /** + * Sets whether log mask is enabled or not. + * + * Default is false. + */ + public void setLogMask(boolean logMask) { + this.logMask = logMask; + } + + public boolean isLogExhaustedMessageBody() { + return logExhaustedMessageBody; + } + + /** + * Sets whether to log exhausted message body with message history. + * + * Default is false. + */ + public void setLogExhaustedMessageBody(boolean logExhaustedMessageBody) { + this.logExhaustedMessageBody = logExhaustedMessageBody; + } + + public boolean isHandleFault() { + return handleFault; + } + + /** + * Sets whether fault handling is enabled or not. + * + * Default is false. + */ + public void setHandleFault(boolean handleFault) { + this.handleFault = handleFault; + } + + public boolean isAutoStartup() { + return autoStartup; + } + + /** + * Sets whether the object should automatically start when Camel starts. + * Important: Currently only routes can be disabled, as CamelContext's are always started. + * Note: When setting auto startup false on CamelContext then that takes precedence + * and no routes is started. You would need to start CamelContext explicit using + * the org.apache.camel.CamelContext.start() method, to start the context, and then + * you would need to start the routes manually using CamelContext.getRouteController().startRoute(String). + * + * Default is true to always start up. + */ + public void setAutoStartup(boolean autoStartup) { + this.autoStartup = autoStartup; + } + + public boolean isAllowUseOriginalMessage() { + return allowUseOriginalMessage; + } + + /** + * Sets whether to allow access to the original message from Camel's error handler, + * or from org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). + * Turning this off can optimize performance, as defensive copy of the original message is not needed. + * + * Default is false. + */ + public void setAllowUseOriginalMessage(boolean allowUseOriginalMessage) { + this.allowUseOriginalMessage = allowUseOriginalMessage; + } + + public boolean isEndpointRuntimeStatisticsEnabled() { + return endpointRuntimeStatisticsEnabled; + } + + /** + * Sets whether endpoint runtime statistics is enabled (gathers runtime usage of each incoming and outgoing endpoints). + * + * The default value is false. + */ + public void setEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { + this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled; + } + + public boolean isUseDataType() { + return useDataType; + } + + /** + * Whether to enable using data type on Camel messages. + * + * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. + * Otherwise data type is default off. + */ + public void setUseDataType(boolean useDataType) { + this.useDataType = useDataType; + } + + public boolean isUseBreadcrumb() { + return useBreadcrumb; + } + + /** + * Set whether breadcrumb is enabled. + * The default value is false. + */ + public void setUseBreadcrumb(boolean useBreadcrumb) { + this.useBreadcrumb = useBreadcrumb; + } + + public ManagementStatisticsLevel getJmxManagementStatisticsLevel() { + return jmxManagementStatisticsLevel; + } + + /** + * Sets the JMX statistics level + * The level can be set to Extended to gather additional information + * + * The default value is Default. + */ + public void setJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { + this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel; + } + + public String getJmxManagementNamePattern() { + return jmxManagementNamePattern; + } + + /** + * The naming pattern for creating the CamelContext JMX management name. + * + * The default pattern is #name# + */ + public void setJmxManagementNamePattern(String jmxManagementNamePattern) { + this.jmxManagementNamePattern = jmxManagementNamePattern; + } + + public boolean isJmxCreateConnector() { + return jmxCreateConnector; + } + + /** + * Whether JMX connector is created, allowing clients to connect remotely + * + * The default value is false. + */ + public void setJmxCreateConnector(boolean jmxCreateConnector) { + this.jmxCreateConnector = jmxCreateConnector; + } + + public boolean isUseMdcLogging() { + return useMdcLogging; + } + + /** + * To turn on MDC logging + */ + public void setUseMdcLogging(boolean useMdcLogging) { + this.useMdcLogging = useMdcLogging; + } + + public String getThreadNamePattern() { + return threadNamePattern; + } + + /** + * Sets the thread name pattern used for creating the full thread name. + * + * The default pattern is: Camel (#camelId#) thread ##counter# - #name# + * + * Where #camelId# is the name of the CamelContext. + * and #counter# is a unique incrementing counter. + * and #name# is the regular thread name. + * + * You can also use #longName# which is the long thread name which can includes endpoint parameters etc. + */ + public void setThreadNamePattern(String threadNamePattern) { + this.threadNamePattern = threadNamePattern; + } + + public String getRouteFilterIncludePattern() { + return routeFilterIncludePattern; + } + + /** + * Used for filtering routes routes matching the given pattern, which follows the following rules: + * + * - Match by route id + * - Match by route input endpoint uri + * + * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. + * + * For example to only include routes which starts with foo in their route id's, use: include=foo* + * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* + * + * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* + * + * Exclude takes precedence over include. + */ + public void setRouteFilterIncludePattern(String include) { + this.routeFilterIncludePattern = include; + } + + public String getRouteFilterExcludePattern() { + return routeFilterExcludePattern; + } + + /** + * Used for filtering routes routes matching the given pattern, which follows the following rules: + * + * - Match by route id + * - Match by route input endpoint uri + * + * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. + * + * For example to only include routes which starts with foo in their route id's, use: include=foo* + * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* + * + * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* + * + * Exclude takes precedence over include. + */ + public void setRouteFilterExcludePattern(String exclude) { + this.routeFilterExcludePattern = exclude; + } + +} diff --git a/catalog/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfigurationParserTest.java b/catalog/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfigurationParserTest.java new file mode 100644 index 0000000..452a6b0 --- /dev/null +++ b/catalog/camel-main-parser/src/test/java/org/apache/camel/main/parser/MyConfigurationParserTest.java @@ -0,0 +1,45 @@ +/* + * 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.main.parser; + +import java.util.List; + +import junit.framework.TestCase; +import org.junit.Test; + +public class MyConfigurationParserTest extends TestCase { + + @Test + public void testMyParser() throws Exception { + String fileName = "src/test/java/org/apache/camel/main/parser/MyConfiguration.java"; + + MainConfigurationParser parser = new MainConfigurationParser(); + List<ConfigurationModel> list = parser.parseConfigurationSource(fileName); + assertNotNull(list); + assertEquals(42, list.size()); + + assertEquals("name", list.get(0).getName()); + assertEquals("java.lang.String", list.get(0).getJavaType()); + assertNull(list.get(0).getDefaultValue()); + assertEquals("Sets the name of the CamelContext.", list.get(0).getDescription()); + + assertEquals("shutdownTimeout", list.get(4).getName()); + assertEquals("int", list.get(4).getJavaType()); + assertEquals("300", list.get(4).getDefaultValue()); + assertEquals("Timeout in seconds to graceful shutdown Camel.", list.get(4).getDescription()); + } +} diff --git a/catalog/camel-main-parser/src/test/resources/log4j2.properties b/catalog/camel-main-parser/src/test/resources/log4j2.properties new file mode 100644 index 0000000..c4233e9 --- /dev/null +++ b/catalog/camel-main-parser/src/test/resources/log4j2.properties @@ -0,0 +1,30 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/route-parser-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type = Console +appender.out.name = out +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +logger.parser.name = org.apache.camel.parser +logger.parser.level = DEBUG +rootLogger.level = INFO +rootLogger.appenderRef.file.ref = file diff --git a/catalog/pom.xml b/catalog/pom.xml index d3178ac..4dbabcb 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -43,6 +43,7 @@ <module>camel-catalog-provider-springboot</module> <module>camel-catalog-lucene</module> <module>camel-catalog-maven</module> + <module>camel-main-parser</module> <!-- tooling that depends on catalog --> <module>camel-route-parser</module> <module>camel-report-maven-plugin</module>