ih, loader, wreplace, delegating, filter ).define(); try { Class mi = Class.forName(methodInterceptorName, true, loader); if (delegating) { factory = (Factory)result.getConstructor(new Class[]{ mi, Constants.TYPE_OBJECT }) .newInstance(new Object[]{ null, null }); } else { factory = (Factory)result.getConstructor(new Class[]{ mi }) .newInstance(new Object[]{ null }); } factories.put(key, factory); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new CodeGenerationException(e); }
ih, loader, wreplace, delegating, filter).define(); Class[] types = delegating ? new Class[]{ mi, Constants.TYPE_OBJECT } : new Class[]{ mi }; factory = (Factory)FactoryCache.newInstance(result, types, new Object[delegating ? 2 : 1]); cache.put(loader, key, factory);
    private static Object enhanceHelper(boolean delegating, Object obj,Class cls,                                        Class[] interfaces, MethodInterceptor ih,                                        ClassLoader loader,Method wreplace,                                        MethodFilter filter) {        if (ih == null) {            throw new IllegalArgumentException("MethodInterceptor is null");        }        if (cls != null && obj != null && !cls.isAssignableFrom(obj.getClass())) {            throw new IllegalArgumentException("Class must be same class or superclass of delegate");        }        if (cls == null) {            if (obj == null) {                cls = Constants.TYPE_OBJECT;            } else {                cls = obj.getClass();            }        }        if (loader == null) {            loader = defaultLoader;        }        Factory factory;        synchronized (cache) {            Map factories = (Map)cache.get(loader);            if (factories == null) {                cache.put(loader, factories = new HashMap());            }            Object key = keyFactory.newInstance(cls, interfaces, wreplace, ih.getClass(), delegating);            factory = (Factory)factories.get(key);            if (factory == null) {                Class result = new EnhancerGenerator(getNextName(cls), cls, interfaces,                                                     ih, loader, wreplace,                                                     delegating, filter ).define();                try {                    Class mi = Class.forName(methodInterceptorName, true, loader);                    if (delegating) {                        factory = (Factory)result.getConstructor(new Class[]{ mi, Constants.TYPE_OBJECT })                            .newInstance(new Object[]{ null, null });                    } else {                        factory = (Factory)result.getConstructor(new Class[]{ mi })                            .newInstance(new Object[]{ null });                    }                    factories.put(key, factory);                } catch (RuntimeException e) {                    throw e;                } catch (Exception e) {                    throw new CodeGenerationException(e);                }            }        }        if (delegating) {            return factory.newInstance(ih, obj);        } else {            return factory.newInstance(ih);        }    }