本文整理汇总了Java中org.springframework.roo.model.SpringJavaType.REQUEST_MAPPING属性的典型用法代码示例。如果您正苦于以下问题:Java SpringJavaType.REQUEST_MAPPING属性的具体用法?Java SpringJavaType.REQUEST_MAPPING怎么用?Java SpringJavaType.REQUEST_MAPPING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.roo.model.SpringJavaType
的用法示例。
在下文中一共展示了SpringJavaType.REQUEST_MAPPING属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewType
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());
}
示例2: getShowMapMethod
/**
* Gets <code>showMap</code> method. <br>
*
* @return
*/
private MethodMetadata getShowMapMethod(String path) {
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
parameterTypes.add(new AnnotatedJavaType(SpringJavaType.MODEL));
parameterTypes.add(new AnnotatedJavaType(new JavaType(
"javax.servlet.http.HttpServletRequest")));
// Check if a method with the same signature already exists in the
// target type
final MethodMetadata method = methodExists(SHOW_MAP_METHOD,
parameterTypes);
if (method != null) {
// If it already exists, just return the method and omit its
// generation via the ITD
return method;
}
// Define method annotations
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
AnnotationMetadataBuilder requestMappingMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
requestMappingMetadataBuilder.addEnumAttribute("method",
SpringJavaType.REQUEST_METHOD, "GET");
requestMappingMetadataBuilder.addStringAttribute("produces",
"text/html");
annotations.add(requestMappingMetadataBuilder);
// Define method throws types
List<JavaType> throwsTypes = new ArrayList<JavaType>();
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(UIMODEL_PARAM_NAME);
parameterNames.add(new JavaSymbolName("request"));
// Create the method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
buildShowMapMethodBody(bodyBuilder, path);
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC, SHOW_MAP_METHOD, JavaType.STRING,
parameterTypes, parameterNames, bodyBuilder);
methodBuilder.setAnnotations(annotations);
methodBuilder.setThrowsTypes(throwsTypes);
return methodBuilder.build(); // Build and return a MethodMetadata
// instance
}
示例3: getShowOnlyListMethod
/**
* Gets <code>showOnlyList</code> method. <br>
*
* @return
*/
private MethodMetadata getShowOnlyListMethod(String plural) {
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
parameterTypes.add(AnnotatedJavaType
.convertFromJavaType(SpringJavaType.MODEL));
parameterTypes.add(AnnotatedJavaType.convertFromJavaType(new JavaType(
"javax.servlet.http.HttpServletRequest")));
// @RequestParam("path") String listPath
AnnotationMetadataBuilder listPathAnnotation = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM);
listPathAnnotation.addStringAttribute("value", "path");
parameterTypes.add(new AnnotatedJavaType(JavaType.STRING,
listPathAnnotation.build()));
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName("uiModel"));
parameterNames.add(new JavaSymbolName("request"));
parameterNames.add(new JavaSymbolName("listPath"));
// Check if a method with the same signature already exists in the
// target type
final MethodMetadata method = methodExists(SHOW_ONLY_LIST,
parameterTypes);
if (method != null) {
// If it already exists, just return the method and omit its
// generation via the ITD
return method;
}
// Define method annotations
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
AnnotationMetadataBuilder requestMappingMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
// @RequestMapping(params = "selector", produces = "text/html")
requestMappingMetadataBuilder.addStringAttribute("params",
"mapselector");
requestMappingMetadataBuilder.addStringAttribute("produces",
"text/html");
annotations.add(requestMappingMetadataBuilder);
// Define method throws types
List<JavaType> throwsTypes = new ArrayList<JavaType>();
// Create the method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
buildShowOnlyListMethodBody(plural, bodyBuilder);
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC, SHOW_ONLY_LIST, JavaType.STRING,
parameterTypes, parameterNames, bodyBuilder);
methodBuilder.setAnnotations(annotations);
methodBuilder.setThrowsTypes(throwsTypes);
return methodBuilder.build(); // Build and return a MethodMetadata
// instance
}
示例4: getCreateLoginMethod
/**
* Gets <code>getAttemptAuthentication</code> method. <br>
*
* @return
*/
private MethodMetadata getCreateLoginMethod() {
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType
.convertFromJavaTypes(SpringJavaType.MODEL);
// Check if a method with the same signature already exists in the
// target type
final MethodMetadata method = methodExists(CREATE_LOGIN_METHOD,
parameterTypes);
if (method != null) {
// If it already exists, just return the method and omit its
// generation via the ITD
return method;
}
// Define method annotations
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
AnnotationMetadataBuilder requestMappingAnnotation = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
requestMappingAnnotation.addStringAttribute("value", "/login");
requestMappingAnnotation
.addEnumAttribute(
"method",
new JavaType(
"org.springframework.web.bind.annotation.RequestMethod"),
"GET");
annotations.add(requestMappingAnnotation);
// Define method throws types
List<JavaType> throwsTypes = new ArrayList<JavaType>();
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName("uiModel"));
// Create the method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
buildCreateLoginMethodBody(bodyBuilder);
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC, CREATE_LOGIN_METHOD, JavaType.STRING,
parameterTypes, parameterNames, bodyBuilder);
methodBuilder.setAnnotations(annotations);
methodBuilder.setThrowsTypes(throwsTypes);
return methodBuilder.build(); // Build and return a MethodMetadata
// instance
}
示例5: getShowOnlyListMethod
/**
* Gets <code>showOnlyList</code> method. <br>
*
* @return
*/
private MethodMetadata getShowOnlyListMethod(JavaType entity) {
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType
.convertFromJavaTypes(new JavaType(
"org.springframework.ui.Model"), new JavaType(
"javax.servlet.http.HttpServletRequest"));
AnnotationMetadataBuilder pathMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_PARAM);
pathMetadataBuilder.addStringAttribute(VALUE_LABEL, "path");
parameterTypes.add(new AnnotatedJavaType(JavaType.STRING,
pathMetadataBuilder.build()));
// Check if a method with the same signature already exists in the
// target type
final MethodMetadata method = methodExists(SHOW_ONLY_METHOD_NAME,
parameterTypes);
if (method != null) {
// If it already exists, just return the method and omit its
// generation via the ITD
return method;
}
// Define method annotations
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
AnnotationMetadataBuilder requestMappingMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
requestMappingMetadataBuilder.addStringAttribute("params", "selector");
requestMappingMetadataBuilder.addStringAttribute("produces",
"text/html");
annotations.add(requestMappingMetadataBuilder);
// Define method throws types
List<JavaType> throwsTypes = new ArrayList<JavaType>();
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName("uiModel"));
parameterNames.add(new JavaSymbolName("request"));
parameterNames.add(new JavaSymbolName("listPath"));
// Create the method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
buildShowOnlyListMethodBody(bodyBuilder, entity);
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC, SHOW_ONLY_METHOD_NAME,
JavaType.STRING, parameterTypes, parameterNames, bodyBuilder);
methodBuilder.setAnnotations(annotations);
methodBuilder.setThrowsTypes(throwsTypes);
return methodBuilder.build(); // Build and return a MethodMetadata
// instance
}
示例6: getListGeoEntityOnMapViewerMethod
/**
* Gets <code>listGeoEntityOnMapViewer</code> method. <br>
*
* @return
*/
private MethodMetadata getListGeoEntityOnMapViewerMethod(JavaType entity,
String plural) {
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
// Adding bbox param
AnnotationMetadataBuilder bboxParamMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_BODY);
bboxParamMetadataBuilder.addBooleanAttribute("required", false);
parameterTypes.add(new AnnotatedJavaType(JavaType.STRING,
bboxParamMetadataBuilder.build()));
// Check if a method with the same signature already exists in the
// target type
final MethodMetadata method = methodExists(
LIST_GEO_ENTITY_ON_MAP_VIEWER, parameterTypes);
if (method != null) {
// If it already exists, just return the method and omit its
// generation via the ITD
return method;
}
// Define method annotations
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
AnnotationMetadataBuilder requestMappingMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.REQUEST_MAPPING);
requestMappingMetadataBuilder.addStringAttribute("params",
"entityMapList");
requestMappingMetadataBuilder.addStringAttribute("headers",
"Accept=application/json");
requestMappingMetadataBuilder.addStringAttribute("produces",
"application/json");
requestMappingMetadataBuilder.addStringAttribute("consumes",
"application/json");
AnnotationMetadataBuilder responseBodyMetadataBuilder = new AnnotationMetadataBuilder(
SpringJavaType.RESPONSE_BODY);
annotations.add(requestMappingMetadataBuilder);
annotations.add(responseBodyMetadataBuilder);
// Define method throws types
List<JavaType> throwsTypes = new ArrayList<JavaType>();
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName("mapBoundingBox"));
// Create the method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
buildlistGeoEntityOnMapViewerMethodBody(entity, plural, bodyBuilder);
// Return type
JavaType responseEntityJavaType = new JavaType(
SpringJavaType.RESPONSE_ENTITY.getFullyQualifiedTypeName(), 0,
DataType.TYPE, null, Arrays.asList(new JavaType(
"java.util.List", 0, DataType.TYPE, null, Arrays
.asList(entity))));
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC, LIST_GEO_ENTITY_ON_MAP_VIEWER,
responseEntityJavaType, parameterTypes, parameterNames,
bodyBuilder);
methodBuilder.setAnnotations(annotations);
methodBuilder.setThrowsTypes(throwsTypes);
return methodBuilder.build(); // Build and return a MethodMetadata
// instance
}