Tabnine Logo
PlasticMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
PlasticMethod
in
org.apache.tapestry5.plastic

Best Java code snippets using org.apache.tapestry5.plastic.PlasticMethod (Showing top 20 results out of 315)

origin: apache/tapestry-5

  private void addMethodAssetOperationAdvice(PlasticMethod method, final FieldHandle access,
                        final Worker<Asset> operation)
  {
    method.addAdvice(new MethodAdvice()
    {
      public void advise(MethodInvocation invocation)
      {
        invocation.proceed();

        Asset[] assets = (Asset[]) access.get(invocation.getInstance());

        F.flow(assets).each(operation);
      }
    });
  }
}
origin: org.apache.tapestry/tapestry-ioc

private void bridgeServiceMethodToFilterMethod(PlasticMethod method, final PlasticField filterField,
                        final PlasticField nextField, final int position, MethodSignature ms, final MethodSignature fms)
{
  method.changeImplementation(new InstructionBuilderCallback()
  {
    @Override
    public void doBuild(InstructionBuilder builder)
    {
      builder.loadThis().getField(filterField);
      int argumentIndex = 0;
      for (int i = 0; i < fms.getParameterTypes().length; i++)
      {
        if (i == position)
        {
          builder.loadThis().getField(nextField);
        } else
        {
          builder.loadArgument(argumentIndex++);
        }
      }
      builder.invoke(fms.getMethod()).returnResult();
    }
  });
}
origin: org.apache.tapestry/plastic

@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);
}
origin: apache/tapestry-5

  public boolean accept(PlasticMethod method)
  {
    return method.getDescription().methodName.equalsIgnoreCase(methodAlias)
        || method.hasAnnotation(methodAnnotationClass);
  }
};
origin: apache/tapestry-5

  public boolean accept(PlasticMethod method)
  {
    return !method.isOverride() && !lifecycleMethods.contains(method.getDescription());
  }
});
origin: apache/tapestry-5

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);
}
origin: org.apache.tapestry/tapestry-ioc

delegateMethod.changeImplementation(new InstructionBuilderCallback()
  plasticClass.introduceMethod(m).delegateTo(delegateMethod);
origin: org.apache.tapestry/tapestry-jpa

  @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 CommitAfterMethodAdvice(manager);

      method.addAdvice(advice);
    }
  }
}
origin: apache/tapestry-5

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);
}
origin: apache/tapestry-5

  public void transform(PlasticClass plasticClass)
  {
    PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(
        PlasticUtils.toTypeName(serviceType), "delegate", null, null);
    delegateMethod.addAdvice(new MethodAdvice()
    {
      public void advise(MethodInvocation invocation)
      {
        invocation.setReturnValue(environment.peekRequired(serviceType));
      }
    });
    for (Method method : serviceType.getMethods())
    {
      plasticClass.introduceMethod(method).delegateTo(delegateMethod);
    }
    plasticClass.addToString(String.format("<EnvironmentalProxy for %s>", serviceType.getName()));
  }
});
origin: org.apache.tapestry/plastic

@Override
public PlasticClass proxyInterface(Class interfaceType, PlasticMethod method)
{
  check();
  assert method != null;
  introduceInterface(interfaceType);
  // TAP5-2582: avoiding adding/delegating the same method more than once
  Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType);
  for (MethodSignature methodSignature : map.keySet())
  {
    introduceMethod(map.get(methodSignature)).delegateTo(method);
  }
  
  return this;
}
origin: apache/tapestry-5

final FieldHandle bindingFieldHandle = plasticClass.introduceField(Binding.class, "cache$watchBinding$" + method.getDescription().methodName).getHandle();
plasticClass.introduceMethod(TransformConstants.CONTAINING_PAGE_DID_LOAD_DESCRIPTION).addAdvice(new MethodAdvice()
origin: apache/tapestry-5

private void invokeMethodWithinLifecycle(PlasticClass plasticClass, PlasticMethod method)
{
  MethodHandle handle = method.getHandle();
  plasticClass.introduceMethod(lifecycleMethodDescription).addAdvice(createAdvice(handle));
}
origin: apache/tapestry-5

  public boolean accept(PlasticMethod method)
  {
    return method.getDescription().argumentTypes.length == 0
        && method.getDescription().methodName.equalsIgnoreCase(methodName);
  }
};
origin: apache/tapestry-5

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);
  }
}
origin: apache/tapestry-5

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()));
}
origin: apache/tapestry-5

  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();
  }
}
origin: apache/tapestry-5

private EventHandlerMethodParameterSource buildSource()
  final String[] parameterTypes = method.getDescription().argumentTypes;
    RequestParameter parameterAnnotation = method.getParameters().get(i).getAnnotation(RequestParameter.class);
  return new EventHandlerMethodParameterSource(method.getMethodIdentifier(), operationTracker, providerArray);
origin: apache/tapestry-5

  private boolean hasAnnotation(PlasticMethod method)
  {
    return method.hasAnnotation(OnEvent.class);
  }
};
origin: apache/tapestry-5

private void decorateMethod(PlasticClass componentClass, MutableComponentModel model, PlasticMethod method)
{
  Import annotation = method.getAnnotation(Import.class);
  decorateMethod(componentClass, model, method, annotation);
}
org.apache.tapestry5.plasticPlasticMethod

Javadoc

A method of a PlasticClass. No methods of this object should be invoked after the class transformation is PlasticClassTransformation#createInstantiator().

Most used methods

  • addAdvice
    Adds advice to the method. Adding advice implicitly rewrites the implementation of the method (this
  • changeImplementation
    Clears the instructions for this method, and creates a new empty InstructionBuilder so that the impl
  • delegateTo
    Much like #delegateTo(PlasticField), but the object to delegate to is dynamically computed by anothe
  • getDescription
    Returns a representation of the method's name, return value, argument types, etc.
  • getAnnotation
  • getPlasticClass
    Returns the PlasticClass containing this method.
  • hasAnnotation
  • getMethodIdentifier
    Returns a short identifier for the method that includes the class name, the method name, and the typ
  • isVoid
    Returns true if this method is type void.
  • getHandle
    Returns a handle that can be used to invoke a method of a transformed class instance.
  • getParameters
    Returns access to the parameters of the method and, in particular, the visible annotations on those
  • isOverride
    Returns true if the method is an override of a method from the parent class.
  • getParameters,
  • isOverride

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now