Java 类net.sf.cglib.proxy.Proxy 实例源码

项目:ojb    文件:InterceptorFactory.java   
public Object createInterceptorFor(Object instanceToIntercept)
    {
        if (getInterceptorClassToBeUsed() != null)
        {
            try
            {


//              Class[] parameterTypes = {Object.class};
//              Object[] parameters = {instanceToIntercept};
//              Constructor constructor = getInterceptorClassToBeUsed().getConstructor(parameterTypes);
//              InvocationHandler handler = (InvocationHandler) constructor.newInstance(parameters);
                // use helper class to instantiate
                InvocationHandler handler = (InvocationHandler) ClassHelper.newInstance(
                                            getInterceptorClassToBeUsed(), Object.class, instanceToIntercept);
                Class[] interfaces = computeInterfaceArrayFor(instanceToIntercept.getClass());
                Object result =
                    Proxy.newProxyInstance(
                        ClassHelper.getClassLoader(),
                        interfaces,
                        handler);
                return result;
            }
            catch (Throwable t)
            {
                LoggerFactory.getDefaultLogger().error("can't use Interceptor " + getInterceptorClassToBeUsed().getName() +
                    "for " + instanceToIntercept.getClass().getName(), t);
                return instanceToIntercept;
            }
        }
        else
        {
            return instanceToIntercept;
        }
    }
项目:lams    文件:CGLIBProxyTypePermission.java   
@Override
public boolean allows(final Class<?> type) {
    return type != null && type != Object.class && !type.isInterface()
        && (Proxy.isProxyClass(type) || type.getName().startsWith(Proxy.class.getPackage().getName() + "."));
}
项目:xstream    文件:CGLIBProxyTypePermission.java   
@Override
public boolean allows(final Class<?> type) {
    return type != null && type != Object.class && !type.isInterface()
        && (Proxy.isProxyClass(type) || type.getName().startsWith(Proxy.class.getPackage().getName() + "."));
}
项目:QuizUpWinner    文件:CGLIBProxyTypePermission.java   
public boolean allows(Class paramClass)
{
  return (paramClass != null) && (paramClass != Object.class) && (!paramClass.isInterface()) && ((Proxy.isProxyClass(paramClass)) || (paramClass.getName().startsWith(Proxy.class.getPackage().getName() + ".")));
}
项目:t4f-data    文件:DynamicFinders.java   
/**
 * Creates a new dynamic accessor instance.
 * 
 * @param accessor specification for the accessor instance to create
 * @param finderInterceptor the finder interceptor to use
 * @return a Warp Persist-generated instance of the given accessor
 */
public static Object newDynamicAccessor(Class<?> accessor,
                                        MethodInterceptor finderInterceptor) {
    return Proxy.newProxyInstance(accessor.getClassLoader(),
                    new Class<?>[] { accessor }, new AopAllianceJdkProxyAdapter(
                    finderInterceptor));
}