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