当前位置: 首页>>代码示例>>Java>>正文


Java BeanUtilsBean2类代码示例

本文整理汇总了Java中org.apache.commons.beanutils.BeanUtilsBean2的典型用法代码示例。如果您正苦于以下问题:Java BeanUtilsBean2类的具体用法?Java BeanUtilsBean2怎么用?Java BeanUtilsBean2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BeanUtilsBean2类属于org.apache.commons.beanutils包,在下文中一共展示了BeanUtilsBean2类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProperties

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public Dictionary<String, ?> getProperties ()
{
    try
    {
        final Dictionary<String, Object> result = new Hashtable<String, Object> ();

        final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean );
        for ( final Map.Entry<?, ?> entry : properties.entrySet () )
        {
            if ( entry.getValue () != null )
            {
                result.put ( entry.getKey ().toString (), entry.getValue () );
            }
        }
        return result;
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to get dictionary", e );
        return new Hashtable<String, Object> ( 1 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:BeanConfigurationFactory.java

示例2: copyProperties

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
/**
 * Copy properties.
 *
 * @param desc 不允许为空
 * @param src 不允许为空
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void copyProperties(Object desc, Object src)
{
	BeanUtilsBean2 beanUtilsBean2 = new BeanUtilsBean2();
	try
	{
		if (desc instanceof Map)
		{
			Map<String, Object> map = beanToMap(src);
			((Map) desc).putAll(map);
		} else
		{
			beanUtilsBean2.copyProperties(desc, src);
		}

	} catch (Exception e)
	{
		log.error(e.getMessage(), e);
	}
}
 
开发者ID:tywo45,项目名称:talent-aio,代码行数:27,代码来源:BeanUtils.java

示例3: main

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
   BeanUtilsBean utilsBean = BeanUtilsBean2.getInstance();
   utilsBean.getConvertUtils().register(false, false, 0);
   BeanOne one = new BeanOne();

   one.setPropertyOne("One");
   one.setPropertyTwo("Two");
   one.setPropertyThree(3L);
   one.setPropertyFour(4);  //this is a string in BeanTwo

   BeanTwo two = new BeanTwo();

   utilsBean.copyProperties(two, one);

   BeanUtilsBean.getInstance().getConvertUtils().register(false, false, 0);

   System.out.println(two);
}
 
开发者ID:developerSid,项目名称:AwesomeJavaLibraryExamples,代码行数:19,代码来源:CopyFromDifferentObjects.java

示例4: init

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
public void init(ServletConfig config) throws ServletException {
    this.config = config;
    BlockingQueue<Filter> waiters = (BlockingQueue<Filter>) config.getServletContext()
            .getAttribute(APPLICATION_CONTEXT_LOCK_KEY);
    if (waiters != null) {
        waiters.add(this);
    } else {
        //Servlet 2.5 lazy filter initing
        delayedInit();
    }
    // register the bean utils converter to fail if encounters a type mismatch between the destination
    // and the original, see RTFACT-3610
    BeanUtilsBean instance = BeanUtilsBean2.getInstance();
    instance.getConvertUtils().register(true, false, 0);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:ArtifactoryRestServlet.java

示例5: GitRiver

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@Inject
protected GitRiver(RiverName riverName, RiverSettings settings, @RiverIndexName String riverIndexName, Client client) throws InvocationTargetException, IllegalAccessException {
    super(riverName, settings);
    this.client = client;
    logger.info("Creating Git river");

    if (settings.settings().containsKey("git")) {
        Map<String, Object> gitSettings = (Map<String, Object>) settings.settings().get("git");
        BeanUtilsBean2.getInstance().populate(context, transformKeys(gitSettings, new Function<String, String>() {
            @Override
            public String apply(String input) {
                return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input);
            }
        }));
    }
    context.setRiverName(riverName.name());
    context.setRiverIndexName(riverIndexName);
    context.setClient(client);
    context.setIssuePattern(compilePattern(context.getIssueRegex()));
}
 
开发者ID:obazoud,项目名称:elasticsearch-river-git,代码行数:21,代码来源:GitRiver.java

示例6: getMarkInumMapEntryAsRemoved

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
private GluuInumMap getMarkInumMapEntryAsRemoved(GluuInumMap currentInumMap, String date) {
	GluuInumMap clonedInumMap;
	try {
		clonedInumMap = (GluuInumMap) BeanUtilsBean2.getInstance().cloneBean(currentInumMap);
	} catch (Exception ex) {
		log.error("Failed to prepare GluuInumMap for removal", ex);
		return null;
	}

	String suffix = "-" + date;

	String[] primaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getPrimaryKeyValues());
	String[] secondaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getSecondaryKeyValues());
	String[] tertiaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getTertiaryKeyValues());

	if (ArrayHelper.isNotEmpty(primaryKeyValues)) {
		markInumMapEntryKeyValuesAsRemoved(primaryKeyValues, suffix);
	}

	if (ArrayHelper.isNotEmpty(secondaryKeyValues)) {
		markInumMapEntryKeyValuesAsRemoved(secondaryKeyValues, suffix);
	}

	if (ArrayHelper.isNotEmpty(tertiaryKeyValues)) {
		markInumMapEntryKeyValuesAsRemoved(tertiaryKeyValues, suffix);
	}

	clonedInumMap.setPrimaryKeyValues(primaryKeyValues);
	clonedInumMap.setSecondaryKeyValues(secondaryKeyValues);
	clonedInumMap.setTertiaryKeyValues(tertiaryKeyValues);

	clonedInumMap.setStatus(GluuStatus.INACTIVE);
	
	return clonedInumMap;
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:36,代码来源:CacheRefreshTimer.java

示例7: onCreate

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@PrePersist
public void onCreate(Object object) {
  final String ID = "id";
  final String CREATED_AT = "createdAt";
  final String LAST_MODIFIED_AT = "lastModifiedAt";
  BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
  try {
    if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
      beanUtilsBean.setProperty(object, CREATED_AT, System.currentTimeMillis());
      beanUtilsBean.setProperty(object, LAST_MODIFIED_AT, System.currentTimeMillis());
    }
  } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}
 
开发者ID:saintdan,项目名称:spring-microservices-boilerplate,代码行数:14,代码来源:PersistentListener.java

示例8: onCreate

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@PrePersist
public void onCreate(Object object) {
  final String ID = "id";
  final String VALID_FLAG = "validFlag";
  BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
  try {
    if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
      beanUtilsBean.setProperty(object, VALID_FLAG, ValidFlag.VALID);
    }
  } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}
 
开发者ID:saintdan,项目名称:spring-microservices-boilerplate,代码行数:12,代码来源:ValidFlagListener.java

示例9: initialValue

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@Override
protected ConvertUtilsBean initialValue() {
  ConvertUtilsBean ret = BeanUtilsBean2.getInstance().getConvertUtils();
  ret.deregister();
  ret.register(false, true, 1);
  return ret;
}
 
开发者ID:apache,项目名称:metron,代码行数:8,代码来源:ConversionUtils.java

示例10: update

import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public void update ( final Map<String, String> parameters ) throws Exception
{
    new BeanUtilsBean2 ().populate ( this.targetBean, parameters );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:BeanConfigurationFactory.java


注:本文中的org.apache.commons.beanutils.BeanUtilsBean2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。