List of usage examples for java.lang.reflect Modifier PUBLIC
int PUBLIC
To view the source code for java.lang.reflect Modifier PUBLIC.
Click Source Link
From source file:org.gvnix.web.screen.roo.addon.AbstractPatternMetadata.java
protected MethodMetadata getRegisterMethod(String patternName) { // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("register" + patternName); // Define method parameter types // @RequestParam(value = "gvnixpattern", required = true) String // pattern, HttpServletRequest req, Model uiModel) List<AnnotatedJavaType> methodParamTypes = new ArrayList<AnnotatedJavaType>(); List<AnnotationAttributeValue<?>> reqParamAttrIndex = new ArrayList<AnnotationAttributeValue<?>>(); reqParamAttrIndex.add(new StringAttributeValue(VALUE_ATTRIBUTE_NAME, "index")); reqParamAttrIndex.add(new BooleanAttributeValue(new JavaSymbolName(REQUIRED_TXT), true)); List<AnnotationMetadata> methodAttrIndexAnnotations = new ArrayList<AnnotationMetadata>(); AnnotationMetadataBuilder methodAttrIndexAnnotation = new AnnotationMetadataBuilder( new JavaType(RQST_PARAM_PATH), reqParamAttrIndex); methodAttrIndexAnnotations.add(methodAttrIndexAnnotation.build()); methodParamTypes.add(new AnnotatedJavaType(JavaType.LONG_OBJECT, methodAttrIndexAnnotations)); methodParamTypes.add(getPatternRequestParam(true).getValue()); Entry<JavaSymbolName, AnnotatedJavaType> httpServletRequest = HTTP_SERVLET_REQUEST_PARAM; methodParamTypes.add(httpServletRequest.getValue()); Entry<JavaSymbolName, AnnotatedJavaType> modelRequestParam = MODEL_REQUEST_PARAM; methodParamTypes.add(modelRequestParam.getValue()); MethodMetadata method = methodExists(methodName, methodParamTypes); if (method != null) { // If it already exists, just return null and omit its // generation via the ITD return null; }/*from ww w .ja v a 2 s . c o m*/ // Define method parameter names // pattern, uiModel, httpServletRequest List<JavaSymbolName> methodParamNames = new ArrayList<JavaSymbolName>(); methodParamNames.add(new JavaSymbolName("index")); Entry<JavaSymbolName, AnnotatedJavaType> patternRequestParam = getPatternRequestParam(false); methodParamNames.add(patternRequestParam.getKey()); methodParamNames.add(httpServletRequest.getKey()); methodParamNames.add(modelRequestParam.getKey()); // Create method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); String entityNamePlural = entityTypeDetails.getPlural(); String entityName = uncapitalize(entity.getSimpleTypeName()); List<JavaType> typeParams = new ArrayList<JavaType>(); typeParams.add(entity); // Add date validation pattern to model if some date type field exists if (!entityDateTypes.isEmpty()) { bodyBuilder.appendFormalLine("addDateTimeFormatPatterns(uiModel);"); } // Check entity count bodyBuilder.appendFormalLine("// Check entity count"); bodyBuilder.appendFormalLine(JavaType.LONG_PRIMITIVE.getNameIncludingTypeParameters().concat(" count = ") .concat(entity.getSimpleTypeName()).concat(".") .concat(entityTypeDetails.getPersistenceDetails().getCountMethod().getMethodName()).concat("();")); bodyBuilder.appendFormalLine("if (count < 1) {"); bodyBuilder.indent(); bodyBuilder.appendFormalLine("// None register found"); bodyBuilder.appendFormalLine(ADD_ATTR.concat(entityName.toLowerCase()).concat("\", null);")); addBodyLinesForDialogMessage(bodyBuilder, DialogType.Info, "message_entitynotfound_problemdescription"); bodyBuilder.appendFormalLine( RETURN_TXT.concat(entityNamePlural.toLowerCase()).concat(CONCAT + GVNIXPATTERN + ");")); bodyBuilder.indentRemove(); bodyBuilder.appendFormalLine("}"); bodyBuilder.appendFormalLine(JavaType.LONG_PRIMITIVE.getNameIncludingTypeParameters() .concat(" curIndex = index == null ? 0 : index;")); bodyBuilder.appendFormalLine("// Check index"); bodyBuilder.appendFormalLine("if (curIndex > count) {"); bodyBuilder.indent(); bodyBuilder.appendFormalLine("curIndex = count;"); bodyBuilder.indentRemove(); bodyBuilder.appendFormalLine("}"); JavaType javaUtilList = new JavaType("java.util.List", 0, DataType.TYPE, null, typeParams); bodyBuilder.appendFormalLine(javaUtilList .getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver()).concat(" ") .concat(entityNamePlural.toLowerCase()).concat(" = ") .concat(entity.getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver())) .concat(".").concat(entityTypeDetails.getPersistenceDetails().getFindEntriesMethod().getMethodName() .concat("((int)curIndex -1, 1);"))); bodyBuilder.appendFormalLine("if (".concat(entityNamePlural.toLowerCase()).concat( ".isEmpty() && httpServletRequest.getSession().getAttribute(\"dialogMessage\") == null) {")); bodyBuilder.indent(); bodyBuilder.appendFormalLine(ADD_ATTR.concat(entityName.toLowerCase()).concat("\", null);")); addBodyLinesForDialogMessage(bodyBuilder, DialogType.Info, "message_entitynotfound_problemdescription"); bodyBuilder.appendFormalLine( RETURN_TXT.concat(entityNamePlural.toLowerCase()).concat(CONCAT + GVNIXPATTERN + ");")); bodyBuilder.indentRemove(); bodyBuilder.appendFormalLine("}"); bodyBuilder.appendFormalLine(entity.getSimpleTypeName().concat(" ").concat(entityName.toLowerCase()) .concat(" = ").concat(entityNamePlural.toLowerCase()).concat(".get(0);")); bodyBuilder.appendFormalLine(ADD_ATTR.concat(entityName.toLowerCase()).concat(QUOTE_COMMA) .concat(entityName.toLowerCase()).concat(");")); bodyBuilder.appendFormalLine("uiModel.addAttribute(\"maxEntities".concat("\", count);")); bodyBuilder.appendFormalLine("uiModel.addAttribute(\"index".concat("\", curIndex);")); // May we need to populate some Model Attributes with the data of // related entities addBodyLinesPopulatingRelatedEntitiesData(bodyBuilder); // Add date validation pattern to model if some date type field exists addBodyLinesRegisteringRelatedEntitiesDateTypesFormat(bodyBuilder); bodyBuilder.appendFormalLine( RETURN_TXT.concat(entityNamePlural.toLowerCase()).concat(CONCAT + GVNIXPATTERN + ");")); MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.STRING, methodParamTypes, methodParamNames, bodyBuilder); // Get Method RequestMapping annotation List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>(); List<AnnotationAttributeValue<? extends Object>> paramValues = new ArrayList<AnnotationAttributeValue<? extends Object>>(); paramValues.add(getPatternParamRequestMapping(patternName)); paramValues.add(new StringAttributeValue(new JavaSymbolName("ignored"), "gvnixform")); paramValues.add(new StringAttributeValue(VALUE_ATTRIBUTE_NAME, "!find")); requestMappingAttributes.add(new ArrayAttributeValue<AnnotationAttributeValue<? extends Object>>( PARAMS_ATTRIBUTE_NAME, paramValues)); requestMappingAttributes.add(getMethodRequestMapping(RequestMethod.GET)); requestMappingAttributes.add(PRODUCES_PARAM_MAPPING); AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(RQST_MAP_ANN_TYPE, requestMappingAttributes); List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(requestMapping); methodBuilder.setAnnotations(annotations); method = methodBuilder.build(); controllerMethods.add(method); return method; }
From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java
/** * Return method <code>renderUpdateForms</code> * /*from ww w. j ava 2 s. c o m*/ * @return */ private MethodMetadata getRenderUpdateFormsMethod() { // method name JavaSymbolName methodName = RENDER_UPDATE_FORMS_METHOD; // Define method parameter types final List<AnnotatedJavaType> parameterTypes = Arrays.asList( AnnotatedJavaType.convertFromJavaType(entityListType), AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_REQUEST), AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_RESPONSE)); // Check if a method exist in type final MethodMetadata method = methodExists(methodName, parameterTypes); if (method != null) { // If it already exists, just return the method return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); throwsTypes.add(SERVLET_EXCEPTION); throwsTypes.add(IO_EXCEPTION); // Define method parameter names (none in this case) List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName(entityList)); parameterNames.add(REQUEST_PARAM_NAME); parameterNames.add(RESPONSE_PARAM_NAME); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildRenderUpdateFormsMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, LIST_MAP_STRING_STRING, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.addon.web.mvc.addon.batch.WebJpaBatchMetadata.java
/** * Gets <code>getRequestPropertyValues</code> method. <br> * This method returns a Map with bean properties which appears on a String * Iterator (usually from webRequest.getParametersNames()) * //from w w w . java 2 s. co m * @return */ private MethodMetadata getGetRequestPropertyValuesMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(entity, ITERATOR_STRING); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(GET_REQUEST_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>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName(entityName)); parameterNames.add(new JavaSymbolName("propertyNames")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildGetRequestPropertyValuesBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, GET_REQUEST_METHOD, MAP_STRING_OBJECT, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java
/** * Gets <code>renderXXX</code> method. <br> * This method renders the required jspx for item an store it in a List of * Map(String,String)/*ww w. ja va2 s . c o m*/ * * @return */ private MethodMetadata getRenderItemsMethod() { JavaType entitySearchResult = new JavaType(SEARCH_RESULTS.getFullyQualifiedTypeName(), 0, DataType.TYPE, null, Arrays.asList(entity)); // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(entitySearchResult, HTTP_SERVLET_REQUEST, HTTP_SERVLET_RESPONSE); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(renderItemsMethodName, 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>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); throwsTypes.add(SERVLET_EXCEPTION); throwsTypes.add(IO_EXCEPTION); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("searchResult")); parameterNames.add(REQUEST_PARAM_NAME); parameterNames.add(RESPONSE_PARAM_NAME); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildRenderItemsMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, renderItemsMethodName, LIST_MAP_STRING_STRING, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.addon.web.mvc.addon.batch.WebJpaBatchMetadata.java
/** * Gets <code>getRequestPropertyValues</code> method. <br> * This method returns a Map with bean properties which appears on a String * Iterator (usually from webRequest.getParametersNames()) * /*w ww. j a v a2s . c o m*/ * @return */ private MethodMetadata getGetOIDListMethod() { JavaSymbolName methodName = GET_OID_LIST_METHOD; // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(listOfEntityType); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(methodName, 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>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(listOfEntityName); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildGetOIDListBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, LIST_STRING, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderMetadata.java
/** * Gets all getters methods. <br>/* w w w . j ava 2 s . co m*/ * * @return */ private MethodMetadata getGetterMethod(String propertyName, JavaType returnType) { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Check if a method with the same signature already exists in the // target type JavaSymbolName propertyMethodName = new JavaSymbolName( "get".concat(Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1))); final MethodMetadata method = methodExists(propertyMethodName, 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>(); // Define method throws types List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildGetterMethodBody(bodyBuilder, propertyName); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, propertyMethodName, returnType, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.web.screen.roo.addon.AbstractPatternMetadata.java
/** * Generates the MethodMedata of createList() method for ITD * //from ww w .j a v a 2 s . co m * @return */ protected MethodMetadata getCreateListMethod() { // Here we're sure that Entity.createList() method exists // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("createList"); // Define method annotations List<AnnotationAttributeValue<?>> requestMappingAttributes = getRequestMappingAttributes( RequestMethod.POST); // Define method parameter types List<AnnotatedJavaType> methodParamTypes = getMethodParameterTypes(); // Check if a method with the same signature already exists in the // target type MethodMetadata method = methodExists(methodName, methodParamTypes); if (method != null) { // If it already exists, just return null and omit its // generation via the ITD return null; } // Define method parameter names List<JavaSymbolName> methodParamNames = getMethodParameterNames(); // Create method body InvocableMemberBodyBuilder bodyBuilder = getMethodBodyBuilderBinding(PersistenceMethod.PERSIST); MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.STRING, methodParamTypes, methodParamNames, bodyBuilder); // Get Method RequestMapping annotation AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(RQST_MAP_ANN_TYPE, requestMappingAttributes); List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(requestMapping); methodBuilder.setAnnotations(annotations); method = methodBuilder.build(); controllerMethods.add(method); return method; }
From source file:org.gvnix.web.screen.roo.addon.AbstractPatternMetadata.java
/** * Generates the MethodMedata of updateList() method for ITD * /* w ww . j a va2s.c o m*/ * @return */ protected MethodMetadata getUpdateListMethod() { // Here we're sure that Entity.updateList() method exists // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("updateList"); // Define method annotations List<AnnotationAttributeValue<?>> requestMappingAttributes = getRequestMappingAttributes(RequestMethod.PUT); // Define method parameter types List<AnnotatedJavaType> methodParamTypes = getMethodParameterTypes(); // Check if a method with the same signature already exists in the // target type MethodMetadata method = methodExists(methodName, methodParamTypes); if (method != null) { // If it already exists, just return null and omit its // generation via the ITD return null; } // Define method parameter names List<JavaSymbolName> methodParamNames = getMethodParameterNames(); // Create method body InvocableMemberBodyBuilder bodyBuilder = getMethodBodyBuilderBinding(PersistenceMethod.MERGE); MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.STRING, methodParamTypes, methodParamNames, bodyBuilder); // Get Method RequestMapping annotation AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(RQST_MAP_ANN_TYPE, requestMappingAttributes); List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(requestMapping); methodBuilder.setAnnotations(annotations); method = methodBuilder.build(); controllerMethods.add(method); return method; }
From source file:org.gvnix.addon.web.mvc.addon.batch.WebJpaBatchMetadata.java
/** * Create metadata for auto-wired convertionService field. * //from w ww.j a v a2 s. c o m * @return a FieldMetadata object */ public FieldMetadata getConversionServiceField() { if (conversionService == null) { JavaSymbolName curName = new JavaSymbolName("conversionService_batch"); // Check if field exist FieldMetadata currentField = governorTypeDetails.getDeclaredField(curName); if (currentField != null && !isConversionServiceField(currentField)) { // No compatible field: look for new name currentField = null; JavaSymbolName newName = new JavaSymbolName("conversionService_batch_"); currentField = governorTypeDetails.getDeclaredField(newName); while (currentField != null && !isConversionServiceField(currentField)) { newName = new JavaSymbolName(newName.getSymbolName().concat("_")); currentField = governorTypeDetails.getDeclaredField(newName); } curName = newName; } if (currentField != null) { conversionService = currentField; } else { // create field List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(1); annotations.add(new AnnotationMetadataBuilder(AUTOWIRED)); // Using the FieldMetadataBuilder to create the field // definition. final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(getId(), Modifier.PUBLIC, annotations, curName, // Field CONVERSION_SERVICE); // Field type conversionService = fieldBuilder.build(); // Build and return a // FieldMetadata // instance } } return conversionService; }
From source file:org.gvnix.web.screen.roo.addon.AbstractPatternMetadata.java
/** * Generates the MethodMedata of deleteList() method for ITD * /*from w w w . ja v a 2 s. c o m*/ * @return */ protected MethodMetadata getDeleteListMethod() { // Here we're sure that Entity.deleteList() method exists // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("deleteList"); // Define method annotations List<AnnotationAttributeValue<?>> requestMappingAttributes = getRequestMappingAttributes( RequestMethod.DELETE); // Define method parameter types List<AnnotatedJavaType> methodParamTypes = getMethodParameterTypes(); // Check if a method with the same signature already exists in the // target type MethodMetadata method = methodExists(methodName, methodParamTypes); if (method != null) { // If it already exists, just return null and omit its // generation via the ITD return null; } // Define method parameter names List<JavaSymbolName> methodParamNames = getMethodParameterNames(); // Create method body InvocableMemberBodyBuilder bodyBuilder = getMethodBodyBuilder(PersistenceMethod.REMOVE); MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.STRING, methodParamTypes, methodParamNames, bodyBuilder); // Get Method RequestMapping annotation AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(RQST_MAP_ANN_TYPE, requestMappingAttributes); List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(requestMapping); methodBuilder.setAnnotations(annotations); method = methodBuilder.build(); controllerMethods.add(method); return method; }