@Override public JavaClassSource decorateSource(UIExecutionContext context, Project project, JavaClassSource source) throws Exception { final JavaClassSource result = wrapped.decorateSource(context, project, source); result.addAnnotation("org.springframework.stereotype.Component"); return result; }
private void addArquillianRunner(JavaClassSource test) { test.addImport("org.junit.runner.RunWith"); test.addImport("org.jboss.arquillian.junit.Arquillian"); test.addAnnotation("RunWith").setLiteralValue("Arquillian.class"); }
protected void addResourceTypeAnnotation(JavaClassSource type, ClassPlan plan) { type.addImport(ResourceType.class); AnnotationSource<JavaClassSource> typeAnno = type.addAnnotation(); typeAnno.setName("ResourceType"); typeAnno.setStringValue(plan.getResourceType()); if (plan.isSingleton()) { type.addImport(Implicit.class); AnnotationSource<JavaClassSource> implicitMeta = type.addAnnotation(); implicitMeta.setName(Implicit.class.getSimpleName()); } }
protected void addResourceTypeAnnotation(JavaClassSource type, ClassPlan plan) { type.addImport(ResourceType.class); AnnotationSource<JavaClassSource> typeAnno = type.addAnnotation(); typeAnno.setName("ResourceType"); typeAnno.setStringValue(plan.getResourceType()); if (plan.isSingleton()) { type.addImport(Implicit.class); AnnotationSource<JavaClassSource> implicitMeta = type.addAnnotation(); implicitMeta.setName(Implicit.class.getSimpleName()); } }
public static JavaClassSource createGreetingPropertiesClass(JavaClassSource current) { JavaClassSource source = Roaster.create(JavaClassSource.class).setName("GreetingProperties").setPackage(current.getPackage()); source.addAnnotation(Component.class); source.addAnnotation(ConfigurationProperties.class).setStringValue("greeting"); source.addProperty(String.class, "message").getField().setStringInitializer("Hello, %s!"); return source; }
protected void addAddressAnnotations(JavaClassSource type, ClassPlan plan) { AddressTemplate address = plan.getAddr(); // resource references if (1 == plan.getAddresses().size()) { type.addImport(Address.class); AnnotationSource<JavaClassSource> addressMeta = type.addAnnotation(Address.class); addressMeta.setStringValue(plan.getAddresses().get(0).toString()); } else { type.addImport(Addresses.class); String[] addresses = new String[plan.getAddresses().size()]; int i = 0; for (AddressTemplate addressTemplate : plan.getAddresses()) { addresses[i] = addressTemplate.toString(); i++; } AnnotationSource<JavaClassSource> addressesMeta = type.addAnnotation(Addresses.class); addressesMeta.setStringArrayValue(addresses); } }
protected void addAddressAnnotations(JavaClassSource type, ClassPlan plan) { AddressTemplate address = plan.getAddr(); // resource references if (1 == plan.getAddresses().size()) { type.addImport(Address.class); AnnotationSource<JavaClassSource> addressMeta = type.addAnnotation(Address.class); addressMeta.setStringValue(plan.getAddresses().get(0).toString()); } else { type.addImport(Addresses.class); String[] addresses = new String[plan.getAddresses().size()]; int i = 0; for (AddressTemplate addressTemplate : plan.getAddresses()) { addresses[i] = addressTemplate.toString(); i++; } AnnotationSource<JavaClassSource> addressesMeta = type.addAnnotation(Addresses.class); addressesMeta.setStringArrayValue(addresses); } }
private void createRepositoryConfiguration(JavaClassSource entitySource, Project project) { final String entitySourcePackage = entitySource.getPackage(); // only create repository configuration if we haven't done so already JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); final DirectoryResource entityPackage = facet.getPackage(entitySourcePackage); final Resource<?> configuration = entityPackage.getChild(REPOSITORY_CONFIGURATION + ".java"); if (configuration == null || !configuration.exists()) { final JavaClassSource source = Roaster.create(JavaClassSource.class) .setName(REPOSITORY_CONFIGURATION) .setPackage(entitySourcePackage); source.addImport("org.springframework.context.annotation.Configuration"); source.addImport("org.springframework.boot.autoconfigure.EnableAutoConfiguration"); source.addImport("org.springframework.transaction.annotation.EnableTransactionManagement"); source.addImport("org.springframework.boot.autoconfigure.domain.EntityScan"); source.addImport("org.springframework.data.jpa.repository.config.EnableJpaRepositories"); source.addAnnotation("Configuration"); source.addAnnotation("EnableAutoConfiguration"); source.addAnnotation("EnableTransactionManagement"); source.addAnnotation("EntityScan") .setStringArrayValue("basePackages", new String[]{entitySourcePackage}); source.addAnnotation("EnableJpaRepositories") .setStringArrayValue("basePackages", new String[]{entitySourcePackage}); facet.saveJavaSource(source); } } }
if (!entity.hasAnnotation(XmlRootElement.class)) entity.addAnnotation(XmlRootElement.class); project.getFacet(JavaSourceFacet.class).saveJavaSource(entity);
private void addDefaultDeploymentAnnotation(JavaClassSource test, Project project) throws ClassNotFoundException, IOException { test.addImport("org.wildfly.swarm.arquillian.DefaultDeployment"); final AnnotationSource<JavaClassSource> defaultDeploymentAnnotation = test.addAnnotation("DefaultDeployment"); if (asClient.hasValue()) { defaultDeploymentAnnotation.setLiteralValue("testable", "false"); } if (mainClass.hasValue()) { defaultDeploymentAnnotation.setLiteralValue("main", mainClass.getValue() + ".class"); } if (archiveType.hasValue()) { defaultDeploymentAnnotation.setLiteralValue("type", String.format("DefaultDeployment.Type.%s", archiveType.getValue())); } }
@Override public void install(Project project) { JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); applicationClass.setSuperType(Application.class); if (applicationClass.hasAnnotation(ApplicationPath.class)) { applicationClass.getAnnotation(ApplicationPath.class).setStringValue(path); } else { applicationClass.addAnnotation(ApplicationPath.class).setStringValue(path); } facet.saveJavaSource(applicationClass); }
javaClass.setPackage(packageName); javaClass.setName(className); javaClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", propertiesPrefix);
if (hasCDI(installedFractions)) restEndpoint.addAnnotation(ApplicationScoped.class); restEndpoint.addAnnotation(Path.class).setStringValue("/hello"); MethodSource<JavaClassSource> method = restEndpoint.addMethod().setPublic().setReturnType(Response.class) .setName("doGet")
javaClass.addAnnotation("RunWith").setLiteralValue("Arquillian.class");
commonClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); configClass.setName(configName); configClass.extendSuperType(commonClass); configClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); configClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", propertiesPrefix); configClass.addImport(Map.class); configClass.addImport(HashMap.class);
javaClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", prefix);
javaClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", prefix);
javaClass.setName(name); javaClass.getJavaDoc().setFullText("Generated by camel-package-maven-plugin - do not edit this file!"); javaClass.addAnnotation(Generated.class).setStringValue("value", SpringBootAutoConfigurationMojo.class.getName()); javaClass.addAnnotation(Configuration.class); javaClass.addAnnotation(Conditional.class).setLiteralValue( "{ ConditionalOnCamelContextAndAutoConfigurationBeans.class, " + name + ".GroupConditions.class }"); javaClass.addAnnotation(AutoConfigureAfter.class).setLiteralValue("CamelAutoConfiguration.class"); javaClass.addAnnotation(EnableConfigurationProperties.class).setLiteralValue( "{ ComponentConfigurationProperties.class, " + configurationName + ".class }" );
source.addAnnotation(RestController.class); source.addField().setPrivate().setFinal(false).setType("GreetingProperties").setName("properties").addAnnotation(Autowired.class); source.addField().setPrivate().setFinal(true).setType("AtomicLong").setName("counter").setLiteralInitializer("new AtomicLong()");
.addAnnotation() .setName("RunWith") .setLiteralValue("VertxUnitRunner.class");