public boolean accept(PlasticMethod method) { return method.getDescription().argumentTypes.length == 0 && method.getDescription().methodName.equalsIgnoreCase(methodName); } };
public boolean accept(PlasticMethod method) { return "getClientId".equalsIgnoreCase(method.getDescription().methodName); } });
private boolean hasCorrectPrefix(PlasticMethod method) { return method.getDescription().methodName.startsWith("on"); }
public boolean accept(PlasticMethod method) { return method.getDescription().methodName.equalsIgnoreCase(methodAlias) || method.hasAnnotation(methodAnnotationClass); } };
public boolean accept(PlasticMethod method) { return !method.isOverride() && !lifecycleMethods.contains(method.getDescription()); } });
public boolean accept(PlasticMethod method) { return method.getDescription().methodName.equalsIgnoreCase("pageReset") || method.hasAnnotation(PageReset.class); } };
private void validateNoCheckedExceptions(PlasticMethod method) { if (method.getDescription().checkedExceptionTypes.length > 0) throw new RuntimeException( String.format( "Method %s is not compatible with the @HeartbeatDeferred annotation, as it throws checked exceptions.", method.getMethodIdentifier())); }
private Class categorizeMethod(PlasticMethod method) { for (Class annotationClass : annotationToDescription.keySet()) { if (method.hasAnnotation(annotationClass)) return annotationClass; } return nameToAnnotation.get(method.getDescription().methodName); }
private void validateAsRenderPhaseMethod(PlasticMethod method) { final String[] argumentTypes = method.getDescription().argumentTypes; switch (argumentTypes.length) { case 0: break; case 1: if (argumentTypes[0].equals(MarkupWriter.class.getName())) break; default: throw new RuntimeException( String.format( "Method %s is not a valid render phase method: it should take no parameters, or take a single parameter of type MarkupWriter.", method.toString())); } }
private void validateMethod(PlasticMethod method) { MethodDescription description = method.getDescription(); if (description.returnType.equals("void")) throw new IllegalArgumentException(String.format( "Method %s may not be used with @Cached because it returns void.", method.getMethodIdentifier())); if (description.argumentTypes.length != 0) throw new IllegalArgumentException(String.format( "Method %s may not be used with @Cached because it has parameters.", method.getMethodIdentifier())); } }
EventHandlerMethod(PlasticMethod method) { this.method = method; description = method.getDescription(); parameterSource = buildSource(); String methodName = method.getDescription().methodName; OnEvent onEvent = method.getAnnotation(OnEvent.class); eventType = extractEventType(methodName, onEvent); componentId = extractComponentId(methodName, onEvent); publishEvent = method.getAnnotation(PublishEvent.class); }
final MethodDescription providerDescriptor = delegateProvidingMethod.getDescription(); final String delegateType = providerDescriptor.returnType;
final MethodDescription providerDescriptor = delegateProvidingMethod.getDescription(); final String delegateType = providerDescriptor.returnType;
@Override public InstructionBuilder invokeVirtual(PlasticMethod method) { check(); assert method != null; MethodDescription description = method.getDescription(); return invokeVirtual(method.getPlasticClass().getClassName(), description.returnType, description.methodName, description.argumentTypes); }
@Override public InstructionBuilder invokeVirtual(PlasticMethod method) { check(); assert method != null; MethodDescription description = method.getDescription(); return invokeVirtual(method.getPlasticClass().getClassName(), description.returnType, description.methodName, description.argumentTypes); }
final FieldHandle bindingFieldHandle = plasticClass.introduceField(Binding.class, "cache$watchBinding$" + method.getDescription().methodName).getHandle();
private void decorateMethodWithOperation(PlasticClass componentClass, MutableComponentModel model, PlasticMethod method, String[] paths, Worker<Asset> operation) { if (paths.length == 0) { return; } String[] expandedPaths = expandPaths(paths); PlasticField assetListField = componentClass.introduceField(Asset[].class, "importedAssets_" + method.getDescription().methodName); initializeAssetsFromPaths(expandedPaths, assetListField, model.getLibraryName()); addMethodAssetOperationAdvice(method, assetListField.getHandle(), operation); }
private void adviseMethod(PlasticClass plasticClass, PlasticMethod method) { // Every instance of the clas srequires its own per-thread value. This handles the case of multiple // pages containing the component, or the same page containing the component multiple times. PlasticField cacheField = plasticClass.introduceField(PerThreadValue.class, "cache$" + method.getDescription().methodName); cacheField.injectComputed(new ComputedValue<PerThreadValue>() { public PerThreadValue get(InstanceContext context) { // Each instance will get a new PerThreadValue return perThreadManager.createValue(); } }); Cached annotation = method.getAnnotation(Cached.class); MethodResultCacheFactory factory = createFactory(plasticClass, annotation.watch(), method); MethodAdvice advice = createAdvice(cacheField, factory); method.addAdvice(advice); }
private void invokeMethod(InstructionBuilder builder, PlasticMethod method) { // First, tell the Event object what method is being invoked. builder.loadArgument(1); builder.loadConstant( method.getMethodIdentifier()); builder.invoke(Event.class, void.class, "setMethodDescription", String.class); builder.loadThis(); // Methods either take no parameters, or take a MarkupWriter parameter. if (method.getParameters().size() > 0) { builder.loadArgument(0); } builder.invokeVirtual(method); // Non-void methods will pass a value to the event. if (!method.isVoid()) { builder.boxPrimitive(method.getDescription().returnType); builder.loadArgument(1).swap(); builder.invoke(Event.class, boolean.class, "storeResult", Object.class); builder.when(Condition.NON_ZERO, JUST_RETURN); } }
private void testFailure(MethodDescription description, String messageFragment) { PlasticMethod method = newMock(PlasticMethod.class); boolean isVoid = description.returnType.equals("void"); expect(method.isVoid()).andReturn(isVoid); if (isVoid) { expect(method.getDescription()).andReturn(description).atLeastOnce(); } expect(method.getMethodIdentifier()).andReturn("<MethodId>"); replay(); try { worker.deferMethodInvocations(method); unreachable(); } catch (RuntimeException ex) { assertMessageContains(ex, messageFragment); } verify(); } }