本文整理汇总了Java中org.springframework.aop.framework.ProxyFactory.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory.setOpaque方法的具体用法?Java ProxyFactory.setOpaque怎么用?Java ProxyFactory.setOpaque使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.framework.ProxyFactory
的用法示例。
在下文中一共展示了ProxyFactory.setOpaque方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProxyForService
import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
/**
* Get a proxy for the given service object, implementing the specified
* service interface.
* <p>Used to export a proxy that does not expose any internals but just
* a specific interface intended for remote access. Furthermore, a
* {@link RemoteInvocationTraceInterceptor} will be registered (by default).
* @return the proxy
* @see #setServiceInterface
* @see #setRegisterTraceInterceptor
* @see RemoteInvocationTraceInterceptor
*/
protected Object getProxyForService() {
checkService();
checkServiceInterface();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addInterface(getServiceInterface());
if (this.registerTraceInterceptor != null ?
this.registerTraceInterceptor.booleanValue() : this.interceptors == null) {
proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
}
if (this.interceptors != null) {
AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
for (int i = 0; i < this.interceptors.length; i++) {
proxyFactory.addAdvisor(adapterRegistry.wrap(this.interceptors[i]));
}
}
proxyFactory.setTarget(getService());
proxyFactory.setOpaque(true);
return proxyFactory.getProxy(getBeanClassLoader());
}
示例2: createProxy
import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public static Object createProxy(Class<?>[] classes, Object target, final ClassLoader classLoader,
BundleContext bundleContext, Advice[] advices) {
final ProxyFactory factory = new ProxyFactory();
ClassUtils.configureFactoryForClass(factory, classes);
for (int i = 0; i < advices.length; i++) {
factory.addAdvice(advices[i]);
}
if (target != null)
factory.setTarget(target);
// no need to add optimize since it means implicit usage of CGLib always
// which is determined automatically anyway
// factory.setOptimize(true);
factory.setFrozen(true);
factory.setOpaque(true);
boolean isSecurityOn = (System.getSecurityManager() != null);
try {
if (isSecurityOn) {
return AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
return factory.getProxy(classLoader);
}
});
} else {
return factory.getProxy(classLoader);
}
} catch (NoClassDefFoundError ncdfe) {
DebugUtils.debugClassLoadingThrowable(ncdfe, bundleContext.getBundle(), classes);
throw ncdfe;
}
}