use of javax.annotation.Resource in project cxf by apache.
the class ResourceManagerImpl method setBus.
@Resource
public final void setBus(Bus b) {
if (bus != b) {
bus = b;
firstCalled = false;
super.addResourceResolver(new ObjectTypeResolver(bus));
if (null != bus) {
bus.setExtension(this, ResourceManager.class);
}
}
}
use of javax.annotation.Resource in project cxf by apache.
the class ResourceInjector method visitMethod.
public final void visitMethod(final Method method, final Annotation annotation) {
assert annotation instanceof Resource : annotation;
Resource res = (Resource) annotation;
String resourceName = getResourceName(res, method);
Class<?> clz = getResourceType(res, method);
Object resource = resolveResource(resourceName, clz);
if (resource == null && "".equals(res.name())) {
resource = resolveResource(null, clz);
}
if (resource != null) {
invokeSetter(method, resource);
} else {
LOG.log(Level.FINE, "RESOURCE_RESOLVE_FAILED", new Object[] { resourceName, clz });
}
}
use of javax.annotation.Resource in project cxf by apache.
the class ResourceInjector method visitField.
public final void visitField(final Field field, final Annotation annotation) {
assert annotation instanceof Resource : annotation;
Resource res = (Resource) annotation;
String name = getFieldNameForResource(res, field);
Class<?> type = getResourceType(res, field);
Object resource = resolveResource(name, type);
if (resource == null && "".equals(res.name())) {
resource = resolveResource(null, type);
}
if (resource != null) {
injectField(field, resource);
} else {
LOG.log(Level.INFO, "RESOURCE_RESOLVE_FAILED", name);
}
}
use of javax.annotation.Resource in project cxf by apache.
the class FactoryBeanListenerManager method setBus.
@Resource
public final void setBus(Bus bus) {
this.bus = bus;
this.bus.setExtension(this, FactoryBeanListenerManager.class);
ConfiguredBeanLocator loc = bus.getExtension(ConfiguredBeanLocator.class);
if (loc != null) {
for (FactoryBeanListener f : loc.getBeansOfType(FactoryBeanListener.class)) {
listeners.add(0, f);
}
}
}
use of javax.annotation.Resource in project Payara by payara.
the class InjectionServicesImpl method validateResourceProducer.
private void validateResourceProducer(Class annotatedClass, AnnotatedField annotatedField, List<InjectionCapable> injectionResources) {
Resource resourceAnnotation = annotatedField.getAnnotation(Resource.class);
if (resourceAnnotation != null) {
String lookupName = getLookupName(annotatedClass, annotatedField, injectionResources);
if (lookupName.equals("java:comp/BeanManager")) {
validateResourceClass(annotatedField, BeanManager.class);
} else {
boolean done = false;
for (InjectionCapable injectionCapable : injectionResources) {
for (com.sun.enterprise.deployment.InjectionTarget target : injectionCapable.getInjectionTargets()) {
if (target.isFieldInjectable()) {
// make sure it's a field and not a method
if (annotatedClass.getName().equals(target.getClassName()) && target.getFieldName().equals(annotatedField.getJavaMember().getName())) {
String type = injectionCapable.getInjectResourceType();
try {
Class clazz = Class.forName(type, false, annotatedClass.getClassLoader());
validateResourceClass(annotatedField, clazz);
} catch (ClassNotFoundException ignore) {
} finally {
done = true;
}
}
}
if (done) {
break;
}
}
}
}
}
}
Aggregations