本文整理汇总了Java中org.springframework.beans.factory.ObjectFactory类的典型用法代码示例。如果您正苦于以下问题:Java ObjectFactory类的具体用法?Java ObjectFactory怎么用?Java ObjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectFactory类属于org.springframework.beans.factory包,在下文中一共展示了ObjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HodParametricValuesServiceImpl
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@SuppressWarnings("ConstructorWithTooManyParameters")
@Autowired
HodParametricValuesServiceImpl(
final HodFieldsService fieldsService,
final ObjectFactory<HodFieldsRequestBuilder> fieldsRequestBuilderFactory,
final GetParametricValuesService getParametricValuesService,
final GetParametricRangesService getParametricRangesService,
final BucketingParamsHelper bucketingParamsHelper,
final TagNameFactory tagNameFactory,
final ConfigService<? extends HodSearchCapable> configService,
final AuthenticationInformationRetriever<?, HodAuthenticationPrincipal> authenticationInformationRetriever
) {
this.fieldsService = fieldsService;
this.fieldsRequestBuilderFactory = fieldsRequestBuilderFactory;
this.getParametricValuesService = getParametricValuesService;
this.getParametricRangesService = getParametricRangesService;
this.bucketingParamsHelper = bucketingParamsHelper;
this.tagNameFactory = tagNameFactory;
this.configService = configService;
this.authenticationInformationRetriever = authenticationInformationRetriever;
}
示例2: get
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory)
{
Object object = objMap.get(name);
if(object == null)
{
object = objectFactory.getObject();
AutoModuleProxy proxy = new AutoModuleProxy(object, recordReportWriters, util);
Object proxyObject = proxy.getProxy();
BeanCopier beanCopier = BeanCopier.create(object.getClass(), proxyObject.getClass(), false);
beanCopier.copy(object, proxyObject, null);
putAware(proxyObject);
object = proxyObject;
objMap.put(name, object);
}
return object;
}
示例3: getObject
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
final Object templates = Gadgets.createTemplatesImpl(command);
final ObjectFactory objectFactoryProxy =
Gadgets.createMemoitizedProxy(Gadgets.createMap("getObject", templates), ObjectFactory.class);
final Type typeTemplatesProxy = Gadgets.createProxy((InvocationHandler)
Reflections.getFirstCtor("org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler")
.newInstance(objectFactoryProxy), Type.class, Templates.class);
final Object typeProviderProxy = Gadgets.createMemoitizedProxy(
Gadgets.createMap("getType", typeTemplatesProxy),
forName("org.springframework.core.SerializableTypeWrapper$TypeProvider"));
final Constructor mitpCtor = Reflections.getFirstCtor("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider");
final Object mitp = mitpCtor.newInstance(typeProviderProxy, Object.class.getMethod("getClass", new Class[] {}), 0);
Reflections.setFieldValue(mitp, "methodName", "newTransformer");
return mitp;
}
示例4: testLocalBeans
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public void testLocalBeans() {
ObjectFactory factory = new ObjectFactory() {
public Object getObject() throws BeansException {
return new Object();
}
};
Object foo = scope.get("foo", factory);
Object foo2 = scope.get("foo", factory);
assertNotNull(foo);
assertSame("instance not cached", foo, foo2);
Object bar = scope.get("bar", factory);
Object bar2 = scope.get("bar", factory);
assertNotNull(bar);
assertSame("instance not cached", bar, bar2);
}
示例5: registerFacesDependencies
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public static void registerFacesDependencies(ConfigurableListableBeanFactory beanFactory) {
beanFactory.registerResolvableDependency(FacesContext.class, new ObjectFactory<FacesContext>() {
@Override
public FacesContext getObject() {
return FacesContext.getCurrentInstance();
}
@Override
public String toString() {
return "Current JSF FacesContext";
}
});
beanFactory.registerResolvableDependency(ExternalContext.class, new ObjectFactory<ExternalContext>() {
@Override
public ExternalContext getObject() {
return FacesContext.getCurrentInstance().getExternalContext();
}
@Override
public String toString() {
return "Current JSF ExternalContext";
}
});
}
示例6: getSingleton
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
/**
* Return the (raw) singleton object registered under the given name.
* <p>Checks already instantiated singletons and also allows for an early
* reference to a currently created singleton (resolving a circular reference).
* @param beanName the name of the bean to look for
* @param allowEarlyReference whether early references should be created or not
* @return the registered singleton object, or {@code null} if none found
*/
protected Object getSingleton(String beanName, boolean allowEarlyReference) {
Object singletonObject = this.singletonObjects.get(beanName);
if (singletonObject == null && isSingletonCurrentlyInCreation(beanName)) {
synchronized (this.singletonObjects) {
singletonObject = this.earlySingletonObjects.get(beanName);
if (singletonObject == null && allowEarlyReference) {
ObjectFactory<?> singletonFactory = this.singletonFactories.get(beanName);
if (singletonFactory != null) {
singletonObject = singletonFactory.getObject();
this.earlySingletonObjects.put(beanName, singletonObject);
this.singletonFactories.remove(beanName);
}
}
}
}
return (singletonObject != NULL_OBJECT ? singletonObject : null);
}
示例7: resolveDependency
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@Override
public Object resolveDependency(DependencyDescriptor descriptor, String beanName,
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
descriptor.initParameterNameDiscovery(getParameterNameDiscoverer());
if (descriptor.getDependencyType().equals(ObjectFactory.class)) {
return new DependencyObjectFactory(descriptor, beanName);
}
else if (descriptor.getDependencyType().equals(javaxInjectProviderClass)) {
return new DependencyProviderFactory().createDependencyProvider(descriptor, beanName);
}
else {
Object result = getAutowireCandidateResolver().getLazyResolutionProxyIfNecessary(descriptor, beanName);
if (result == null) {
result = doResolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
}
return result;
}
}
示例8: getObject
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception {
final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
final ObjectFactory objectFactoryProxy =
Gadgets.createMemoitizedProxy(Gadgets.createMap("getObject", templates), ObjectFactory.class);
final Type typeTemplatesProxy = Gadgets.createProxy((InvocationHandler)
Reflections.getFirstCtor("org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler")
.newInstance(objectFactoryProxy), Type.class, Templates.class);
final Object typeProviderProxy = Gadgets.createMemoitizedProxy(
Gadgets.createMap("getType", typeTemplatesProxy),
forName("org.springframework.core.SerializableTypeWrapper$TypeProvider"));
final Constructor mitpCtor = Reflections.getFirstCtor("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider");
final Object mitp = mitpCtor.newInstance(typeProviderProxy, Object.class.getMethod("getClass", new Class[] {}), 0);
Reflections.setFieldValue(mitp, "methodName", "newTransformer");
return mitp;
}
示例9: get
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
/**
* Get the bean instance with given <code>beanName</code>.
* @param beanName Bean name to obtain
* @param objectFactory Spring ObjectFactory
* @return The bean instance present in this store. If not yet available, a new instance will be created, stored and
* returned
*/
public Object get(String beanName, ObjectFactory<?> objectFactory) {
LOGGER.debug(() -> "Getting bean with name [" + beanName + "] from: " + this);
Object bean = objectMap.get(beanName);
if (bean == null) {
bean = create(beanName, objectFactory);
objectMap.put(beanName, bean);
if (LOGGER.isEnabled(Level.DEBUG)) {
final Object b = bean;
LOGGER.debug(() -> "Added bean [" + b + "] with name [" + beanName + "] to: " + this);
}
}
return bean;
}
示例10: getObject
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
final Object templates = Gadgets.createTemplatesImpl(command);
final ObjectFactory objectFactoryProxy =
Gadgets.createMemoitizedProxy(Gadgets.createMap("getObject", templates), ObjectFactory.class);
final Type typeTemplatesProxy = Gadgets.createProxy((InvocationHandler)
Reflections.getFirstCtor("org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler")
.newInstance(objectFactoryProxy), Type.class, Templates.class);
final Object typeProviderProxy = Gadgets.createMemoitizedProxy(
Gadgets.createMap("getType", typeTemplatesProxy),
forName("org.springframework.core.SerializableTypeWrapper$TypeProvider"));
final Constructor mitpCtor = Reflections.getFirstCtor("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider");
final Object mitp = mitpCtor.newInstance(typeProviderProxy, Object.class.getMethod("getClass", new Class[] {}), 0);
Reflections.setFieldValue(mitp, "methodName", "newTransformer");
return mitp;
}
示例11: init
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@PostConstruct
public void init() {
List<Module> modules = new ArrayList<Module>(this.modules);
modules.add(new SpringModule(beanFactory));
injector = Guice.createInjector(modules);
for (Entry<Key<?>, Binding<?>> entry : injector.getBindings().entrySet()) {
if (entry.getKey().getTypeLiteral().getRawType().equals(Injector.class)) {
continue;
}
final Provider<?> provider = entry.getValue().getProvider();
beanFactory.registerResolvableDependency(entry.getKey().getTypeLiteral().getRawType(), new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return provider.get();
}
});
}
}
示例12: get
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes" })
@Override
public Object get(final String name, final ObjectFactory factory) {
Object result = null;
try {
final ThreadScopeContext context = ThreadScopeContextHolder.getContext();
if (context != null) {
result = context.get(name);
if (result == null) {
result = factory.getObject();
context.put(name, result);
}
}
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
throw e;
}
return result;
}
示例13: get
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
if (createNewScope) {
beans.clear();
// reset the flag back
createNewScope = false;
}
Object bean = beans.get(name);
// if a new object is requested or none exists under the current
// name, create one
if (bean == null) {
beans.put(name, objectFactory.getObject());
}
return beans.get(name);
}
示例14: getObject
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
final ObjectFactory objectFactoryProxy =
Gadgets.createMemoitizedProxy(Gadgets.createMap("getObject", templates), ObjectFactory.class);
final Type typeTemplatesProxy = Gadgets.createProxy((InvocationHandler)
Reflections.getFirstCtor("org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler")
.newInstance(objectFactoryProxy), Type.class, Templates.class);
final Object typeProviderProxy = Gadgets.createMemoitizedProxy(
Gadgets.createMap("getType", typeTemplatesProxy),
forName("org.springframework.core.SerializableTypeWrapper$TypeProvider"));
final Constructor mitpCtor = Reflections.getFirstCtor("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider");
final Object mitp = mitpCtor.newInstance(typeProviderProxy, Object.class.getMethod("getClass", new Class[] {}), 0);
Reflections.setFieldValue(mitp, "methodName", "newTransformer");
return mitp;
}
示例15: resolveDependency
import org.springframework.beans.factory.ObjectFactory; //导入依赖的package包/类
@Override
public Object resolveDependency(DependencyDescriptor descriptor, String beanName,
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
descriptor.initParameterNameDiscovery(getParameterNameDiscoverer());
if (descriptor.getDependencyType().equals(javaUtilOptionalClass)) {
return new OptionalDependencyFactory().createOptionalDependency(descriptor, beanName);
}
else if (ObjectFactory.class == descriptor.getDependencyType()) {
return new DependencyObjectFactory(descriptor, beanName);
}
else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
return new DependencyProviderFactory().createDependencyProvider(descriptor, beanName);
}
else {
Object result = getAutowireCandidateResolver().getLazyResolutionProxyIfNecessary(descriptor, beanName);
if (result == null) {
result = doResolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
}
return result;
}
}