@Override public void afterPropertiesSet() throws Exception { beanContext = new BackendBeanContext(beanFactory); BeanContextBean.getInstance().setBeanContext(beanContext); VenusBeanUtilsBean.setInstance(new BackendBeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean(), beanContext)); AthenaExtensionResolver.getInstance().resolver(); CodeMapScanner.getCodeMap(); List<ServiceConfig> serviceConfigList = new ArrayList<ServiceConfig>(); Map<String, InterceptorMapping> interceptors = new HashMap<String, InterceptorMapping>(); Map<String, InterceptorStackConfig> interceptorStacks = new HashMap<String, InterceptorStackConfig>(); loadVenusService(serviceConfigList, interceptors, interceptorStacks); loadMonitorService(interceptors, interceptorStacks); loadRegistryService(interceptors, interceptorStacks); initMonitor(serviceConfigList, interceptors, interceptorStacks); }
public static void configureConvertUtilsBean( ConvertUtilsBean convertUtilsBean, ResourceBundle resourceBundle) { convertUtilsBean.register(new QualquerObjetoParaString(resourceBundle), String.class); convertUtilsBean.register(new StringParaDataConverter(resourceBundle), Date.class); convertUtilsBean.register( new StringParaNumberConverter(resourceBundle), Double.class); convertUtilsBean.register( new StringParaNumberConverter(resourceBundle), Float.class); convertUtilsBean.register( new StringParaNumberConverter(resourceBundle), Integer.class); convertUtilsBean.register( new StringParaNumberConverter(resourceBundle), Long.class); convertUtilsBean.register( new StringParaNumberConverter(resourceBundle), Short.class); convertUtilsBean.register( new CollectionParaSetConverter(resourceBundle), Set.class); convertUtilsBean.register(new CollectionParaListConverter( resourceBundle), List.class); }
public static void registerConverters(ConvertUtilsBean convertUtils,String[] datePatterns) { convertUtils.register(new StringConverter(), String.class); //date convertUtils.register(ConvertRegisterHelper.setPatterns(new DateConverter(null),datePatterns),java.util.Date.class); convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlDateConverter(null),datePatterns),java.sql.Date.class); convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlTimeConverter(null),datePatterns),Time.class); convertUtils.register(ConvertRegisterHelper.setPatterns(new SqlTimestampConverter(null),datePatterns),Timestamp.class); //number convertUtils.register(new BooleanConverter(null), Boolean.class); convertUtils.register(new ShortConverter(null), Short.class); convertUtils.register(new IntegerConverter(null), Integer.class); convertUtils.register(new LongConverter(null), Long.class); convertUtils.register(new FloatConverter(null), Float.class); convertUtils.register(new DoubleConverter(null), Double.class); convertUtils.register(new BigDecimalConverter(null), BigDecimal.class); convertUtils.register(new BigIntegerConverter(null), BigInteger.class); }
public CsvReaderDataSource getFileDataSource(int csvVersion, DaTable table, String content, char dataDelimiter, String nullToken, Function<String, String> convertDbObjectName) { CsvReaderDataSource fileSource = new CsvReaderDataSource(csvVersion, "fileSource", new StringReader(content), dataDelimiter, convertDbObjectName, nullToken); ConvertUtilsBean cub = new ConvertUtilsBean(); for (DaColumn col : table.getColumns()) { Class targetClassName; // This is to handle cases in Sybase ASE where a column comes back in quotes, e.g. "Date" // This happens if the column name happens to be a keyword, e.g. for Date String columnName = col.getName(); if (columnName.startsWith("\"") && columnName.endsWith("\"")) { columnName = columnName.substring(1, columnName.length() - 1); } try { // this is to handle "tinyint" if (col.getColumnDataType().getTypeClassName().equalsIgnoreCase("byte")) { targetClassName = Integer.class; } else { targetClassName = Class.forName(col.getColumnDataType().getTypeClassName()); } } catch (ClassNotFoundException e) { throw new DeployerRuntimeException(e); } fileSource.addDerivedField(new MyDerivedField(csvVersion, convertDbObjectName.valueOf(columnName), targetClassName, cub, nullToken)); } fileSource.init(); // initialize so that we can discover the fields in the file return fileSource; }
public MyDerivedField(int csvVersion, String field, Class targetClass, ConvertUtilsBean cub, String nullToken) { this.csvVersion = csvVersion; this.field = field; this.cub = cub; this.targetClass = targetClass; this.nullToken = nullToken; }
private static Function<FieldToColumnMapping, String> convertWithDefault(final ConvertUtilsBean cub) { return new Function<FieldToColumnMapping, String>() { @Override public String valueOf(FieldToColumnMapping field) { return field.getColumnName() + " DEFAULT '" + cub.convert(field.getDefaultValue()) + "'"; } }; }
/** * Creates a BeanUtilsBean that is configured to use * type converters that throw a ConversionException * instead of using the default value when something * goes wrong. * * @return a configured BeanUtilsBean */ private static BeanUtilsBean createBeanUtilsBean() { final ConvertUtilsBean cub = new ConvertUtilsBean(); registerIntegralTypes(cub); registerCustomTypes(cub); return new BeanUtilsBean(cub, new PropertyUtilsBean()); }
/** * Register basic types of JDK like boolean, int, and String to use with BeanUtils. All these * types are found in the {@code java.lang} package. * @param cub * Instance of {@link ConvertUtilsBean} to register types with. */ private static void registerIntegralTypes(ConvertUtilsBean cub) { cub.register(new BooleanConverter(), Boolean.TYPE); cub.register(new BooleanConverter(), Boolean.class); cub.register(new ArrayConverter( boolean[].class, new BooleanConverter()), boolean[].class); cub.register(new ByteConverter(), Byte.TYPE); cub.register(new ByteConverter(), Byte.class); cub.register(new ArrayConverter(byte[].class, new ByteConverter()), byte[].class); cub.register(new CharacterConverter(), Character.TYPE); cub.register(new CharacterConverter(), Character.class); cub.register(new ArrayConverter(char[].class, new CharacterConverter()), char[].class); cub.register(new DoubleConverter(), Double.TYPE); cub.register(new DoubleConverter(), Double.class); cub.register(new ArrayConverter(double[].class, new DoubleConverter()), double[].class); cub.register(new FloatConverter(), Float.TYPE); cub.register(new FloatConverter(), Float.class); cub.register(new ArrayConverter(float[].class, new FloatConverter()), float[].class); cub.register(new IntegerConverter(), Integer.TYPE); cub.register(new IntegerConverter(), Integer.class); cub.register(new ArrayConverter(int[].class, new IntegerConverter()), int[].class); cub.register(new LongConverter(), Long.TYPE); cub.register(new LongConverter(), Long.class); cub.register(new ArrayConverter(long[].class, new LongConverter()), long[].class); cub.register(new ShortConverter(), Short.TYPE); cub.register(new ShortConverter(), Short.class); cub.register(new ArrayConverter(short[].class, new ShortConverter()), short[].class); cub.register(new RelaxedStringArrayConverter(), String[].class); // BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp // do not use defaults in the default configuration of ConvertUtilsBean }
/** * Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils. * None of these types should be found in the {@code java.lang} package. * @param cub * Instance of {@link ConvertUtilsBean} to register types with. */ private static void registerCustomTypes(ConvertUtilsBean cub) { cub.register(new PatternConverter(), Pattern.class); cub.register(new SeverityLevelConverter(), SeverityLevel.class); cub.register(new ScopeConverter(), Scope.class); cub.register(new UriConverter(), URI.class); cub.register(new RelaxedAccessModifierArrayConverter(), AccessModifier[].class); }
private static void prepare(){ //使用自定义的替换 PropertyUtilsBean propertyUtilsBean = new CustPropertyUtilsBean(); ConvertUtilsBean convertUtilsBean = new CustConvertUtilsBean(); BeanUtilsBean beanUtilsBean = new BeanUtilsBean(convertUtilsBean,propertyUtilsBean); BeanUtilsBean.setInstance(beanUtilsBean); //注册转换器,处理枚举 registEnumConvert(); }
public static void initBeanUtils() { // begin Kuali Foundation modification ConvertUtilsBean convUtils = new ConvertUtilsBean(); PropertyUtilsBean propUtils = new PojoPropertyUtilsBean(); BeanUtilsBean pojoBeanUtils = new BeanUtilsBean(convUtils, propUtils); BeanUtilsBean.setInstance(pojoBeanUtils); logger.fine("Initialized BeanUtilsBean with " + pojoBeanUtils); // end Kuali Foundation modification }
/** * Register the conversion types. * * @param convertUtilsBean registrar. */ @Override public void register(ConvertUtilsBean convertUtilsBean) { convertUtilsBean.deregister(String.class); convertUtilsBean.deregister(Calendar.class); convertUtilsBean.deregister(Date.class); convertUtilsBean.register(this, String.class); convertUtilsBean.register(this, Calendar.class); convertUtilsBean.register(this, Date.class); }
/** * Register the conversion types. * * @param convertUtilsBean registrar. */ @Override public void register(ConvertUtilsBean convertUtilsBean) { convertUtilsBean.deregister(String.class); convertUtilsBean.deregister(Color.class); convertUtilsBean.register(this, String.class); convertUtilsBean.register(this, Color.class); }
/** * Perform CoerceUtil setup. */ private static void setup() { BeanUtilsBean.setInstance(new BeanUtilsBean(new ConvertUtilsBean() { { // https://github.com/yahoo/elide/issues/260 // enable throwing exceptions when conversion fails register(true, false, 0); } @Override /* * Overriding lookup to execute enum converter if target is enum * or map convert if source is map */ public Converter lookup(Class<?> sourceType, Class<?> targetType) { if (targetType.isEnum()) { return TO_ENUM_CONVERTER; } else if (targetType == UUID.class) { return TO_UUID_CONVERTER; } else if (Map.class.isAssignableFrom(sourceType)) { return FROM_MAP_CONVERTER; } else if ((String.class.isAssignableFrom(sourceType) || Number.class.isAssignableFrom(sourceType)) && ClassUtils.isAssignable(targetType, Date.class)) { return EPOCH_TO_DATE_CONVERTER; } else { return super.lookup(sourceType, targetType); } } })); }
/** * @return Returns the argumentValues. * @throws PopUpControllerException */ protected Object[] getArgumentValues() throws PopUpControllerException { Object[] argumentValues = new Object[arguments.size()]; Iterator iterator = arguments.iterator(); int i = 0; while (iterator.hasNext()) { PopUpArgument popUpArgument = (PopUpArgument) iterator.next(); /* valor em formato String */ String value = popUpArgument.getValue(); /* tipo do valor */ Class type = popUpArgument.getArgumentType(); /* CRIANDO UM OBJETO ConvertUtilsBean */ ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); /* Configura um ConvertUtilsBean j� criado */ FrameworkAcheUtil.configureConvertUtilsBean(convertUtilsBean, getResourceBundle()); /* INVOCANDO CONVERS�O */ Object objectValue = convertUtilsBean.convert(value, type); /* ATRIBUINDO AA LISTA DE ARGUMENTOS */ argumentValues[i++] = objectValue; } return argumentValues; }
/** * Cria e configura uma inst�ncia do Helper ConvertUtilsBean */ protected ConvertUtilsBean getConvertUtilsBean(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ActionException { ResourceBundle resourceBundle = getResourceBundle(mapping, form, request, response); ConvertUtilsBean convertUtilsBean = getConvertUtilsBean(resourceBundle); return convertUtilsBean; }
protected ConvertUtilsBean getConvertUtilsBean() { ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); FrameworkAcheUtil.configureConvertUtilsBean(convertUtilsBean, getResourceBundle()); return convertUtilsBean; }
/** * Converte um array quaisquer objetos para um array de Strings de acordo * com o padrao internacionalizado de conversao do framework (Utilizando os * converters) */ public static String[] transformaEmString(Object[] objects, ResourceBundle resourceBundle) { String[] strings = new String[objects.length]; ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); FrameworkAcheUtil.configureConvertUtilsBean(convertUtilsBean, resourceBundle); for (int i = 0; i < objects.length; i++) { strings[i] = convertUtilsBean.convert(objects[i]); } return strings; }
/** * Register conversion types. * * @param convertUtilsBean */ @Override public void register(ConvertUtilsBean convertUtilsBean) { convertUtilsBean.deregister(String.class); convertUtilsBean.deregister(Calendar.class); convertUtilsBean.deregister(Date.class); convertUtilsBean.register(this, String.class); convertUtilsBean.register(this, Calendar.class); convertUtilsBean.register(this, Date.class); }
@Override protected ConvertUtilsBean initialValue() { ConvertUtilsBean ret = BeanUtilsBean2.getInstance().getConvertUtils(); ret.deregister(); ret.register(false, true, 1); return ret; }
private static void setProperty(Object bean, String propertyName, String propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { // apache commons BeanUtilsBean silently ignores missing properties, so we do the work ourselves PropertyDescriptor propertyDescriptor = propertyUtilsBean.getPropertyDescriptor(bean, propertyName); if (propertyDescriptor == null) { throw new IllegalArgumentException("Property " + propertyName + " not found on class " + bean.getClass().getName()); } ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); convertUtilsBean.register(true, true, 0); Object value = convertUtilsBean.convert(propertyValue, propertyDescriptor.getPropertyType()); propertyUtilsBean.setProperty(bean, propertyName, value); }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { UserDao userDao = new UserDao(); //1.�Ȼ�ȡ��ʲô���� String method = request.getParameter("method");//��ȡ����method try { //ע����������ת���� //�õ����е���������ת������Bean���� ConvertUtilsBean convertUtils = BeanUtilsBean.getInstance().getConvertUtils(); convertUtils.register(new MyDateConvetor(), Date.class); //��װrequest�е����� UserData temp = new UserData(); BeanUtils.populate(temp, request.getParameterMap());//���õ��IJ���ȫ����װ��һ��temp��ȥ if("login".equals(method)){//�û���¼ //1.��ȡ�û������� // String username = request.getParameter("userName"); // String password = request.getParameter("passWord"); temp.setPassWord(DigestUtils.md5Hex(temp.getPassWord()));//����ȡ�������ܺ������ý�ȥ //2.��ѯ���ݿ���֤ //2.1����ֱ�Ӵ�temp��ȡ��������ҳ�еõ���username��passWord UserData user =userDao.validateUserInfo(temp.getUserName(), temp.getPassWord()); //3.������֤��� if(user!=null){ request.getSession().setAttribute("loginUser", user); //3.1�ɹ�--�������û������ if(user.getStatus()==UserData.admin){ request.getRequestDispatcher("WEB-INF/manage/index.jsp").forward(request, response); }else{ // request.getRequestDispatcher("indexGeneral.jsp").forward(request, response); response.sendRedirect(request.getContextPath()+"/indexGeneral.jsp"); } }else{ request.setAttribute("msg", "�û������������"); request.getRequestDispatcher("login.jsp").forward(request, response); } /**web-inf������ļ�����ͨ�������������,ֻ��ͨ��ת��������,����ζ������ÿ����web-inf����תҳ�� * ���ý�һ��servlet,�����ͺ��鷳,---��servletÿ�ζ�Ҫ�ύ����,���������Ƿ���request���� * ����������һ������IJ�����ʵ��web-inf�����ҳ��ת���������IJ������Ǹ���������Ҫ��ʲô*/ }else if("user".equals(method)){//�û�������� List<UserData> users = userDao.findAll(); request.setAttribute("users", users); request.getRequestDispatcher("WEB-INF/manage/user.jsp").forward(request, response); }else if(method==null){ request.getRequestDispatcher("WEB-INF/manage/index.jsp").forward(request, response); }else if("order".equals(method)){ request.getRequestDispatcher("WEB-INF/manage/order.jsp").forward(request, response); }else if("user-add".equals(method)){ request.getRequestDispatcher("WEB-INF/manage/user-add.jsp").forward(request, response); }else if("order-modify".equals(method)){ request.getRequestDispatcher("WEB-INF/manage/order-modify.jsp").forward(request, response); }else if("save".equals(method)){ temp.setStatus(temp.admin); userDao.saveUser(temp); response.sendRedirect(request.getContextPath()+"/UserServlet?method=user"); }else if("delete".equals(method)){ userDao.deleteById(temp.getId()); response.sendRedirect(request.getContextPath()+"/UserServlet?method=user"); }else if("modify".equals(method)){ userDao.modifyById(temp.getId()); response.sendRedirect(request.getContextPath()+"/UserServlet?method=user"); } } catch (Exception e) { e.printStackTrace(); } }
public BackendBeanUtilsBean(ConvertUtilsBean convertUtilsBean, PropertyUtilsBean propertyUtilsBean, BeanContext beanContext) { super(convertUtilsBean, propertyUtilsBean); this.beanContext = beanContext; }
@SuppressWarnings("unchecked") public void afterPropertiesSet() throws Exception { if(inited){ return; } inited = true; logger.trace("current Venus Client id=" + PacketConstant.VENUS_CLIENT_ID); if (venusExceptionFactory == null) { XmlVenusExceptionFactory xmlVenusExceptionFactory = new XmlVenusExceptionFactory(); //3.0.8版本将采用自动扫描的方式获得 exception 相关的配置 //xmlVenusExceptionFactory.setConfigFiles(new String[] { "classpath:com/meidusa/venus/exception/VenusSystemException.xml" }); xmlVenusExceptionFactory.init(); this.venusExceptionFactory = xmlVenusExceptionFactory; } handler.setVenusExceptionFactory(venusExceptionFactory); if (enableAsync) { if (connector == null) { this.connector = new ConnectionConnector("connection Connector"); connector.setDaemon(true); } if (connManager == null) { try { connManager = new ConnectionManager("Connection Manager", this.getAsyncExecutorSize()); } catch (IOException e) { throw new InitialisationException(e); } connManager.setDaemon(true); connManager.start(); } connector.setProcessors(new ConnectionManager[]{connManager}); connector.start(); } beanContext = new ClientBeanContext(applicationContext!= null ?applicationContext.getAutowireCapableBeanFactory(): null); BeanContextBean.getInstance().setBeanContext(beanContext); VenusBeanUtilsBean.setInstance(new ClientBeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean(), beanContext)); AthenaExtensionResolver.getInstance().resolver(); handler.setContainer(this.container); reloadConfiguration(); /*__RELOAD: { if (enableReload) { File[] files = new File[this.configFiles.length]; for (int i = 0; i < this.configFiles.length; i++) { try { files[i] = ResourceUtils.getFile(configFiles[i].trim()); } catch (FileNotFoundException e) { logger.warn(e.getMessage()); enableReload = false; logger.warn("venus serviceFactory configuration reload disabled!"); break __RELOAD; } } VenusFileWatchdog dog = new VenusFileWatchdog(files); dog.setDelay(1000 * 10); dog.start(); } }*/ }
public ClientBeanUtilsBean(ConvertUtilsBean convertUtilsBean, PropertyUtilsBean propertyUtilsBean, BeanContext beanContext) { super(convertUtilsBean, propertyUtilsBean); this.beanContext = beanContext; }
/** * Get the provided conversions. * * @param convertUtilsBean register conversions. */ @Override public void register(ConvertUtilsBean convertUtilsBean) { convertUtilsBean.deregister(Class.class); convertUtilsBean.register(this, Class.class); }
/** * Cria e configura uma inst�ncia do Helper ConvertUtilsBean */ protected ConvertUtilsBean getConvertUtilsBean(ResourceBundle resourceBundle) { ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); FrameworkAcheUtil.configureConvertUtilsBean(convertUtilsBean, resourceBundle); return convertUtilsBean; }
/** * Get the provided conversions. * * @param convertUtilsBean */ @Override public void register(ConvertUtilsBean convertUtilsBean) { convertUtilsBean.deregister(Class.class); convertUtilsBean.register(this, Class.class); }
private CamsFixture() { BeanUtilsBean instance = BeanUtilsBean.getInstance(); ConvertUtilsBean convertUtils = instance.getConvertUtils(); // Register Kuali Decimal Converter convertUtils.register(new KualiDecimalConverter(), KualiDecimal.class); }
public static void init() { ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils(); service.register(new LongConverter(null), Long.class); service.register(new IntegerConverter(null), Integer.class); }
@PostConstruct public void init() { ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils(); service.register(new LongConverter(null), Long.class); service.register(new IntegerConverter(null), Integer.class); }
@PostConstruct public void init() { ConvertUtilsBean service = BeanUtilsBean.getInstance().getConvertUtils(); service.register(new LongConverter(null), Long.class); service.register(new IntegerConverter(null), Long.class); }
public SimplePropertyConverterImpl() { this.convertUtils = new ConvertUtilsBean(); }
public SimplePropertyConverterImpl(ConvertUtilsBean convertUtils) { this.convertUtils = convertUtils; }
/** * Construct instance that uses given locale conversion * * @param localeConvertUtils use this <code>localeConvertUtils</code> to perform * conversions * @param convertUtilsBean use this for standard conversions * @param propertyUtilsBean use this for property conversions */ public LocaleBeanUtilsBean( final LocaleConvertUtilsBean localeConvertUtils, final ConvertUtilsBean convertUtilsBean, final PropertyUtilsBean propertyUtilsBean) { super(convertUtilsBean, propertyUtilsBean); this.localeConvertUtils = localeConvertUtils; }