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


Java ClassOrInterfaceTypeDetailsBuilder.setDeclaredMethods方法代碼示例

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


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

示例1: build

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public MemberHoldingTypeDetails build() {
    if (existing instanceof ItdTypeDetails) {
        final ItdTypeDetailsBuilder itdBuilder = new ItdTypeDetailsBuilder(
                (ItdTypeDetails) existing);
        // Push in all members that may have been modified
        itdBuilder.setDeclaredFields(getDeclaredFields());
        itdBuilder.setDeclaredMethods(getDeclaredMethods());
        itdBuilder.setAnnotations(getAnnotations());
        itdBuilder.setCustomData(getCustomData());
        itdBuilder.setDeclaredConstructors(getDeclaredConstructors());
        itdBuilder.setDeclaredInitializers(getDeclaredInitializers());
        itdBuilder.setDeclaredInnerTypes(getDeclaredInnerTypes());
        itdBuilder.setExtendsTypes(getExtendsTypes());
        itdBuilder.setImplementsTypes(getImplementsTypes());
        itdBuilder.setModifier(getModifier());
        return itdBuilder.build();
    }
    else if (existing instanceof ClassOrInterfaceTypeDetails) {
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                (ClassOrInterfaceTypeDetails) existing);
        // Push in all members that may
        cidBuilder.setDeclaredFields(getDeclaredFields());
        cidBuilder.setDeclaredMethods(getDeclaredMethods());
        cidBuilder.setAnnotations(getAnnotations());
        cidBuilder.setCustomData(getCustomData());
        cidBuilder.setDeclaredConstructors(getDeclaredConstructors());
        cidBuilder.setDeclaredInitializers(getDeclaredInitializers());
        cidBuilder.setDeclaredInnerTypes(getDeclaredInnerTypes());
        cidBuilder.setExtendsTypes(getExtendsTypes());
        cidBuilder.setImplementsTypes(getImplementsTypes());
        cidBuilder.setModifier(getModifier());
        return cidBuilder.build();
    }
    else {
        throw new IllegalStateException(
                "Unknown instance of MemberHoldingTypeDetails");
    }
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:39,代碼來源:MemberDetailsBuilder.java

示例2: createManualController

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * Creates a new Spring MVC controller.
 * <p>
 * Request mappings assigned by this method will always commence with "/"
 * and end with "/**". You may present this prefix and/or this suffix if you
 * wish, although it will automatically be added should it not be provided.
 * 
 * @param controller the controller class to create (required)
 * @param preferredMapping the mapping this controller should adopt
 *            (optional; if unspecified it will be based on the controller
 *            name)
 */
public void createManualController(final JavaType controller,
        final String preferredMapping, final LogicalPath webappPath) {
    Validate.notNull(controller, "Controller Java Type required");

    // Create annotation @RequestMapping("/myobject/**")
    final ImmutablePair<String, String> folderAndMapping = getFolderAndMapping(
            preferredMapping, controller);
    final String folderName = folderAndMapping.getKey();

    final String resourceIdentifier = pathResolver.getFocusedCanonicalPath(
            Path.SRC_MAIN_JAVA, controller);
    final String declaredByMetadataId = PhysicalTypeIdentifier
            .createIdentifier(controller, projectOperations
                    .getPathResolver().getPath(resourceIdentifier));
    final List<MethodMetadataBuilder> methods = new ArrayList<MethodMetadataBuilder>();

    // Add HTTP post method
    methods.add(getHttpPostMethod(declaredByMetadataId));

    // Add index method
    methods.add(getIndexMethod(folderName, declaredByMetadataId));

    // Create Type definition
    final List<AnnotationMetadataBuilder> typeAnnotations = new ArrayList<AnnotationMetadataBuilder>();

    final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
    requestMappingAttributes.add(new StringAttributeValue(
            new JavaSymbolName("value"), folderAndMapping.getValue()));
    final AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(
            REQUEST_MAPPING, requestMappingAttributes);
    typeAnnotations.add(requestMapping);

    // Create annotation @Controller
    final List<AnnotationAttributeValue<?>> controllerAttributes = new ArrayList<AnnotationAttributeValue<?>>();
    final AnnotationMetadataBuilder controllerAnnotation = new AnnotationMetadataBuilder(
            CONTROLLER, controllerAttributes);
    typeAnnotations.add(controllerAnnotation);

    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            declaredByMetadataId, Modifier.PUBLIC, controller,
            PhysicalTypeCategory.CLASS);
    cidBuilder.setAnnotations(typeAnnotations);
    cidBuilder.setDeclaredMethods(methods);
    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());

    installView(
            folderName,
            "/index",
            new JavaSymbolName(controller.getSimpleTypeName())
                    .getReadableSymbolName() + " View", "Controller", null,
            false, webappPath);
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:65,代碼來源:JspOperationsImpl.java

