本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}