public MethodResultCache create(Object instance) { Binding binding = (Binding) bindingFieldHandle.get(instance); return new WatchedBindingMethodResultCache(binding); } };
public void handleEvent(Component instance, ComponentEvent event) { int count = Math.min(handles.length, event.getEventContext().getCount()); for (int i = 0; i < count; ++i) { String fieldType = fieldTypes[i]; FieldHandle handle = handles[i]; Object value = event.coerceContext(i, fieldType); handle.set(instance, value); } } };
public void handleEvent(Component instance, ComponentEvent event) { Object result; if (handles.length == 1) { // simple / common case for a single @PageActivationContext result = handles[0].get(instance); } else { LinkedList<Object> list = CollectionFactory.newLinkedList(); // iterate backwards for (int i = handles.length - 1; i > -1; i--) { FieldHandle handle = handles[i]; Object value = handle.get(instance); // ignore trailing nulls if (value != null || !list.isEmpty()) { list.addFirst(value); } } result = list.isEmpty() ? null : list; } event.storeResult(result); } };
public void handleEvent(Component instance, ComponentEvent event) { String clientValue = request.getParameter(parameterName); if (clientValue == null) { if (required) { throw new TapestryException(String.format("Activation request parameter field %s is marked as required, but query parameter '%s' is null.", fieldName, parameterName), null); } return; } // TAP5-1768: unescape encoded value clientValue = urlEncoder.decode(clientValue); Object value = encoder.toValue(clientValue); handle.set(instance, value); } };
public void advise(MethodInvocation invocation) { invocation.proceed(); Asset[] assets = (Asset[]) access.get(invocation.getInstance()); F.flow(assets).each(operation); } });
public void advise(MethodInvocation invocation) { ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class); Binding binding = bindingSource.newBinding("@Cached watch", resources, BindingConstants.PROP, watch); bindingFieldHandle.set(invocation.getInstance(), binding); invocation.proceed(); } });
public void handleEvent(Component instance, ComponentEvent event) { Object value = handle.get(instance); if (value == null) { return; } Link link = event.getEventContext().get(Link.class, 0); String clientValue = encoder.toClient(value); // TAP5-1768: escape special characters clientValue = urlEncoder.encode(clientValue); link.addParameter(parameterName, clientValue); } };
private MethodResultCache getOrCreateCache(MethodInvocation invocation) { Object instance = invocation.getInstance(); // The PerThreadValue is created in the instance constructor. PerThreadValue<MethodResultCache> value = (PerThreadValue<MethodResultCache>) fieldHandle .get(instance); // But it will be empty when first created, or at the start of a new request. if (value.exists()) { return value.get(); } // Use the factory to create a MethodResultCache for the combination of instance, method, and thread. return value.set(factory.create(instance)); } };