Search in sources :

Example 6 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class ServiceUsageFinder method collectInInjectedField.

private void collectInInjectedField(Iterable<InjectedFieldDetailDescriptor> iter, Object ownerDescriptor) {
    for (InjectedFieldDetailDescriptor descriptorField : iter) {
        DependencyDescriptor dependencyDescriptor = descriptorField.descriptor().dependency();
        Annotation annotation = dependencyDescriptor.injectionAnnotation();
        Class<? extends Annotation> clazz = annotation.annotationType();
        if (Uses.class.equals(clazz) || Service.class.equals(clazz)) {
            boolean used = false;
            if (dependencyDescriptor.injectionType().equals(first(this.descriptor.descriptor().types()))) {
                ServiceUsage usage;
                if (ownerDescriptor instanceof MixinDetailDescriptor) {
                    MixinDetailDescriptor mixinDescriptor = (MixinDetailDescriptor) ownerDescriptor;
                    usage = new ServiceUsage(mixinDescriptor.composite(), descriptorField, mixinDescriptor.composite().module(), mixinDescriptor.composite().module().layer());
                } else {
                    // assume ObjectDetailDescriptor
                    ObjectDetailDescriptor objectDescriptor = (ObjectDetailDescriptor) ownerDescriptor;
                    usage = new ServiceUsage(objectDescriptor, descriptorField, objectDescriptor.module(), objectDescriptor.module().layer());
                }
                usages.add(usage);
            }
        }
    }
}
Also used : Uses(org.qi4j.api.injection.scope.Uses) InjectedFieldDetailDescriptor(org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor) DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor) MixinDetailDescriptor(org.qi4j.tools.model.descriptor.MixinDetailDescriptor) ServiceUsage(org.qi4j.tools.model.descriptor.ServiceUsage) Service(org.qi4j.api.injection.scope.Service) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) Annotation(java.lang.annotation.Annotation)

Aggregations

DependencyDescriptor (org.qi4j.api.composite.DependencyDescriptor)6 Annotation (java.lang.annotation.Annotation)3 InjectedFieldDetailDescriptor (org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor)2 Stack (java.util.Stack)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 MethodDescriptor (org.qi4j.api.composite.MethodDescriptor)1 TransientDescriptor (org.qi4j.api.composite.TransientDescriptor)1 Service (org.qi4j.api.injection.scope.Service)1 Uses (org.qi4j.api.injection.scope.Uses)1 MixinDescriptor (org.qi4j.api.mixin.MixinDescriptor)1 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)1 LayerDescriptor (org.qi4j.api.structure.LayerDescriptor)1 ModuleDescriptor (org.qi4j.api.structure.ModuleDescriptor)1 TableRow (org.qi4j.envisage.util.TableRow)1 MixinDetailDescriptor (org.qi4j.tools.model.descriptor.MixinDetailDescriptor)1 ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)1 ServiceUsage (org.qi4j.tools.model.descriptor.ServiceUsage)1 Attr (org.w3c.dom.Attr)1 DOMException (org.w3c.dom.DOMException)1 Document (org.w3c.dom.Document)1