示例3: newIntegrationTest

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void newIntegrationTest(final JavaType entity,
        final boolean transactional) {
    Validate.notNull(entity,
            "Entity to produce an integration test for is required");

    // Verify the requested entity actually exists as a class and is not
    // abstract
    final ClassOrInterfaceTypeDetails cid = getEntity(entity);
    Validate.isTrue(!Modifier.isAbstract(cid.getModifier()),
            "Type %s is abstract", entity.getFullyQualifiedTypeName());

    final LogicalPath path = PhysicalTypeIdentifier.getPath(cid
            .getDeclaredByMetadataId());
    dataOnDemandOperations.newDod(entity,
            new JavaType(entity.getFullyQualifiedTypeName()
                    + "DataOnDemand"));

    final JavaType name = new JavaType(entity + "IntegrationTest");
    final String declaredByMetadataId = PhysicalTypeIdentifier
            .createIdentifier(name,
                    Path.SRC_TEST_JAVA.getModulePathId(path.getModule()));

    if (metadataService.get(declaredByMetadataId) != null) {
        // The file already exists
        return;
    }

    final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
    final List<AnnotationAttributeValue<?>> config = new ArrayList<AnnotationAttributeValue<?>>();
    config.add(new ClassAttributeValue(new JavaSymbolName("entity"), entity));
    if (!transactional) {
        config.add(new BooleanAttributeValue(new JavaSymbolName(
                "transactional"), false));
    }
    annotations.add(new AnnotationMetadataBuilder(ROO_INTEGRATION_TEST,
            config));

    final List<MethodMetadataBuilder> methods = new ArrayList<MethodMetadataBuilder>();
    final List<AnnotationMetadataBuilder> methodAnnotations = new ArrayList<AnnotationMetadataBuilder>();
    methodAnnotations.add(new AnnotationMetadataBuilder(TEST));
    final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
            declaredByMetadataId, Modifier.PUBLIC, new JavaSymbolName(
                    "testMarkerMethod"), JavaType.VOID_PRIMITIVE,
            new InvocableMemberBodyBuilder());
    methodBuilder.setAnnotations(methodAnnotations);
    methods.add(methodBuilder);

    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            declaredByMetadataId, Modifier.PUBLIC, name,
            PhysicalTypeCategory.CLASS);
    cidBuilder.setAnnotations(annotations);
    cidBuilder.setDeclaredMethods(methods);

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

示例4: newMockTest

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
 * Creates a mock test for the entity. Silently returns if the mock test
 * file already exists.
 * 
 * @param entity to produce a mock test for (required)
 */
public void newMockTest(final JavaType entity) {
    Validate.notNull(entity,
            "Entity to produce a mock test for is required");

    final JavaType name = new JavaType(entity + "Test");
    final String declaredByMetadataId = PhysicalTypeIdentifier
            .createIdentifier(name, Path.SRC_TEST_JAVA
                    .getModulePathId(projectOperations
                            .getFocusedModuleName()));

    if (metadataService.get(declaredByMetadataId) != null) {
        // The file already exists
        return;
    }

    // Determine if the mocking infrastructure needs installing
    final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
    final List<AnnotationAttributeValue<?>> config = new ArrayList<AnnotationAttributeValue<?>>();
    config.add(new ClassAttributeValue(new JavaSymbolName("value"), JUNIT_4));
    annotations.add(new AnnotationMetadataBuilder(RUN_WITH, config));
    annotations.add(new AnnotationMetadataBuilder(
            MOCK_STATIC_ENTITY_METHODS));

    final List<MethodMetadataBuilder> methods = new ArrayList<MethodMetadataBuilder>();
    final List<AnnotationMetadataBuilder> methodAnnotations = new ArrayList<AnnotationMetadataBuilder>();
    methodAnnotations.add(new AnnotationMetadataBuilder(TEST));

    // Get the entity so we can hopefully make a demo method that will be
    // usable
    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();

    final ClassOrInterfaceTypeDetails cid = typeLocationService
            .getTypeDetails(entity);
    if (cid != null) {
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(
                        IntegrationTestOperationsImpl.class.getName(), cid);
        final List<MethodMetadata> countMethods = memberDetails
                .getMethodsWithTag(CustomDataKeys.COUNT_ALL_METHOD);
        if (countMethods.size() == 1) {
            final String countMethod = entity.getSimpleTypeName() + "."
                    + countMethods.get(0).getMethodName().getSymbolName()
                    + "()";
            bodyBuilder.appendFormalLine("int expectedCount = 13;");
            bodyBuilder.appendFormalLine(countMethod + ";");
            bodyBuilder
                    .appendFormalLine("org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.expectReturn(expectedCount);");
            bodyBuilder
                    .appendFormalLine("org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.playback();");
            bodyBuilder
                    .appendFormalLine("org.junit.Assert.assertEquals(expectedCount, "
                            + countMethod + ");");
        }
    }

    final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
            declaredByMetadataId, Modifier.PUBLIC, new JavaSymbolName(
                    "testMethod"), JavaType.VOID_PRIMITIVE, bodyBuilder);
    methodBuilder.setAnnotations(methodAnnotations);
    methods.add(methodBuilder);

    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            declaredByMetadataId, Modifier.PUBLIC, name,
            PhysicalTypeCategory.CLASS);
    cidBuilder.setAnnotations(annotations);
    cidBuilder.setDeclaredMethods(methods);

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

