use of org.jboss.weld.injection.spi.ResourceReference 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();
}
};
}
};
}
use of org.jboss.weld.injection.spi.ResourceReference in project wildfly by wildfly.
the class WeldEjbInjectionServices method createLazyResourceReferenceFactory.
protected ResourceReferenceFactory<Object> createLazyResourceReferenceFactory(final ViewDescription viewDescription) {
return new ResourceReferenceFactory<Object>() {
@Override
public ResourceReference<Object> createResource() {
final ManagedReference instance;
try {
final ServiceController<?> controller = serviceRegistry.getRequiredService(viewDescription.getServiceName());
final ComponentView view = (ComponentView) controller.getValue();
instance = view.createInstance();
return new ResourceReference<Object>() {
@Override
public Object getInstance() {
return instance.getInstance();
}
@Override
public void release() {
instance.release();
}
};
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
}
Aggregations