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.addon.datatables.addon.DatatablesMetadata.java
/** * Returns <code>listDatatables</code> method <br> * This method is default list request handler for datatables controllers * //from ww w . jav a2 s . co m * @return */ private MethodMetadata getListDatatablesRequestMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(MODEL, HTTP_SERVLET_REQUEST); if (!isAjax()) { // In DOM mode we include Item in parameters to use // spring's binder to get baseFilter values parameterTypes .add(new AnnotatedJavaType(entity, new AnnotationMetadataBuilder(MODEL_ATTRIBUTE).build())); } // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(LIST_DATATABLES, 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>(); // @RequestMapping AnnotationMetadataBuilder methodAnnotation = new AnnotationMetadataBuilder(); methodAnnotation.setAnnotationType(REQUEST_MAPPING); // @RequestMapping(method = RequestMethod.GET... methodAnnotation.addEnumAttribute(METHOD_VAR, REQUEST_METHOD, "GET"); // @RequestMapping(... produces = "text/html") methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_PROD_NAME, DatatablesConstants.RQST_MAP_ANN_VAL_HTML); annotations.add(methodAnnotation); // 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(UI_MODEL); parameterNames.add(new JavaSymbolName(DatatablesConstants.REQUEST_PARAMETER_NAME)); if (!isAjax()) { // In DOM mode we include Item in parameters to use // spring's binder to get baseFilter values parameterNames.add(new JavaSymbolName(entityName)); } // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); if (isAjax()) { buildListDatatablesRequesMethodAjaxBody(bodyBuilder); } else { buildListDatatablesRequesMethodDomBody(bodyBuilder); } // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, LIST_DATATABLES, JavaType.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.datatables.addon.DatatablesMetadata.java
/** * Redefines {@code list} Roo webScaffod method to delegate on * {@link #LIST_DATATABLES}/*from w w w. j a v a 2 s . c om*/ * * @return */ private MethodMetadata getListRooRequestMethod() { // public String OwnerController.list( // @RequestParam(value = "page", required = false) Integer page, // @RequestParam(value = "size", required = false) Integer size, /** Added on 1.2.6.RELEASE Roo Version */ // @RequestParam(value = "sortFieldName", required = false) String // sortFieldName, // @RequestParam(value = "sortOrder", required = false) String sortOrder /** Added on 1.2.6.RELEASE Roo Version */ // Model uiModel) { // Define method parameter types final List<AnnotatedJavaType> parameterTypes = Arrays.asList( helper.createRequestParam(JavaType.INT_OBJECT, PAGE_VAR, false, null), helper.createRequestParam(JavaType.INT_OBJECT, SIZE_VAR, false, null), helper.createRequestParam(JavaType.STRING, SORT_FIELD_NAME, false, null), helper.createRequestParam(JavaType.STRING, SORT_ORDER, false, null), new AnnotatedJavaType(MODEL)); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(LIST_ROO, 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>(); // @RequestMapping(produces = "text/html") annotations.add(helper.getRequestMappingAnnotation(null, null, null, DatatablesConstants.RQST_MAP_ANN_VAL_HTML, null, null)); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names final List<JavaSymbolName> parameterNames = Arrays.asList(new JavaSymbolName(PAGE_VAR), new JavaSymbolName(SIZE_VAR), new JavaSymbolName(SORT_FIELD_NAME), new JavaSymbolName(SORT_ORDER), UI_MODEL); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("// overrides the standard Roo list method and"); bodyBuilder.appendFormalLine("// delegates on datatables list method"); // return listDatatables(uiModel); if (isAjax()) { bodyBuilder .appendFormalLine(String.format("return %s(uiModel, null);", LIST_DATATABLES.getSymbolName())); } else { bodyBuilder.appendFormalLine( String.format("return %s(uiModel, null, null);", LIST_DATATABLES.getSymbolName())); } // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, LIST_ROO, JavaType.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.datatables.addon.DatatablesMetadata.java
/** * Returns <code>findAllMethod</code> method <br> * This method handles datatables AJAX request for data which are no related * to a Roo Dynamic finder./*from ww w . j a v a 2 s . co m*/ * * @return */ private MethodMetadata getFindAllMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(new AnnotatedJavaType(DATATABLES_CRITERIA_TYPE, new AnnotationMetadataBuilder(DATATABLES_PARAMS).build())); parameterTypes.add(new AnnotatedJavaType(entity, new AnnotationMetadataBuilder(MODEL_ATTRIBUTE).build())); parameterTypes.addAll(AnnotatedJavaType.convertFromJavaTypes(HTTP_SERVLET_REQUEST)); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(findAllMethodName, 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 methodAnnotation = new AnnotationMetadataBuilder(); methodAnnotation.setAnnotationType(REQUEST_MAPPING); methodAnnotation.addStringAttribute(HEADERS, ACCEPT_APPLICATION_JSON); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_VAL_NAME, "/datatables/ajax"); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_PROD_NAME, APPLICATION_JSON); annotations.add(methodAnnotation); annotations.add(new AnnotationMetadataBuilder(RESPONSE_BODY)); // 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(CRITERIA_PARAM_NAME); parameterNames.add(new JavaSymbolName(StringUtils.uncapitalize(entityName))); parameterNames.add(REQUEST_PARAM_NAME); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildFindAllDataMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, findAllMethodName, FIND_ALL_RETURN, 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
/** * Returns <code>findAll</code> method for render-a-view visualization mode. <br> * This method handles datatables AJAX request for data which are no related * to a Roo Dynamic finder.//w ww . j a v a 2s . co m * * @return */ private MethodMetadata getFindAllMethodRenderMode() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(new AnnotatedJavaType(DATATABLES_CRITERIA_TYPE, new AnnotationMetadataBuilder(DATATABLES_PARAMS).build())); parameterTypes.add(new AnnotatedJavaType(entity, new AnnotationMetadataBuilder(MODEL_ATTRIBUTE).build())); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_REQUEST)); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_RESPONSE)); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(findAllMethodName, 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 methodAnnotation = new AnnotationMetadataBuilder(); methodAnnotation.setAnnotationType(REQUEST_MAPPING); methodAnnotation.addStringAttribute(HEADERS, ACCEPT_APPLICATION_JSON); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_VAL_NAME, "/datatables/ajax"); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_PROD_NAME, APPLICATION_JSON); annotations.add(methodAnnotation); annotations.add(new AnnotationMetadataBuilder(RESPONSE_BODY)); // 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(CRITERIA_PARAM_NAME); parameterNames.add(new JavaSymbolName(StringUtils.uncapitalize(entityName))); parameterNames.add(REQUEST_PARAM_NAME); parameterNames.add(RESPONSE_PARAM_NAME); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildFindAllMethodBodyRenderMode(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, findAllMethodName, FIND_ALL_RETURN, 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
/** * Create metadata for auto-wired convertionService field. * //from w w w .j av a2s . c om * @return a FieldMetadata object */ public FieldMetadata getConversionServiceField() { if (conversionService == null) { JavaSymbolName curName = new JavaSymbolName("conversionService_dtt"); // 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_dt"); 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.addon.datatables.addon.DatatablesMetadata.java
/** * Create metadata for auto-wired messageSource field. * // w ww.j a v a2 s . c o m * @return a FieldMetadata object */ public FieldMetadata getMessageSourceField() { if (messageSource == null) { JavaSymbolName curName = new JavaSymbolName("messageSource_dtt"); // Check if field exist FieldMetadata currentField = governorTypeDetails.getDeclaredField(curName); if (currentField != null && !isMessageSourceField(currentField)) { // No compatible field: look for new name currentField = null; JavaSymbolName newName = new JavaSymbolName("messageSource_dt"); currentField = governorTypeDetails.getDeclaredField(newName); while (currentField != null && !isConversionServiceField(currentField)) { newName = new JavaSymbolName(newName.getSymbolName().concat("_")); currentField = governorTypeDetails.getDeclaredField(newName); } curName = newName; } if (currentField != null) { messageSource = 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 MESSAGE_SOURCE); // Field type messageSource = fieldBuilder.build(); // Build and return a // FieldMetadata // instance } } return messageSource; }
From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java
/** * Create metadata for DatatablesUtilsBean field. * /*from w ww . j av a 2 s. com*/ * @return a FieldMetadata object */ public FieldMetadata getDatatablesUtilsBean() { if (datatablesUtilsBean == null) { JavaSymbolName curName = new JavaSymbolName("datatablesUtilsBean_dtt"); // Check if field exist FieldMetadata currentField = governorTypeDetails.getDeclaredField(curName); if (currentField != null && !isDatatablesUtilsBean(currentField)) { // No compatible field: look for new name currentField = null; JavaSymbolName newName = new JavaSymbolName("datatablesUtilsBean_dt"); currentField = governorTypeDetails.getDeclaredField(newName); while (currentField != null && !isDatatablesUtilsBean(currentField)) { newName = new JavaSymbolName(newName.getSymbolName().concat("_")); currentField = governorTypeDetails.getDeclaredField(newName); } curName = newName; } if (currentField != null) { datatablesUtilsBean = 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 DATATABLES_UTILS_BEAN); // Field type datatablesUtilsBean = fieldBuilder.build(); // Build and // return a // FieldMetadata // instance } } return datatablesUtilsBean; }
From source file:gov.nih.nci.security.dao.AuthorizationDAOImpl.java
public Object secureObject(String userName, Object obj) throws CSException { Object o = null;//from ww w . j a v a2 s . com if (StringUtilities.isBlank(userName)) { throw new CSException("No user name have been supplied!"); } if (obj == null) { return obj; } Field[] fields = obj.getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (fields[i].getType().isPrimitive()) throw new CSException("The Object to be secured does not follow Java Bean Specification"); } try { Class cl = obj.getClass(); log.debug(cl.getName()); ObjectAccessMap accessMap = this.getObjectAccessMap(cl.getName(), userName, "READ"); log.debug(accessMap.toString()); o = cl.newInstance(); Method methods[] = cl.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; String name = m.getName(); //log.debug("Name from outer block"+name); //log.debug("Para type"+m.getParameterTypes()); if (name.startsWith("set") && (m.getModifiers() == Modifier.PUBLIC)) { String att = name.substring(3, name.length()); String methodName = "get" + att; //log.debug(methodName); Method m2 = cl.getMethod(methodName, (Class[]) null); //log.debug("Method Name m2"+m2.getName()); //log.debug(m2.invoke(obj,null)); if (!accessMap.hasAccess(att)) { m.invoke(o, new Object[] { null }); } else { m.invoke(o, new Object[] { m2.invoke(obj, (Object[]) null) }); } } } } catch (Exception ex) { if (log.isDebugEnabled()) log.debug("Authorization||" + userName + "|secureObject|Failure|Error in Secure Object|" + ex.getMessage()); throw new CSException("Failed to secure the object:" + ex.getMessage(), ex); } return o; }
From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java
/** * Create metadata for QuerydslUtilsBean field * /* w w w .j a va 2 s. co m*/ * @return FieldMetadata */ public FieldMetadata getQuerydslUtilsBean() { if (querydslUtilsBean == null) { JavaSymbolName curName = new JavaSymbolName("querydslUtilsBean_dtt"); // Check if field exist FieldMetadata currentField = governorTypeDetails.getDeclaredField(curName); if (currentField != null && !isQuerydslUtilsBean(currentField)) { // No compatible field: look for new name currentField = null; JavaSymbolName newName = new JavaSymbolName("querydslUtilsBean_dt"); currentField = governorTypeDetails.getDeclaredField(newName); while (currentField != null && !isQuerydslUtilsBean(currentField)) { newName = new JavaSymbolName(newName.getSymbolName().concat("_")); currentField = governorTypeDetails.getDeclaredField(newName); } curName = newName; } if (currentField != null) { querydslUtilsBean = 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 QUERYDSL_UTILS_BEAN); // Field type querydslUtilsBean = fieldBuilder.build(); // Build and return // a // FieldMetadata // instance } } return querydslUtilsBean; }
From source file:gov.nih.nci.security.dao.AuthorizationDAOImpl.java
public Collection secureCollection(String userName, Collection collection) throws CSException { ArrayList result = new ArrayList(); if (collection.size() == 0) { return collection; }/* w w w. ja va2 s. c o m*/ if (StringUtilities.isBlank(userName)) { throw new CSException("No userName have been supplied!"); } try { Iterator it = collection.iterator(); List l = (List) collection; Object obj_ = (Object) l.get(0); Class cl = obj_.getClass(); log.debug(cl.getName()); ObjectAccessMap accessMap = this.getObjectAccessMap(cl.getName(), userName, "READ"); while (it.hasNext()) { Object obj = (Object) it.next(); Object o = cl.newInstance(); Method methods[] = cl.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; String name = m.getName(); //log.debug("Name from outer block"+name); //log.debug("Para type"+m.getParameterTypes()); if (name.startsWith("set") && (m.getModifiers() == Modifier.PUBLIC)) { String att = name.substring(3, name.length()); String methodName = "get" + att; //log.debug(methodName); Method m2 = cl.getMethod(methodName, (Class[]) null); //log.debug("Method Name m2"+m2.getName()); //log.debug(m2.invoke(obj,null)); if (!accessMap.hasAccess(att)) { m.invoke(o, new Object[] { null }); } else { m.invoke(o, new Object[] { m2.invoke(obj, (Object[]) null) }); } } } result.add(o); } } catch (Exception ex) { if (log.isDebugEnabled()) log.debug("Authorization||" + userName + "|secureCollection|Failure|Error in Secure Collection|" + ex.getMessage()); throw new CSException("Failed to secure Collection:" + ex.getMessage(), ex); } return result; }