Package javassist

Examples of javassist.CtMethod.insertBefore()


            managedCtClass
        );
      }

      if ( enhancementContext.doDirtyCheckingInline( managedCtClass ) && !isComposite ) {
        writer.insertBefore( typeDescriptor.buildInLineDirtyCheckingBodyFragment( persistentField ) );
      }

      if ( isComposite ) {
        StringBuilder builder = new StringBuilder();
        builder.append( " if(  " )
View Full Code Here


            .append( EnhancerConstants.TRACKER_COMPOSITE_FIELD_NAME )
            .append( ".callOwner(\"." )
            .append( persistentField.getName() )
            .append( "\");" );

        writer.insertBefore( builder.toString() );
      }

      //composite types
      if ( persistentField.getAnnotation( Embedded.class ) != null ) {
        //make sure to add the CompositeOwner interface
View Full Code Here

        if ( isComposite ) {
          createTrackChangeCompositeMethod( managedCtClass );
        }


        writer.insertBefore( cleanupPreviousOwner( persistentField ) );

        writer.insertAfter( compositeMethodBody( persistentField ) );
      }

      managedCtClass.addMethod( writer );
View Full Code Here

            managedCtClass
        );
      }

      if ( enhancementContext.doDirtyCheckingInline( managedCtClass ) ) {
        writer.insertBefore( typeDescriptor.buildInLineDirtyCheckingBodyFragment( fieldName ) );
      }

      managedCtClass.addMethod( writer );
      return writer;
    }
View Full Code Here

        failIfFrozen();
       
        CtMethod method = findMethod(methodSignature);
        try
        {
            method.insertBefore(methodBody);
        }
        catch (CannotCompileException ex)
        {
            throw new MethodCompileException(ServicesMessages.methodCompileError(
                    methodSignature,
View Full Code Here

        + "\", (System.currentTimeMillis() - _eurekaJTimingStart), _eurekaJTimingStart, \"" + mi.getClassType() + "\", \"" + cii.getPath() + "\");\n");
   
   
    //after.append("org.eurekaJ.agent.model.CallStackTraceBuilderFactory.getCallStackTraceBuilder().leave(System.currentTimeMillis() - _eurekaJTimingStart);\n");
   
    oldMethod.insertBefore(before.append("}").toString());
    oldMethod.insertAfter(after.append("}").toString());
   
  }

  private void addIncrement(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException, IOException {
View Full Code Here

  private void addIncrement(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException, IOException {
    CtMethod oldMethod = clas.getDeclaredMethod(mname);
    log.info("\tadding increment for class: " + clas.getName() + " method: " + mname);
    // Report increment value for this path
    oldMethod.insertBefore("org.eurekaJ.agent.EurekaJStringLogger.addIncrement(\"" + cii.getPath() + "\");\n");
   
  }

  private void addDecrement(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException, IOException {
    CtMethod oldMethod = clas.getDeclaredMethod(mname);
View Full Code Here

  private void addDecrement(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException, IOException {
    CtMethod oldMethod = clas.getDeclaredMethod(mname);
    // Report increment value for this path
    log.info("\tadding decrement for class: " + clas.getName() + " method: " + mname);
    oldMethod.insertBefore("org.eurekaJ.agent.EurekaJStringLogger.addDecrement(\"" + cii.getPath() + "\");\n");
  }

  private void addValueInstrumentation(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException,
      IOException {
    CtMethod oldMethod = clas.getDeclaredMethod(mname);
View Full Code Here

        aFoo.sayHello();

        ClassPool cp = ClassPool.getDefault();
        CtClass newFoo = cp.get("org.codehaus.aspectwerkz.extension.hotswap.Foo");
        CtMethod m = newFoo.getDeclaredMethod("sayHello");
        m.insertBefore("{System.out.println(\"\thotswapped talks:\");}");
        byte[] newFooB = cp.write("org.codehaus.aspectwerkz.extension.hotswap.Foo");

        client.hotswap(Foo.class, newFooB);

        // same instance is hotswapped
View Full Code Here

      ctChieldClass.setSuperclass(ctSuperClass);

      CtMethod ctChieldMethod;
      for (CtMethod ctSuperMethod : getMethods(ctSuperClass)) {
        ctChieldMethod = CtNewMethod.delegator(ctSuperMethod, ctChieldClass);
        ctChieldMethod.insertBefore("load(this);");

        ctChieldClass.addMethod(ctChieldMethod);
      }

      clazzProxy = ctChieldClass.toClass(classLoader, type.getProtectionDomain());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.