Search in sources :

Example 6 with Resource

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);
        }
    }
}
Also used : ObjectTypeResolver(org.apache.cxf.resource.ObjectTypeResolver) Resource(javax.annotation.Resource)

Example 7 with Resource

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 });
    }
}
Also used : Resource(javax.annotation.Resource)

Example 8 with Resource

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);
    }
}
Also used : Resource(javax.annotation.Resource)

Example 9 with Resource

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);
        }
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) Resource(javax.annotation.Resource)

Example 10 with Resource

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;
                    }
                }
            }
        }
    }
}
Also used : Resource(javax.annotation.Resource) com.sun.enterprise.deployment(com.sun.enterprise.deployment)

Aggregations

Resource (javax.annotation.Resource)56 Collectors (java.util.stream.Collectors)22 Set (java.util.Set)20 List (java.util.List)18 Subject (alien4cloud.security.Subject)17 Sets (com.google.common.collect.Sets)17 Arrays (java.util.Arrays)17 ArrayUtils (org.apache.commons.lang3.ArrayUtils)15 IGenericSearchDAO (alien4cloud.dao.IGenericSearchDAO)14 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)12 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)12 Audit (alien4cloud.audit.annotation.Audit)11 ResourcePermissionService (alien4cloud.authorization.ResourcePermissionService)11 RestResponse (alien4cloud.rest.model.RestResponse)11 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)11 ApplicationEnvironmentAuthorizationUpdateRequest (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationUpdateRequest)11 ApiOperation (io.swagger.annotations.ApiOperation)11 IOException (java.io.IOException)11 MediaType (org.springframework.http.MediaType)11 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)11