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


Java ObjectInstantiator类代码示例

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


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

示例1: getInstantiatorOf

import org.springframework.objenesis.instantiator.ObjectInstantiator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz) {
	ObjectInstantiator<?> instantiator = this.cache.get(clazz);
	if (instantiator == null) {
		ObjectInstantiator<T> newInstantiator = newInstantiatorOf(clazz);
		instantiator = this.cache.putIfAbsent(clazz, newInstantiator);
		if (instantiator == null) {
			instantiator = newInstantiator;
		}
	}
	return (ObjectInstantiator<T>) instantiator;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:SpringObjenesis.java

示例2: newInstantiatorOf

import org.springframework.objenesis.instantiator.ObjectInstantiator; //导入依赖的package包/类
protected <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> clazz) {
	Boolean currentWorthTrying = this.worthTrying;
	try {
		ObjectInstantiator<T> instantiator = this.strategy.newInstantiatorOf(clazz);
		if (currentWorthTrying == null) {
			this.worthTrying = Boolean.TRUE;
		}
		return instantiator;
	}
	catch (ObjenesisException ex) {
		if (currentWorthTrying == null) {
			Throwable cause = ex.getCause();
			if (cause instanceof ClassNotFoundException || cause instanceof IllegalAccessException) {
				// Indicates that the chosen instantiation strategy does not work on the given JVM.
				// Typically a failure to initialize the default SunReflectionFactoryInstantiator.
				// Let's assume that any subsequent attempts to use Objenesis will fail as well...
				this.worthTrying = Boolean.FALSE;
			}
		}
		throw ex;
	}
	catch (NoClassDefFoundError err) {
		// Happening on the production version of Google App Engine, coming out of the
		// restricted "sun.reflect.ReflectionFactory" class...
		if (currentWorthTrying == null) {
			this.worthTrying = Boolean.FALSE;
		}
		throw new ObjenesisException(err);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:SpringObjenesis.java

示例3: instanceOfClass

import org.springframework.objenesis.instantiator.ObjectInstantiator; //导入依赖的package包/类
/**
 * <b>Don't copy paste this stuff, cuz its evil.</b><br>
 * Creates ANY object from simple class name. With any i mean ANY, no restrictions.<br>
 * Used to call class methods on that object in JSP, because classes can't be used in JSP.<br>
 * Use carefully, because this is probably slow as fuck.
 */
public static <T> T instanceOfClass(String clazz) throws ClassNotFoundException {
	@SuppressWarnings("unchecked")
	Class<T> resolvedClass = (Class<T>) getClassFromSimpleString(clazz);
	ObjectInstantiator<T> instantiator = objenesis.getInstantiatorOf(resolvedClass);
	return resolvedClass.cast(instantiator.newInstance());
}
 
开发者ID:Katharsas,项目名称:GMM,代码行数:13,代码来源:ElFunctions.java


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