當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassOrInterfaceTypeDetailsBuilder.addMethod方法代碼示例

本文整理匯總了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder.addMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceTypeDetailsBuilder.addMethod方法的具體用法?Java ClassOrInterfaceTypeDetailsBuilder.addMethod怎麽用?Java ClassOrInterfaceTypeDetailsBuilder.addMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder的用法示例。


在下文中一共展示了ClassOrInterfaceTypeDetailsBuilder.addMethod方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRevisionListener

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
private ClassOrInterfaceTypeDetails getRevisionListener() {

        // Check class exists
        ClassOrInterfaceTypeDetails innerClass = governorTypeDetails
                .getDeclaredInnerType(revisionListenerType);

        if (innerClass != null) {
            // If class exists (already push-in) we can do nothing
            return innerClass;
        }

        // Create inner class

        ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                context.getMetadataId(), Modifier.PUBLIC + Modifier.STATIC,
                revisionListenerType, PhysicalTypeCategory.CLASS);
        classBuilder.addImplementsType(REVISION_LISTENER);

        classBuilder.addMethod(getNewRevisionMethod());

        return classBuilder.build();
    }
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:23,代碼來源:EnversRevisionLogEntityMetadataBuilder.java

示例2: getListInnerClass

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * Gets Inner class to manage elements list for batch operations
 * 
 * @return
 */
public ClassOrInterfaceTypeDetails getListInnerClass() {
    // Generate inner class name
    JavaType listInnerClassJavaType = new JavaType(destination
            .getSimpleTypeName().concat("List"), 0, DataType.TYPE, null,
            null);

    // Create class builder
    ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            getId(), Modifier.STATIC | Modifier.PUBLIC,
            listInnerClassJavaType, PhysicalTypeCategory.CLASS);

    // Add fields
    FieldMetadata listField = getListInner_field("list", destination)
            .build();
    FieldMetadata selectedField = getListInner_field("selected",
            new JavaType("Integer")).build();
    classBuilder.addField(listField);
    classBuilder.addField(selectedField);

    // Adds getter/setter for list field
    classBuilder.addMethod(getListInner_getter(listField));
    classBuilder.addMethod(getListInner_setter(listField));

    // Adds getter/setter for selected field
    classBuilder.addMethod(getListInner_getter(selectedField));
    classBuilder.addMethod(getListInner_setter(selectedField));

    // Return generated class
    return classBuilder.build();
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:36,代碼來源:EntityBatchMetadata.java

示例3: injectJmsTemplate

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void injectJmsTemplate(final JavaType targetType,
        final JavaSymbolName fieldName, final boolean asynchronous) {
    Validate.notNull(targetType, "Java type required");
    Validate.notNull(fieldName, "Field name required");

    final ClassOrInterfaceTypeDetails targetTypeDetails = typeLocationService
            .getTypeDetails(targetType);
    Validate.isTrue(targetTypeDetails != null,
            "Cannot locate source for '%s'",
            targetType.getFullyQualifiedTypeName());

    final String declaredByMetadataId = targetTypeDetails
            .getDeclaredByMetadataId();
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            targetTypeDetails);

    // Create the field
    cidBuilder.addField(new FieldMetadataBuilder(declaredByMetadataId,
            PRIVATE | TRANSIENT, Arrays
                    .asList(new AnnotationMetadataBuilder(AUTOWIRED)),
            fieldName, JMS_OPERATIONS));

    // Create the method
    cidBuilder.addMethod(createSendMessageMethod(fieldName,
            declaredByMetadataId, asynchronous));

    if (asynchronous) {
        ensureSpringAsynchronousSupportEnabled();
    }

    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:33,代碼來源:JmsOperationsImpl.java

示例4: injectEmailTemplate

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void injectEmailTemplate(final JavaType targetType,
        final JavaSymbolName fieldName, final boolean async) {
    Validate.notNull(targetType, "Java type required");
    Validate.notNull(fieldName, "Field name required");

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

    // Obtain the physical type and its mutable class details
    final String declaredByMetadataId = typeLocationService
            .getPhysicalTypeIdentifier(targetType);
    final ClassOrInterfaceTypeDetails existing = typeLocationService
            .getTypeDetails(targetType);
    if (existing == null) {
        LOGGER.warning("Aborting: Unable to find metadata for target type '"
                + targetType.getFullyQualifiedTypeName() + "'");
        return;
    }
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            existing);

    // Add the MailSender field
    final FieldMetadataBuilder mailSenderFieldBuilder = new FieldMetadataBuilder(
            declaredByMetadataId, PRIVATE_TRANSIENT, annotations,
            fieldName, MAIL_SENDER);
    cidBuilder.addField(mailSenderFieldBuilder);

    // Add the "sendMessage" method
    cidBuilder.addMethod(getSendMethod(fieldName, async,
            declaredByMetadataId, cidBuilder));
    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:33,代碼來源:MailOperationsImpl.java

