Package org.springframework.roo.classpath.details.annotations

Examples of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder


                annotationExpr);
    }

    @Override
    public AnnotationMetadata build() {
        final AnnotationMetadataBuilder annotationMetadataBuilder = new AnnotationMetadataBuilder(
                annotationType, attributeValues);

        final AnnotationMetadata md = annotationMetadataBuilder.build();
        md.setCommentStructure(commentStructure);

        return md;
    }
View Full Code Here


     */
    protected AnnotationMetadata getTypeAnnotation(final JavaType annotationType) {
        if (governorTypeDetails.getAnnotation(annotationType) != null) {
            return null;
        }
        return new AnnotationMetadataBuilder(annotationType).build();
    }
View Full Code Here

        final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
                getId(), Modifier.PUBLIC, methodName, JavaType.VOID_PRIMITIVE,
                new ArrayList<AnnotatedJavaType>(),
                new ArrayList<JavaSymbolName>(), bodyBuilder);
        methodBuilder.addAnnotation(new AnnotationMetadataBuilder(
                POST_CONSTRUCT));
        return methodBuilder;
    }
View Full Code Here

    private AnnotationMetadata getScopeAnnotation() {
        if (hasScopeAnnotation()) {
            return null;
        }
        return new AnnotationMetadataBuilder(REQUEST_SCOPED).build();
    }
View Full Code Here

                    destination.getFullyQualifiedTypeName());
        }
        else {
            // Add the method via the ITD
            final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
            annotations.add(new AnnotationMetadataBuilder(BEFORE_CLASS));

            final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
            bodyBuilder.appendFormalLine("helper.setUp();");

            final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
                    getId(), Modifier.PUBLIC | Modifier.STATIC,
                    setUpMethodName, JavaType.VOID_PRIMITIVE,
                    AnnotatedJavaType.convertFromJavaTypes(SETUP_PARAMETERS),
                    new ArrayList<JavaSymbolName>(), bodyBuilder);
            methodBuilder.setAnnotations(annotations);
            builder.addMethod(methodBuilder);
        }

        // Prepare tearDown method signature
        final JavaSymbolName tearDownMethodName = new JavaSymbolName("tearDown");
        final MethodMetadata tearDownMethod = getGovernorMethod(
                tearDownMethodName, TEARDOWN_PARAMETERS);
        if (tearDownMethod != null) {
            Validate.notNull(
                    MemberFindingUtils.getAnnotationOfType(
                            tearDownMethod.getAnnotations(), AFTER_CLASS),
                    "Method 'tearDown' on '%s' must be annotated with @AfterClass",
                    destination.getFullyQualifiedTypeName());
        }
        else {
            // Add the method via the ITD
            final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
            annotations.add(new AnnotationMetadataBuilder(AFTER_CLASS));

            final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
            bodyBuilder.appendFormalLine("helper.tearDown();");

            final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
View Full Code Here

            final JavaType dodGovernor) {
        // Add an @RunWith(SpringJunit4ClassRunner) annotation to the type, if
        // the user did not define it on the governor directly
        if (MemberFindingUtils.getAnnotationOfType(
                governorTypeDetails.getAnnotations(), RUN_WITH) == null) {
            final AnnotationMetadataBuilder runWithBuilder = new AnnotationMetadataBuilder(
                    RUN_WITH);
            runWithBuilder
                    .addClassAttribute("value",
                            "org.springframework.test.context.junit4.SpringJUnit4ClassRunner");
            builder.addAnnotation(runWithBuilder);
        }

        // Add an @ContextConfiguration("classpath:/applicationContext.xml")
        // annotation to the type, if the user did not define it on the governor
        // directly
        if (MemberFindingUtils.getAnnotationOfType(
                governorTypeDetails.getAnnotations(), CONTEXT_CONFIGURATION) == null) {
            final AnnotationMetadataBuilder contextConfigurationBuilder = new AnnotationMetadataBuilder(
                    CONTEXT_CONFIGURATION);
            contextConfigurationBuilder.addStringAttribute("locations",
                    "classpath*:/META-INF/spring/applicationContext*.xml");
            builder.addAnnotation(contextConfigurationBuilder);
        }

        // Add an @Transactional, if the user did not define it on the governor
        // directly
        if (annotationValues.isTransactional()
                && MemberFindingUtils.getAnnotationOfType(
                        governorTypeDetails.getAnnotations(), TRANSACTIONAL) == null) {
            final AnnotationMetadataBuilder transactionalBuilder = new AnnotationMetadataBuilder(
                    TRANSACTIONAL);
            if (StringUtils.isNotBlank(transactionManager)
                    && !"transactionManager".equals(transactionManager)) {
                transactionalBuilder.addStringAttribute("value",
                        transactionManager);
            }
            builder.addAnnotation(transactionalBuilder);
        }

        // Add the data on demand field if the user did not define it on the
        // governor directly
        final FieldMetadata field = governorTypeDetails
                .getField(new JavaSymbolName("dod"));
        if (field != null) {
            Validate.isTrue(field.getFieldType().equals(dodGovernor),
                    "Field 'dod' on '%s' must be of type '%s'",
                    destination.getFullyQualifiedTypeName(),
                    dodGovernor.getFullyQualifiedTypeName());
            Validate.notNull(
                    MemberFindingUtils.getAnnotationOfType(
                            field.getAnnotations(), AUTOWIRED),
                    "Field 'dod' on '%s' must be annotated with @Autowired",
                    destination.getFullyQualifiedTypeName());
        }
        else {
            // Add the field via the ITD
            final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
            annotations.add(new AnnotationMetadataBuilder(AUTOWIRED));
            final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
                    getId(), 0, annotations, new JavaSymbolName("dod"),
                    dodGovernor);
            builder.addField(fieldBuilder);
        }
View Full Code Here

        if (governorHasMethod(methodName)) {
            return null;
        }

        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        annotations.add(new AnnotationMetadataBuilder(TEST));

        final String entityName = annotationValues.getEntity()
                .getSimpleTypeName();

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
View Full Code Here

        }

        builder.getImportRegistrationResolver().addImport(LIST);

        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        annotations.add(new AnnotationMetadataBuilder(TEST));

        final String entityName = annotationValues.getEntity()
                .getSimpleTypeName();

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
View Full Code Here

        }

        builder.getImportRegistrationResolver().addImport(LIST);

        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        annotations.add(new AnnotationMetadataBuilder(TEST));

        final String entityName = annotationValues.getEntity()
                .getSimpleTypeName();

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
View Full Code Here

        builder.getImportRegistrationResolver().addImport(
                identifierAccessorMethod.getReturnType());

        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        annotations.add(new AnnotationMetadataBuilder(TEST));

        final String entityName = annotationValues.getEntity()
                .getSimpleTypeName();

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.