Package javassist

Examples of javassist.CtMethod.insertBefore()


      ctChieldClass.setSuperclass(ctSuperClass);

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

        ctChieldClass.addMethod(ctChieldMethod);
      }

      clazzProxy = ctChieldClass.toClass(classLoader, type.getProtectionDomain());
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

        }
       
        CtMethod overridenMethod = CtNewMethod.delegator(method, subClass);
        subClass.addMethod(overridenMethod);
       
        overridenMethod.insertBefore("{System.out.println(\"juuubel!:\");};");
    }
}
View Full Code Here

   private void instrumentSetHTML(CtClass c) throws CannotCompileException {
      // add behavior to HasHTML.setHTML method
      try {
         CtMethod setHTML = c.getDeclaredMethod("setHTML", setArgs);
         addHTMLField(c);
         setHTML.insertBefore("this.instrument_oldHTML = this.getHTML();");
         setHTML.insertAfter(GwtFinder.class.getName()
                  + ".onSetHTML(this, $1, this.instrument_oldHTML);");
      } catch (NotFoundException e) {
         // don't instrument method if not existing
      }
View Full Code Here

   private void instrumentSetText(CtClass c) throws CannotCompileException {
      // add behavior to HasHTML.setHTML method
      try {
         CtMethod setText = c.getDeclaredMethod("setText", setArgs);
         addTextField(c);
         setText.insertBefore("this.instrument_oldText = this.getText();");
         setText.insertAfter(GwtFinder.class.getName()
                  + ".onSetText(this, $1, this.instrument_oldText);");
      } catch (NotFoundException e) {
         // don't instrument method if not existing
      }
View Full Code Here

   private void instrumentSetName(CtClass c) throws CannotCompileException {
      // add behavior to HasHTML.setHTML method
      try {
         CtMethod setName = c.getDeclaredMethod("setName", setArgs);
         addTextField(c);
         setName.insertBefore("this.instrument_oldName = this.getName();");
         setName.insertAfter(GwtFinder.class.getName()
                  + ".onSetName(this, $1, this.instrument_oldName);");
      } catch (NotFoundException e) {
         // don't instrument method if not existing
      }
View Full Code Here

                        + ".onRadioGroupChanged(this, $1, $2); }", c);
      c.addMethod(setValue);

      // add behavior to RadioButton.setName method
      CtMethod setName = c.getMethod("setName", "(Ljava/lang/String;)V");
      setName.insertBefore(RadioButtonManager.class.getName() + ".beforeSetName(this, $1);");

      // Add overrided RadioButton.onLoad method
      CtMethod onLoad = CtMethod.make("protected void onLoad() { super.onLoad(); "
               + RadioButtonManager.class.getName() + ".onLoad(this); }", c);
      c.addMethod(onLoad);
View Full Code Here

      CtMethod defaultConstMethod = defaultCons.toMethod(DEFAULT_CONS_METHOD_NAME, classToModify);
      defaultConstMethod.setModifiers(Modifier.PUBLIC);

      if (hasDefaultConstMethod(classToModify.getSuperclass())) {
         defaultConstMethod.insertBefore("super." + DEFAULT_CONS_METHOD_NAME + "();");
      }
      classToModify.addMethod(defaultConstMethod);

      overrideReadObject(classToModify);
   }
View Full Code Here

               "fireNativeEvent",
               "(Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/event/shared/HasHandlers;Lcom/google/gwt/dom/client/Element;)V");

      // fire browser event loop first because some command or async callback may modify the DOM
      // structure + fire NativePreviewHandler
      fireNativeEvent.insertBefore(BrowserSimulatorImpl.class.getName() + ".get().fireLoopEnd(); "
               + DomEventPatcher.class.getName() + ".triggerNativeEvent($1, $3);");

      // fire browser event loop at the end because some command may have been scheduled or RPC call
      // made when the event was dispatched.
      fireNativeEvent.insertAfter(BrowserSimulatorImpl.class.getName() + ".get().fireLoopEnd();");
View Full Code Here

   @InitMethod
   static void initClass(CtClass c) throws CannotCompileException, NotFoundException {

      // add behavior to Widget.onAttach method
      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

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.