Package javassist

Examples of javassist.CtClass.addMethod()


         {
            CtField field = new CtField(pool.get(param.getType()), param.getVariable(), clazz);
            field.setModifiers(Modifier.PRIVATE);
            clazz.addField(field);
            clazz.addMethod(CtNewMethod.getter("get" + JavaUtils.capitalize(param.getVariable()), field));
            clazz.addMethod(CtNewMethod.setter("set" + JavaUtils.capitalize(param.getVariable()), field));
         }

         wrapperType = (Class)pool.toClass(clazz, loader);
      }
      catch (Exception e)
View Full Code Here


            if (isClassAdvised) {
                context.markAsAdvised();

                // add the wrapper methods
                for (Iterator it2 = wrapperMethods.iterator(); it2.hasNext();) {
                    ctClass.addMethod((CtMethod)it2.next());
                }
            }

            // handles pointcut unweaving
            // looping on the original methods is enough since we will look for method with no pc
View Full Code Here

                context.markAsPrepared();
                context.markAsAdvised();

                // add the wrapper methods
                for (Iterator it2 = wrapperMethods.iterator(); it2.hasNext();) {
                    ctClass.addMethod((CtMethod)it2.next());
                }
            }
        }
    }
View Full Code Here

         for (WrappedParameter param : wrappedParameters)
         {
            CtField field = new CtField(pool.get(param.getType()), param.getVariable(), clazz);
            field.setModifiers(Modifier.PRIVATE);
            clazz.addField(field);
            clazz.addMethod(CtNewMethod.getter("get" + JavaUtils.capitalize(param.getVariable()), field));
            clazz.addMethod(CtNewMethod.setter("set" + JavaUtils.capitalize(param.getVariable()), field));
         }

         wrapperType = (Class)pool.toClass(clazz, loader);
      }
View Full Code Here

         {
            CtField field = new CtField(pool.get(param.getType()), param.getVariable(), clazz);
            field.setModifiers(Modifier.PRIVATE);
            clazz.addField(field);
            clazz.addMethod(CtNewMethod.getter("get" + JavaUtils.capitalize(param.getVariable()), field));
            clazz.addMethod(CtNewMethod.setter("set" + JavaUtils.capitalize(param.getVariable()), field));
         }

         wrapperType = (Class)pool.toClass(clazz, loader);
      }
      catch (Exception e)
View Full Code Here

      constructor.setBody("{super();}");
      clazz.addConstructor(constructor);

      // add the method implementation
      CtMethod m = CtNewMethod.make(methodDef, clazz);
      clazz.addMethod(m);

      // make this class implements WebAppBootstrap
      ClassFile cf = clazz.getClassFile();
      cf.setVersionToJava5();
      cf.setInterfaces(new String[]{WebAppBootstrap.class.getName()});
View Full Code Here

            }
            methodBody.append("return builder.toString();\n");
            methodBody.append("} catch (Exception e) { throw new RuntimeException(e); } \n");
            methodBody.append("}\n");
            logger.trace(methodBody.toString());
            cc.addMethod(CtNewMethod.make(methodBody.toString(), cc));
        } catch (NotFoundException | CannotCompileException e) {
            logger.error(e.getMessage(), "Compiled body is:\n" + methodBody.toString());
            throw Throwables.propagate(e);
        }
View Full Code Here

                        // Créé le getter
                        String code = "public " + ctField.getType().getName() + " " + getter + "() { return this." + ctField.getName() + "; }";
                        CtMethod getMethod = CtMethod.make(code, ctClass);
                        getMethod.setModifiers(getMethod.getModifiers() | AccessFlag.SYNTHETIC);
                        ctClass.addMethod(getMethod);
                    }

                    try {
                        CtMethod ctMethod = ctClass.getDeclaredMethod(setter);
                        if (ctMethod.getParameterTypes().length != 1 || !ctMethod.getParameterTypes()[0].equals(ctField.getType()) || Modifier.isStatic(ctMethod.getModifiers())) {
View Full Code Here

                        }
                    } catch (NotFoundException noSetter) {
                        // Créé le setter
                        CtMethod setMethod = CtMethod.make("public void " + setter + "(" + ctField.getType().getName() + " value) { this." + ctField.getName() + " = value; }", ctClass);
                        setMethod.setModifiers(setMethod.getModifiers() | AccessFlag.SYNTHETIC);
                        ctClass.addMethod(setMethod);
                        createAnnotation(getAnnotations(setMethod), PlayPropertyAccessor.class);
                    }

                }
View Full Code Here

        String entityName = ctClass.getName();

        // count
        CtMethod count = CtMethod.make("public static long count() { return play.db.jpa.JPQL.instance.count(\"" + entityName + "\"); }", ctClass);
        ctClass.addMethod(count);

        // count2
        CtMethod count2 = CtMethod.make("public static long count(String query, Object[] params) { return play.db.jpa.JPQL.instance.count(\"" + entityName + "\", query, params); }", ctClass);
        ctClass.addMethod(count2);
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.