Package javassist

Examples of javassist.CtMethod.insertBefore()


      CtMethod onAttach = c.getMethod("onAttach", "()V");
      onAttach.insertBefore(GwtFinder.class.getName() + ".onAttach(this);");

      // add behavior to RadioButton.setName method
      CtMethod onDetach = c.getMethod("onDetach", "()V");
      onDetach.insertBefore(GwtFinder.class.getName() + ".onDetach(this);");
   }

}
View Full Code Here


            "      " + updatedAdvicesFieldName + " = false;" +
            "      super.rebindJoinPointWithInstanceInformation(" + names.getInfoFieldName() + ");" +
            "   } finally {" +
            "   " + names.getInfoFieldName() + ".getInterceptorChainReadWriteLock().writeLock().unlock();}" +
            "}";
         instanceAdvisorMethod.insertBefore(code);
         genInstanceAdvisor.addMethod(instanceAdvisorMethod);
      }
   }

   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)throws NotFoundException
View Full Code Here

            "      " + updatedAdvicesFieldName + " = false;" +
            "      super.rebindJoinPointWithInstanceInformation(" + names.getInfoFieldName() + ");" +
            "   } finally {" +
            "   " + names.getInfoFieldName() + ".getInterceptorChainReadWriteLock().writeLock().unlock();}" +
            "}";
         instanceAdvisorMethod.insertBefore(code);
         genInstanceAdvisor.addMethod(instanceAdvisorMethod);
      }
   }

   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)throws NotFoundException
View Full Code Here

            "   " + updatedAdvicesFieldName + " = false;" +
            "   " + names.getJoinPointField().getName() + " = null;" +
//            "   " + names.getInfoFieldName() + ".setInterceptors(copy.getInterceptors());" +  //We need a way to make this "transient"
            "   super.rebindJoinPointWithInstanceInformation(copy);" +
            "}";
         instanceAdvisorMethod.insertBefore(code);
         genInstanceAdvisor.addMethod(instanceAdvisorMethod);
      }
   }

   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)throws NotFoundException
View Full Code Here

      ctChieldClass.setSuperclass(ctSuperClass);

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

        ctChieldClass.addMethod(ctChieldMethod);
      }
      clazz = ctChieldClass.toClass(classLoader, type.getProtectionDomain());
    }
View Full Code Here

            managedCtClass
        );
      }

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

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

            "      " + updatedAdvicesFieldName + " = false;" +
            "      super.rebindJoinPointWithInstanceInformation(" + names.getInfoFieldName() + ");" +
            "   } finally {" +
            "   " + names.getInfoFieldName() + ".getInterceptorChainReadWriteLock().writeLock().unlock();}" +
            "}";
         instanceAdvisorMethod.insertBefore(code);
         genInstanceAdvisor.addMethod(instanceAdvisorMethod);
      }
   }

   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)throws NotFoundException
View Full Code Here

            "      " + updatedAdvicesFieldName + " = false;" +
            "      super.rebindJoinPointWithInstanceInformation(" + names.getInfoFieldName() + ");" +
            "   } finally {" +
            "   " + names.getInfoFieldName() + ".getInterceptorChainReadWriteLock().writeLock().unlock();}" +
            "}";
         instanceAdvisorMethod.insertBefore(code);
         genInstanceAdvisor.addMethod(instanceAdvisorMethod);
      }
   }

   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)throws NotFoundException
View Full Code Here

/*     */     catch (NotFoundException e)
/*     */     {
/* 714 */       CtMethod instanceAdvisorMethod = CtNewMethod.delegator(names.getWrapper(), this.genInstanceAdvisor);
/* 715 */       String code = "checkVersion();if (" + updatedAdvicesFieldName + ")" + "{ " + "   " + JoinPointInfo.class.getName() + " copy = " + names.getInfoFieldName() + ".copy();" + "   copy.setInterceptors( " + "instanceAdvisorMixin" + ".getWrappers(copy.getInterceptors()) );" + "   " + updatedAdvicesFieldName + " = false;" + "   " + names.getJoinPointField().getName() + " = null;" + "   super.rebindJoinPointWithInstanceInformation(copy);" + "}";
/*     */
/* 726 */       instanceAdvisorMethod.insertBefore(code);
/* 727 */       this.genInstanceAdvisor.addMethod(instanceAdvisorMethod);
/*     */     }
/*     */   }
/*     */
/*     */   protected void initaliseMethodInfo(String infoName, long hash, long unadvisedHash)
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

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.