Search in sources :

Example 1 with ModelDescriptor

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

the class InjectionProviderFactoryStrategy method newInjectionProvider.

@Override
public InjectionProvider newInjectionProvider(Resolution resolution, DependencyModel dependencyModel) throws InvalidInjectionException {
    Class<? extends Annotation> injectionAnnotationType = dependencyModel.injectionAnnotation().annotationType();
    InjectionProviderFactory factory1 = generalProviderFactories.get(injectionAnnotationType);
    InjectionProviderFactory factory2 = valuesProviderFactories.get(injectionAnnotationType);
    if (factory1 == null && factory2 == null) {
        InjectionProviderFactory factory = metaInfo.get(InjectionProviderFactory.class);
        if (factory != null) {
            return factory.newInjectionProvider(resolution, dependencyModel);
        } else {
            throw new InvalidInjectionException("Unknown injection annotation @" + injectionAnnotationType.getSimpleName());
        }
    }
    ModelDescriptor composite = resolution.model();
    Class<?> compositeType = first(composite.types());
    if (factory1 != null && ValueComposite.class.isAssignableFrom(compositeType)) {
        throw new InvalidValueCompositeException("@" + injectionAnnotationType.getSimpleName() + " is not allowed in ValueComposites: " + compositeType);
    }
    InjectionProviderFactory factory;
    if (factory1 == null) {
        factory = factory2;
    } else {
        factory = factory1;
    }
    return factory.newInjectionProvider(resolution, dependencyModel);
}
Also used : InvalidValueCompositeException(org.qi4j.api.composite.InvalidValueCompositeException) InvalidInjectionException(org.qi4j.bootstrap.InvalidInjectionException) ModelDescriptor(org.qi4j.api.composite.ModelDescriptor) ValueComposite(org.qi4j.api.value.ValueComposite) InjectionProviderFactory(org.qi4j.runtime.injection.InjectionProviderFactory)

Example 2 with ModelDescriptor

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

the class PDFWriter method writeTypeServiceConfigurationPage.

private void writeTypeServiceConfigurationPage(Object objectDesciptor) {
    setFont(header5Font, header5FontSize);
    writeString("Configuration: ", headerLineSpace);
    Object configDescriptor = DescriptorUtilities.findServiceConfiguration((ServiceDetailDescriptor) objectDesciptor);
    if (configDescriptor == null) {
        return;
    }
    ModelDescriptor spiDescriptor;
    String typeString;
    if (configDescriptor instanceof ServiceDetailDescriptor) {
        spiDescriptor = ((ServiceDetailDescriptor) configDescriptor).descriptor();
        typeString = "Service";
    } else if (configDescriptor instanceof EntityDetailDescriptor) {
        spiDescriptor = ((EntityDetailDescriptor) configDescriptor).descriptor();
        typeString = "Entity";
    } else if (configDescriptor instanceof ValueDetailDescriptor) {
        spiDescriptor = ((ValueDetailDescriptor) configDescriptor).descriptor();
        typeString = "Value";
    } else if (configDescriptor instanceof ObjectDetailDescriptor) {
        spiDescriptor = ((ObjectDetailDescriptor) configDescriptor).descriptor();
        typeString = "Object";
    } else if (configDescriptor instanceof CompositeDetailDescriptor) {
        spiDescriptor = ((CompositeDetailDescriptor) configDescriptor).descriptor();
        typeString = "Transient";
    } else {
        throw new PrintingException("Unknown configuration descriptor: " + configDescriptor.getClass().getName(), null);
    }
    setFont(normalFont, normalFontSize);
    writeString("- name: " + spiDescriptor.toString());
    writeString("- class: " + spiDescriptor.toString());
    writeString("- type: " + typeString);
}
Also used : ModelDescriptor(org.qi4j.api.composite.ModelDescriptor)

Example 3 with ModelDescriptor

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

the class ServiceConfigurationPane method setDescriptor.

@Override
protected void setDescriptor(Object objectDesciptor) {
    clear();
    if (!(objectDesciptor instanceof ServiceDetailDescriptor)) {
        return;
    }
    configDescriptor = DescriptorUtilities.findServiceConfiguration((ServiceDetailDescriptor) objectDesciptor);
    if (configDescriptor == null) {
        return;
    }
    ModelDescriptor spiDescriptor = null;
    String typeString = null;
    if (configDescriptor instanceof ServiceDetailDescriptor) {
        spiDescriptor = ((ServiceDetailDescriptor) configDescriptor).descriptor();
        typeString = "Service";
    } else if (configDescriptor instanceof EntityDetailDescriptor) {
        spiDescriptor = ((EntityDetailDescriptor) configDescriptor).descriptor();
        typeString = "Entity";
    } else if (configDescriptor instanceof ValueDetailDescriptor) {
        spiDescriptor = ((ValueDetailDescriptor) configDescriptor).descriptor();
        typeString = "Value";
    } else if (configDescriptor instanceof ObjectDetailDescriptor) {
        spiDescriptor = ((ObjectDetailDescriptor) configDescriptor).descriptor();
        typeString = "Object";
    } else if (configDescriptor instanceof CompositeDetailDescriptor) {
        spiDescriptor = ((ObjectDetailDescriptor) configDescriptor).descriptor();
        typeString = "Transient";
    }
    Class<?> type = first(spiDescriptor.types());
    String simpleName = type.getSimpleName();
    nameLabel.setText("<html><a href='" + simpleName + "'>" + simpleName + "</a></html>");
    classLabel.setText(type.getName());
    typeLabel.setText(typeString);
    linkButton.setEnabled(true);
}
Also used : ServiceDetailDescriptor(org.qi4j.tools.model.descriptor.ServiceDetailDescriptor) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) ModelDescriptor(org.qi4j.api.composite.ModelDescriptor) ValueDetailDescriptor(org.qi4j.tools.model.descriptor.ValueDetailDescriptor) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) CompositeDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)

Aggregations

ModelDescriptor (org.qi4j.api.composite.ModelDescriptor)3 InvalidValueCompositeException (org.qi4j.api.composite.InvalidValueCompositeException)1 ValueComposite (org.qi4j.api.value.ValueComposite)1 InvalidInjectionException (org.qi4j.bootstrap.InvalidInjectionException)1 InjectionProviderFactory (org.qi4j.runtime.injection.InjectionProviderFactory)1 CompositeDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)1 EntityDetailDescriptor (org.qi4j.tools.model.descriptor.EntityDetailDescriptor)1 ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)1 ServiceDetailDescriptor (org.qi4j.tools.model.descriptor.ServiceDetailDescriptor)1 ValueDetailDescriptor (org.qi4j.tools.model.descriptor.ValueDetailDescriptor)1