Search in sources :

Example 11 with IObjectDescriptor

use of org.eclipse.e4.core.di.suppliers.IObjectDescriptor in project eclipse.platform.runtime by eclipse.

the class InjectorImpl method getImplementationClass.

private Class<?> getImplementationClass(Class<?> clazz) {
    IObjectDescriptor descriptor = new ObjectDescriptor(clazz, null);
    Binding binding = findBinding(descriptor);
    if (binding == null)
        return getDesiredClass(descriptor.getDesiredType());
    return binding.getImplementationClass();
}
Also used : IBinding(org.eclipse.e4.core.di.IBinding) IObjectDescriptor(org.eclipse.e4.core.di.suppliers.IObjectDescriptor) IObjectDescriptor(org.eclipse.e4.core.di.suppliers.IObjectDescriptor)

Example 12 with IObjectDescriptor

use of org.eclipse.e4.core.di.suppliers.IObjectDescriptor in project eclipse.platform.runtime by eclipse.

the class InjectorImpl method findExtendedSupplier.

private ExtendedObjectSupplier findExtendedSupplier(IObjectDescriptor descriptor, PrimaryObjectSupplier objectSupplier) {
    Annotation[] qualifiers = descriptor.getQualifiers();
    if (qualifiers == null)
        return null;
    for (Annotation qualifier : qualifiers) {
        Class<?> type = qualifier.annotationType();
        String key = ((Class<?>) type).getName();
        ExtendedObjectSupplier supplier;
        try {
            // use qualified name to refer to a class that might be missing
            supplier = org.eclipse.e4.core.internal.di.osgi.ProviderHelper.findProvider(key, defaultSupplier);
        } catch (NoClassDefFoundError e) {
            // OSGi framework not present
            return null;
        }
        if (supplier != null)
            return supplier;
    }
    return null;
}
Also used : Annotation(java.lang.annotation.Annotation) ExtendedObjectSupplier(org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier)

Example 13 with IObjectDescriptor

use of org.eclipse.e4.core.di.suppliers.IObjectDescriptor in project eclipse.platform.runtime by eclipse.

the class ClassRequestor method calcDependentObjects.

@Override
public IObjectDescriptor[] calcDependentObjects() {
    if (pseudoVariableDescriptor == null) {
        Field field = null;
        try {
            // $NON-NLS-1$
            field = ClassRequestor.class.getField("pseudoVariable");
        } catch (SecurityException e) {
            // tested - not going to happen
            e.printStackTrace();
            return null;
        } catch (NoSuchFieldException e) {
            // tested - not going to happen
            e.printStackTrace();
            return null;
        }
        pseudoVariableDescriptor = new IObjectDescriptor[] { new ObjectDescriptor(field.getGenericType(), field.getAnnotations()) };
    }
    return pseudoVariableDescriptor;
}
Also used : Field(java.lang.reflect.Field) IObjectDescriptor(org.eclipse.e4.core.di.suppliers.IObjectDescriptor)

Aggregations

IObjectDescriptor (org.eclipse.e4.core.di.suppliers.IObjectDescriptor)7 Type (java.lang.reflect.Type)4 IBinding (org.eclipse.e4.core.di.IBinding)4 ExtendedObjectSupplier (org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier)3 Annotation (java.lang.annotation.Annotation)2 InjectionException (org.eclipse.e4.core.di.InjectionException)2 Bundle (org.osgi.framework.Bundle)2 BundleContext (org.osgi.framework.BundleContext)2 Field (java.lang.reflect.Field)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Named (javax.inject.Named)1 Active (org.eclipse.e4.core.contexts.Active)1 RunAndTrack (org.eclipse.e4.core.contexts.RunAndTrack)1 Creatable (org.eclipse.e4.core.di.annotations.Creatable)1 EventTopic (org.eclipse.e4.core.di.extensions.EventTopic)1 Preference (org.eclipse.e4.core.di.extensions.Preference)1