This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-15224 in repository https://gitbox.apache.org/repos/asf/camel.git
commit be51f95b47bc80c01364a019f2d7cc2e2a1218d9 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Jun 22 11:49:09 2020 +0200 CAMEL-15224: camel-api-component - Avoid reflection when configured nested configuration classes. --- components/camel-as2/camel-as2-component/pom.xml | 57 +----- .../as2/AS2ClientManagerEndpointConfiguration.java | 204 +++++++++++++++++++++ ...ientManagerEndpointConfigurationConfigurer.java | 190 +++++++++++++++++++ .../component/as2/AS2ConfigurationConfigurer.java | 180 ++++++++++++++++++ .../as2/AS2ServerManagerEndpointConfiguration.java | 28 +++ ...rverManagerEndpointConfigurationConfigurer.java | 185 +++++++++++++++++++ .../component/as2/internal/AS2ApiCollection.java | 68 +++++++ .../camel/component/as2/internal/AS2ApiName.java | 40 ++++ .../as2/internal/AS2ClientManagerApiMethod.java | 66 +++++++ .../as2/internal/AS2ServerManagerApiMethod.java | 51 ++++++ .../AS2ClientManagerEndpointConfiguration | 2 + .../org/apache/camel/configurer/AS2Configuration | 2 + .../AS2ServerManagerEndpointConfiguration | 2 + .../camel/component/as2/AS2Configuration.java | 13 +- .../camel/maven/packaging/DynamicClassLoader.java | 10 + .../maven/packaging/GenerateConfigurerMojo.java | 150 +++++++++++++-- 16 files changed, 1177 insertions(+), 71 deletions(-) diff --git a/components/camel-as2/camel-as2-component/pom.xml b/components/camel-as2/camel-as2-component/pom.xml index 834416e..b4eb77c 100644 --- a/components/camel-as2/camel-as2-component/pom.xml +++ b/components/camel-as2/camel-as2-component/pom.xml @@ -77,6 +77,7 @@ <build> <defaultGoal>install</defaultGoal> + <pluginManagement> <plugins> <plugin> @@ -92,18 +93,8 @@ </plugin> </plugins> </pluginManagement> - <plugins> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - </plugin> + <plugins> <!-- generate Component source and test source --> <plugin> <groupId>org.apache.camel</groupId> @@ -162,53 +153,21 @@ </execution> </executions> </plugin> - - <!-- add generated source and test source to build --> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> + <!-- we need to generate additional configurer classes --> + <groupId>org.apache.camel</groupId> + <artifactId>camel-package-maven-plugin</artifactId> <executions> <execution> - <id>add-generated-sources</id> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-sources/camel-component</source> - </sources> - </configuration> - </execution> - <execution> - <id>add-generated-test-sources</id> + <id>generate-configurer</id> + <phase>process-classes</phase> <goals> - <goal>add-test-source</goal> + <goal>generate-configurer</goal> </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-test-sources/camel-component</source> - </sources> - </configuration> </execution> </executions> </plugin> - </plugins> </build> - <reporting> - <plugins> - <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-api-component-maven-plugin</artifactId> - <version>${project.version}</version> - <configuration> - <scheme>${schemeName}</scheme> - <componentName>${componentName}</componentName> - <componentPackage>${componentPackage}</componentPackage> - <outPackage>${outPackage}</outPackage> - </configuration> - </plugin> - </plugins> - </reporting> </project> diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfiguration.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfiguration.java new file mode 100644 index 0000000..ff84c8c --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfiguration.java @@ -0,0 +1,204 @@ + +/* + * Camel EndpointConfiguration generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2; + +import org.apache.camel.spi.Configurer; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; + +/** + * Camel EndpointConfiguration for org.apache.camel.component.as2.api.AS2ClientManager + */ +@UriParams +@Configurer +public final class AS2ClientManagerEndpointConfiguration extends AS2Configuration { + + @UriParam + private String as2From; + + @UriParam + private org.apache.camel.component.as2.api.AS2MessageStructure as2MessageStructure; + + @UriParam + private String as2To; + + @UriParam + private org.apache.camel.component.as2.api.AS2CompressionAlgorithm compressionAlgorithm; + + @UriParam + private String dispositionNotificationTo; + + @UriParam + private String ediMessage; + + @UriParam + private org.apache.http.entity.ContentType ediMessageContentType; + + @UriParam + private String ediMessageTransferEncoding; + + @UriParam + private org.apache.camel.component.as2.api.AS2EncryptionAlgorithm encryptingAlgorithm; + + @UriParam + private java.security.cert.Certificate[] encryptingCertificateChain; + + @UriParam + private String from; + + @UriParam + private String requestUri; + + @UriParam + private String[] signedReceiptMicAlgorithms; + + @UriParam + private org.apache.camel.component.as2.api.AS2SignatureAlgorithm signingAlgorithm; + + @UriParam + private java.security.cert.Certificate[] signingCertificateChain; + + @UriParam + private java.security.PrivateKey signingPrivateKey; + + @UriParam + private String subject; + + public String getAs2From() { + return as2From; + } + + public void setAs2From(String as2From) { + this.as2From = as2From; + } + + public org.apache.camel.component.as2.api.AS2MessageStructure getAs2MessageStructure() { + return as2MessageStructure; + } + + public void setAs2MessageStructure(org.apache.camel.component.as2.api.AS2MessageStructure as2MessageStructure) { + this.as2MessageStructure = as2MessageStructure; + } + + public String getAs2To() { + return as2To; + } + + public void setAs2To(String as2To) { + this.as2To = as2To; + } + + public org.apache.camel.component.as2.api.AS2CompressionAlgorithm getCompressionAlgorithm() { + return compressionAlgorithm; + } + + public void setCompressionAlgorithm(org.apache.camel.component.as2.api.AS2CompressionAlgorithm compressionAlgorithm) { + this.compressionAlgorithm = compressionAlgorithm; + } + + public String getDispositionNotificationTo() { + return dispositionNotificationTo; + } + + public void setDispositionNotificationTo(String dispositionNotificationTo) { + this.dispositionNotificationTo = dispositionNotificationTo; + } + + public String getEdiMessage() { + return ediMessage; + } + + public void setEdiMessage(String ediMessage) { + this.ediMessage = ediMessage; + } + + public org.apache.http.entity.ContentType getEdiMessageContentType() { + return ediMessageContentType; + } + + public void setEdiMessageContentType(org.apache.http.entity.ContentType ediMessageContentType) { + this.ediMessageContentType = ediMessageContentType; + } + + public String getEdiMessageTransferEncoding() { + return ediMessageTransferEncoding; + } + + public void setEdiMessageTransferEncoding(String ediMessageTransferEncoding) { + this.ediMessageTransferEncoding = ediMessageTransferEncoding; + } + + public org.apache.camel.component.as2.api.AS2EncryptionAlgorithm getEncryptingAlgorithm() { + return encryptingAlgorithm; + } + + public void setEncryptingAlgorithm(org.apache.camel.component.as2.api.AS2EncryptionAlgorithm encryptingAlgorithm) { + this.encryptingAlgorithm = encryptingAlgorithm; + } + + public java.security.cert.Certificate[] getEncryptingCertificateChain() { + return encryptingCertificateChain; + } + + public void setEncryptingCertificateChain(java.security.cert.Certificate[] encryptingCertificateChain) { + this.encryptingCertificateChain = encryptingCertificateChain; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public String getRequestUri() { + return requestUri; + } + + public void setRequestUri(String requestUri) { + this.requestUri = requestUri; + } + + public String[] getSignedReceiptMicAlgorithms() { + return signedReceiptMicAlgorithms; + } + + public void setSignedReceiptMicAlgorithms(String[] signedReceiptMicAlgorithms) { + this.signedReceiptMicAlgorithms = signedReceiptMicAlgorithms; + } + + public org.apache.camel.component.as2.api.AS2SignatureAlgorithm getSigningAlgorithm() { + return signingAlgorithm; + } + + public void setSigningAlgorithm(org.apache.camel.component.as2.api.AS2SignatureAlgorithm signingAlgorithm) { + this.signingAlgorithm = signingAlgorithm; + } + + public java.security.cert.Certificate[] getSigningCertificateChain() { + return signingCertificateChain; + } + + public void setSigningCertificateChain(java.security.cert.Certificate[] signingCertificateChain) { + this.signingCertificateChain = signingCertificateChain; + } + + public java.security.PrivateKey getSigningPrivateKey() { + return signingPrivateKey; + } + + public void setSigningPrivateKey(java.security.PrivateKey signingPrivateKey) { + this.signingPrivateKey = signingPrivateKey; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfigurationConfigurer.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfigurationConfigurer.java new file mode 100644 index 0000000..b5733e5 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ClientManagerEndpointConfigurationConfigurer.java @@ -0,0 +1,190 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.as2; + +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@SuppressWarnings("unchecked") +public class AS2ClientManagerEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration target = (org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.as2.internal.AS2ApiName.class, value)); return true; + case "as2from": + case "As2From": target.setAs2From(property(camelContext, java.lang.String.class, value)); return true; + case "as2messagestructure": + case "As2MessageStructure": target.setAs2MessageStructure(property(camelContext, org.apache.camel.component.as2.api.AS2MessageStructure.class, value)); return true; + case "as2to": + case "As2To": target.setAs2To(property(camelContext, java.lang.String.class, value)); return true; + case "as2version": + case "As2Version": target.setAs2Version(property(camelContext, java.lang.String.class, value)); return true; + case "clientfqdn": + case "ClientFqdn": target.setClientFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "compressionalgorithm": + case "CompressionAlgorithm": target.setCompressionAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class, value)); return true; + case "decryptingprivatekey": + case "DecryptingPrivateKey": target.setDecryptingPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "dispositionnotificationto": + case "DispositionNotificationTo": target.setDispositionNotificationTo(property(camelContext, java.lang.String.class, value)); return true; + case "edimessage": + case "EdiMessage": target.setEdiMessage(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagecontenttype": + case "EdiMessageContentType": target.setEdiMessageContentType(property(camelContext, org.apache.http.entity.ContentType.class, value)); return true; + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": target.setEdiMessageTransferEncoding(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagetype": + case "EdiMessageType": target.setEdiMessageType(property(camelContext, org.apache.http.entity.ContentType.class, value)); return true; + case "encryptingalgorithm": + case "EncryptingAlgorithm": target.setEncryptingAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class, value)); return true; + case "encryptingcertificatechain": + case "EncryptingCertificateChain": target.setEncryptingCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "from": + case "From": target.setFrom(property(camelContext, java.lang.String.class, value)); return true; + case "mdnmessagetemplate": + case "MdnMessageTemplate": target.setMdnMessageTemplate(property(camelContext, java.lang.String.class, value)); return true; + case "methodname": + case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; + case "requesturi": + case "RequestUri": target.setRequestUri(property(camelContext, java.lang.String.class, value)); return true; + case "server": + case "Server": target.setServer(property(camelContext, java.lang.String.class, value)); return true; + case "serverfqdn": + case "ServerFqdn": target.setServerFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "serverportnumber": + case "ServerPortNumber": target.setServerPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": target.setSignedReceiptMicAlgorithms(property(camelContext, java.lang.String[].class, value)); return true; + case "signingalgorithm": + case "SigningAlgorithm": target.setSigningAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class, value)); return true; + case "signingcertificatechain": + case "SigningCertificateChain": target.setSigningCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "signingprivatekey": + case "SigningPrivateKey": target.setSigningPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "subject": + case "Subject": target.setSubject(property(camelContext, java.lang.String.class, value)); return true; + case "targethostname": + case "TargetHostname": target.setTargetHostname(property(camelContext, java.lang.String.class, value)); return true; + case "targetportnumber": + case "TargetPortNumber": target.setTargetPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "useragent": + case "UserAgent": target.setUserAgent(property(camelContext, java.lang.String.class, value)); return true; + default: return false; + } + } + + @Override + public Map<String, Object> getAllOptions(Object target) { + Map<String, Object> answer = new CaseInsensitiveMap(); + answer.put("ApiName", org.apache.camel.component.as2.internal.AS2ApiName.class); + answer.put("As2From", java.lang.String.class); + answer.put("As2MessageStructure", org.apache.camel.component.as2.api.AS2MessageStructure.class); + answer.put("As2To", java.lang.String.class); + answer.put("As2Version", java.lang.String.class); + answer.put("ClientFqdn", java.lang.String.class); + answer.put("CompressionAlgorithm", org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class); + answer.put("DecryptingPrivateKey", java.security.PrivateKey.class); + answer.put("DispositionNotificationTo", java.lang.String.class); + answer.put("EdiMessage", java.lang.String.class); + answer.put("EdiMessageContentType", org.apache.http.entity.ContentType.class); + answer.put("EdiMessageTransferEncoding", java.lang.String.class); + answer.put("EdiMessageType", org.apache.http.entity.ContentType.class); + answer.put("EncryptingAlgorithm", org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class); + answer.put("EncryptingCertificateChain", java.security.cert.Certificate[].class); + answer.put("From", java.lang.String.class); + answer.put("MdnMessageTemplate", java.lang.String.class); + answer.put("MethodName", java.lang.String.class); + answer.put("RequestUri", java.lang.String.class); + answer.put("Server", java.lang.String.class); + answer.put("ServerFqdn", java.lang.String.class); + answer.put("ServerPortNumber", java.lang.Integer.class); + answer.put("SignedReceiptMicAlgorithms", java.lang.String[].class); + answer.put("SigningAlgorithm", org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class); + answer.put("SigningCertificateChain", java.security.cert.Certificate[].class); + answer.put("SigningPrivateKey", java.security.PrivateKey.class); + answer.put("Subject", java.lang.String.class); + answer.put("TargetHostname", java.lang.String.class); + answer.put("TargetPortNumber", java.lang.Integer.class); + answer.put("UserAgent", java.lang.String.class); + return answer; + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration target = (org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": return target.getApiName(); + case "as2from": + case "As2From": return target.getAs2From(); + case "as2messagestructure": + case "As2MessageStructure": return target.getAs2MessageStructure(); + case "as2to": + case "As2To": return target.getAs2To(); + case "as2version": + case "As2Version": return target.getAs2Version(); + case "clientfqdn": + case "ClientFqdn": return target.getClientFqdn(); + case "compressionalgorithm": + case "CompressionAlgorithm": return target.getCompressionAlgorithm(); + case "decryptingprivatekey": + case "DecryptingPrivateKey": return target.getDecryptingPrivateKey(); + case "dispositionnotificationto": + case "DispositionNotificationTo": return target.getDispositionNotificationTo(); + case "edimessage": + case "EdiMessage": return target.getEdiMessage(); + case "edimessagecontenttype": + case "EdiMessageContentType": return target.getEdiMessageContentType(); + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": return target.getEdiMessageTransferEncoding(); + case "edimessagetype": + case "EdiMessageType": return target.getEdiMessageType(); + case "encryptingalgorithm": + case "EncryptingAlgorithm": return target.getEncryptingAlgorithm(); + case "encryptingcertificatechain": + case "EncryptingCertificateChain": return target.getEncryptingCertificateChain(); + case "from": + case "From": return target.getFrom(); + case "mdnmessagetemplate": + case "MdnMessageTemplate": return target.getMdnMessageTemplate(); + case "methodname": + case "MethodName": return target.getMethodName(); + case "requesturi": + case "RequestUri": return target.getRequestUri(); + case "server": + case "Server": return target.getServer(); + case "serverfqdn": + case "ServerFqdn": return target.getServerFqdn(); + case "serverportnumber": + case "ServerPortNumber": return target.getServerPortNumber(); + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": return target.getSignedReceiptMicAlgorithms(); + case "signingalgorithm": + case "SigningAlgorithm": return target.getSigningAlgorithm(); + case "signingcertificatechain": + case "SigningCertificateChain": return target.getSigningCertificateChain(); + case "signingprivatekey": + case "SigningPrivateKey": return target.getSigningPrivateKey(); + case "subject": + case "Subject": return target.getSubject(); + case "targethostname": + case "TargetHostname": return target.getTargetHostname(); + case "targetportnumber": + case "TargetPortNumber": return target.getTargetPortNumber(); + case "useragent": + case "UserAgent": return target.getUserAgent(); + default: return null; + } + } +} + diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ConfigurationConfigurer.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ConfigurationConfigurer.java new file mode 100644 index 0000000..8293563 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ConfigurationConfigurer.java @@ -0,0 +1,180 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.as2; + +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.as2.AS2Configuration; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@SuppressWarnings("unchecked") +public class AS2ConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + org.apache.camel.component.as2.AS2Configuration target = (org.apache.camel.component.as2.AS2Configuration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.as2.internal.AS2ApiName.class, value)); return true; + case "as2from": + case "As2From": target.setAs2From(property(camelContext, java.lang.String.class, value)); return true; + case "as2messagestructure": + case "As2MessageStructure": target.setAs2MessageStructure(property(camelContext, org.apache.camel.component.as2.api.AS2MessageStructure.class, value)); return true; + case "as2to": + case "As2To": target.setAs2To(property(camelContext, java.lang.String.class, value)); return true; + case "as2version": + case "As2Version": target.setAs2Version(property(camelContext, java.lang.String.class, value)); return true; + case "clientfqdn": + case "ClientFqdn": target.setClientFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "compressionalgorithm": + case "CompressionAlgorithm": target.setCompressionAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class, value)); return true; + case "decryptingprivatekey": + case "DecryptingPrivateKey": target.setDecryptingPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "dispositionnotificationto": + case "DispositionNotificationTo": target.setDispositionNotificationTo(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": target.setEdiMessageTransferEncoding(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagetype": + case "EdiMessageType": target.setEdiMessageType(property(camelContext, org.apache.http.entity.ContentType.class, value)); return true; + case "encryptingalgorithm": + case "EncryptingAlgorithm": target.setEncryptingAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class, value)); return true; + case "encryptingcertificatechain": + case "EncryptingCertificateChain": target.setEncryptingCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "from": + case "From": target.setFrom(property(camelContext, java.lang.String.class, value)); return true; + case "mdnmessagetemplate": + case "MdnMessageTemplate": target.setMdnMessageTemplate(property(camelContext, java.lang.String.class, value)); return true; + case "methodname": + case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; + case "requesturi": + case "RequestUri": target.setRequestUri(property(camelContext, java.lang.String.class, value)); return true; + case "server": + case "Server": target.setServer(property(camelContext, java.lang.String.class, value)); return true; + case "serverfqdn": + case "ServerFqdn": target.setServerFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "serverportnumber": + case "ServerPortNumber": target.setServerPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": target.setSignedReceiptMicAlgorithms(property(camelContext, java.lang.String[].class, value)); return true; + case "signingalgorithm": + case "SigningAlgorithm": target.setSigningAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class, value)); return true; + case "signingcertificatechain": + case "SigningCertificateChain": target.setSigningCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "signingprivatekey": + case "SigningPrivateKey": target.setSigningPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "subject": + case "Subject": target.setSubject(property(camelContext, java.lang.String.class, value)); return true; + case "targethostname": + case "TargetHostname": target.setTargetHostname(property(camelContext, java.lang.String.class, value)); return true; + case "targetportnumber": + case "TargetPortNumber": target.setTargetPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "useragent": + case "UserAgent": target.setUserAgent(property(camelContext, java.lang.String.class, value)); return true; + default: return false; + } + } + + @Override + public Map<String, Object> getAllOptions(Object target) { + Map<String, Object> answer = new CaseInsensitiveMap(); + answer.put("ApiName", org.apache.camel.component.as2.internal.AS2ApiName.class); + answer.put("As2From", java.lang.String.class); + answer.put("As2MessageStructure", org.apache.camel.component.as2.api.AS2MessageStructure.class); + answer.put("As2To", java.lang.String.class); + answer.put("As2Version", java.lang.String.class); + answer.put("ClientFqdn", java.lang.String.class); + answer.put("CompressionAlgorithm", org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class); + answer.put("DecryptingPrivateKey", java.security.PrivateKey.class); + answer.put("DispositionNotificationTo", java.lang.String.class); + answer.put("EdiMessageTransferEncoding", java.lang.String.class); + answer.put("EdiMessageType", org.apache.http.entity.ContentType.class); + answer.put("EncryptingAlgorithm", org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class); + answer.put("EncryptingCertificateChain", java.security.cert.Certificate[].class); + answer.put("From", java.lang.String.class); + answer.put("MdnMessageTemplate", java.lang.String.class); + answer.put("MethodName", java.lang.String.class); + answer.put("RequestUri", java.lang.String.class); + answer.put("Server", java.lang.String.class); + answer.put("ServerFqdn", java.lang.String.class); + answer.put("ServerPortNumber", java.lang.Integer.class); + answer.put("SignedReceiptMicAlgorithms", java.lang.String[].class); + answer.put("SigningAlgorithm", org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class); + answer.put("SigningCertificateChain", java.security.cert.Certificate[].class); + answer.put("SigningPrivateKey", java.security.PrivateKey.class); + answer.put("Subject", java.lang.String.class); + answer.put("TargetHostname", java.lang.String.class); + answer.put("TargetPortNumber", java.lang.Integer.class); + answer.put("UserAgent", java.lang.String.class); + return answer; + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + org.apache.camel.component.as2.AS2Configuration target = (org.apache.camel.component.as2.AS2Configuration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": return target.getApiName(); + case "as2from": + case "As2From": return target.getAs2From(); + case "as2messagestructure": + case "As2MessageStructure": return target.getAs2MessageStructure(); + case "as2to": + case "As2To": return target.getAs2To(); + case "as2version": + case "As2Version": return target.getAs2Version(); + case "clientfqdn": + case "ClientFqdn": return target.getClientFqdn(); + case "compressionalgorithm": + case "CompressionAlgorithm": return target.getCompressionAlgorithm(); + case "decryptingprivatekey": + case "DecryptingPrivateKey": return target.getDecryptingPrivateKey(); + case "dispositionnotificationto": + case "DispositionNotificationTo": return target.getDispositionNotificationTo(); + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": return target.getEdiMessageTransferEncoding(); + case "edimessagetype": + case "EdiMessageType": return target.getEdiMessageType(); + case "encryptingalgorithm": + case "EncryptingAlgorithm": return target.getEncryptingAlgorithm(); + case "encryptingcertificatechain": + case "EncryptingCertificateChain": return target.getEncryptingCertificateChain(); + case "from": + case "From": return target.getFrom(); + case "mdnmessagetemplate": + case "MdnMessageTemplate": return target.getMdnMessageTemplate(); + case "methodname": + case "MethodName": return target.getMethodName(); + case "requesturi": + case "RequestUri": return target.getRequestUri(); + case "server": + case "Server": return target.getServer(); + case "serverfqdn": + case "ServerFqdn": return target.getServerFqdn(); + case "serverportnumber": + case "ServerPortNumber": return target.getServerPortNumber(); + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": return target.getSignedReceiptMicAlgorithms(); + case "signingalgorithm": + case "SigningAlgorithm": return target.getSigningAlgorithm(); + case "signingcertificatechain": + case "SigningCertificateChain": return target.getSigningCertificateChain(); + case "signingprivatekey": + case "SigningPrivateKey": return target.getSigningPrivateKey(); + case "subject": + case "Subject": return target.getSubject(); + case "targethostname": + case "TargetHostname": return target.getTargetHostname(); + case "targetportnumber": + case "TargetPortNumber": return target.getTargetPortNumber(); + case "useragent": + case "UserAgent": return target.getUserAgent(); + default: return null; + } + } +} + diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfiguration.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfiguration.java new file mode 100644 index 0000000..2193a38 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfiguration.java @@ -0,0 +1,28 @@ + +/* + * Camel EndpointConfiguration generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2; + +import org.apache.camel.spi.Configurer; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; + +/** + * Camel EndpointConfiguration for org.apache.camel.component.as2.api.AS2ServerManager + */ +@UriParams +@Configurer +public final class AS2ServerManagerEndpointConfiguration extends AS2Configuration { + + @UriParam + private String requestUriPattern; + + public String getRequestUriPattern() { + return requestUriPattern; + } + + public void setRequestUriPattern(String requestUriPattern) { + this.requestUriPattern = requestUriPattern; + } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfigurationConfigurer.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfigurationConfigurer.java new file mode 100644 index 0000000..da99a09 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/AS2ServerManagerEndpointConfigurationConfigurer.java @@ -0,0 +1,185 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.as2; + +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@SuppressWarnings("unchecked") +public class AS2ServerManagerEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration target = (org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.as2.internal.AS2ApiName.class, value)); return true; + case "as2from": + case "As2From": target.setAs2From(property(camelContext, java.lang.String.class, value)); return true; + case "as2messagestructure": + case "As2MessageStructure": target.setAs2MessageStructure(property(camelContext, org.apache.camel.component.as2.api.AS2MessageStructure.class, value)); return true; + case "as2to": + case "As2To": target.setAs2To(property(camelContext, java.lang.String.class, value)); return true; + case "as2version": + case "As2Version": target.setAs2Version(property(camelContext, java.lang.String.class, value)); return true; + case "clientfqdn": + case "ClientFqdn": target.setClientFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "compressionalgorithm": + case "CompressionAlgorithm": target.setCompressionAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class, value)); return true; + case "decryptingprivatekey": + case "DecryptingPrivateKey": target.setDecryptingPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "dispositionnotificationto": + case "DispositionNotificationTo": target.setDispositionNotificationTo(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": target.setEdiMessageTransferEncoding(property(camelContext, java.lang.String.class, value)); return true; + case "edimessagetype": + case "EdiMessageType": target.setEdiMessageType(property(camelContext, org.apache.http.entity.ContentType.class, value)); return true; + case "encryptingalgorithm": + case "EncryptingAlgorithm": target.setEncryptingAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class, value)); return true; + case "encryptingcertificatechain": + case "EncryptingCertificateChain": target.setEncryptingCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "from": + case "From": target.setFrom(property(camelContext, java.lang.String.class, value)); return true; + case "mdnmessagetemplate": + case "MdnMessageTemplate": target.setMdnMessageTemplate(property(camelContext, java.lang.String.class, value)); return true; + case "methodname": + case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; + case "requesturi": + case "RequestUri": target.setRequestUri(property(camelContext, java.lang.String.class, value)); return true; + case "requesturipattern": + case "RequestUriPattern": target.setRequestUriPattern(property(camelContext, java.lang.String.class, value)); return true; + case "server": + case "Server": target.setServer(property(camelContext, java.lang.String.class, value)); return true; + case "serverfqdn": + case "ServerFqdn": target.setServerFqdn(property(camelContext, java.lang.String.class, value)); return true; + case "serverportnumber": + case "ServerPortNumber": target.setServerPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": target.setSignedReceiptMicAlgorithms(property(camelContext, java.lang.String[].class, value)); return true; + case "signingalgorithm": + case "SigningAlgorithm": target.setSigningAlgorithm(property(camelContext, org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class, value)); return true; + case "signingcertificatechain": + case "SigningCertificateChain": target.setSigningCertificateChain(property(camelContext, java.security.cert.Certificate[].class, value)); return true; + case "signingprivatekey": + case "SigningPrivateKey": target.setSigningPrivateKey(property(camelContext, java.security.PrivateKey.class, value)); return true; + case "subject": + case "Subject": target.setSubject(property(camelContext, java.lang.String.class, value)); return true; + case "targethostname": + case "TargetHostname": target.setTargetHostname(property(camelContext, java.lang.String.class, value)); return true; + case "targetportnumber": + case "TargetPortNumber": target.setTargetPortNumber(property(camelContext, java.lang.Integer.class, value)); return true; + case "useragent": + case "UserAgent": target.setUserAgent(property(camelContext, java.lang.String.class, value)); return true; + default: return false; + } + } + + @Override + public Map<String, Object> getAllOptions(Object target) { + Map<String, Object> answer = new CaseInsensitiveMap(); + answer.put("ApiName", org.apache.camel.component.as2.internal.AS2ApiName.class); + answer.put("As2From", java.lang.String.class); + answer.put("As2MessageStructure", org.apache.camel.component.as2.api.AS2MessageStructure.class); + answer.put("As2To", java.lang.String.class); + answer.put("As2Version", java.lang.String.class); + answer.put("ClientFqdn", java.lang.String.class); + answer.put("CompressionAlgorithm", org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class); + answer.put("DecryptingPrivateKey", java.security.PrivateKey.class); + answer.put("DispositionNotificationTo", java.lang.String.class); + answer.put("EdiMessageTransferEncoding", java.lang.String.class); + answer.put("EdiMessageType", org.apache.http.entity.ContentType.class); + answer.put("EncryptingAlgorithm", org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class); + answer.put("EncryptingCertificateChain", java.security.cert.Certificate[].class); + answer.put("From", java.lang.String.class); + answer.put("MdnMessageTemplate", java.lang.String.class); + answer.put("MethodName", java.lang.String.class); + answer.put("RequestUri", java.lang.String.class); + answer.put("RequestUriPattern", java.lang.String.class); + answer.put("Server", java.lang.String.class); + answer.put("ServerFqdn", java.lang.String.class); + answer.put("ServerPortNumber", java.lang.Integer.class); + answer.put("SignedReceiptMicAlgorithms", java.lang.String[].class); + answer.put("SigningAlgorithm", org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class); + answer.put("SigningCertificateChain", java.security.cert.Certificate[].class); + answer.put("SigningPrivateKey", java.security.PrivateKey.class); + answer.put("Subject", java.lang.String.class); + answer.put("TargetHostname", java.lang.String.class); + answer.put("TargetPortNumber", java.lang.Integer.class); + answer.put("UserAgent", java.lang.String.class); + return answer; + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration target = (org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "apiname": + case "ApiName": return target.getApiName(); + case "as2from": + case "As2From": return target.getAs2From(); + case "as2messagestructure": + case "As2MessageStructure": return target.getAs2MessageStructure(); + case "as2to": + case "As2To": return target.getAs2To(); + case "as2version": + case "As2Version": return target.getAs2Version(); + case "clientfqdn": + case "ClientFqdn": return target.getClientFqdn(); + case "compressionalgorithm": + case "CompressionAlgorithm": return target.getCompressionAlgorithm(); + case "decryptingprivatekey": + case "DecryptingPrivateKey": return target.getDecryptingPrivateKey(); + case "dispositionnotificationto": + case "DispositionNotificationTo": return target.getDispositionNotificationTo(); + case "edimessagetransferencoding": + case "EdiMessageTransferEncoding": return target.getEdiMessageTransferEncoding(); + case "edimessagetype": + case "EdiMessageType": return target.getEdiMessageType(); + case "encryptingalgorithm": + case "EncryptingAlgorithm": return target.getEncryptingAlgorithm(); + case "encryptingcertificatechain": + case "EncryptingCertificateChain": return target.getEncryptingCertificateChain(); + case "from": + case "From": return target.getFrom(); + case "mdnmessagetemplate": + case "MdnMessageTemplate": return target.getMdnMessageTemplate(); + case "methodname": + case "MethodName": return target.getMethodName(); + case "requesturi": + case "RequestUri": return target.getRequestUri(); + case "requesturipattern": + case "RequestUriPattern": return target.getRequestUriPattern(); + case "server": + case "Server": return target.getServer(); + case "serverfqdn": + case "ServerFqdn": return target.getServerFqdn(); + case "serverportnumber": + case "ServerPortNumber": return target.getServerPortNumber(); + case "signedreceiptmicalgorithms": + case "SignedReceiptMicAlgorithms": return target.getSignedReceiptMicAlgorithms(); + case "signingalgorithm": + case "SigningAlgorithm": return target.getSigningAlgorithm(); + case "signingcertificatechain": + case "SigningCertificateChain": return target.getSigningCertificateChain(); + case "signingprivatekey": + case "SigningPrivateKey": return target.getSigningPrivateKey(); + case "subject": + case "Subject": return target.getSubject(); + case "targethostname": + case "TargetHostname": return target.getTargetHostname(); + case "targetportnumber": + case "TargetPortNumber": return target.getTargetPortNumber(); + case "useragent": + case "UserAgent": return target.getUserAgent(); + default: return null; + } + } +} + diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiCollection.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiCollection.java new file mode 100644 index 0000000..880a51d --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiCollection.java @@ -0,0 +1,68 @@ + +/* + * Camel ApiCollection generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2.internal; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import org.apache.camel.component.as2.AS2Configuration; +import org.apache.camel.component.as2.AS2ClientManagerEndpointConfiguration; +import org.apache.camel.component.as2.AS2ServerManagerEndpointConfiguration; + +import org.apache.camel.support.component.ApiCollection; +import org.apache.camel.support.component.ApiMethod; +import org.apache.camel.support.component.ApiMethodHelper; + +/** + * Camel {@link ApiCollection} for AS2 + */ +public final class AS2ApiCollection extends ApiCollection<AS2ApiName, AS2Configuration> { + + private static AS2ApiCollection collection; + + private AS2ApiCollection() { + final Map<String, String> aliases = new HashMap<String, String>(); + final Map<AS2ApiName, ApiMethodHelper<? extends ApiMethod>> apiHelpers = new HashMap<>(); + final Map<Class<? extends ApiMethod>, AS2ApiName> apiMethods = new HashMap<>(); + + List<String> nullableArgs; + + aliases.clear(); + nullableArgs = Arrays.asList("ediMessageTransferEncoding", "signingAlgorithm", "signingCertificateChain", "signingPrivateKey", "compressionAlgorithm", "dispositionNotificationTo", "signedReceiptMicAlgorithms", "encryptingAlgorithm", "encryptingCertificateChain"); + apiHelpers.put(AS2ApiName.CLIENT, new ApiMethodHelper<AS2ClientManagerApiMethod>(AS2ClientManagerApiMethod.class, aliases, nullableArgs)); + apiMethods.put(AS2ClientManagerApiMethod.class, AS2ApiName.CLIENT); + + aliases.clear(); + nullableArgs = Arrays.asList(); + apiHelpers.put(AS2ApiName.SERVER, new ApiMethodHelper<AS2ServerManagerApiMethod>(AS2ServerManagerApiMethod.class, aliases, nullableArgs)); + apiMethods.put(AS2ServerManagerApiMethod.class, AS2ApiName.SERVER); + + setApiHelpers(apiHelpers); + setApiMethods(apiMethods); + } + + public AS2Configuration getEndpointConfiguration(AS2ApiName apiName) { + AS2Configuration result = null; + switch (apiName) { + case CLIENT: + result = new AS2ClientManagerEndpointConfiguration(); + break; + case SERVER: + result = new AS2ServerManagerEndpointConfiguration(); + break; + } + return result; + } + + public static synchronized AS2ApiCollection getCollection() { + if (collection == null) { + collection = new AS2ApiCollection(); + } + return collection; + } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiName.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiName.java new file mode 100644 index 0000000..05f55d4 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ApiName.java @@ -0,0 +1,40 @@ + +/* + * Camel ApiName Enumeration generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2.internal; + +import org.apache.camel.support.component.ApiName; + +/** + * Camel {@link ApiName} Enumeration for Component AS2 + */ +public enum AS2ApiName implements ApiName { + + CLIENT("client"), + + SERVER("server"); + + + private static final AS2ApiName[] VALUES = values(); + + private final String name; + + private AS2ApiName(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + public static AS2ApiName fromValue(String value) throws IllegalArgumentException { + for (int i = 0; i < VALUES.length; i++) { + if (VALUES[i].name.equals(value)) { + return VALUES[i]; + } + } + throw new IllegalArgumentException("Invalid value " + value); + } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ClientManagerApiMethod.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ClientManagerApiMethod.java new file mode 100644 index 0000000..0160b44 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ClientManagerApiMethod.java @@ -0,0 +1,66 @@ + +/* + * Camel ApiMethod Enumeration generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2.internal; + +import java.lang.reflect.Method; +import java.util.List; + +import org.apache.camel.component.as2.api.AS2ClientManager; + +import org.apache.camel.support.component.ApiMethod; +import org.apache.camel.support.component.ApiMethodArg; +import org.apache.camel.support.component.ApiMethodImpl; + +import static org.apache.camel.support.component.ApiMethodArg.arg; + +/** + * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.as2.api.AS2ClientManager + */ +public enum AS2ClientManagerApiMethod implements ApiMethod { + + SEND( + org.apache.http.protocol.HttpCoreContext.class, + "send", + arg("ediMessage", String.class), + arg("requestUri", String.class), + arg("subject", String.class), + arg("from", String.class), + arg("as2From", String.class), + arg("as2To", String.class), + arg("as2MessageStructure", org.apache.camel.component.as2.api.AS2MessageStructure.class), + arg("ediMessageContentType", org.apache.http.entity.ContentType.class), + arg("ediMessageTransferEncoding", String.class), + arg("signingAlgorithm", org.apache.camel.component.as2.api.AS2SignatureAlgorithm.class), + arg("signingCertificateChain", new java.security.cert.Certificate[0].getClass()), + arg("signingPrivateKey", java.security.PrivateKey.class), + arg("compressionAlgorithm", org.apache.camel.component.as2.api.AS2CompressionAlgorithm.class), + arg("dispositionNotificationTo", String.class), + arg("signedReceiptMicAlgorithms", new String[0].getClass()), + arg("encryptingAlgorithm", org.apache.camel.component.as2.api.AS2EncryptionAlgorithm.class), + arg("encryptingCertificateChain", new java.security.cert.Certificate[0].getClass())); + + + + private final ApiMethod apiMethod; + + private AS2ClientManagerApiMethod(Class<?> resultType, String name, ApiMethodArg... args) { + this.apiMethod = new ApiMethodImpl(AS2ClientManager.class, resultType, name, args); + } + + @Override + public String getName() { return apiMethod.getName(); } + + @Override + public Class<?> getResultType() { return apiMethod.getResultType(); } + + @Override + public List<String> getArgNames() { return apiMethod.getArgNames(); } + + @Override + public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); } + + @Override + public Method getMethod() { return apiMethod.getMethod(); } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ServerManagerApiMethod.java b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ServerManagerApiMethod.java new file mode 100644 index 0000000..bc09701 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/java/org/apache/camel/component/as2/internal/AS2ServerManagerApiMethod.java @@ -0,0 +1,51 @@ + +/* + * Camel ApiMethod Enumeration generated by camel-api-component-maven-plugin + */ +package org.apache.camel.component.as2.internal; + +import java.lang.reflect.Method; +import java.util.List; + +import org.apache.camel.component.as2.api.AS2ServerManager; + +import org.apache.camel.support.component.ApiMethod; +import org.apache.camel.support.component.ApiMethodArg; +import org.apache.camel.support.component.ApiMethodImpl; + +import static org.apache.camel.support.component.ApiMethodArg.arg; + +/** + * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.as2.api.AS2ServerManager + */ +public enum AS2ServerManagerApiMethod implements ApiMethod { + + LISTEN( + void.class, + "listen", + arg("requestUriPattern", String.class), + arg("handler", org.apache.http.protocol.HttpRequestHandler.class)); + + + + private final ApiMethod apiMethod; + + private AS2ServerManagerApiMethod(Class<?> resultType, String name, ApiMethodArg... args) { + this.apiMethod = new ApiMethodImpl(AS2ServerManager.class, resultType, name, args); + } + + @Override + public String getName() { return apiMethod.getName(); } + + @Override + public Class<?> getResultType() { return apiMethod.getResultType(); } + + @Override + public List<String> getArgNames() { return apiMethod.getArgNames(); } + + @Override + public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); } + + @Override + public Method getMethod() { return apiMethod.getMethod(); } +} diff --git a/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ClientManagerEndpointConfiguration b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ClientManagerEndpointConfiguration new file mode 100644 index 0000000..559e457 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ClientManagerEndpointConfiguration @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.as2.AS2ClientManagerEndpointConfigurationConfigurer diff --git a/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2Configuration b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2Configuration new file mode 100644 index 0000000..329b9f1 --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2Configuration @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.as2.AS2ConfigurationConfigurer diff --git a/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ServerManagerEndpointConfiguration b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ServerManagerEndpointConfiguration new file mode 100644 index 0000000..cc758ca --- /dev/null +++ b/components/camel-as2/camel-as2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/AS2ServerManagerEndpointConfiguration @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.as2.AS2ServerManagerEndpointConfigurationConfigurer diff --git a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java index 1ba8f60..f0049b2 100644 --- a/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java +++ b/components/camel-as2/camel-as2-component/src/main/java/org/apache/camel/component/as2/AS2Configuration.java @@ -25,6 +25,7 @@ import org.apache.camel.component.as2.api.AS2EncryptionAlgorithm; import org.apache.camel.component.as2.api.AS2MessageStructure; import org.apache.camel.component.as2.api.AS2SignatureAlgorithm; import org.apache.camel.component.as2.internal.AS2ApiName; +import org.apache.camel.spi.Configurer; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -35,6 +36,7 @@ import org.apache.http.entity.ContentType; * Component configuration for AS2 component. */ @UriParams +@Configurer public class AS2Configuration { @UriPath @@ -220,17 +222,6 @@ public class AS2Configuration { /** * The port number of target host. -1 indicates the scheme default port. */ - public void setTargetPortNumber(String targetPortNumber) { - try { - this.targetPortNumber = Integer.valueOf(targetPortNumber); - } catch (NumberFormatException e) { - throw new RuntimeCamelException(String.format("Invalid target port number: %s", targetPortNumber)); - } - } - - /** - * The port number of target host. -1 indicates the scheme default port. - */ public void setTargetPortNumber(Integer targetPortNumber) { this.targetPortNumber = targetPortNumber; } diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/DynamicClassLoader.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/DynamicClassLoader.java index adf4330..0511a14 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/DynamicClassLoader.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/DynamicClassLoader.java @@ -32,6 +32,16 @@ class DynamicClassLoader extends URLClassLoader { super(urls, parent); } + public static DynamicClassLoader createDynamicClassLoaderFromUrls(List<URL> classpathElements) { + final URL[] urls = new URL[classpathElements.size()]; + int i = 0; + for (Iterator<URL> it = classpathElements.iterator(); it.hasNext(); i++) { + urls[i] = it.next(); + } + final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + return new DynamicClassLoader(urls, tccl != null ? tccl : DynamicClassLoader.class.getClassLoader()); + } + public static DynamicClassLoader createDynamicClassLoader(List<String> classpathElements) { final URL[] urls = new URL[classpathElements.size()]; int i = 0; diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateConfigurerMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateConfigurerMojo.java index e1f941f..e0614a9 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateConfigurerMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateConfigurerMojo.java @@ -23,20 +23,35 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.net.MalformedURLException; +import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.camel.tooling.model.BaseOptionModel; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +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.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationValue; @@ -46,15 +61,22 @@ import org.jboss.jandex.Index; import org.jboss.jandex.IndexReader; import static org.apache.camel.tooling.util.ReflectionHelper.doWithMethods; +import static org.apache.camel.tooling.util.Strings.between; /** * Generate configurer classes from @Configuer annotated classes. */ -@Mojo(name = "generate-configurer", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES) +@Mojo(name = "generate-configurer", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES, + requiresDependencyCollection = ResolutionScope.COMPILE, + requiresDependencyResolution = ResolutionScope.COMPILE) +// must include runtime dependencies to generate configurer source public class GenerateConfigurerMojo extends AbstractGeneratorMojo { public static final DotName CONFIGURER = DotName.createSimple("org.apache.camel.spi.Configurer"); + @Component + private ArtifactFactory artifactFactory; + /** * The output directory for generated java source code */ @@ -86,7 +108,13 @@ public class GenerateConfigurerMojo extends AbstractGeneratorMojo { public Option(String name, Class type, String getter) { // we just use name, type setName(name); - setJavaType(type.getName()); + if (type.isArray()) { + // special for array + String arrType = between(type.getName(), "[L", ";") + "[]"; + setJavaType(arrType); + } else { + setJavaType(type.getName()); + } setGetterMethod(getter); } } @@ -107,14 +135,10 @@ public class GenerateConfigurerMojo extends AbstractGeneratorMojo { resourcesOutputDir = new File(project.getBasedir(), "src/generated/resources"); } - List<String> cp = new ArrayList<>(); - cp.add(0, project.getBuild().getOutputDirectory()); - project.getDependencyArtifacts().forEach(a -> { - if (a.isResolved() && a.getFile() != null) { - cp.add(a.getFile().getPath()); - } - }); - projectClassLoader = DynamicClassLoader.createDynamicClassLoader(cp); + List<URL> urls = new ArrayList<>(); + // need to include project compile dependencies (code similar to camel-maven-plugin) + addRelevantProjectDependenciesToClasspath(urls); + projectClassLoader = DynamicClassLoader.createDynamicClassLoaderFromUrls(urls); Set<String> set = new LinkedHashSet<>(); @@ -165,8 +189,109 @@ public class GenerateConfigurerMojo extends AbstractGeneratorMojo { } } + /** + * Add any relevant project dependencies to the classpath. Takes + * includeProjectDependencies into consideration. + * + * @param path classpath of {@link java.net.URL} objects + * @throws MojoExecutionException + */ + private void addRelevantProjectDependenciesToClasspath(List<URL> path) throws MojoExecutionException { + try { + getLog().debug("Project Dependencies will be included."); + + URL mainClasses = new File(project.getBuild().getOutputDirectory()).toURI().toURL(); + getLog().debug("Adding to classpath : " + mainClasses); + path.add(mainClasses); + + Set<Artifact> dependencies = project.getArtifacts(); + + // system scope dependencies are not returned by maven 2.0. See + // MEXEC-17 + dependencies.addAll(getAllNonTestScopedDependencies()); + + Iterator<Artifact> iter = dependencies.iterator(); + while (iter.hasNext()) { + Artifact classPathElement = iter.next(); + getLog().debug("Adding project dependency artifact: " + classPathElement.getArtifactId() + + " to classpath"); + File file = classPathElement.getFile(); + if (file != null) { + path.add(file.toURI().toURL()); + } + } + + } catch (MalformedURLException e) { + throw new MojoExecutionException("Error during setting up classpath", e); + } + } + + 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)) { + 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; + } + private List<Option> processClass(String fqn) throws ClassNotFoundException { List<Option> answer = new ArrayList<>(); + Set<String> names = new HashSet<>(); Class clazz = projectClassLoader.loadClass(fqn); // find all public setters @@ -187,7 +312,10 @@ public class GenerateConfigurerMojo extends AbstractGeneratorMojo { } } String t = Character.toUpperCase(m.getName().charAt(3)) + m.getName().substring(3 + 1); - answer.add(new Option(t, type, getter)); + if (names.add(t)) { + // filter out duplicates by using a names set that has already added + answer.add(new Option(t, type, getter)); + } } });