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


Java ObjectFactory.getObject方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.ObjectFactory.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectFactory.getObject方法的具体用法?Java ObjectFactory.getObject怎么用?Java ObjectFactory.getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.ObjectFactory的用法示例。


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

示例1: 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;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:22,代码来源:AutoModuleScope.java

示例2: 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:DefaultSingletonBeanRegistry.java

示例3: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {

    if (FacesContext.getCurrentInstance().getViewRoot() != null) {
        Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();
        if (viewMap.containsKey(name)) {
            return viewMap.get(name);
        } else {
            Object object = objectFactory.getObject();
            viewMap.put(name, object);
            return object;
        }
    } else {
        return null;
    }

}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:18,代码来源:ViewScope.java

示例4: testDoesNotComplainWhenTargetBeanNameRefersToSingleton

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Test
public void testDoesNotComplainWhenTargetBeanNameRefersToSingleton() throws Exception {
	final String targetBeanName = "singleton";
	final String expectedSingleton = "Alicia Keys";

	BeanFactory beanFactory = mock(BeanFactory.class);
	given(beanFactory.getBean(targetBeanName)).willReturn(expectedSingleton);

	ObjectFactoryCreatingFactoryBean factory = new ObjectFactoryCreatingFactoryBean();
	factory.setTargetBeanName(targetBeanName);
	factory.setBeanFactory(beanFactory);
	factory.afterPropertiesSet();
	ObjectFactory<?> objectFactory = factory.getObject();
	Object actualSingleton = objectFactory.getObject();
	assertSame(expectedSingleton, actualSingleton);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:ObjectFactoryCreatingFactoryBeanTests.java

示例5: 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();
		objMap.put(name, object);
	}
	
	return object;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:13,代码来源:AutotestScope.java

示例6: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(final String name,
    final ObjectFactory<?> objectFactory) {

    final ContainerRequestContext containerRequest = containerRequestHolder.get();
    Object scopedObject = containerRequest.getProperty(name);
    if (scopedObject == null) {
        scopedObject = objectFactory.getObject();
        containerRequest.setProperty(name, scopedObject);
    }
    return scopedObject;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:13,代码来源:ContainerRequestScope.java

示例7: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
public Object get(String name, ObjectFactory objectFactory) {
	System.out.println("tag is " + tag);
	System.out.println("requested " + name + " w/ objFact " + objectFactory);
	if (ScopeTests.tag == null) {
		Object obj = objectFactory.getObject();
		System.out.println("set tag to " + obj);
		System.out.println("obj is " + obj + "|hash=" + System.identityHashCode(obj));
		ScopeTests.tag = obj;
	}

	return tag;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:13,代码来源:ScopeTests.java

示例8: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
	RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
	Object scopedObject = attributes.getAttribute(name, getScope());
	if (scopedObject == null) {
		scopedObject = objectFactory.getObject();
		attributes.setAttribute(name, scopedObject, getScope());
	}
	return scopedObject;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AbstractRequestAttributesScope.java

示例9: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
	Object scopedObject = this.servletContext.getAttribute(name);
	if (scopedObject == null) {
		scopedObject = objectFactory.getObject();
		this.servletContext.setAttribute(name, scopedObject);
	}
	return scopedObject;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ServletContextScope.java

示例10: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
	Map<String, Object> scope = this.threadScope.get();
	Object object = scope.get(name);
	if (object == null) {
		object = objectFactory.getObject();
		scope.put(name, object);
	}
	return object;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:SimpleThreadScope.java

示例11: resolveAutowiringValue

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
/**
 * Resolve the given autowiring value against the given required type,
 * e.g. an {@link ObjectFactory} value to its actual object result.
 * @param autowiringValue the value to resolve
 * @param requiredType the type to assign the result to
 * @return the resolved value
 */
public static Object resolveAutowiringValue(Object autowiringValue, Class<?> requiredType) {
	if (autowiringValue instanceof ObjectFactory && !requiredType.isInstance(autowiringValue)) {
		ObjectFactory<?> factory = (ObjectFactory<?>) autowiringValue;
		if (autowiringValue instanceof Serializable && requiredType.isInterface()) {
			autowiringValue = Proxy.newProxyInstance(requiredType.getClassLoader(),
					new Class<?>[] {requiredType}, new ObjectFactoryDelegatingInvocationHandler(factory));
		}
		else {
			return factory.getObject();
		}
	}
	return autowiringValue;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AutowireUtils.java

示例12: create

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
/**
 * Create a new bean instance for given <code>beanName</code>.
 * @param beanName Bean name
 * @param objectFactory Spring ObjectFactory
 * @return New bean instance
 */
protected Object create(String beanName, ObjectFactory<?> objectFactory) {
	final Object bean = objectFactory.getObject();
	if (!(bean instanceof Serializable)) {
		LOGGER.warn("Storing non-serializable bean [" + bean + "] with name [" + beanName + "] in: " + this);
	}
	return bean;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:14,代码来源:TenantBeanStore.java

示例13: get

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    if (VaadinSession.getCurrent() == null || !VaadinSession.getCurrent().hasLock()) {
        throw new IllegalStateException("Unable to use VaadinSessionScope from non-Vaadin thread");
    }

    Object object = VaadinSession.getCurrent().getAttribute(name);
    if (object == null) {
        object = objectFactory.getObject();
        VaadinSession.getCurrent().setAttribute(name, object);
    }
    return object;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:VaadinSessionScope.java

示例14: getContentRequestIndexBuilder

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Bean
@Primary
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public IdolGetContentRequestIndexBuilder getContentRequestIndexBuilder(
        @Qualifier(GET_CONTENT_REQUEST_INDEX_BUILDER_BEAN_NAME) final ObjectFactory<IdolGetContentRequestIndexBuilder> getContentRequestIndexBuilderFactory
) {
    return getContentRequestIndexBuilderFactory.getObject();
}
 
开发者ID:hpe-idol,项目名称:haven-search-components,代码行数:9,代码来源:IdolCustomRequestBuilderConfiguration.java

示例15: customViewRequestBuilder

import org.springframework.beans.factory.ObjectFactory; //导入方法依赖的package包/类
@Bean
@Primary
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public IdolViewRequestBuilder customViewRequestBuilder(
        @Qualifier(VIEW_REQUEST_BUILDER_BEAN_NAME) final ObjectFactory<IdolViewRequestBuilder> requestBuilderFactory
) {
    return requestBuilderFactory.getObject();
}
 
开发者ID:hpe-idol,项目名称:haven-search-components,代码行数:9,代码来源:IdolCustomRequestBuilderConfiguration.java


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