示例5: addJmsListener

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void addJmsListener(final JavaType targetType, final String name,
        final JmsDestinationType destinationType) {
    Validate.notNull(targetType, "Java type required");

    final String declaredByMetadataId = PhysicalTypeIdentifier
            .createIdentifier(targetType, projectOperations
                    .getPathResolver().getFocusedPath(Path.SRC_MAIN_JAVA));

    final List<MethodMetadataBuilder> methods = new ArrayList<MethodMetadataBuilder>();
    final List<JavaType> parameterTypes = Arrays.asList(OBJECT);
    final List<JavaSymbolName> parameterNames = Arrays
            .asList(new JavaSymbolName("message"));

    // Create some method content to get people started
    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder
            .appendFormalLine("System.out.println(\"JMS message received: \" + message);");
    methods.add(new MethodMetadataBuilder(declaredByMetadataId, PUBLIC,
            new JavaSymbolName("onMessage"), JavaType.VOID_PRIMITIVE,
            AnnotatedJavaType.convertFromJavaTypes(parameterTypes),
            parameterNames, bodyBuilder));

    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            declaredByMetadataId, PUBLIC, targetType,
            PhysicalTypeCategory.CLASS);
    cidBuilder.setDeclaredMethods(methods);

    // Determine the canonical filename
    final String physicalLocationCanonicalPath = getPhysicalLocationCanonicalPath(declaredByMetadataId);

    // Check the file doesn't already exist
    Validate.isTrue(!fileManager.exists(physicalLocationCanonicalPath),
            "%s already exists", projectOperations.getPathResolver()
                    .getFriendlyName(physicalLocationCanonicalPath));

    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());

    final String jmsContextPath = projectOperations.getPathResolver()
            .getFocusedIdentifier(Path.SPRING_CONFIG_ROOT,
                    "applicationContext-jms.xml");
    final Document document = XmlUtils.readXml(fileManager
            .getInputStream(jmsContextPath));
    final Element root = document.getDocumentElement();

    Element listenerContainer = DomUtils.findFirstElementByName(
            "jms:listener-container", root);
    if (listenerContainer != null
            && destinationType.name().equalsIgnoreCase(
                    listenerContainer.getAttribute("destination-type"))) {
        listenerContainer = document
                .createElement("jms:listener-container");
        listenerContainer.setAttribute("connection-factory", "jmsFactory");
        listenerContainer.setAttribute("destination-type", destinationType
                .name().toLowerCase());
        root.appendChild(listenerContainer);
    }

    if (listenerContainer != null) {
        final Element jmsListener = document.createElement("jms:listener");
        jmsListener.setAttribute("ref",
                StringUtils.uncapitalize(targetType.getSimpleTypeName()));
        jmsListener.setAttribute("method", "onMessage");
        jmsListener.setAttribute("destination", name);

        final Element bean = document.createElement("bean");
        bean.setAttribute("class", targetType.getFullyQualifiedTypeName());
        bean.setAttribute("id",
                StringUtils.uncapitalize(targetType.getSimpleTypeName()));
        root.appendChild(bean);

        listenerContainer.appendChild(jmsListener);
    }

    fileManager.createOrUpdateTextFileIfRequired(jmsContextPath,
            XmlUtils.nodeToString(document), false);
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:77,代碼來源:JmsOperationsImpl.java


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