Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.MethodNode


                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {

                        ComponentWorkbench workbench = context.getWorkbench();
                        // @Property on method parameter
                        Element properties = Elements.getPropertiesElement(workbench);
                        MethodNode method = context.getMethodNode();
                        return new ParameterPropertyVisitor(properties, method, context.getParameterIndex());
                    }
                });

        bind(Validate.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new LifecycleVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name),
                                LifecycleVisitor.Transition.VALIDATE);
                    }
                });

        bind(Invalidate.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new LifecycleVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name),
                                LifecycleVisitor.Transition.INVALIDATE);
                    }
                });

        bind(Updated.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new UpdatedVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name));
                    }
                });

        bind(Bind.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.BIND, node, context.getReporter());
                    }
                });

        bind(Unbind.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.UNBIND, node, context.getReporter());
                    }
                });

        bind(Modified.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.MODIFIED, node, context.getReporter());
                    }
                });

        bind(PostRegistration.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new PostRegistrationVisitor(context.getWorkbench(), node.name);
                    }
                });

        bind(PostUnregistration.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new PostUnregistrationVisitor(context.getWorkbench(), node.name);
                    }
                });

        bind(Context.class).to(new GenericVisitorFactory("context", ""));
View Full Code Here


      }

      List<ClassContractHandle> helpers =
          contracts.getClassHandles(ContractKind.HELPER);
      for (ClassContractHandle h : helpers) {
        MethodNode methodNode = h.getContractMethod();
        DebugUtils.info("instrument", "helper method "
                        + className + "." + methodNode.name
                        + methodNode.desc);
        ClassVisitor visitor = cv;
        List<Long> lineNumbers = h.getLineNumbers();
        if (lineNumbers != null) {
          visitor = new LineNumberingClassAdapter(visitor, lineNumbers);
        }
        methodNode.accept(new ContractFixingClassAdapter(visitor));
        h.setInjected(true);
      }
    }
    super.visitEnd();
  }
View Full Code Here

    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, true);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
      if (method.instructions.size() > 0) {
        if (!analyze(ca.classNode, method)) {
          Analyzer a = new Analyzer(new BasicVerifier());
          try {
            a.analyze(ca.classNode, method);
View Full Code Here

    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(new CheckClassAdapter(ca), true);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
      if (method.instructions.size() > 0) {
        Analyzer a = new Analyzer(new SimpleVerifier());
        try {
          a.analyze(ca.classNode, method);
          continue;
View Full Code Here

    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, false);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
     
      if (method.instructions.size() > 0) {
        Analyzer a = new Analyzer(new BasicVerifier());
        a.analyze(ca.classNode, method);
      }
View Full Code Here

    TreeClassAdapter ca = new TreeClassAdapter(null);
    cr.accept(ca, false);
   
    List methods = ca.classNode.methods;
    for (int i = 0; i < methods.size(); ++i) {
      MethodNode method = (MethodNode)methods.get(i);
     
      if (method.instructions.size() > 0) {
        Analyzer a = new Analyzer(new SimpleVerifier());
        a.analyze(ca.classNode, method);
      }
View Full Code Here

public class MethodBindVisitorTestCase extends TestCase {

    public void testIdentifierProvided() throws Exception {
        Reporter reporter = mock(Reporter.class);
        ComponentWorkbench workbench = new ComponentWorkbench(null, type());
        MethodNode node = new MethodNode();
        node.name = "myMethod";

        MethodBindVisitor visitor = new MethodBindVisitor(workbench, Action.BIND, node, reporter);
        visitor.visit("id", "my-identifier");
        visitor.visitEnd();
View Full Code Here

    }

    public void testNoIdentifierButSpecificationAsAttributeProvided() throws Exception {
        Reporter reporter = mock(Reporter.class);
        ComponentWorkbench workbench = new ComponentWorkbench(null, type());
        MethodNode node = new MethodNode();
        node.name = "notify";
        node.desc = "()V";

        MethodBindVisitor visitor = new MethodBindVisitor(workbench, Action.BIND, node, reporter);
        visitor.visit("specification", "my.Service");
View Full Code Here

    }

    public void testNoIdentifierAndNoSpecificationProvided() throws Exception {
        Reporter reporter = mock(Reporter.class);
        ComponentWorkbench workbench = new ComponentWorkbench(null, type());
        MethodNode node = new MethodNode();
        node.name = "notify";
        node.desc = "()V";

        MethodBindVisitor visitor = new MethodBindVisitor(workbench, Action.BIND, node, reporter);
        visitor.visitEnd();
View Full Code Here

    public void testComputeEffectiveMethodNameForNullInput() throws Exception {
        assertNull(computeEffectiveMethodName(null));
    }

    public void testBindPatternRecognition() throws Exception {
        MethodNode node = new MethodNode();
        node.name = "bindService";
        assertEquals("Service", getMethodIdentifier(node));
    }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.MethodNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.