Search in sources :

Example 21 with MutableComponentModel

use of org.apache.tapestry5.model.MutableComponentModel 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 22 with MutableComponentModel

use of org.apache.tapestry5.model.MutableComponentModel 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 23 with MutableComponentModel

use of org.apache.tapestry5.model.MutableComponentModel in project tapestry-5 by apache.

the class LogWorker method transform.

public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) {
    List<PlasticMethod> methods = plasticClass.getMethodsWithAnnotation(Log.class);
    if (methods.isEmpty()) {
        return;
    }
    final MethodAdvice loggingAdvice = new LoggingAdvice(model.getLogger(), exceptionTracker);
    for (PlasticMethod method : methods) {
        method.addAdvice(loggingAdvice);
    }
}
Also used : LoggingAdvice(org.apache.tapestry5.ioc.internal.services.LoggingAdvice) PlasticMethod(org.apache.tapestry5.plastic.PlasticMethod) MethodAdvice(org.apache.tapestry5.plastic.MethodAdvice)

Example 24 with MutableComponentModel

use of org.apache.tapestry5.model.MutableComponentModel 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)

Example 25 with MutableComponentModel

use of org.apache.tapestry5.model.MutableComponentModel in project tapestry-5 by apache.

the class OnEventWorker method addPublishEventInfo.

private void addPublishEventInfo(Flow<EventHandlerMethod> eventHandlerMethods, MutableComponentModel model) {
    JSONArray publishEvents = new JSONArray();
    for (EventHandlerMethod eventHandlerMethod : eventHandlerMethods) {
        if (eventHandlerMethod.publishEvent != null) {
            publishEvents.add(eventHandlerMethod.eventType.toLowerCase());
        }
    }
    // event information to it.
    if (publishEvents.size() > 0) {
        model.addMixinClassName(PublishServerSideEvents.class.getName(), "after:*");
        model.setMeta(InternalConstants.PUBLISH_COMPONENT_EVENTS_META, publishEvents.toString());
    }
}
Also used : JSONArray(org.apache.tapestry5.json.JSONArray) PublishServerSideEvents(org.apache.tapestry5.corelib.mixins.PublishServerSideEvents)

Aggregations

MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)42 Test (org.testng.annotations.Test)42 Resource (org.apache.tapestry5.commons.Resource)37 Logger (org.slf4j.Logger)37 MutableEmbeddedComponentModel (org.apache.tapestry5.model.MutableEmbeddedComponentModel)10 PlasticField (org.apache.tapestry5.plastic.PlasticField)7 PlasticClass (org.apache.tapestry5.plastic.PlasticClass)6 PlasticMethod (org.apache.tapestry5.plastic.PlasticMethod)4 BeginRender (org.apache.tapestry5.annotations.BeginRender)3 Location (org.apache.tapestry5.commons.Location)3 Annotation (java.lang.annotation.Annotation)2 PersistenceContext (javax.persistence.PersistenceContext)2 SneakyThrows (lombok.SneakyThrows)2 ComponentResources (org.apache.tapestry5.ComponentResources)2 Import (org.apache.tapestry5.annotations.Import)2 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)2 JSONArray (org.apache.tapestry5.json.JSONArray)2 InstanceContext (org.apache.tapestry5.plastic.InstanceContext)2 MethodAdvice (org.apache.tapestry5.plastic.MethodAdvice)2 SessionTracker (com.flowlogix.web.mixins.SessionTracker)1