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);
}
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);
}
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);
}
Aggregations