Package javassist

Examples of javassist.CtMethod$LongConstParameter


    private void copyStaticMethodsToSubclass(CtClass document, CtClass targetClass) throws Exception {
        CtMethod[] ctMethods = document.getMethods();

        for (CtMethod ctMethod : ctMethods) {
            if (Modifier.isStatic(ctMethod.getModifiers()) && !shouldNotCopyToSubclassStaticMethods.contains(ctMethod.getName())) {
                CtMethod ctNewMethod = CtNewMethod.copy(ctMethod, targetClass, null);
                targetClass.addMethod(ctNewMethod);
            }

        }
    }
View Full Code Here


       
        // all
        try {
          ctClass.getDeclaredMethod("all");
        }catch(NotFoundException ex){
            CtMethod all = CtMethod.make("public static play.modules.siena.QueryWrapper all() { return new play.modules.siena.QueryWrapper(siena.Model.all("+entityName+".class)); }", ctClass);
            ctClass.addMethod(all);         
        }
 
        // batch
        try {
          ctClass.getDeclaredMethod("batch");
        }catch(NotFoundException ex){
          CtMethod batch = CtMethod.make("public static play.modules.siena.BatchWrapper batch() { return new play.modules.siena.BatchWrapper(siena.Model.batch("+entityName+".class)); }", ctClass);
          ctClass.addMethod(batch);
        }
       
        // getbyKey
        try {
          ctClass.getDeclaredMethod("getByKey");
        }catch(NotFoundException ex){
          CtMethod batch = CtMethod.make("public static play.modules.siena.EnhancedModel getByKey(Object key) { return (play.modules.siena.EnhancedModel)siena.Model.getByKey("+entityName+".class, key); }", ctClass);
          ctClass.addMethod(batch);
        }

        // create
        try {
          ctClass.getDeclaredMethod("create");
        }catch(NotFoundException ex){
            CtMethod create = CtMethod.make("public static play.modules.siena.EnhancedModel create(String name, play.mvc.Scope.Params params) { return play.modules.siena.EnhancedModel.create("+entityName+".class, name, params.all()); }",ctClass);
            ctClass.addMethod(create);
        }


        // count
        try {
          ctClass.getDeclaredMethod("count");
        }catch(NotFoundException ex){
          CtMethod count = CtMethod.make("public static long count() { return (long)siena.Model.all("+entityName+".class).count(); }", ctClass);
          ctClass.addMethod(count);
        }

        // findAll
        try {
          ctClass.getDeclaredMethod("findAll");
        }catch(NotFoundException ex){
          CtMethod findAll = CtMethod.make("public static java.util.List findAll() { return (java.util.List)siena.Model.all("+entityName+".class).fetch(); }", ctClass);
          ctClass.addMethod(findAll);
        }

        // deleteAll
        try {
          ctClass.getDeclaredMethod("deleteAll");
       }catch(NotFoundException ex){
          CtMethod deleteAll = CtMethod.make("public static long deleteAll() { return (long)siena.Model.all("+entityName+".class).delete(); }", ctClass);
          ctClass.addMethod(deleteAll);
        }
 
        // findById
       try {
         ctClass.getDeclaredMethod("findById");
       }catch(NotFoundException ex){
         CtMethod findById = CtMethod.make("public static play.modules.siena.EnhancedModel findById(Object id) { return (play.modules.siena.EnhancedModel)siena.Model.getByKey("+entityName+".class, id); }", ctClass);
         ctClass.addMethod(findById);
       }
       
        // Done.
        applicationClass.enhancedByteCode = ctClass.toBytecode();
View Full Code Here

                PARAMETER_ACCESSOR_TEMPLATE,
                new Object[] { readBindingMethodName, bindingValueAccessor, castToType });

        try
        {
            CtMethod method = cf.createAccessor(_type, _propertyName, _readMethodName);
            method.setBody(readMethodBody);
            cf.addMethod(method);
        }
        catch (CannotCompileException e)
        {
            throw new CodeGenerationException(e);
View Full Code Here

                PARAMETER_MUTATOR_TEMPLATE,
                new Object[] { readBindingMethodName, bindingValueAccessor, valueCast });

        try
        {
            CtMethod method = cf.createMutator(_type, _propertyName);
            method.setBody(writeMethodBody);
            cf.addMethod(method);
        }
        catch (CannotCompileException e)
        {
            throw new CodeGenerationException(e);
View Full Code Here

        CtClass[] arguments)
    {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating method: " + methodName);

        CtMethod method = new CtMethod(returnType, methodName, arguments, _genClass);

        return method;
    }
View Full Code Here

            readMethodName == null ? buildMethodName("get", propertyName) : readMethodName;

        if (LOG.isDebugEnabled())
            LOG.debug("Creating accessor: " + methodName);

        CtMethod method = new CtMethod(fieldType, methodName, new CtClass[0], _genClass);

        return method;
    }
View Full Code Here

        try
        {
            String accessorBody =
                MessageFormat.format(PROPERTY_ACCESSOR_TEMPLATE, new Object[] { fieldName, propertyName });

            CtMethod method = createAccessor(fieldType, propertyName, readMethodName);
            method.setBody(accessorBody);
            _genClass.addMethod(method);
        }
        catch (CannotCompileException e)
        {
            throw new CodeGenerationException(e);
View Full Code Here

        String methodName = buildMethodName("set", propertyName);

        if (LOG.isDebugEnabled())
            LOG.debug("Creating mutator: " + methodName);

        CtMethod method =
            new CtMethod(CtClass.voidType, methodName, new CtClass[] { fieldType }, _genClass);

        return method;
    }
View Full Code Here

        String bodyTemplate = isPersistent ? PERSISTENT_PROPERTY_MUTATOR_TEMPLATE : PROPERTY_MUTATOR_TEMPLATE;
        String body = MessageFormat.format(bodyTemplate, new Object[] { fieldName, propertyName });

        try
        {
            CtMethod method = createMutator(fieldType, propertyName);
            method.setBody(body);
            _genClass.addMethod(method);
        }
        catch (CannotCompileException e)
        {
            throw new CodeGenerationException(e);
View Full Code Here

        CtClass ctReturnType = convertClass(ms.getReturnType());

        CtClass[] ctParameters = convertClasses(ms.getParameterTypes());
        CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes());

        CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass());

        try
        {
            method.setModifiers(modifiers);
            method.setBody(body);
            method.setExceptionTypes(ctExceptions);

            getCtClass().addMethod(method);
        }
        catch (Exception ex)
        {
View Full Code Here

TOP

Related Classes of javassist.CtMethod$LongConstParameter

Copyright © 2018 www.massapicom. 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.