當前位置: 首頁>>代碼示例>>Java>>正文


Java ProxyFactory.setUseCache方法代碼示例

本文整理匯總了Java中javassist.util.proxy.ProxyFactory.setUseCache方法的典型用法代碼示例。如果您正苦於以下問題:Java ProxyFactory.setUseCache方法的具體用法?Java ProxyFactory.setUseCache怎麽用?Java ProxyFactory.setUseCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javassist.util.proxy.ProxyFactory的用法示例。


在下文中一共展示了ProxyFactory.setUseCache方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: benchmarkJavassist

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
/**
 * Performs a benchmark for a trivial class creation using javassist proxies.
 *
 * @return The created instance, in order to avoid JIT removal.
 */
@Benchmark
public Class<?> benchmarkJavassist() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setUseCache(false);
    ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider() {
        @Override
        public ClassLoader get(ProxyFactory proxyFactory) {
            return newClassLoader();
        }
    };
    proxyFactory.setSuperclass(baseClass);
    proxyFactory.setFilter(new MethodFilter() {
        public boolean isHandled(Method method) {
            return false;
        }
    });
    return proxyFactory.createClass();
}
 
開發者ID:raphw,項目名稱:byte-buddy,代碼行數:24,代碼來源:TrivialClassCreationBenchmark.java

示例2: createJavassistProxyFactory

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
private static ProxyFactory createJavassistProxyFactory(Class<?> persistentClass, Class<?>[] interfaces) {
    ProxyFactory factory = new ProxyFactory();
    factory.setSuperclass(persistentClass);
    factory.setInterfaces(interfaces);
    factory.setFilter(METHOD_FILTERS);
    factory.setUseCache(true);
    if (WRITE_CLASSES_DIRECTORY != null) {
        factory.writeDirectory = WRITE_CLASSES_DIRECTORY;
    }
    return factory;
}
 
開發者ID:grails,項目名稱:gorm-hibernate5,代碼行數:12,代碼來源:JavassistEntityProxyUtils.java

示例3: createProxyFactory

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
private static ProxyFactory createProxyFactory(Class<?> persistentClass, Class<?>[] interfaces) {
    ProxyFactory factory = new ProxyFactory();
    factory.setSuperclass(persistentClass);
    factory.setInterfaces(interfaces);
    factory.setFilter(METHOD_FILTERS);
    factory.setUseCache(true);
    if (WRITE_CLASSES_DIRECTORY != null) {
        factory.writeDirectory = WRITE_CLASSES_DIRECTORY;
    }
    return factory;
}
 
開發者ID:grails,項目名稱:gorm-hibernate5,代碼行數:12,代碼來源:GroovyAwareJavassistLazyInitializer.java

示例4: benchmarkJavassist

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
/**
 * Performs a benchmark of a class extension using javassist proxies.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws java.lang.Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkJavassist() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory() {
        @Override
        protected ClassLoader getClassLoader() {
            return newClassLoader();
        }
    };
    proxyFactory.setUseCache(false);
    proxyFactory.setSuperclass(baseClass);
    proxyFactory.setFilter(new MethodFilter() {
        public boolean isHandled(Method method) {
            return method.getDeclaringClass() == baseClass;
        }
    });
    @SuppressWarnings("unchecked")
    Object instance = proxyFactory.createClass().getDeclaredConstructor().newInstance();
    ((javassist.util.proxy.Proxy) instance).setHandler(new MethodHandler() {
        public Object invoke(Object self,
                             Method thisMethod,
                             Method proceed,
                             Object[] args) throws Throwable {
            return proceed.invoke(self, args);
        }
    });
    return (ExampleClass) instance;
}
 
開發者ID:raphw,項目名稱:byte-buddy,代碼行數:34,代碼來源:ClassByExtensionBenchmark.java

示例5: load

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
@Override
public Class<?> load(final Class<?> frameClass) throws Exception {
	final Class<?> handlerClass = getHandlerClass(frameClass);
	ProxyFactory proxyFactory = new ProxyFactory() {
		@Override
		protected ClassLoader getClassLoader() {

			return new URLClassLoader(new URL[0], handlerClass.getClassLoader());
		}
	};
	proxyFactory.setUseCache(false);
	proxyFactory.setSuperclass(handlerClass);
	return proxyFactory.createClass();
}
 
開發者ID:OpenNTF,項目名稱:org.openntf.domino,代碼行數:15,代碼來源:JavaHandlerModule.java

示例6: benchmarkJavassist

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
/**
 * Performs a benchmark of an interface implementation using javassist proxies.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws java.lang.Exception If the reflective invocation causes an exception.
 */