示例5: setupRepository

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void setupRepository(final JavaType interfaceType,
        final JavaType domainType) {
    Validate.notNull(interfaceType, "Interface type required");
    Validate.notNull(domainType, "Domain type required");

    final String interfaceIdentifier = getPathResolver()
            .getFocusedCanonicalPath(Path.SRC_MAIN_JAVA, interfaceType);

    if (getFileManager().exists(interfaceIdentifier)) {
        return; // Type exists already - nothing to do
    }

    // Build interface type
    final AnnotationMetadataBuilder interfaceAnnotationMetadata = new AnnotationMetadataBuilder(
            ROO_REPOSITORY_MONGO);
    interfaceAnnotationMetadata.addAttribute(new ClassAttributeValue(
            new JavaSymbolName("domainType"), domainType));
    final String interfaceMdId = PhysicalTypeIdentifier.createIdentifier(
            interfaceType, getPathResolver().getPath(interfaceIdentifier));
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            interfaceMdId, Modifier.PUBLIC, interfaceType,
            PhysicalTypeCategory.INTERFACE);
    cidBuilder.addAnnotation(interfaceAnnotationMetadata.build());
    final JavaType listType = new JavaType(List.class.getName(), 0,
            DataType.TYPE, null, Arrays.asList(domainType));
    cidBuilder.addMethod(new MethodMetadataBuilder(interfaceMdId, 0,
            new JavaSymbolName("findAll"), listType,
            new InvocableMemberBodyBuilder()));
    getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:31,代碼來源:MongoOperationsImpl.java

