Package javassist

Examples of javassist.CtClass.addMethod()


      proxy.addMethod(getInstanceAdvisor);
      proxy.addMethod(setInstanceAdvisor);
      proxy.addMethod(dynamicInvoke);
      proxy.addMethod(setMixins);
      if (!interceptWriteReplace)
         proxy.addMethod(writeReplace);

      /*
      CtMethod writeEx = template.getDeclaredMethod("writeExternal");
      CtMethod readEx = template.getDeclaredMethod("readExternal");
      CtMethod getInstanceAdvisor = template.getDeclaredMethod("_getInstanceAdvisor");
View Full Code Here


               params,
               trans.getWMethod().getExceptionTypes(),
               code,
               genadvisor);

         genadvisor.addMethod(advisorMethod);
         advisorMethod.setModifiers(Modifier.setProtected(advisorMethod.getModifiers()));
      }
      catch (CannotCompileException e)
      {
         throw new RuntimeException("code was: " + code + " for method " + getAdvisorMethodName(trans), e);
View Full Code Here

               
                CtMethod getInstance = pcClass.getMethod("getInstance", "()Lorg/rhq/core/pc/PluginContainer;");
                getInstance.setBody("return (org.rhq.core.pc.PluginContainer) INSTANCES.get(CURRENT_INSTANCE_NAME);");
               
                CtMethod setContainerInstance = CtMethod.make("public static void setContainerInstance(java.lang.String name) { CURRENT_INSTANCE_NAME = name; if (!INSTANCES.containsKey((Object)name)) { INSTANCES.put(name, new org.rhq.core.pc.PluginContainer());}}", pcClass);
                pcClass.addMethod(setContainerInstance);
               
                CtMethod createContainerInstance = CtMethod.make("public static org.rhq.core.pc.PluginContainer getContainerInstance(java.lang.String name) { org.rhq.core.pc.PluginContainer inst = (org.rhq.core.pc.PluginContainer) INSTANCES.get(name); if (inst == null) { inst = new org.rhq.core.pc.PluginContainer(); INSTANCES.put(name, inst);} return inst;}", pcClass);
                pcClass.addMethod(createContainerInstance);
               
                pcClass.toClass(cl, null);
View Full Code Here

               
                CtMethod setContainerInstance = CtMethod.make("public static void setContainerInstance(java.lang.String name) { CURRENT_INSTANCE_NAME = name; if (!INSTANCES.containsKey((Object)name)) { INSTANCES.put(name, new org.rhq.core.pc.PluginContainer());}}", pcClass);
                pcClass.addMethod(setContainerInstance);
               
                CtMethod createContainerInstance = CtMethod.make("public static org.rhq.core.pc.PluginContainer getContainerInstance(java.lang.String name) { org.rhq.core.pc.PluginContainer inst = (org.rhq.core.pc.PluginContainer) INSTANCES.get(name); if (inst == null) { inst = new org.rhq.core.pc.PluginContainer(); INSTANCES.put(name, inst);} return inst;}", pcClass);
                pcClass.addMethod(createContainerInstance);
               
                pcClass.toClass(cl, null);
            } catch (Exception e) {
                throw new IllegalStateException("Could not enhance the PluginContainer class", e);
            } finally {
View Full Code Here

                    try {
                        ResourceClientProxy.class.getMethod(name);
                    } catch (NoSuchMethodException nsme) {
                        CtMethod method = CtNewMethod.abstractMethod(pool.get(ResourceClientProxy.Measurement.class.getName()),
                                ResourceClientProxy.getterName(key), new CtClass[0], new CtClass[0], customClass);
                        customClass.addMethod(method);
                    }
                } else if (prop instanceof ResourceClientProxy.Operation) {
                    ResourceClientProxy.Operation o = (ResourceClientProxy.Operation) prop;

                    LinkedHashMap<String, CtClass> types = ConfigurationClassBuilder.translateParameters(pool, o
View Full Code Here

                    ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
                            method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
                    newAnnotationsAttribute.setAnnotations(newAnnotations);
                    method.getMethodInfo().addAttribute(newAnnotationsAttribute);

                    customClass.addMethod(method);
                }
            }

            return customClass.toClass();
        } catch (NotFoundException e) {
View Full Code Here

        // Implement method getName()

        CtMethod method = CtNewMethod.make(
                "public String getName() { return \"" + name + "\"; }",
                ctClass);
        ctClass.addMethod(method);

        ctClass.addInterface(pool.get(Named.class.getName()));

        ctClass.writeFile(_extraClasspath.getAbsolutePath());
    }
View Full Code Here

                   
                    generatedMethod.append(";");
                    generatedMethod.append("}");

                    CtMethod m = CtNewMethod.make(generatedMethod.toString(), cc);
                    cc.addMethod(m);

                    result = (Function)cc.toClass().newInstance();

                    hGeneratedBeanFunctions.put(key, result);
                   
View Full Code Here

                    exceptions[0] = pool.getCtClass(RemoteException.class.getName());
                    i = 1;
                    for (Class<?> et : method.getExceptionTypes()) {
                        exceptions[i++] = pool.getCtClass(et.getCanonicalName());
                    }
                    ctClass.addMethod(CtNewMethod.abstractMethod(
                            pool.getCtClass(method.getReturnType().getCanonicalName()),
                            method.getName(), parameters, exceptions, ctClass));
                }
                return ctClass.toClass();
            }
View Full Code Here

                    exceptions[0] = getCtClass(pool, RemoteException.class.getName());
                    i = 1;
                    for (Class<?> et : method.getExceptionTypes()) {
                        exceptions[i++] = getCtClass(pool, et.getCanonicalName());
                    }
                    ctClass.addMethod(CtNewMethod.abstractMethod(
                            getCtClass(pool, method.getReturnType().getCanonicalName()),
                            method.getName(), parameters, exceptions, ctClass));
                }
                return ctClass.toClass();
            }
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.