本文整理匯總了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder.addAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceTypeDetailsBuilder.addAnnotation方法的具體用法?Java ClassOrInterfaceTypeDetailsBuilder.addAnnotation怎麽用?Java ClassOrInterfaceTypeDetailsBuilder.addAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder
的用法示例。
在下文中一共展示了ClassOrInterfaceTypeDetailsBuilder.addAnnotation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: annotateTypeWithGvNIXEntityBatch
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Annotates with GvNIXEntityBatch given JavaType
*
* @param type
*/
private void annotateTypeWithGvNIXEntityBatch(JavaType type) {
ClassOrInterfaceTypeDetails typeMutableDetails = typeLocationService
.getTypeDetails(type);
AnnotationMetadata annotationMetadata = MemberFindingUtils
.getAnnotationOfType(typeMutableDetails.getAnnotations(),
ENTITYBATCH_ANNOTATION);
// Annotate type with GvNIXEntityBatch just if is not
// annotated already. We don't need to update attributes
if (annotationMetadata == null) {
// Prepare annotation builder
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
ENTITYBATCH_ANNOTATION);
ClassOrInterfaceTypeDetailsBuilder mutableTypeDetailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
typeMutableDetails);
mutableTypeDetailsBuilder.addAnnotation(annotationBuilder.build());
typeManagementService
.createOrUpdateTypeOnDisk(mutableTypeDetailsBuilder.build());
}
}
示例2: createServiceClass
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* <p>
* Adds @org.springframework.stereotype.Service annotation to the class.
* </p>
*/
public void createServiceClass(JavaType serviceClass) {
// Service class
String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(
serviceClass, LogicalPath.getInstance(Path.SRC_MAIN_JAVA, ""));
// Service annotations
List<AnnotationMetadata> serviceAnnotations = new ArrayList<AnnotationMetadata>();
serviceAnnotations.add(new AnnotationMetadataBuilder(new JavaType(
"org.springframework.stereotype.Service"),
new ArrayList<AnnotationAttributeValue<?>>()).build());
ClassOrInterfaceTypeDetailsBuilder serviceDetails = new ClassOrInterfaceTypeDetailsBuilder(
declaredByMetadataId, Modifier.PUBLIC, serviceClass,
PhysicalTypeCategory.CLASS);
for (AnnotationMetadata annotationMetadata : serviceAnnotations) {
serviceDetails.addAnnotation(annotationMetadata);
}
typeManagementService.createOrUpdateTypeOnDisk(serviceDetails.build());
}
示例3: createType
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/** {@inheritDoc} */
public void createType(JavaType classType) {
// Use Roo's Assert type for null checks
Validate.notNull(classType, "Class type required");
final String classIdentifier = typeLocationService.getPhysicalTypeCanonicalPath(classType,
pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA));
if (fileManager.exists(classIdentifier)) {
return; // Type exists already - nothing to do
}
final String classMdId = PhysicalTypeIdentifier.createIdentifier(classType, pathResolver.getPath(classIdentifier));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
classMdId, Modifier.PUBLIC, classType, PhysicalTypeCategory.CLASS);
// Make this type a java bean and a toString() implementor.
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(RooJavaType.ROO_JAVA_BEAN));
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(RooJavaType.ROO_TO_STRING));
final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(new JavaType(RooElasticsearchEntity.class), attributes));
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
開發者ID:lbroudoux,項目名稱:spring-roo-addon-layers-repository-elasticsearch,代碼行數:25,代碼來源:ElasticsearchOperationsImpl.java
示例4: annotateController
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void annotateController(JavaType javaType) {
Validate.notNull(javaType, "Controller required");
ClassOrInterfaceTypeDetails existing = getControllerDetails(javaType);
// Only for @RooWebScaffold annotated controllers
final AnnotationMetadata controllerAnnotation = MemberFindingUtils
.getAnnotationOfType(existing.getAnnotations(),
SCAFFOLD_ANNOTATION);
Validate.isTrue(controllerAnnotation != null,
"Operation for @RooWebScaffold annotated controllers only.");
final boolean isJQueryAnnotated = MemberFindingUtils
.getAnnotationOfType(existing.getAnnotations(),
JQUERY_ANNOTATION) != null;
// If annotation already exists on the target type do nothing
if (isJQueryAnnotated) {
return;
}
ClassOrInterfaceTypeDetailsBuilder detailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
existing);
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
JQUERY_ANNOTATION);
// Add annotation to target type
detailsBuilder.addAnnotation(annotationBuilder.build());
// Save changes to disk
getTypeManagementService().createOrUpdateTypeOnDisk(
detailsBuilder.build());
}
示例5: addEqualsAndHashCodeMethods
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void addEqualsAndHashCodeMethods(final JavaType javaType,
final boolean appendSuper, final Set<String> excludeFields) {
// Add @RooEquals annotation to class if not yet present
final ClassOrInterfaceTypeDetails cid = typeLocationService
.getTypeDetails(javaType);
if (cid == null || cid.getTypeAnnotation(ROO_EQUALS) != null) {
return;
}
final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
ROO_EQUALS);
if (appendSuper) {
annotationBuilder.addBooleanAttribute("appendSuper", appendSuper);
}
if (!CollectionUtils.isEmpty(excludeFields)) {
final List<StringAttributeValue> attributes = new ArrayList<StringAttributeValue>();
for (final String excludeField : excludeFields) {
attributes.add(new StringAttributeValue(new JavaSymbolName(
"value"), excludeField));
}
annotationBuilder
.addAttribute(new ArrayAttributeValue<StringAttributeValue>(
new JavaSymbolName("excludeFields"), attributes));
}
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
cid);
cidBuilder.addAnnotation(annotationBuilder.build());
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
示例6: createPermissionEvaluator
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
private void createPermissionEvaluator(
final JavaPackage permissionEvaluatorPackage) {
installPermissionEvaluatorTemplate(permissionEvaluatorPackage);
final LogicalPath focusedSrcMainJava = LogicalPath.getInstance(
SRC_MAIN_JAVA, getProjectOperations().getFocusedModuleName());
JavaType permissionEvaluatorClass = new JavaType(
permissionEvaluatorPackage.getFullyQualifiedPackageName()
+ ".ApplicationPermissionEvaluator");
final String identifier = getPathResolver().getFocusedCanonicalPath(
Path.SRC_MAIN_JAVA, permissionEvaluatorClass);
if (getFileManager().exists(identifier)) {
return; // Type already exists - nothing to do
}
final AnnotationMetadataBuilder classAnnotationMetadata = new AnnotationMetadataBuilder(
ROO_PERMISSION_EVALUATOR);
final String classMid = PhysicalTypeIdentifier.createIdentifier(
permissionEvaluatorClass, getPathResolver().getPath(identifier));
final ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
classMid, PUBLIC, permissionEvaluatorClass, CLASS);
classBuilder.addAnnotation(classAnnotationMetadata.build());
classBuilder.addImplementsType(PERMISSION_EVALUATOR);
getTypeManagementService().createOrUpdateTypeOnDisk(classBuilder.build());
getMetadataService().get(PermissionEvaluatorMetadata.createIdentifier(
permissionEvaluatorClass, focusedSrcMainJava));
}
示例7: annotateEntity
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Annotated entity with {@link GvNIXJpaAudit}
* <p/>
*
* @param entity
* @return true if entity has been annotated or false if entity is already
* annotated
*/
public boolean annotateEntity(final JavaType entity) {
Validate.notNull(entity, "Java type required");
// get class details
final ClassOrInterfaceTypeDetails cid = typeLocationService
.getTypeDetails(entity);
if (cid == null) {
throw new IllegalArgumentException("Cannot locate source for '"
.concat(entity.getFullyQualifiedTypeName()).concat("'"));
}
// Check for @GvNIXJpaAudit annotation
if (MemberFindingUtils.getAnnotationOfType(cid.getAnnotations(),
AUDIT_ANNOTATION_TYPE) == null) {
// Add GvNIXJpaAudit annotation
final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
AUDIT_ANNOTATION_TYPE);
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
cid);
cidBuilder.addAnnotation(annotationBuilder);
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
return true;
}
else {
// Already annotated
return false;
}
}
示例8: addAnnotation
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public static ClassOrInterfaceTypeDetails addAnnotation(
final ClassOrInterfaceTypeDetails ptd,
final AnnotationMetadata annotation) {
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
ptd);
cidBuilder.addAnnotation(annotation);
return cidBuilder.build();
}
示例9: addSolrSearchableAnnotation
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
private void addSolrSearchableAnnotation(
final ClassOrInterfaceTypeDetails cid) {
if (cid.getTypeAnnotation(ROO_SOLR_SEARCHABLE) == null) {
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
cid);
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
ROO_SOLR_SEARCHABLE));
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
}
示例10: annotateType
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void annotateType(final JavaType javaType, final String rootName,
final boolean deepSerialize, final boolean iso8601Dates) {
Validate.notNull(javaType, "Java type required");
final ClassOrInterfaceTypeDetails cid = typeLocationService
.getTypeDetails(javaType);
if (cid == null) {
throw new IllegalArgumentException("Cannot locate source for '"
+ javaType.getFullyQualifiedTypeName() + "'");
}
if (MemberFindingUtils.getAnnotationOfType(cid.getAnnotations(),
RooJavaType.ROO_JSON) == null) {
final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
RooJavaType.ROO_JSON);
if (rootName != null && rootName.length() > 0) {
annotationBuilder.addStringAttribute("rootName", rootName);
}
if (deepSerialize) {
annotationBuilder.addBooleanAttribute("deepSerialize", true);
}
if (iso8601Dates) {
annotationBuilder.addBooleanAttribute("iso8601Dates", true);
}
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
cid);
cidBuilder.addAnnotation(annotationBuilder);
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
}
示例11: createType
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void createType(final JavaType classType, final JavaType idType,
final boolean testAutomatically) {
Validate.notNull(classType, "Class type required");
Validate.notNull(idType, "Identifier type required");
final String classIdentifier = getTypeLocationService()
.getPhysicalTypeCanonicalPath(classType,
getPathResolver().getFocusedPath(Path.SRC_MAIN_JAVA));
if (getFileManager().exists(classIdentifier)) {
return; // Type exists already - nothing to do
}
final String classMdId = PhysicalTypeIdentifier.createIdentifier(
classType, getPathResolver().getPath(classIdentifier));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
classMdId, Modifier.PUBLIC, classType,
PhysicalTypeCategory.CLASS);
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
RooJavaType.ROO_JAVA_BEAN));
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
RooJavaType.ROO_TO_STRING));
final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
if (!idType.equals(JdkJavaType.BIG_INTEGER)) {
attributes.add(new ClassAttributeValue(new JavaSymbolName(
"identifierType"), idType));
}
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
RooJavaType.ROO_MONGO_ENTITY, attributes));
getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
if (testAutomatically) {
getIntegrationTestOperations().newIntegrationTest(classType, false);
getDataOnDemandOperations().newDod(classType,
new JavaType(classType.getFullyQualifiedTypeName()
+ "DataOnDemand"));
}
}
示例12: doAddControllerAnnotation
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Annotates given Controller with GvNIXLoupeController
*
* @param controller
*/
private void doAddControllerAnnotation(JavaType controller) {
Validate.notNull(controller, "Controller required");
// Getting current controller
ClassOrInterfaceTypeDetails existingController = getTypeLocationService()
.getTypeDetails(controller);
// Get @Controller annotation
WebScaffoldAnnotationValues annotationValues = new WebScaffoldAnnotationValues(
existingController);
JavaType entity = annotationValues.getFormBackingObject();
// Validating if is a controller
Validate.notNull(entity, "Operation only supported for controllers");
// Checking if is already annoted
final boolean isAlreadyAnnotated = MemberFindingUtils
.getAnnotationOfType(existingController.getAnnotations(),
ANNOTATION_LOUPE_CONTROLLER) != null;
if (!isAlreadyAnnotated) {
ClassOrInterfaceTypeDetailsBuilder detailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
existingController);
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
ANNOTATION_LOUPE_CONTROLLER);
// Add annotation to target type
detailsBuilder.addAnnotation(annotationBuilder.build());
// Save changes to disk
getTypeManagementService().createOrUpdateTypeOnDisk(
detailsBuilder.build());
}
}
示例13: 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
示例14: annotateController
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
private void annotateController(JavaType controller, JavaType service) {
Validate.notNull(controller, "Controller required");
Validate.notNull(service, "Service required");
ClassOrInterfaceTypeDetails existing = getTypeLocationService()
.getTypeDetails(controller);
// Get controller annotation
JavaType entity = getFormBackingObject(existing);
Validate.notNull(entity, "Operation only supported for controllers");
final boolean isAlreadyAnnotated = MemberFindingUtils
.getAnnotationOfType(existing.getAnnotations(),
WEB_JPA_BATCH_ANNOTATION) != null;
// Test if the annotation already exists on the target type
if (!isAlreadyAnnotated) {
ClassOrInterfaceTypeDetailsBuilder detailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
existing);
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
WEB_JPA_BATCH_ANNOTATION);
annotationBuilder.addClassAttribute("service", service);
// Add annotation to target type
detailsBuilder.addAnnotation(annotationBuilder.build());
// Save changes to disk
getTypeManagementService().createOrUpdateTypeOnDisk(
detailsBuilder.build());
}
}
示例15: addPattern
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/** {@inheritDoc} */
public boolean addPattern(JavaType controllerClass, JavaSymbolName name,
WebPatternType pattern) {
Validate.notNull(controllerClass, "controller class is required");
Validate.notNull(name, "pattern name is required");
Validate.notNull(pattern, "pattern type is required");
// Get mutableTypeDetails from controllerClass. Also checks javaType is
// a controller
ClassOrInterfaceTypeDetails controllerDetails = patternService
.getControllerTypeDetails(controllerClass);
// Check if controller entity is a active-record entity (supported)
Validate.isTrue(
isControllerEntityActiveRecord(controllerDetails),
"This operation only supports controllers of entities with @RooJpaActiveRecord annotation");
// Check if there are pattern names used more than once in project
Validate.isTrue(
!patternService.existsMasterPatternDuplicated()
&& !patternService.existsMasterPatternDefined(name
.getSymbolName()),
"There is a pattern name used more than once in the project");
// All checks passed OK
// Test if the annotation already exists on the target type
AnnotationMetadata annotationMetadata = MemberFindingUtils
.getAnnotationOfType(controllerDetails.getAnnotations(),
PATTERN_ANNOTATION);
// Get pattern attributes of the controller
List<StringAttributeValue> patternList = patternService
.getControllerMasterPattern(controllerClass);
// Build string parameter for the pattern
String patternParameter = name.toString().concat("=")
.concat(pattern.toString());
// Adds new pattern
patternList.add(new StringAttributeValue(
new JavaSymbolName(ARRAY_ELEM), patternParameter));
// Prepare annotation builder
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
PATTERN_ANNOTATION);
annotationBuilder
.addAttribute(new ArrayAttributeValue<StringAttributeValue>(
PAT_ANN_ATTR_VAL_NAME, patternList));
// Add or update annotation to target type
ClassOrInterfaceTypeDetailsBuilder mutableTypeDetailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(
controllerDetails);
if (annotationMetadata != null) {
mutableTypeDetailsBuilder.updateTypeAnnotation(
annotationBuilder.build(), new HashSet<JavaSymbolName>());
}
else {
mutableTypeDetailsBuilder.addAnnotation(annotationBuilder.build());
}
typeManagementService
.createOrUpdateTypeOnDisk(mutableTypeDetailsBuilder.build());
// Tabular style patterns requires batch operations
if (pattern.equals(WebPatternType.tabular)
|| pattern.equals(WebPatternType.tabular_edit_register)) {
// TODO If tabular_edit_register, only delete entity in batch
// required
annotateTypeWithGvNIXEntityBatch(getFormBakingObject(controllerDetails));
}
return true;
}