示例6: addCustomArtifactToRevisionItem

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void addCustomArtifactToRevisionItem(
        ClassOrInterfaceTypeDetailsBuilder classBuilder) {

    classBuilder.addField(createRevisionItemField());
    classBuilder.addField(createRevisionEntityRevisionField());
    classBuilder.addField(createRevisionTypeField());
    classBuilder.addConstructor(createRevisionItemConstructor());
    classBuilder.addMethod(createRevisionItemCreateList());
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:14,代碼來源:EnversRevisionLogMetadataBuilder.java

示例7: getRevisionClass

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * @return revision item class definition
 */
private ClassOrInterfaceTypeDetails getRevisionClass() {

    // Check class exists
    ClassOrInterfaceTypeDetails innerClass = governorTypeDetails
            .getDeclaredInnerType(revisonItemType);

    if (innerClass != null) {
        // If class exists (already pushed-in) we can do nothing
        return innerClass;
    }

    // Create class builder for inner class
    ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            getId(), Modifier.PUBLIC + Modifier.STATIC, revisonItemType,
            PhysicalTypeCategory.CLASS);

    // Add revisionLog-provider required artifacts
    revisionLogBuilder.addCustomArtifactToRevisionItem(classBuilder);

    // Add Revision item common methods
    classBuilder.addMethod(createRevisionItemGetItemMethod());
    classBuilder.addMethod(createRevisionItemGetRevisionNumberMethod());
    classBuilder.addMethod(createRevisionItemGetRevisionUserMethod());
    classBuilder.addMethod(createRevisionItemGetRevisionDateMethod());
    classBuilder.addMethod(createRevisionItemIsCreateMethod());
    classBuilder.addMethod(createRevisionItemIsUpdateMethod());
    classBuilder.addMethod(createRevisionItemIsDeleteMethod());
    classBuilder.addMethod(createRevisionItemGetTypeMethod());

    // Build class definition from builder
    return classBuilder.build();
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:36,代碼來源:JpaAuditMetadata.java

示例8: createRepository

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/** {@inheritDoc} */
public void createRepository(JavaType interfaceType, JavaType domainType){
    // Use Roo's Assert type for null checks
    Validate.notNull(interfaceType, "Interface type required");
    Validate.notNull(domainType, "Domain type required");
    
    final String interfaceIdentifier = pathResolver.getFocusedCanonicalPath(Path.SRC_MAIN_JAVA, interfaceType);
    if (fileManager.exists(interfaceIdentifier)) {
       return; // Type exists already - nothing to do
    }
    
    // Build interface type.
    final AnnotationMetadataBuilder interfaceAnnotationMetadata = new AnnotationMetadataBuilder(
          ElasticsearchJavaType.ROO_REPOSITORY_ELASTICSEARCH);
    interfaceAnnotationMetadata.addAttribute(new ClassAttributeValue(
          new JavaSymbolName("domainType"), domainType));
    final String interfaceMdId = PhysicalTypeIdentifier.createIdentifier(
          interfaceType, pathResolver.getPath(interfaceIdentifier));
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
          interfaceMdId, Modifier.PUBLIC, interfaceType,
          PhysicalTypeCategory.INTERFACE);
    cidBuilder.addAnnotation(interfaceAnnotationMetadata.build());
    
    final JavaType listType = new JavaType(Iterable.class.getName(), 0,
          DataType.TYPE, null, Arrays.asList(domainType));
    cidBuilder.addMethod(new MethodMetadataBuilder(interfaceMdId, 0,
          new JavaSymbolName("findAll"), listType,
          new InvocableMemberBodyBuilder()));
    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
 
開發者ID:lbroudoux,項目名稱:spring-roo-addon-layers-repository-elasticsearch,代碼行數:31,代碼來源:ElasticsearchOperationsImpl.java

示例9: getMethodAdditions

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * Returns the additions the caller should make in order to invoke the given
 * method for the given domain entity.
 * 
 * @param callerMID the caller's metadata ID (required)
 * @param methodName the name of the method being invoked (required)
 * @param serviceInterface the domain service type (required)
 * @param parameterNames the names of the parameters being passed by the
 *            caller to the method
 * @return a non-<code>null</code> set of additions
 */
private MemberTypeAdditions getMethodAdditions(final String callerMID,
        final String methodName, final JavaType serviceInterface,
        final List<MethodParameter> parameters, boolean autowire) {
    // The method is supported by this service interface; make a builder
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            callerMID);

    final String fieldName = StringUtils.uncapitalize(serviceInterface
            .getSimpleTypeName());

    if (autowire) {
        // Add an autowired field of the type of this service
        cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
                .asList(new AnnotationMetadataBuilder(AUTOWIRED)),
                new JavaSymbolName(fieldName), serviceInterface));
    }
    else {
        // Add a set method of the type of this service
        cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0,
                new JavaSymbolName(fieldName), serviceInterface, null));
        JavaSymbolName setMethodName = new JavaSymbolName("set"
                + serviceInterface.getSimpleTypeName());
        List<JavaType> parameterTypes = new ArrayList<JavaType>();
        parameterTypes.add(serviceInterface);
        List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
        parameterNames.add(new JavaSymbolName(fieldName));
        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
        bodyBuilder.append("\n\tthis." + fieldName + " = " + fieldName
                + ";\n");

        MethodMetadataBuilder setSeviceMethod = new MethodMetadataBuilder(
                callerMID, PUBLIC, setMethodName, JavaType.VOID_PRIMITIVE,
                AnnotatedJavaType.convertFromJavaTypes(parameterTypes),
                parameterNames, bodyBuilder);

        cidBuilder.addMethod(setSeviceMethod);
    }

    // Generate an additions object that includes a call to the method
    return MemberTypeAdditions.getInstance(cidBuilder, fieldName,
            methodName, false, parameters);
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:54,代碼來源:ServiceLayerProvider.java

示例10: addChecksumFieldToEntity

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * Add checksum field (plus getter/setter) to builder
 * 
 * @param field
 * @param getter
 * @param setter
 * @param typeManagementService
 */
private void addChecksumFieldToEntity(FieldMetadata field,
        MethodMetadata getter, MethodMetadata setter,
        TypeManagementService typeManagementService) {

    PhysicalTypeDetails ptd = governorPhysicalTypeMetadata
            .getMemberHoldingTypeDetails();

    Validate.isInstanceOf(
            ClassOrInterfaceTypeDetails.class,
            ptd,
            "Java source code is immutable for type "
                    + PhysicalTypeIdentifier
                            .getFriendlyName(governorPhysicalTypeMetadata
                                    .getId()));

    ClassOrInterfaceTypeDetailsBuilder mutableTypeDetails = new ClassOrInterfaceTypeDetailsBuilder(
            (ClassOrInterfaceTypeDetails) ptd);

    // Try to locate an existing field with @javax.persistence.Version

    try {
        if (!fieldExist(mutableTypeDetails, field)) {
            mutableTypeDetails.addField(new FieldMetadataBuilder(
                    governorTypeDetails.getDeclaredByMetadataId(), field));
        }
        if (!methodExists(mutableTypeDetails, getter)) {
            mutableTypeDetails.addMethod(getter);
        }
        if (!methodExists(mutableTypeDetails, setter)) {
            mutableTypeDetails.addMethod(setter);
        }
        typeManagementService.createOrUpdateTypeOnDisk(mutableTypeDetails
                .build());

    }
    catch (IllegalArgumentException e) {
        // TODO In some cases, one element is added more than one time
        LOGGER.finest("Problem adding version field: ".concat(e.toString()));
    }

}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:50,代碼來源:OCCChecksumMetadata.java

