use of org.apache.tapestry5.plastic.PlasticField in project flowlogix by flowlogix.
the class EJBAnnotationWorker method transform.
@Override
@SneakyThrows({ NamingException.class })
public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) {
for (PlasticField field : plasticClass.getFieldsWithAnnotation(EJB.class)) {
final EJB annotation = field.getAnnotation(EJB.class);
final Stateful stateful = field.getAnnotation(Stateful.class);
final String fieldType = field.getTypeName();
final String fieldName = field.getName();
final String mappedName = annotation.mappedName();
final JNDIObjectLocator locator = JNDIObjectLocator.builder().build();
final String lookupname = getLookupName(annotation, fieldType, locator);
Object injectionValue = lookupBean(field, fieldType, fieldName, lookupname, mappedName, stateful, locator);
if (injectionValue != null) {
field.claim(annotation);
}
}
}
use of org.apache.tapestry5.plastic.PlasticField in project tapestry-5 by apache.
the class BlockInjectionProvider method createConduit.
private FieldConduit<Object> createConduit(PlasticField field, final String blockId) {
final String className = field.getPlasticClass().getClassName();
final String fieldName = field.getName();
return new ReadOnlyComponentFieldConduit(className, fieldName) {
public Object get(Object instance, InstanceContext context) {
ComponentResources resources = context.get(ComponentResources.class);
return resources.getBlock(blockId);
}
};
}
use of org.apache.tapestry5.plastic.PlasticField in project tapestry-5 by apache.
the class AssetInjectionProvider method provideInjection.
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) {
Path path = field.getAnnotation(Path.class);
if (path == null) {
return false;
}
final String assetPath = path.value();
final String libraryName = componentModel.getLibraryName();
ComputedValue<Asset> computedAsset = new ComputedValue<Asset>() {
public Asset get(InstanceContext context) {
ComponentResources resources = context.get(ComponentResources.class);
// a different library name than the subclass).
return assetSource.getComponentAsset(resources, assetPath, libraryName);
}
};
field.injectComputed(computedAsset);
return true;
}
use of org.apache.tapestry5.plastic.PlasticField in project tapestry-5 by apache.
the class DefaultInjectionProvider method provideInjection.
public boolean provideInjection(final PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) {
Class fieldType = classCache.forName(field.getTypeName());
Object injectionValue = masterObjectProvider.provide(fieldType, new AnnotationProvider() {
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return field.getAnnotation(annotationClass);
}
}, this.locator, false);
if (injectionValue != null) {
field.inject(injectionValue);
return true;
}
return false;
}
use of org.apache.tapestry5.plastic.PlasticField in project tapestry-5 by apache.
the class MixinWorker method replaceFieldWithMixin.
private void replaceFieldWithMixin(MutableComponentModel model, PlasticField field) {
Mixin annotation = field.getAnnotation(Mixin.class);
field.claim(annotation);
String mixinType = annotation.value();
String[] order = annotation.order();
String fieldType = field.getTypeName();
String mixinClassName = InternalUtils.isBlank(mixinType) ? fieldType : resolver.resolveMixinTypeToClassName(mixinType);
model.addMixinClassName(mixinClassName, order);
replaceFieldAccessWithMixin(field, mixinClassName);
}
Aggregations