Search in sources :

Example 1 with PlasticField

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);
        }
    }
}
Also used : Stateful(com.flowlogix.web.services.annotations.Stateful) PlasticField(org.apache.tapestry5.plastic.PlasticField) EJB(javax.ejb.EJB) JNDIObjectLocator(org.omnifaces.util.JNDIObjectLocator) SneakyThrows(lombok.SneakyThrows)

Example 2 with PlasticField

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);
        }
    };
}
Also used : ReadOnlyComponentFieldConduit(org.apache.tapestry5.internal.transform.ReadOnlyComponentFieldConduit) InstanceContext(org.apache.tapestry5.plastic.InstanceContext) ComponentResources(org.apache.tapestry5.ComponentResources)

Example 3 with PlasticField

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;
}
Also used : Path(org.apache.tapestry5.annotations.Path) ComputedValue(org.apache.tapestry5.plastic.ComputedValue) InstanceContext(org.apache.tapestry5.plastic.InstanceContext) Asset(org.apache.tapestry5.Asset) ComponentResources(org.apache.tapestry5.ComponentResources)

Example 4 with PlasticField

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;
}
Also used : AnnotationProvider(org.apache.tapestry5.commons.AnnotationProvider)

Example 5 with PlasticField

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);
}
Also used : Mixin(org.apache.tapestry5.annotations.Mixin)

Aggregations

PlasticField (org.apache.tapestry5.plastic.PlasticField)15 PlasticClass (org.apache.tapestry5.plastic.PlasticClass)7 ComponentResources (org.apache.tapestry5.ComponentResources)5 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)5 InstanceContext (org.apache.tapestry5.plastic.InstanceContext)5 Method (java.lang.reflect.Method)4 InstructionBuilder (org.apache.tapestry5.plastic.InstructionBuilder)4 InstructionBuilderCallback (org.apache.tapestry5.plastic.InstructionBuilderCallback)4 PlasticClassTransformer (org.apache.tapestry5.plastic.PlasticClassTransformer)3 PageActivationContext (org.apache.tapestry5.annotations.PageActivationContext)2 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 ReadOnlyComponentFieldConduit (org.apache.tapestry5.internal.transform.ReadOnlyComponentFieldConduit)2 ComputedValue (org.apache.tapestry5.plastic.ComputedValue)2 FieldHandle (org.apache.tapestry5.plastic.FieldHandle)2 IFn (clojure.lang.IFn)1 Symbol (clojure.lang.Symbol)1 CDI (com.flowlogix.web.services.annotations.CDI)1 Stateful (com.flowlogix.web.services.annotations.Stateful)1 Annotation (java.lang.annotation.Annotation)1 EJB (javax.ejb.EJB)1