@Benchmark
public ExampleInterface benchmarkJavassist() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setUseCache(false);
    ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider() {
        @Override
        public ClassLoader get(ProxyFactory proxyFactory) {
            return newClassLoader();
        }
    };
    proxyFactory.setSuperclass(Object.class);
    proxyFactory.setInterfaces(new Class<?>[]{baseClass});
    proxyFactory.setFilter(new MethodFilter() {
        public boolean isHandled(Method method) {
            return true;
        }
    });
    @SuppressWarnings("unchecked")
    Object instance = proxyFactory.createClass().getDeclaredConstructor().newInstance();
    ((javassist.util.proxy.Proxy) instance).setHandler(new MethodHandler() {
        public Object invoke(Object self,
                             Method thisMethod,
                             Method proceed,
                             Object[] args) throws Throwable {
            Class<?> returnType = thisMethod.getReturnType();
            if (returnType.isPrimitive()) {
                if (returnType == boolean.class) {
                    return defaultBooleanValue;
                } else if (returnType == byte.class) {
                    return defaultByteValue;
                } else if (returnType == short.class) {
                    return defaultShortValue;
                } else if (returnType == char.class) {
                    return defaultCharValue;
                } else if (returnType == int.class) {
                    return defaultIntValue;
                } else if (returnType == long.class) {
                    return defaultLongValue;
                } else if (returnType == float.class) {
                    return defaultFloatValue;
                } else {
                    return defaultDoubleValue;
                }
            } else {
                return defaultReferenceValue;
            }
        }
    });
    return (ExampleInterface) instance;
}
 
開發者ID:raphw,項目名稱:byte-buddy,代碼行數:57,代碼來源:ClassByImplementationBenchmark.java

示例7: createProxy

import javassist.util.proxy.ProxyFactory; //導入方法依賴的package包/類
public static Object createProxy(final EntityMeta meta, final Object key, final EntitySession session, final ElementIdentity factory) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException
{
    if (null == meta)
    {
        return null;
    }

    final Class<?> clazz = meta.getType(meta.getId().fromKey(key));
    Class<?> proxy = proxies.get(clazz);
    if (null == proxy)
    {
        ProxyFactory.classLoaderProvider = pf ->
        {
            final List<ClassLoader> loaders = new ArrayList<>(2);
            loaders.add(AssociationUtils.class.getClassLoader());
            if (null == pf)
            {
                return new CompositeClassLoader(ProxyFactory.class.getClassLoader(), loaders);
            }
            final Class<?> type = pf.getSuperclass();
            if (type != null)
            {
                loaders.add(type.getClassLoader());
            }
            return new CompositeClassLoader(ProxyFactory.class.getClassLoader(), loaders);
        };
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setSuperclass(clazz);
        proxyFactory.setUseCache(false);
        proxy = proxyFactory.createClass();
        proxies.put(clazz, proxy);
    }

    final Object instance = proxy.newInstance();
    if (null == instance)
    {
        return null;
    }

    final AssociationAccessor accessor = new ManyToOneAccessor(key, session, factory);
    final LazyAssociationHandler handler = new LazyAssociationHandler(meta, accessor, session);
    ((ProxyObject) instance).setHandler(handler);
    return clazz.cast(instance);
}
 
開發者ID:trajar,項目名稱:normandra,代碼行數:45,代碼來源:AssociationUtils.java


注:本文中的javassist.util.proxy.ProxyFactory.setUseCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。