本文整理汇总了Java中org.springframework.roo.model.SpringJavaType类的典型用法代码示例。如果您正苦于以下问题:Java SpringJavaType类的具体用法?Java SpringJavaType怎么用?Java SpringJavaType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpringJavaType类属于org.springframework.roo.model包,在下文中一共展示了SpringJavaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getControllerPathFromViewerController
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Get controller path from GvNIXMapViewer annotated controllers
*
* @param controller
* @return
*/
private String getControllerPathFromViewerController(JavaType controller) {
final ClassOrInterfaceTypeDetails cidController = getTypeLocationService()
.getTypeDetails(controller);
Validate.notNull(cidController,
"The type specified, '%s', doesn't exist", cidController);
// Only for @GvNIXMapViewer annotated controllers
final AnnotationMetadata controllerAnnotation = MemberFindingUtils
.getAnnotationOfType(cidController.getAnnotations(),
new JavaType(GvNIXMapViewer.class.getName()));
Validate.isTrue(controllerAnnotation != null,
"Operation for @GvNIXMapViewer annotated controllers only.");
String controllerPath = (String) cidController
.getAnnotation(SpringJavaType.REQUEST_MAPPING)
.getAttribute(VALUE).getValue();
controllerPath = controllerPath.replaceAll("/", "").trim();
return controllerPath;
}
示例2: getAllMapsControllers
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
*
* This method returns all available maps Controllers
*
* @param typeLocationService
* @return
*/
public static List<JavaType> getAllMapsControllers(
TypeLocationService typeLocationService) {
List<JavaType> controllers = new ArrayList<JavaType>();
for (JavaType mapViewer : typeLocationService
.findTypesWithAnnotation(MAP_VIEWER_ANNOTATION)) {
Validate.notNull(mapViewer, "@GvNIXMapViewer required");
ClassOrInterfaceTypeDetails mapViewerController = typeLocationService
.getTypeDetails(mapViewer);
// Getting RequestMapping annotations
final AnnotationMetadata requestMappingAnnotation = MemberFindingUtils
.getAnnotationOfType(mapViewerController.getAnnotations(),
SpringJavaType.REQUEST_MAPPING);
Validate.notNull(mapViewer, String.format(
"Error on %s getting @RequestMapping value", mapViewer));
controllers.add(mapViewer);
}
return controllers;
}
示例3: getField
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
private FieldMetadataBuilder getField() {
final JavaSymbolName fieldName = new JavaSymbolName("typeConverter");
// Locate user-defined field
final FieldMetadata userField = governorTypeDetails.getField(fieldName);
final JavaType fieldType = SpringJavaType.SIMPLE_TYPE_CONVERTER;
if (userField != null) {
Validate.isTrue(userField.getFieldType().equals(fieldType),
"Field '%s' on '%s' must be of type '%s'", fieldName,
destination, fieldType.getNameIncludingTypeParameters());
return new FieldMetadataBuilder(userField);
}
return new FieldMetadataBuilder(getId(), Modifier.PRIVATE, fieldName,
fieldType, "new " + fieldType + "()");
}
示例4: getIdentifierField
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
private FieldMetadata getIdentifierField() {
if (parent != null) {
final FieldMetadata parentIdField = parent.getIdentifierField();
if (parentIdField.getFieldType().equals(idType)) {
return parentIdField;
}
}
// Try to locate an existing field with DATA_ID
final List<FieldMetadata> idFields = governorTypeDetails
.getFieldsWithAnnotation(SpringJavaType.DATA_ID);
if (!idFields.isEmpty()) {
return idFields.get(0);
}
final JavaSymbolName idFieldName = governorTypeDetails
.getUniqueFieldName("id");
final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
getId(), Modifier.PRIVATE, idFieldName, idType, null);
fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(
SpringJavaType.DATA_ID));
return fieldBuilder.build();
}
示例5: RepositoryMongoMetadata
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Constructor
*
* @param identifier the identifier for this item of metadata (required)
* @param aspectName the Java type of the ITD (required)
* @param governorPhysicalTypeMetadata the governor, which is expected to
* contain a {@link ClassOrInterfaceTypeDetails} (required)
* @param annotationValues (required)
* @param identifierType the type of the entity's identifier field
* (required)
*/
public RepositoryMongoMetadata(final String identifier,
final JavaType aspectName,
final PhysicalTypeMetadata governorPhysicalTypeMetadata,
final RepositoryMongoAnnotationValues annotationValues,
final JavaType identifierType) {
super(identifier, aspectName, governorPhysicalTypeMetadata);
Validate.notNull(annotationValues, "Annotation values required");
Validate.notNull(identifierType, "Identifier type required");
// Make the user's Repository interface extend Spring Data's Repository
// interface if it doesn't already
ensureGovernorExtends(new JavaType(SPRING_DATA_REPOSITORY, 0,
DataType.TYPE, null, Arrays.asList(
annotationValues.getDomainType(), identifierType)));
builder.addAnnotation(getTypeAnnotation(SpringJavaType.REPOSITORY));
// Build the ITD
itdTypeDetails = builder.build();
}
示例6: createNewType
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
private void createNewType(final JavaType type, final JavaType jsonEntity) {
final PluralMetadata pluralMetadata = (PluralMetadata) metadataService
.get(PluralMetadata.createIdentifier(jsonEntity,
typeLocationService.getTypePath(jsonEntity)));
if (pluralMetadata == null) {
return;
}
final String declaredByMetadataId = PhysicalTypeIdentifier
.createIdentifier(type,
pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
declaredByMetadataId, Modifier.PUBLIC, type,
PhysicalTypeCategory.CLASS);
cidBuilder.addAnnotation(getAnnotation(jsonEntity));
cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
SpringJavaType.CONTROLLER));
final AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
requestMapping.addAttribute(new StringAttributeValue(
new JavaSymbolName("value"), "/"
+ pluralMetadata.getPlural().toLowerCase()));
cidBuilder.addAnnotation(requestMapping);
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
示例7: createRequestParam
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Creates a "RequestParam" annotated type
*
* @param paramType
* @param value (optional) "value" attribute value
* @param required (optional) attribute value
* @param defaultValue (optional) attribute value
* @return
*/
public AnnotatedJavaType createRequestParam(JavaType paramType,
String value, Boolean required, String defaultValue) {
// create annotation values
final List<AnnotationAttributeValue<?>> annotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
if (StringUtils.isNotBlank(value)) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("value"), value));
}
if (required != null) {
annotationAttributes.add(new BooleanAttributeValue(
new JavaSymbolName("required"), required.booleanValue()));
}
if (defaultValue != null) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("defaultValue"), defaultValue));
}
AnnotationMetadataBuilder paramAnnotationBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM, annotationAttributes);
return new AnnotatedJavaType(paramType, paramAnnotationBuilder.build());
}
示例8: createRequestParam
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Creates a "RequestParam" annotated type
*
* @param paramType
* @param value (optional) "value" attribute value
* @param required (optional) attribute value
* @param defaultValue (optional) attribute value
* @return
*/
public AnnotatedJavaType createRequestParam(JavaType paramType,
String value, Boolean required, String defaultValue) {
// create annotation values
final List<AnnotationAttributeValue<?>> annotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
if (StringUtils.isNotBlank(value)) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("value"), value));
}
if (required != null) {
annotationAttributes.add(new BooleanAttributeValue(
new JavaSymbolName("required"), required.booleanValue()));
}
if (defaultValue != null) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("defaultValue"), defaultValue));
}
AnnotationMetadataBuilder paramAnnotationBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM, annotationAttributes);
return new AnnotatedJavaType(paramType, paramAnnotationBuilder.build());
}
示例9: createDateTimeRequestParam
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Creates a "RequestParam" annotated type including DateTimeFormat annotation for Date fields.
*
* @param paramType
* @param value (optional) "value" attribute value
* @param required (optional) attribute value
* @param defaultValue (optional) attribute value
* @param dateTimeFormatAnnotation DateTimeFormat annotation metadata from referred Date field
* @return
*/
public AnnotatedJavaType createDateTimeRequestParam(JavaType paramType,
String value, Boolean required, String defaultValue,
AnnotationMetadata dateTimeFormatAnnotation) {
// create annotation values
final List<AnnotationAttributeValue<?>> annotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
if (StringUtils.isNotBlank(value)) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("value"), value));
}
if (required != null) {
annotationAttributes.add(new BooleanAttributeValue(
new JavaSymbolName("required"), required.booleanValue()));
}
if (defaultValue != null) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("defaultValue"), defaultValue));
}
AnnotationMetadataBuilder paramAnnotationBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM, annotationAttributes);
return new AnnotatedJavaType(paramType, paramAnnotationBuilder.build(),
dateTimeFormatAnnotation);
}
示例10: addClass
import org.springframework.roo.model.SpringJavaType; //导入依赖的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 ");
}
}
示例11: RepositoryElasticsearchMetadata
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
*
* @param identifier
* @param aspectName
* @param governorPhysicalTypeMetadata
*/
protected RepositoryElasticsearchMetadata(String identifier, JavaType aspectName,
PhysicalTypeMetadata governorPhysicalTypeMetadata,
final RepositoryElasticsearchAnnotationValues annotationValues){
super(identifier, aspectName, governorPhysicalTypeMetadata);
Validate.notNull(annotationValues, "Annotation values required");
// Make the user's Repository interface extend Spring Data's Repository
// interface if it doesn't already.
ensureGovernorExtends(new JavaType(SPRING_DATA_REPOSITORY, 0,
DataType.TYPE, null, Arrays.asList(
annotationValues.getDomainType(), JavaType.STRING)));
builder.addAnnotation(getTypeAnnotation(SpringJavaType.REPOSITORY));
// Build the ITD.
itdTypeDetails = builder.build();
}
开发者ID:lbroudoux,项目名称:spring-roo-addon-layers-repository-elasticsearch,代码行数:25,代码来源:RepositoryElasticsearchMetadata.java
示例12: createDateTimeRequestParam
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* Creates a "RequestParam" annotated type including DateTimeFormat
* annotation for Date fields.
*
* @param paramType
* @param value (optional) "value" attribute value
* @param required (optional) attribute value
* @param defaultValue (optional) attribute value
* @param dateTimeFormatAnnotation DateTimeFormat annotation metadata from
* referred Date field
* @return
*/
public AnnotatedJavaType createDateTimeRequestParam(JavaType paramType,
String value, Boolean required, String defaultValue,
AnnotationMetadata dateTimeFormatAnnotation) {
// create annotation values
final List<AnnotationAttributeValue<?>> annotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
if (StringUtils.isNotBlank(value)) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("value"), value));
}
if (required != null) {
annotationAttributes.add(new BooleanAttributeValue(
new JavaSymbolName("required"), required.booleanValue()));
}
if (defaultValue != null) {
annotationAttributes.add(new StringAttributeValue(
new JavaSymbolName("defaultValue"), defaultValue));
}
AnnotationMetadataBuilder paramAnnotationBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM, annotationAttributes);
return new AnnotatedJavaType(paramType, paramAnnotationBuilder.build(),
dateTimeFormatAnnotation);
}
示例13: checkExistsDeleteBatchMethod
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* This method check if another delete method exists to the current
* controller
*
* @param governorTypeDetails
* @param parameterTypes
* @return
*/
private MethodMetadata checkExistsDeleteBatchMethod(
ClassOrInterfaceTypeDetails governorTypeDetails,
List<AnnotatedJavaType> parameterTypes) {
// Getting all methods
List<? extends MethodMetadata> methods = governorTypeDetails
.getDeclaredMethods();
Iterator<? extends MethodMetadata> it = methods.iterator();
while (it.hasNext()) {
MethodMetadata method = it.next();
// Getting request
AnnotationMetadata requestAnnotation = method
.getAnnotation(SpringJavaType.REQUEST_MAPPING);
if (requestAnnotation != null) {
// Getting request value
AnnotationAttributeValue<?> request = requestAnnotation
.getAttribute(new JavaSymbolName("value"));
if (request != null) {
String value = request.getValue().toString();
// Getting method parameterTypes
final List<JavaType> methodParameters = AnnotatedJavaType
.convertFromAnnotatedJavaTypes(method
.getParameterTypes());
// If method exists with same params, return method
String methodName = method.getMethodName().getSymbolName();
if ("/delete".equals(value)
&& AnnotatedJavaType.convertFromAnnotatedJavaTypes(
parameterTypes).equals(methodParameters)
&& !"deleteBatch".equals(methodName)) {
return method;
}
}
}
}
return null;
}
示例14: addMapViewerController
import org.springframework.roo.model.SpringJavaType; //导入依赖的package包/类
/**
* This method generates a new class annotated with @GvNIXMapViewer
*
* @param controller
* @param path
*/
public void addMapViewerController(JavaType controller,
JavaSymbolName path, ProjectionCRSTypes projection) {
// Getting all classes with @GvNIXMapViewer annotation
// and checking that not exists another with the specified path
for (JavaType mapViewer : getTypeLocationService()
.findTypesWithAnnotation(MAP_VIEWER_ANNOTATION)) {
Validate.notNull(mapViewer, "@GvNIXMapViewer required");
ClassOrInterfaceTypeDetails mapViewerController = getTypeLocationService()
.getTypeDetails(mapViewer);
// Getting RequestMapping annotations
final AnnotationMetadata requestMappingAnnotation = MemberFindingUtils
.getAnnotationOfType(mapViewerController.getAnnotations(),
SpringJavaType.REQUEST_MAPPING);
Validate.notNull(mapViewer, String.format(
"Error on %s getting @RequestMapping value", mapViewer));
String requestMappingPath = requestMappingAnnotation
.getAttribute(VALUE).getValue().toString();
// If exists some path like the selected, shows an error
String finalPath = String.format("/%s", path.toString());
if (finalPath.equals(requestMappingPath)) {
throw new RuntimeException(
String.format(
"ERROR. There's other class annotated with @GvNIXMapViewer and path \"%s\"",
finalPath));
}
}
// Create new class
createNewController(controller, generateJavaType(controller), path,
projection);
}
示例15: generatePathFromEntity
import org.springframework.roo.model.SpringJavaType; //导入依赖的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();
}