Search in sources :

Example 1 with SimpleResourceReference

use of org.jboss.weld.injection.spi.helpers.SimpleResourceReference in project wildfly by wildfly.

the class AbstractResourceInjectionServices method createLazyResourceReferenceFactory.

protected ResourceReferenceFactory<Object> createLazyResourceReferenceFactory(final ContextNames.BindInfo ejbBindInfo) {
    return new ResourceReferenceFactory<Object>() {

        @Override
        public ResourceReference<Object> createResource() {
            final ManagedReferenceFactory factory = getManagedReferenceFactory(ejbBindInfo);
            if (factory == null) {
                return new SimpleResourceReference<>(null);
            }
            final ManagedReference instance = factory.getReference();
            return new ResourceReference<Object>() {

                @Override
                public Object getInstance() {
                    return instance.getInstance();
                }

                @Override
                public void release() {
                    instance.release();
                }
            };
        }
    };
}
Also used : ResourceReferenceFactory(org.jboss.weld.injection.spi.ResourceReferenceFactory) ContextListManagedReferenceFactory(org.jboss.as.naming.ContextListManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) SimpleResourceReference(org.jboss.weld.injection.spi.helpers.SimpleResourceReference) ManagedReference(org.jboss.as.naming.ManagedReference) ResourceReference(org.jboss.weld.injection.spi.ResourceReference) SimpleResourceReference(org.jboss.weld.injection.spi.helpers.SimpleResourceReference)

Aggregations

ContextListManagedReferenceFactory (org.jboss.as.naming.ContextListManagedReferenceFactory)1 ManagedReference (org.jboss.as.naming.ManagedReference)1 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)1 ResourceReference (org.jboss.weld.injection.spi.ResourceReference)1 ResourceReferenceFactory (org.jboss.weld.injection.spi.ResourceReferenceFactory)1 SimpleResourceReference (org.jboss.weld.injection.spi.helpers.SimpleResourceReference)1