public void transform( PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { final ImportJQueryUI annotation = plasticClass.getAnnotation(ImportJQueryUI.class); PlasticMethod setupRender = plasticClass.introduceMethod(TransformConstants.SETUP_RENDER_DESCRIPTION); if (annotation != null) { if (annotation.value().length > 0) { final Flow<Asset> assetFlow = F.flow(annotation.value()).map(expandSimpleName).map(pathToAsset); setupRender.addAdvice( new MethodAdvice() { public void advise(MethodInvocation invocation) { assetFlow.each(importLibrary); invocation.proceed(); } }); } } if (model.isPage()) { setupRender.addAdvice( new MethodAdvice() { public void advise(MethodInvocation invocation) { String path = (annotation != null && InternalUtils.isNonBlank(annotation.theme())) ? annotation.theme() : themePath; javaScriptSupport.importStylesheet(assetSource.getExpandedAsset(path)); invocation.proceed(); } }); } model.addRenderPhase(SetupRender.class); }
@SuppressWarnings("unchecked") private void transform(PlasticClass transformation, PlasticField field, final boolean create) { final Class fieldClass = componentClassCache.forName(field.getTypeName()); field.setConduit( new FieldConduit() { public void set(Object instance, InstanceContext context, Object newValue) { windowStateManager.set(fieldClass, newValue); } public Object get(Object instance, InstanceContext context) { return create ? windowStateManager.get(fieldClass) : windowStateManager.getIfExists(fieldClass); } }); final String expectedName = field.getName() + "Exists"; List<PlasticField> fields = F.flow(transformation.getAllFields()) .filter( new Predicate<PlasticField>() { public boolean accept(PlasticField field) { return field.getTypeName().equals("boolean") && field.getName().equalsIgnoreCase(expectedName); } }) .toList(); for (PlasticField existsField : fields) { existsField.claim(this); final String className = transformation.getClassName(); final String fieldName = existsField.getName(); existsField.setConduit( new ReadOnlyComponentFieldConduit(className, fieldName) { public Object get(Object instance, InstanceContext context) { return windowStateManager.exists(fieldClass); } }); } }
@Override public void transform( PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (PlasticField field : plasticClass.getFieldsWithAnnotation(WindowState.class)) { WindowState annotation = field.getAnnotation(WindowState.class); transform(plasticClass, field, annotation.create()); field.claim(annotation); } }
@Override public void transform( PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (final PlasticMethod method : plasticClass.getMethodsWithAnnotation(CommitAfter.class)) { PersistenceContext annotation = method.getAnnotation(PersistenceContext.class); MethodAdvice advice = annotation == null ? shared : new TransactionalUnitMethodAdvice(manager, annotation); method.addAdvice(advice); } }