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

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

Best Java code snippets using org.apache.tapestry5.plastic.PlasticMethod.addAdvice (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: apache/tapestry-5

  @Override
  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(CommitAfter.class))
    {
      method.addAdvice(advice);
    }
  }
}
origin: org.apache.tapestry/tapestry-ioc

@Override
public void adviseMethod(Method method, org.apache.tapestry5.plastic.MethodAdvice advice)
{
  assert method != null;
  assert advice != null;
  if (!allMethods.contains(method))
    throw new IllegalArgumentException(String.format("Method %s is not defined for interface %s.", method,
        serviceInterface));
  plasticClass.introduceMethod(method).addAdvice(advice);
}
origin: apache/tapestry-5

private void importStacks(PlasticMethod method, String[] stacks)
{
  if (stacks.length != 0)
  {
    method.addAdvice(createImportStackAdvice(stacks));
  }
}
origin: apache/tapestry-5

  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(DiscardAfter.class))
    {
      method.addAdvice(advice);
    }
  }
}
origin: org.apache.tapestry/tapestry-hibernate

  @Override
  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(CommitAfter.class))
    {
      method.addAdvice(advice);
    }
  }
}
origin: apache/tapestry-5

private void importModules(PlasticMethod method, String[] moduleNames)
{
  if (moduleNames.length != 0)
  {
    method.addAdvice(createImportModulesAdvice(moduleNames));
  }
}
origin: apache/tapestry-5

@Override
public void adviseMethod(Method method, org.apache.tapestry5.plastic.MethodAdvice advice)
{
  assert method != null;
  assert advice != null;
  if (!allMethods.contains(method))
    throw new IllegalArgumentException(String.format("Method %s is not defined for interface %s.", method,
        serviceInterface));
  plasticClass.introduceMethod(method).addAdvice(advice);
}
origin: apache/tapestry-5

/**
 * Commits any stored changes to the PlasticClass; this is used to defer adding advice to the dispatch method.
 */
public void commit()
{
  if (!eventHandlerAdvice.isEmpty())
  {
    PlasticMethod dispatchMethod = plasticClass.introduceMethod(TransformConstants.DISPATCH_COMPONENT_EVENT_DESCRIPTION);
    for (MethodAdvice advice : eventHandlerAdvice)
    {
      dispatchMethod.addAdvice(advice);
    }
  }
}
origin: apache/tapestry-5

void deferMethodInvocations(PlasticMethod method)
{
  validateVoid(method);
  validateNoCheckedExceptions(method);
  method.addAdvice(deferredAdvice);
}
origin: apache/tapestry-5

  @Override
  public void transform(PlasticClass plasticClass, TransformationSupport support,
      MutableComponentModel model)
  {
    for (final PlasticMethod method : plasticClass.getMethodsWithAnnotation(CommitAfter.class))
    {
      PersistenceContext annotation = method.getAnnotation(PersistenceContext.class);

      method.addAdvice(methodAdvices.get(annotation == null ? null : annotation.unitName()));
    }
  }
}
origin: org.got5/tapestry5-jquery

  public void transform(PlasticClass plasticClass,
      TransformationSupport support, MutableComponentModel model) {
    if (model.getComponentClassName().equals(Form.class.getName()))
    {
      PlasticMethod setupRender = plasticClass.introduceMethod(TransformConstants.SETUP_RENDER_DESCRIPTION);
      
      setupRender.addAdvice(new MethodAdvice() {
        
        public void advise(MethodInvocation invocation) {
          javaScriptSupport.importStack(FormSupportStack.STACK_ID);

          invocation.proceed();
        }
      });
      
      model.addRenderPhase(SetupRender.class);
    }
  }
}
origin: apache/tapestry-5

  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    List<PlasticMethod> methods = plasticClass.getMethodsWithAnnotation(Log.class);

    if (methods.isEmpty())
    {
      return;
    }

    final MethodAdvice loggingAdvice = new LoggingAdvice(model.getLogger(), exceptionTracker);

    for (PlasticMethod method : methods)
    {
      method.addAdvice(loggingAdvice);
    }
  }
}
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

  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(ReverseStrings.class))
    {
      method.addAdvice(advice);
    }
  }
}
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 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: apache/tapestry-5

private void invokeMethodsOnPageReset(PlasticClass plasticClass, Flow<PlasticMethod> methods)
{
  final MethodHandle[] handles = methods.map(TO_HANDLE).toArray(MethodHandle.class);
  plasticClass.introduceMethod(TransformConstants.CONTAINING_PAGE_DID_RESET_DESCRIPTION).addAdvice(new MethodAdvice()
  {
    public void advise(MethodInvocation invocation)
    {
      invocation.proceed();
      Object instance = invocation.getInstance();
      for (MethodHandle handle : handles)
      {
        handle.invoke(instance);
      }
    }
  });
}
origin: apache/tapestry-5

  public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
  {
    for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(Operation.class))
    {
      Operation annotation = method.getAnnotation(Operation.class);

      method.addAdvice(advisor.createAdvice(annotation.value()));
    }
  }
}
origin: apache/tapestry-5

private void addComponentIdValidationLogicOnPageLoad(PlasticClass plasticClass, Flow<EventHandlerMethod> eventHandlerMethods)
{
  ComponentIdValidator[] validators = extractComponentIdValidators(eventHandlerMethods);
  if (validators.length > 0)
  {
    plasticClass.introduceInterface(PageLifecycleListener.class);
    plasticClass.introduceMethod(TransformConstants.CONTAINING_PAGE_DID_LOAD_DESCRIPTION).addAdvice(new ValidateComponentIds(validators));
  }
}
org.apache.tapestry5.plasticPlasticMethodaddAdvice

Javadoc

Adds advice to the method. Adding advice implicitly rewrites the implementation of the method (this occurs inside at the end of the class transformation). When the method is invoked, control will flow through the MethodAdvice in the order they are added. Each piece of advice will receive the MethodInvocation and should invoke MethodInvocation#proceed() to pass control to the next piece of advice (and ultimately, to the actual method invocation). If a method implementation is changed, using #changeImplementation(InstructionBuilderCallback), that change will be honored, but the logic will only be invoked at the end of the chain of MethodAdvice. Internally, a new method is created with the same parameters, exceptions, return type and implementation (bytecode) as the advised method, then the advised method's implementation is changed. Note additionally that a recursive method invocation will still invoke the MethodAdvice chain on each recursive call (this is an intended side-effect of copying the exact bytecode of the method implementation.

Popular methods of PlasticMethod

  • 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.
  • isOverride

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Kernel (java.awt.image)
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top plugins for Android Studio
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