@Override public JavaClassSource decorateSource(UIExecutionContext context, Project project, JavaClassSource source) throws Exception { source.addImport("org.wildfly.swarm.Swarm"); MethodSource<JavaClassSource> method = source.addMethod() .setPublic() .setStatic(true) .setReturnTypeVoid() .setName("main") .addThrows(Exception.class); method.addParameter("String[]", "args"); StringBuilder body = new StringBuilder(); body.append("Swarm swarm = new Swarm();").append(System.lineSeparator()); body.append("swarm.start();").append(System.lineSeparator()); body.append("swarm.deploy();"); method.setBody(body.toString()); WildFlySwarmFacet facet = project.getFacet(WildFlySwarmFacet.class); WildFlySwarmConfigurationBuilder newConfig = WildFlySwarmConfigurationBuilder.create(facet.getConfiguration()); newConfig.mainClass(source.getQualifiedName()); facet.setConfiguration(newConfig); return source; }
private void addInitializeUIMethod(JavaClassSource command) { command.addMethod() .setPublic() .setName("initializeUI") .setReturnTypeVoid() .setBody("// not implemented") .setParameters("UIBuilder builder") .addThrows(Exception.class) .addAnnotation(Override.class); }
private void addNextMethod(JavaClassSource command) { MethodSource<JavaClassSource> method = command.addMethod().setPublic() .setName("next") .setReturnType(NavigationResult.class) .setParameters("UINavigationContext context"); method.addThrows(Exception.class).addAnnotation(Override.class); try { final String bodyTemplate = loadTextResource( Boolean.TRUE.equals(requireProject.getValue()) ? "nextMethodBodyP.txt" : "nextMethodBody.txt"); method.setBody(String.format(bodyTemplate, command.getName(), script.getValue().getName())); } catch (IOException e) { method.setBody("// ERROR READING BODY TEMPLATE"); } }
private void addExecuteMethod(JavaClassSource command) { command.addMethod() .setPublic() .setName("execute") .setReturnType(Result.class) .setParameters("UIExecutionContext context") .setBody( "return Results.success(\"Command '" + commandName.getValue() + "' successfully executed!\");") .addThrows(Exception.class) .addAnnotation(Override.class); }
for (String o : (List<String>) method.getThrownExceptions()) decoratorMethod.addThrows(o);
for (String o : (List<String>) method.getThrownExceptions()) decoratorMethod.addThrows(o);
.setBody("// not implemented") .setParameters("UIBuilder builder") .addThrows(Exception.class) .addAnnotation(Override.class); .setParameters("UIExecutionContext context") .setBody("return Results.success(\"Command '" + commandName.getValue() + "' successfully executed!\");") .addThrows(Exception.class) .addAnnotation(Override.class);
method.setName("configure" + model.getShortJavaType()); method.setPublic(); method.addThrows(Exception.class); method.setReturnType("org.apache.camel.spi.RestConfiguration"); method.addAnnotation(Lazy.class);
.setBody(body) .setReturnType("org.apache.camel.spi.DataFormatFactory") .addThrows(Exception.class);
.setBody(body) .setReturnType(model.getShortJavaType()) .addThrows(Exception.class);
.setBody(body) .setReturnType(model.getShortJavaType()) .addThrows(Exception.class);
setName("testRunningPodStaysUp"). setBody(testBody). addThrows("Exception"). addAnnotation("Test");
setName("testKubernetesProvisionsAtLeastOnePod"). setBody(testBody). addThrows("Exception"). addAnnotation("Test");