Package javassist

Examples of javassist.ClassPool.makeClass()


   */
  private byte[] doClass(String name, Class<?> clazz, byte[] b) {
    ClassPool pool = ClassPool.getDefault();
    CtClass cl = null;
    try {
      cl = pool.makeClass(new ByteArrayInputStream(b));
      if (cl.isInterface() == false) {

        loggerName = "_____log";

        // We have to declare the log variable.
View Full Code Here


      System.out.println("libDir = " + libDir.getAbsolutePath());
      // Create a SimpleResponseDTO class with a static serialVersionUID of 1L
      //ClassPool defaultPool = ClassPool.getDefault();
      ClassPool classes1Pool = ClassPool.getDefault();
      //ClassPool classes1Pool = new ClassPool(defaultPool);
      CtClass info = classes1Pool.makeClass("org.jboss.test.scoped.interfaces.dto.SimpleResponseDTO");
      info.addInterface(classes1Pool.get("java.io.Serializable"));
      CtClass s = classes1Pool.get("java.lang.String");
      CtField firstName = new CtField(s, "firstName", info);
      firstName.setModifiers(Modifier.PRIVATE);
      info.addField(firstName);
View Full Code Here

      System.out.println("libDir = " + libDir.getAbsolutePath());
      // Create a SimpleResponseDTO class with a static serialVersionUID of 1L
      //ClassPool defaultPool = ClassPool.getDefault();
      ClassPool classes1Pool = ClassPool.getDefault();
      //ClassPool classes1Pool = new ClassPool(defaultPool);
      CtClass info = classes1Pool.makeClass("org.jboss.test.scoped.interfaces.dto.SimpleResponseDTO");
      info.addInterface(classes1Pool.get("java.io.Serializable"));
      CtClass s = classes1Pool.get("java.lang.String");
      CtField firstName = new CtField(s, "firstName", info);
      firstName.setModifiers(Modifier.PRIVATE);
      info.addField(firstName);
View Full Code Here

    {
        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();

        CtClass ctClass = pool.makeClass(CLASS);

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

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);
View Full Code Here

    {
        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();

        CtClass ctClass = pool.makeClass(CLASS);

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

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);
View Full Code Here

    }

    private Class<?> createArtificialApplicationResourcesClass() {
        try {
            ClassPool classPool = ClassPool.getDefault();
            CtClass applicationResourcesCtClass = classPool.makeClass(APP_FUSE_RESOURCE_FILE_NAME);
            return applicationResourcesCtClass.toClass();
        } catch (CannotCompileException e) {
            throw new RuntimeException("Unable to instantiate Wicket application", e);
        }
    }
View Full Code Here

  public static BeanInterface createJavassistBean() {
    try {
      ClassPool classPool = new ClassPool();
      classPool.appendClassPath(new LoaderClassPath(BeanInterface.class
          .getClassLoader()));
      CtClass theClass = classPool
          .makeClass(ClassFabUtils.generateClassName( BeanInterface.class ) );

      theClass.addInterface(classPool.get(BeanInterface.class.getName()));
      CtMethod theMethod = new CtMethod(
          classPool.get("java.lang.String"), "interfaceMethod",
View Full Code Here

        ClassPool pool = new ClassPool();
        // Inside Maven Surefire, the system classpath is not sufficient to find all
        // the necessary files.
        pool.appendClassPath(new LoaderClassPath(_extraLoader));

        CtClass ctClass = pool.makeClass(SYNTH_COMPONENT_CLASSNAME);

        ctClass.setSuperclass(pool.get(BasicComponent.class.getName()));

        // Implement method getName()
View Full Code Here

        ClassPool pool = new ClassPool();
        // Inside Maven Surefire, the system classpath is not sufficient to find all
        // the necessary files.
        pool.appendClassPath(new LoaderClassPath(extraLoader));

        CtClass ctClass = pool.makeClass(SYNTH_COMPONENT_CLASSNAME);

        ctClass.setSuperclass(pool.get(BasicComponent.class.getName()));

        // Implement method getName()
View Full Code Here

        ClassPool pool = new ClassPool(null);

        pool.appendSystemPath();
        pool.appendClassPath(classesDir.getAbsolutePath());

        CtClass ctClass = pool.makeClass(CLASS);

        ctClass.setSuperclass(pool.get(BASE_CLASS));

        ctClass.writeFile(classesDir.getAbsolutePath());
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.