示例11: createGvNixWebServiceClass

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 * <p>
 * Only creates the class if not exists in project.
 * </p>
 */
public void createGvNixWebServiceClass(JavaType type,
        List<AnnotationMetadata> annots, GvNIXAnnotationType gvNixAnnot,
        List<FieldMetadata> fields, List<MethodMetadata> methods,
        List<ConstructorMetadata> constrs, List<JavaType> exts,
        PhysicalTypeCategory physicalType, List<JavaSymbolName> enumConsts) {

    // Metadata Id.
    String id = PhysicalTypeIdentifier.createIdentifier(type,
            LogicalPath.getInstance(Path.SRC_MAIN_JAVA, ""));

    // Determine the canonical filename
    String physicalPath = typeLocationService
            .getPhysicalTypeCanonicalPath(id);

    // Check the file doesn't already exist
    if (!fileManager.exists(physicalPath)) {

        if (!physicalType.equals(PhysicalTypeCategory.ENUMERATION)) {
            enumConsts = null;
        }

        // Create class
        ClassOrInterfaceTypeDetailsBuilder typeDetails = new ClassOrInterfaceTypeDetailsBuilder(
                id, Modifier.PUBLIC, type, physicalType);
        for (AnnotationMetadata annotationMetadata : annots) {
            typeDetails.addAnnotation(annotationMetadata);
        }
        for (FieldMetadata field : fields) {
            typeDetails.addField(field);
        }
        for (ConstructorMetadata constr : constrs) {
            typeDetails.addConstructor(constr);
        }
        for (MethodMetadata method : methods) {
            typeDetails.addMethod(method);
        }
        for (JavaType ext : exts) {
            typeDetails.addExtendsTypes(ext);
        }
        if (enumConsts != null) {
            for (JavaSymbolName enumConst : enumConsts) {
                typeDetails.addEnumConstant(enumConst);
            }
        }

        typeManagementService.createOrUpdateTypeOnDisk(typeDetails.build());
    }
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:55,代碼來源:JavaParserServiceImpl.java

示例12: createMethod

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 * <p>
 * Updates the class with the new method created with selected attributes.
 * </p>
 */
public void createMethod(JavaSymbolName methodName, JavaType returnType,
        JavaType targetType, int modifier, List<JavaType> throwsTypes,
        List<AnnotationMetadata> annotationList,
        List<AnnotatedJavaType> paramTypes,
        List<JavaSymbolName> paramNames, String body) {

    Validate.notNull(paramTypes, "Param type mustn't be null");
    Validate.notNull(paramNames, "Param name mustn't be null");

    // MetadataID
    String targetId = PhysicalTypeIdentifier.createIdentifier(targetType,
            LogicalPath.getInstance(Path.SRC_MAIN_JAVA, ""));

    // Obtain the physical type and itd mutable details
    PhysicalTypeMetadata ptm = (PhysicalTypeMetadata) metadataService
            .get(targetId);
    Validate.notNull(ptm, "Java source class doesn't exists.");

    PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails();

    Validate.notNull(ptd, "Java source code details unavailable for type "
            + PhysicalTypeIdentifier.getFriendlyName(targetId));
    Validate.isInstanceOf(ClassOrInterfaceTypeDetails.class, ptd,
            "Java source code is immutable for type "
                    + PhysicalTypeIdentifier.getFriendlyName(targetId));
    ClassOrInterfaceTypeDetails mutableTypeDetails = (ClassOrInterfaceTypeDetails) ptd;

    // create method
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine(body);
    MethodMetadataBuilder operationMetadata = new MethodMetadataBuilder(
            targetId, modifier, methodName,
            (returnType == null ? JavaType.VOID_PRIMITIVE : returnType),
            paramTypes, paramNames, bodyBuilder);
    for (AnnotationMetadata annotationMetadata : annotationList) {
        operationMetadata.addAnnotation(annotationMetadata);
    }
    for (JavaType javaType : throwsTypes) {
        operationMetadata.addThrowsType(javaType);
    }

    ClassOrInterfaceTypeDetailsBuilder mutableTypeDetailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            mutableTypeDetails);
    mutableTypeDetailsBuilder.addMethod(operationMetadata.build());
    typeManagementService
            .createOrUpdateTypeOnDisk(mutableTypeDetailsBuilder.build());
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:54,代碼來源:JavaParserServiceImpl.java


注:本文中的org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder.addMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。