Package javassist

Examples of javassist.ClassPool


        component = new String(string);
        return component;
    }

    private ClassPool getClassPool(Type rootComponent) {
        ClassPool pool = rootComponent.clazz.getClassPool();
        return pool != null ? pool : ClassPool.getDefault();
    }
View Full Code Here


  private ClassLoader parent;
  private ClassPool classPool;

  /*package*/ TransformingClassLoader(ClassLoader parent, String[] classpath) {
    this.parent = parent;
    classPool = new ClassPool( true );
    for ( int i = 0; i < classpath.length; i++ ) {
      try {
        classPool.appendClassPath( classpath[i] );
      }
      catch ( NotFoundException e ) {
View Full Code Here

    private ClassPool _pool;
    private ClassFactoryClassLoader _loader;

    public CtClassSource(ClassLoader parentLoader)
    {
        _pool = new ClassPool(null);

        ClassPath path = new LoaderClassPath(parentLoader);

        _pool.appendClassPath(path);
View Full Code Here

    * @param classLoader the class loader
    * @return javassist class pool
    */
   protected ClassPool createClassPool(ClassLoader classLoader)
   {
      ClassPool pool = new ClassPool();
      ClassPath classPath = new LoaderClassPath(classLoader);
      pool.insertClassPath(classPath);
      return pool;
   }
View Full Code Here

      if (log.isTraceEnabled())
         log.trace("Creating AnnotationEnvironment for " + unit.getName() + ", module: " + module + ", force annotations: " + forceAnnotations);

      ClassLoader classLoader = unit.getClassLoader();
      ClassPool pool = createClassPool(classLoader);
      GenericAnnotationResourceVisitor visitor = createGenericAnnotationResourceVisitor(unit, pool, classLoader);

      // something in javassist uses TCL
      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(classLoader);
View Full Code Here

    @SuppressWarnings("unchecked")
    public static <T> Class<T> getModifiedClass(Class<T> clazz, Annotation[] add)
        throws javassist.NotFoundException, CannotCompileException, InvocationTargetException, IllegalAccessException
    {
        ClassPool pool = ClassPool.getDefault();
        CtClass cc = pool.get(clazz.getCanonicalName());
        for (CtMethod method : cc.getDeclaredMethods()) {
            ClassFile ccFile = cc.getClassFile();
            ConstPool constpool = ccFile.getConstPool();
            AnnotationsAttribute attr;
            attr = filterExistingAnnotations(add, method);
            addNewAnnotations(add, method, constpool, pool, attr);
        }
        cc.setName(cc.getName() + "$ClassModifier$" + COUNTER.increment());
        cc.setSuperclass(pool.get(clazz.getCanonicalName()));
        return cc.toClass();
    }
View Full Code Here

   * @param manager
   */
  @SuppressWarnings({ "deprecation", "unchecked" })
  public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager) throws RuntimeException {
    try {
      ClassPool cp = ClassPool.getDefault();
      cp.insertClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));
      cp.importPackage("org.zkoss.zul");
      cp.importPackage("org.zkoss.zk.ui");
      cp.importPackage("org.zkoss.cdi.util");
     
      CtClass mainclas = cp.makeClass("org.zkoss.zkplus.cdi.ZKComponentProducerMethods");
      final List<URL> l = getUrlsForCurrentClasspath();
     
      Reflections reflections = new Reflections(
          new ConfigurationBuilder().setUrls(l)
          .setScanners(new FieldAnnotationsScanner()));
     
      Set<Field> fields = reflections.getFieldsAnnotatedWith(ComponentId.class);
      for (Iterator iterator2 = fields.iterator(); iterator2
          .hasNext();) {
        Field field = (Field) iterator2.next();
        CtClass cls = cp.get(field.getType().getName());
        String pckgName = cls.getPackageName();
        if (Component.class.isAssignableFrom(field.getType()) || !pckgName.endsWith("zul.api")) {
          addProducerMethod(field, mainclas);
        }
      }
View Full Code Here

    * @param classLoader the class loader
    * @return javassist class pool
    */
   protected ClassPool createClassPool(ClassLoader classLoader)
   {
      ClassPool pool = new ClassPool();
      ClassPath classPath = new LoaderClassPath(classLoader);
      pool.insertClassPath(classPath);
      return pool;
   }
View Full Code Here

   {
      if (log.isTraceEnabled())
         log.trace("Creating AnnotationEnvironment for " + unit.getName() + ", module: " + module + ", force annotations: " + forceAnnotations);

      ClassLoader classLoader = unit.getClassLoader();
      ClassPool pool = createClassPool(classLoader);
      GenericAnnotationResourceVisitor visitor = createGenericAnnotationResourceVisitor(unit, pool, classLoader);

      // something in javassist uses TCL
      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(classLoader);
View Full Code Here

  private final CtClass oneWaySuperClass ;
  private final CtClass requestResponseSuperClass ;
 
  public JAXWSProviderClassGenerator()
      throws WebServicePublishException {
    pool = new ClassPool() ;
    final ClassLoader tccl = Thread.currentThread().getContextClassLoader() ;
    if (tccl != null)
    {
      pool.appendClassPath(new LoaderClassPath(tccl)) ;
    }
View Full Code Here

TOP

Related Classes of javassist.ClassPool

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.