Skip to content

Commit

Permalink
CAMEL-20333 camel-kotlin-api: fixed dataformat dsl generation
Browse files Browse the repository at this point in the history
  • Loading branch information
iMashtak committed Jan 22, 2024
1 parent c32dd0c commit f0006d4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ public class Aws2S3UriDsl(
it.property("secretKey", secretKey)
}

public fun sessionToken(sessionToken: String) {
it.property("sessionToken", sessionToken)
}

public fun trustAllCertificates(trustAllCertificates: String) {
it.property("trustAllCertificates", trustAllCertificates)
}
Expand All @@ -492,4 +496,12 @@ public class Aws2S3UriDsl(
public fun useProfileCredentialsProvider(useProfileCredentialsProvider: Boolean) {
it.property("useProfileCredentialsProvider", useProfileCredentialsProvider.toString())
}

public fun useSessionCredentials(useSessionCredentials: String) {
it.property("useSessionCredentials", useSessionCredentials)
}

public fun useSessionCredentials(useSessionCredentials: Boolean) {
it.property("useSessionCredentials", useSessionCredentials.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public class Aws2SesUriDsl(
it.property("secretKey", secretKey)
}

public fun sessionToken(sessionToken: String) {
it.property("sessionToken", sessionToken)
}

public fun trustAllCertificates(trustAllCertificates: String) {
it.property("trustAllCertificates", trustAllCertificates)
}
Expand All @@ -152,4 +156,12 @@ public class Aws2SesUriDsl(
public fun useProfileCredentialsProvider(useProfileCredentialsProvider: Boolean) {
it.property("useProfileCredentialsProvider", useProfileCredentialsProvider.toString())
}

public fun useSessionCredentials(useSessionCredentials: String) {
it.property("useSessionCredentials", useSessionCredentials)
}

public fun useSessionCredentials(useSessionCredentials: Boolean) {
it.property("useSessionCredentials", useSessionCredentials.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public class Aws2SnsUriDsl(
it.property("secretKey", secretKey)
}

public fun sessionToken(sessionToken: String) {
it.property("sessionToken", sessionToken)
}

public fun trustAllCertificates(trustAllCertificates: String) {
it.property("trustAllCertificates", trustAllCertificates)
}
Expand All @@ -180,4 +184,12 @@ public class Aws2SnsUriDsl(
public fun useProfileCredentialsProvider(useProfileCredentialsProvider: Boolean) {
it.property("useProfileCredentialsProvider", useProfileCredentialsProvider.toString())
}

public fun useSessionCredentials(useSessionCredentials: String) {
it.property("useSessionCredentials", useSessionCredentials)
}

public fun useSessionCredentials(useSessionCredentials: Boolean) {
it.property("useSessionCredentials", useSessionCredentials.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ public class Aws2SqsUriDsl(
it.property("secretKey", secretKey)
}

public fun sessionToken(sessionToken: String) {
it.property("sessionToken", sessionToken)
}

public fun trustAllCertificates(trustAllCertificates: String) {
it.property("trustAllCertificates", trustAllCertificates)
}
Expand All @@ -432,4 +436,12 @@ public class Aws2SqsUriDsl(
public fun useProfileCredentialsProvider(useProfileCredentialsProvider: Boolean) {
it.property("useProfileCredentialsProvider", useProfileCredentialsProvider.toString())
}

public fun useSessionCredentials(useSessionCredentials: String) {
it.property("useSessionCredentials", useSessionCredentials)
}

public fun useSessionCredentials(useSessionCredentials: Boolean) {
it.property("useSessionCredentials", useSessionCredentials.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ public class KafkaUriDsl(
it.property("autoOffsetReset", autoOffsetReset)
}

public fun batching(batching: String) {
it.property("batching", batching)
}

public fun batching(batching: Boolean) {
it.property("batching", batching.toString())
}

public fun breakOnFirstError(breakOnFirstError: String) {
it.property("breakOnFirstError", breakOnFirstError)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -159,7 +162,9 @@ private void createDataFormatDsl(DataFormatModel model) throws MojoFailureExcept
String dslClassName = pascalCaseName + "DataFormatDsl";
Class<?> clazz;
try {
clazz = Class.forName(model.getModelJavaType());
ClassLoader classLoader = constructClassLoaderForCamelProjects(
"core/camel-core-model", "core/camel-api");
clazz = classLoader.loadClass(model.getModelJavaType());
} catch (ClassNotFoundException e) {
throw new MojoFailureException("Error while discovering class", e);
}
Expand Down Expand Up @@ -456,4 +461,18 @@ private TypeName parseJavaType(String javaType) throws MojoFailureException {
throw ex;
}
}

private ClassLoader constructClassLoaderForCamelProjects(String... projectPaths) throws MojoFailureException {
URL[] urls = new URL[projectPaths.length];
for (int i = 0; i < urls.length; ++i) {
String projectPath = projectPaths[i];
File buildDirectory = Path.of(baseDir.toPath().toString(), "../../", projectPath, "target/classes").toFile();
try {
urls[i] = buildDirectory.toURI().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException("Error while resolving build directory of project " + projectPath, e);
}
}
return new URLClassLoader(urls);
}
}

0 comments on commit f0006d4

Please sign in to comment.