当前位置: 首页>>代码示例>>Java>>正文


Java ClassOrInterfaceTypeDetails.getAnnotation方法代码示例

本文整理汇总了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java ClassOrInterfaceTypeDetails.getAnnotation方法的具体用法?Java ClassOrInterfaceTypeDetails.getAnnotation怎么用?Java ClassOrInterfaceTypeDetails.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails的用法示例。


在下文中一共展示了ClassOrInterfaceTypeDetails.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateIdFromEntity

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * 
 * This method returns valid id from received entity controller
 * 
 * @param entity
 * @param typeLocationService
 * @return
 */
private String generateIdFromEntity(JavaType controller,
        TypeLocationService typeLocationService) {

    ClassOrInterfaceTypeDetails controllerDetails = typeLocationService
            .getTypeDetails(controller);
    AnnotationMetadata scaffoldAnnotation = controllerDetails
            .getAnnotation(RooJavaType.ROO_WEB_SCAFFOLD);

    JavaType entity = (JavaType) scaffoldAnnotation.getAttribute(
            "formBackingObject").getValue();

    String entityPackage = entity.getPackage()
            .getFullyQualifiedPackageName();

    String entityName = entity.getSimpleTypeName();

    String mapId = String.format("l_%s_%s", entityPackage.replaceAll("[.]",
            "_"), new JavaSymbolName(entityName)
            .getSymbolNameCapitalisedFirstLetter());

    return mapId;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:31,代码来源:GvNIXMapViewerMetadata.java

示例2: getDataOnDemandMetadataId

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
private String getDataOnDemandMetadataId(final JavaType javaType,
        final Iterable<ClassOrInterfaceTypeDetails> dataOnDemandTypes) {
    for (final ClassOrInterfaceTypeDetails cid : dataOnDemandTypes) {
        final AnnotationMetadata dodAnnotation = cid
                .getAnnotation(ROO_DATA_ON_DEMAND);
        final AnnotationAttributeValue<JavaType> entityAttribute = dodAnnotation
                .getAttribute("entity");
        if (entityAttribute != null
                && entityAttribute.getValue().equals(javaType)) {
            // Found the DoD type for the given field's type
            return DataOnDemandMetadata.createIdentifier(cid.getName(),
                    PhysicalTypeIdentifier.getPath(cid
                            .getDeclaredByMetadataId()));
        }
    }
    return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:18,代码来源:DataOnDemandMetadataProviderImpl.java

示例3: getWebJsonMidIfMvcController

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * If the given type is a web MVC controller, returns the ID of the
 * WebJsonMetadata for its form backing type, to ensure that any required
 * layer components are injected. This is a workaround to AspectJ not
 * handling multiple ITDs introducing the same field (in our case the layer
 * component) into one Java class.
 * 
 * @param governorTypeDetails the type to check (required)
 */
private String getWebJsonMidIfMvcController(
        final ClassOrInterfaceTypeDetails governorTypeDetails) {
    final AnnotationMetadata controllerAnnotation = governorTypeDetails
            .getAnnotation(ROO_WEB_SCAFFOLD);
    if (controllerAnnotation != null) {
        final JavaType formBackingType = (JavaType) controllerAnnotation
                .getAttribute("formBackingObject").getValue();
        final String webJsonMetadataId = managedEntityTypes
                .get(formBackingType);
        if (webJsonMetadataId != null) {
            /*
             * We've been notified of a change to an MVC controller for
             * whose backing object we produce WebJsonMetadata; refresh that
             * MD to ensure our ITD does or does not introduce any required
             * layer components, as appropriate.
             */
            getMetadataService().get(webJsonMetadataId);
        }
    }
    return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:31,代码来源:WebJsonMetadataProviderImpl.java

示例4: AbstractAnnotationValues

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
protected AbstractAnnotationValues(
        final MemberHoldingTypeDetails memberHoldingTypeDetails,
        final JavaType annotationType) {
    Validate.notNull(annotationType, "Annotation to locate is required");

    if (memberHoldingTypeDetails instanceof ClassOrInterfaceTypeDetails) {
        classParsed = true;

        // We have reliable physical type details
        governorTypeDetails = (ClassOrInterfaceTypeDetails) memberHoldingTypeDetails;

        // Process values from the annotation, if present
        annotationMetadata = governorTypeDetails
                .getAnnotation(annotationType);
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:17,代码来源:AbstractAnnotationValues.java

示例5: addClass

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method is a command declaration to add a class to be monitored as a
 * Spring service
 */
@CliCommand(value = "monitoring add class",
        help = "Add a class to be monitored as a Spring service")
public void addClass(@CliOption(key = "name",
        mandatory = true,
        help = "Set the class name to be monitored") final JavaType name) {

    // Getting class details
    ClassOrInterfaceTypeDetails typeDetails = getTypeLocationService()
            .getTypeDetails(name);

    // Getting class @Controller annotations
    AnnotationMetadata annotations = typeDetails
            .getAnnotation(SpringJavaType.CONTROLLER);

    // If class doesn't have @Controller annotations means that is not a
    // valid controller
    if (annotations != null) {
        operations.addClass(name);
    }
    else {
        LOGGER.log(Level.WARNING,
                "Error. You must to specify a valid class annotated with @Controller ");
    }

}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:30,代码来源:MonitoringCommands.java

示例6: setLoupeController

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void setLoupeController(JavaType controller) {
    Validate.notNull(controller, "Controller Java Type required");

    // Checks if controller is a GvNIXDatatablesController
    ClassOrInterfaceTypeDetails existingController = getTypeLocationService()
            .getTypeDetails(controller);
    AnnotationMetadata datatablesAnnotation = existingController
            .getAnnotation(DATATABLES_ANNOTATION);
    Validate.notNull(datatablesAnnotation, controller.getSimpleTypeName()
            .concat(" must be annotated with @GvNIXDatatables"));

    // Adding annotation to Controller
    doAddControllerAnnotation(controller);

    // Adding uri to create.jspx and update.jspx views
    updateCreateAndUpdateViews(controller);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:19,代码来源:LoupefieldOperationsImpl.java

示例7: generatePathFromEntity

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * 
 * This method returns valid path from received entity controller
 * 
 * @param entity
 * @param typeLocationService
 * @return
 */
private String generatePathFromEntity(JavaType entity,
        TypeLocationService typeLocationService) {

    ClassOrInterfaceTypeDetails entityDetails = typeLocationService
            .getTypeDetails(entity);
    AnnotationMetadata requestMappingAnnotation = entityDetails
            .getAnnotation(SpringJavaType.REQUEST_MAPPING);
    Object entityPath = requestMappingAnnotation.getAttribute("value")
            .getValue();

    return entityPath.toString();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:21,代码来源:GvNIXMapViewerMetadata.java

示例8: generatePKFromEntity

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method obtains current entity PK
 * 
 * @param controller
 * @param typeLocationService
 * @return
 */
private String generatePKFromEntity(JavaType controller,
        TypeLocationService typeLocationService) {

    ClassOrInterfaceTypeDetails controllerDetails = typeLocationService
            .getTypeDetails(controller);
    AnnotationMetadata scaffoldAnnotation = controllerDetails
            .getAnnotation(RooJavaType.ROO_WEB_SCAFFOLD);

    JavaType entity = (JavaType) scaffoldAnnotation.getAttribute(
            "formBackingObject").getValue();

    // Getting entity details
    ClassOrInterfaceTypeDetails entityDetails = typeLocationService
            .getTypeDetails(entity);

    List<FieldMetadata> idField = entityDetails
            .getFieldsWithAnnotation(new JavaType("javax.persistence.Id"));

    // If main entity not have ID field, check if exists on extended class
    if (!idField.isEmpty()) {
        return idField.get(0).getFieldName().toString();
    }
    else {
        // TODO: CHECK IF IS CORRECT
        return "id";
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:35,代码来源:GvNIXMapViewerMetadata.java

示例9: getEntityGeoFields

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method obtains all GEO fields to represent on map from entity
 * 
 * @param controller
 * @param typeLocationService
 * @return
 */
private List<FieldMetadata> getEntityGeoFields(JavaType controller,
        TypeLocationService typeLocationService) {

    ClassOrInterfaceTypeDetails controllerDetails = typeLocationService
            .getTypeDetails(controller);
    AnnotationMetadata scaffoldAnnotation = controllerDetails
            .getAnnotation(RooJavaType.ROO_WEB_SCAFFOLD);

    JavaType entity = (JavaType) scaffoldAnnotation.getAttribute(
            "formBackingObject").getValue();

    // Getting entity details
    ClassOrInterfaceTypeDetails entityDetails = typeLocationService
            .getTypeDetails(entity);

    // Getting entity fields
    List<? extends FieldMetadata> entityFields = entityDetails
            .getDeclaredFields();

    // Generating empty field list
    List<FieldMetadata> geoFields = new ArrayList<FieldMetadata>();

    for (FieldMetadata field : entityFields) {
        JavaType fieldType = field.getFieldType();
        JavaPackage fieldPackage = fieldType.getPackage();

        // If is jts field, return as geo field
        if (fieldPackage.toString().equals("com.vividsolutions.jts.geom")) {
            geoFields.add(field);
        }

    }

    return geoFields;

}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:44,代码来源:GvNIXMapViewerMetadata.java

示例10: getMapControllerByPath

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method returns a map controller by recived path
 * 
 * @param path
 * @return
 */
public static ClassOrInterfaceTypeDetails getMapControllerByPath(
        TypeLocationService typeLocationService, String path) {
    // Looking for Controller with current path on @RequestMapping
    // annotation
    Set<ClassOrInterfaceTypeDetails> controllersList = typeLocationService
            .findClassesOrInterfaceDetailsWithAnnotation(new JavaType(
                    "org.gvnix.addon.geo.GvNIXMapViewer"));

    Validate.notNull(controllersList,
            "Controllers with @GvNIXMapViewer annotation doesn't found");

    // Creating empty controller where set current map controller
    ClassOrInterfaceTypeDetails mapController = null;

    Iterator<ClassOrInterfaceTypeDetails> it = controllersList.iterator();
    while (it.hasNext()) {
        ClassOrInterfaceTypeDetails controller = it.next();
        AnnotationMetadata requestMapping = controller
                .getAnnotation(SpringJavaType.REQUEST_MAPPING);
        AnnotationAttributeValue<Object> annotationPath = requestMapping
                .getAttribute("value");
        String annotationPathValue = annotationPath.getValue().toString()
                .replaceAll("/", "");
        if (path.equals(annotationPathValue)) {
            mapController = controller;
            break;
        }
    }

    return mapController;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:38,代码来源:GeoUtils.java

示例11: getJpaAnnotation

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * Returns the JPA-related annotation on the given managed entity
 * 
 * @param managedEntity an existing DBRE-managed entity (required)
 * @return <code>null</code> if there isn't one
 */
private AnnotationMetadata getJpaAnnotation(
        final ClassOrInterfaceTypeDetails managedEntity) {
    // The @RooJpaEntity annotation takes precedence if present
    final AnnotationMetadata rooJpaEntity = managedEntity
            .getAnnotation(ROO_JPA_ENTITY);
    if (rooJpaEntity != null) {
        return rooJpaEntity;
    }
    return managedEntity.getAnnotation(ROO_JPA_ACTIVE_RECORD);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:17,代码来源:DbreDatabaseListenerImpl.java

示例12: isControllerAnnotated

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method checks if controller is annotated with @GvNIXLoupeController
 * 
 * @param controller
 * @return
 */
private boolean isControllerAnnotated(ClassOrInterfaceTypeDetails controller) {
    AnnotationMetadata annotations = controller.getAnnotation(new JavaType(
            GvNIXLoupeController.class));
    if (annotations == null) {
        return false;
    }
    return true;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:15,代码来源:LoupefieldOperationsImpl.java

示例13: add

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method adds specific GEO entities to specific map controller
 */
@Override
public void add(JavaType controller, JavaType mapController) {

    // Checking if exists map element before to generate geo web layer
    if (!checkExistsMapElement()) {
        throw new RuntimeException(ERR_N_TO_CREATE_NEW_MAP);
    }

    Validate.notNull(controller,
            "Controller is necessary to execute this operation");

    // Checking that the specified controller is a valid controller
    ClassOrInterfaceTypeDetails controllerDetails = getTypeLocationService()
            .getTypeDetails(controller);

    // Getting scaffold annotation
    AnnotationMetadata scaffoldAnnotation = controllerDetails
            .getAnnotation(ROO_WEB_SCAFFOLD_ANNOTATION);

    Validate.notNull(
            scaffoldAnnotation,
            String.format(
                    "%s is not a valid controller. Controller must be annotated with @RooWebScaffold",
                    controller.getFullyQualifiedTypeName()));

    // Check if is valid GEO Entity
    boolean isValidEntity = GeoUtils.isGeoEntity(scaffoldAnnotation,
            getTypeLocationService());

    Validate.isTrue(isValidEntity, String
            .format("Specified entity \"%s\" has not GEO fields",
                    scaffoldAnnotation.getAttribute("formBackingObject")
                            .getValue()));

    // Checking if entity has geo finder
    JavaType entity = (JavaType) scaffoldAnnotation.getAttribute(
            new JavaSymbolName("formBackingObject")).getValue();

    ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService()
            .getTypeDetails(entity);
    AnnotationMetadata gvNIXEntityMapLayerAnnotation = entityDetails
            .getAnnotation(GVNIX_ENTITY_MAP_LAYER_ANNOTATION);

    Validate.notNull(
            gvNIXEntityMapLayerAnnotation,
            String.format(
                    "Specified entity \"%s\" is not annotated with @GvNIXEntityMapLayer. Use \"finder geo add\" command to generate necessary methods",
                    entity.getSimpleTypeName()));

    String path = getControllerPathFromViewerController(mapController);

    createEntityLayers(controller, mapController);

    annotateGeoEntityController(controller, path);

    // Update necessary map controllers with current entity
    // If developer specify map path add on it
    if (StringUtils.isNotBlank(path)) {
        // Annotate map controllers adding current entity
        annotateMapController(mapController, getTypeLocationService(),
                getTypeManagementService(), controllerDetails.getType());
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:67,代码来源:GeoOperationsImpl.java

示例14: entitySimpleLayer

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method add a new entity-simple layer on selected map or controller
 * 
 * @param field
 * @param pk
 * @param mapController
 * @param label
 * @param labelCode
 */
@Override
public void entitySimpleLayer(JavaType controller, String field, String pk,
        JavaType mapController, String label, String labelCode, String group) {

    // Checking if exists map element before to generate geo tile layer
    if (!checkExistsMapElement()) {
        throw new RuntimeException(ERR_N_TO_CREATE_NEW_MAP);
    }

    Validate.notNull(controller, "Valid controller is necessary");

    // Getting controller Details
    ClassOrInterfaceTypeDetails controllerDetails = getTypeLocationService()
            .getTypeDetails(controller);

    // Getting roo web scaffold annotation
    AnnotationMetadata rooWebScaffoldAnnotation = controllerDetails
            .getAnnotation(ROO_WEB_SCAFFOLD_ANNOTATION);

    Validate.notNull(
            rooWebScaffoldAnnotation,
            "Controller annotated with @RooWebScaffold is necessary. Generate controller for your entity using 'web mvc scaffold'");

    // Getting @RequestMapping annotation
    AnnotationMetadata requestMappingAnnotation = controllerDetails
            .getAnnotation(SpringJavaType.REQUEST_MAPPING);

    Validate.notNull(
            requestMappingAnnotation,
            "Controller annotated with @RequestMapping is necessary. Generate controller for your entity using 'web mvc scaffold'");

    // Getting path
    String entityPath = requestMappingAnnotation.getAttribute(VALUE)
            .getValue().toString();

    // Creating map with params to send
    Map<String, String> tileLayerAttr = new HashMap<String, String>();

    tileLayerAttr.put("field", field);
    tileLayerAttr.put("path", entityPath);
    tileLayerAttr.put("pk", pk);
    tileLayerAttr.put("label", label);
    tileLayerAttr.put("labelCode", labelCode);

    field = field.replaceAll(" ", "_");

    annotateGeoEntityController(controller,
            getControllerPathFromViewerController(mapController));

    createBaseLayer(field, tileLayerAttr, mapController, "entity-simple",
            label, labelCode, group);

}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:63,代码来源:GeoOperationsImpl.java

示例15: annotateMapController

import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails; //导入方法依赖的package包/类
/**
 * This method annotates MapControllers with entities to represent
 * 
 * @param mapControllersToAnnotate
 * @param typeLocationService
 * @param typeManagementService
 * @param entity
 */
private void annotateMapController(JavaType mapController,
        TypeLocationService typeLocationService,
        TypeManagementService typeManagementService, JavaType controller) {

    ClassOrInterfaceTypeDetails mapControllerDetails = typeLocationService
            .getTypeDetails(mapController);

    // Getting @GvNIXMapViewer Annotation
    AnnotationMetadata mapViewerAnnotation = mapControllerDetails
            .getAnnotation(MAP_VIEWER_ANNOTATION);

    // Generating new annotation
    ClassOrInterfaceTypeDetailsBuilder classOrInterfaceTypeDetailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
            mapControllerDetails);
    AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
            MAP_VIEWER_ANNOTATION);

    // Getting current entities
    @SuppressWarnings({ "unchecked", "rawtypes" })
    ArrayAttributeValue<ClassAttributeValue> mapViewerAttributesOld = (ArrayAttributeValue) mapViewerAnnotation
            .getAttribute("entityLayers");

    // Initialize class attributes list for detail fields
    final List<ClassAttributeValue> entityAttributes = new ArrayList<ClassAttributeValue>();
    boolean notIncluded = true;

    if (mapViewerAttributesOld != null) {
        // Adding by default old entities
        entityAttributes.addAll(mapViewerAttributesOld.getValue());
        // Checking that current entity is not included yet
        List<ClassAttributeValue> mapViewerAttributesOldValues = mapViewerAttributesOld
                .getValue();
        for (ClassAttributeValue currentEntity : mapViewerAttributesOldValues) {
            if (currentEntity.getValue().equals(controller)) {
                notIncluded = false;
                break;
            }
        }
    }

    // If current entity is not included in old values, include to new
    // annotation
    if (notIncluded) {
        // Create a class attribute for property
        final ClassAttributeValue entityAttribute = new ClassAttributeValue(
                new JavaSymbolName(VALUE), controller);
        entityAttributes.add(entityAttribute);
    }

    // Create "entityLayers" attributes array from string attributes
    // list
    ArrayAttributeValue<ClassAttributeValue> entityLayersArray = new ArrayAttributeValue<ClassAttributeValue>(
            new JavaSymbolName("entityLayers"), entityAttributes);

    annotationBuilder.addAttribute(entityLayersArray);
    annotationBuilder.build();

    // Update annotation into controller
    classOrInterfaceTypeDetailsBuilder
            .updateTypeAnnotation(annotationBuilder);

    // Save controller changes to disk
    getTypeManagementService().createOrUpdateTypeOnDisk(
            classOrInterfaceTypeDetailsBuilder.build());

}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:75,代码来源:GeoOperationsImpl.java


注:本文中的org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。