本文整理汇总了Java中org.springframework.aop.framework.ProxyFactory类的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory类的具体用法?Java ProxyFactory怎么用?Java ProxyFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProxyFactory类属于org.springframework.aop.framework包,在下文中一共展示了ProxyFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBootstrap
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
@Override
protected void onBootstrap(ApplicationEvent event)
{
if (rmiRegistryHost == null)
{
throw new AlfrescoRuntimeException("Property 'rmiRegistryHost' not set");
}
if (rmiRegistryPort == 0)
{
throw new AlfrescoRuntimeException("Property 'rmiRegistryPort' not set");
}
RmiClientInterceptor rmiClientInterceptor = new RmiClientInterceptor();
rmiClientInterceptor.setRefreshStubOnConnectFailure(true);
rmiClientInterceptor.setServiceUrl("rmi://" + rmiRegistryHost + ":" + rmiRegistryPort + "/emailService");
emailServiceProxy = (EmailService) ProxyFactory.getProxy(EmailService.class, rmiClientInterceptor);
}
示例2: testBasicDenyParentAssocNode
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicDenyParentAssocNode() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("testOneChildAssociationRef", new Class[] { ChildAssociationRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_PARENT.0.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
try
{
method.invoke(proxy, new Object[] { nodeService.getPrimaryParent(systemNodeRef) });
assertNotNull(null);
}
catch (InvocationTargetException e)
{
}
}
示例3: getDisposalLockProxy
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
/**
* Apply a lock (preferably a read lock allowing multiple concurrent access) to the bean. Callers should replace the
* bean input with the output.
*
* @param bean the bean to lock
* @param lock the lock to apply
* @return a proxy that locks while its methods are executed
*/
private Object getDisposalLockProxy(Object bean, final Lock lock) {
ProxyFactory factory = new ProxyFactory(bean);
factory.setProxyTargetClass(proxyTargetClass);
factory.addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
lock.lock();
try {
return invocation.proceed();
} finally {
lock.unlock();
}
}
});
return factory.getProxy();
}
示例4: create
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
/**
* Helper method to create a {@link PermissionCheckedValue} from an existing <code>Object</code>.
*
* @param object the <code>Object</code> to proxy
* @return a <code>Object</code> of the same type but including the
* {@link PermissionCheckedValue} interface
*/
@SuppressWarnings("unchecked")
public static final <T extends Object> T create(T object)
{
// Create the mixin
DelegatingIntroductionInterceptor mixin = new PermissionCheckedValueMixin();
// Create the advisor
IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckedValue.class);
// Proxy
ProxyFactory pf = new ProxyFactory(object);
pf.addAdvisor(advisor);
Object proxiedObject = pf.getProxy();
// Done
return (T) proxiedObject;
}
示例5: create
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
/**
* Helper method to create a {@link PermissionCheckedCollection} from an existing <code>Collection</code>
*
* @param <TT> the type of the <code>Collection</code>
* @param collection the <code>Collection</code> to proxy
* @param isCutOff <tt>true</tt> if permission checking was cut off before completion
* @param sizeUnchecked number of entries from the original collection that were not checked
* @param sizeOriginal number of entries in the original, pre-checked collection
* @return a <code>Collection</code> of the same type but including the
* {@link PermissionCheckedCollection} interface
*/
@SuppressWarnings("unchecked")
public static final <TT> Collection<TT> create(
Collection<TT> collection,
boolean isCutOff, int sizeUnchecked, int sizeOriginal)
{
// Create the mixin
DelegatingIntroductionInterceptor mixin = new PermissionCheckedCollectionMixin<Integer>(
isCutOff,
sizeUnchecked,
sizeOriginal
);
// Create the advisor
IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckedCollection.class);
// Proxy
ProxyFactory pf = new ProxyFactory(collection);
pf.addAdvisor(advisor);
Object proxiedObject = pf.getProxy();
// Done
return (Collection<TT>) proxiedObject;
}
示例6: create
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
/**
* Helper method to create a {@link PermissionCheckCollection} from an existing <code>Collection</code>
*
* @param <TT> the type of the <code>Collection</code>
* @param collection the <code>Collection</code> to proxy
* @param targetResultCount the desired number of results or default to the collection size
* @param cutOffAfterTimeMs the number of milliseconds to wait before cut-off or zero to use the system default
* time-based cut-off.
* @param cutOffAfterCount the number of permission checks to process before cut-off or zero to use the system default
* count-based cut-off.
* @return a <code>Collection</code> of the same type but including the
* {@link PermissionCheckCollection} interface
*/
@SuppressWarnings("unchecked")
public static final <TT> Collection<TT> create(
Collection<TT> collection,
int targetResultCount, long cutOffAfterTimeMs, int cutOffAfterCount)
{
if (targetResultCount <= 0)
{
targetResultCount = collection.size();
}
// Create the mixin
DelegatingIntroductionInterceptor mixin = new PermissionCheckCollectionMixin<Integer>(
targetResultCount,
cutOffAfterTimeMs,
cutOffAfterCount);
// Create the advisor
IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckCollection.class);
// Proxy
ProxyFactory pf = new ProxyFactory(collection);
pf.addAdvisor(advisor);
Object proxiedObject = pf.getProxy();
// Done
return (Collection<TT>) proxiedObject;
}
示例7: testBasicAllowNullNode
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowNullNode() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoNodeRef", new Class[] { NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
Object answer = method.invoke(proxy, new Object[] { null });
assertNull(answer);
}
示例8: testBasicAllowNullStore
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowNullStore() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoStoreRef", new Class[] { StoreRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
Object answer = method.invoke(proxy, new Object[] { null });
assertNull(answer);
}
示例9: testBasicAllowUnrecognisedObject
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowUnrecognisedObject() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoObject", new Class[] { Object.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
Object answer = method.invoke(proxy, new Object[] { "noodle" });
assertNotNull(answer);
}
示例10: testBasicDenyStore
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicDenyStore() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoStoreRef", new Class[] { StoreRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
try
{
Object answer = method.invoke(proxy, new Object[] { rootNodeRef.getStoreRef() });
assertNotNull(answer);
}
catch (InvocationTargetException e)
{
}
}
示例11: testBasicDenyNode
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicDenyNode() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoNodeRef", new Class[] { NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
try
{
Object answer = method.invoke(proxy, new Object[] { rootNodeRef });
assertNotNull(answer);
}
catch (InvocationTargetException e)
{
}
}
示例12: testBasicAllowNode
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowNode() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoNodeRef", new Class[] { NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Object answer = method.invoke(proxy, new Object[] { rootNodeRef });
assertEquals(answer, rootNodeRef);
}
示例13: testBasicAllowNodePair
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowNodePair() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoNodePair", new Class[] { NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Pair<Long, NodeRef> rootNodePair = new Pair<Long, NodeRef>(Long.valueOf(1), rootNodeRef);
Object answer = method.invoke(proxy, new Object[] { rootNodeRef });
assertEquals(rootNodePair, answer);
}
示例14: testBasicAllowStore
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowStore() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoStoreRef", new Class[] { StoreRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Object answer = method.invoke(proxy, new Object[] { rootNodeRef.getStoreRef() });
assertEquals(answer, rootNodeRef.getStoreRef());
}
示例15: testBasicAllowNullChildAssociationRef1
import org.springframework.aop.framework.ProxyFactory; //导入依赖的package包/类
public void testBasicAllowNullChildAssociationRef1() throws Exception
{
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("echoChildAssocRef", new Class[] { ChildAssociationRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
Object answer = method.invoke(proxy, new Object[] { null });
assertNull(answer);
}