public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { if (!field.getTypeName().equals(BLOCK_TYPE_NAME)) { return false; } Id annotation = field.getAnnotation(Id.class); String blockId = getBlockId(field.getName(), annotation); FieldConduit<Object> conduit = createConduit(field, blockId); field.setConduit(conduit); return true; // claim the field }
private void convertFieldToSessionAccess(PlasticField field) { SessionAttribute annotation = field.getAnnotation(SessionAttribute.class); field.claim(annotation); String key = determineSessionKey(field, annotation.value()); field.setConduit(new SessionKeyConduit(key)); }
@Override public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (final PlasticField field : plasticClass .getFieldsWithAnnotation(PersistenceContext.class)) { final PersistenceContext annotation = field.getAnnotation(PersistenceContext.class); field.claim(annotation); field.setConduit(new ReadOnlyComponentFieldConduit(plasticClass.getClassName(), field.getName()) { @Override public Object get(Object instance, InstanceContext context) { return JpaInternalUtils.getEntityManager(entityManagerManager, annotation); } }); } } }
@Override public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (final PlasticField field : plasticClass .getFieldsWithAnnotation(PersistenceContext.class)) { final PersistenceContext annotation = field.getAnnotation(PersistenceContext.class); field.claim(annotation); field.setConduit(new ReadOnlyComponentFieldConduit(plasticClass.getClassName(), field.getName()) { @Override public Object get(Object instance, InstanceContext context) { return JpaInternalUtils.getEntityManager(entityManagerManager, annotation); } }); } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { if (canHandle(field)) { Service service = field.getAnnotation(Service.class); final String serviceId = service == null ? ObjectsForComponentsStore.NO_ID : service.value(); final Class fieldType = classCache.forName(field.getTypeName()); final Object valueInjectedByTapestry = findTapestrysInjectedValue(field, fieldType); field.setConduit(new FieldConduit() { public Object get(Object instance, InstanceContext context) { Object testDouble = objectStore.get(fieldType, serviceId); return testDouble == null ? valueInjectedByTapestry : testDouble; } public void set(Object instance, InstanceContext context, Object newValue) { throw new RuntimeException("Field is read-only"); } }); return true; } return false; }
field.setConduit(new FieldConduit() existsField.setConduit(new ReadOnlyComponentFieldConduit(className, fieldName)
private void addInjectedPage(PlasticField field) { InjectPage annotation = field.getAnnotation(InjectPage.class); field.claim(annotation); String pageName = annotation.value(); String fieldName = field.getName(); String injectedPageName = InternalUtils.isBlank(pageName) ? resolver .resolvePageClassNameToPageName(field.getTypeName()) : pageName; field.setConduit(new InjectedPageConduit(field.getPlasticClass().getClassName(), fieldName, injectedPageName)); } }