当前位置: 首页>>代码示例>>Java>>正文


Java ProxyFactory.setTargetSource方法代码示例

本文整理汇总了Java中org.springframework.aop.framework.ProxyFactory.setTargetSource方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory.setTargetSource方法的具体用法?Java ProxyFactory.setTargetSource怎么用?Java ProxyFactory.setTargetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.aop.framework.ProxyFactory的用法示例。


在下文中一共展示了ProxyFactory.setTargetSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMethodACL4

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMethodACL4() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("testMethod", new Class[] {});

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_METHOD.woof", "ACL_METHOD.BOO")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    try
    {
        method.invoke(proxy, new Object[] {});
    }
    catch (InvocationTargetException e)
    {

    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:ACLEntryVoterTest.java

示例2: 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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:ACLEntryAfterInvocationTest.java

示例3: 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());

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:ACLEntryAfterInvocationTest.java

示例4: testMethodACL

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMethodACL() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("testMethod", new Class[] {});

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_METHOD.andy", "ACL_METHOD.BANANA")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    method.invoke(proxy, new Object[] {});
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ACLEntryVoterTest.java

示例5: createRefreshableProxy

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(proxyTargetClass);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ScriptFactoryPostProcessor.java

示例6: testBasicDenyChildAssocNode

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testBasicDenyChildAssocNode() 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_NODE.0.sys:base.Read")));

    proxyFactory.setTargetSource(new SingletonTargetSource(o));

    Object proxy = proxyFactory.getProxy();

    try
    {
        method.invoke(proxy, new Object[] { nodeService.getPrimaryParent(rootNodeRef) });
        assertNotNull(null);
    }
    catch (InvocationTargetException e)
    {

    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:ACLEntryVoterTest.java

示例7: testBasicAllowChildAssociationRef2

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testBasicAllowChildAssociationRef2() 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_PARENT.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[] { nodeService.getPrimaryParent(rootNodeRef) });
    assertEquals(answer, nodeService.getPrimaryParent(rootNodeRef));

    answer = method.invoke(proxy, new Object[] { nodeService.getPrimaryParent(systemNodeRef) });
    assertEquals(answer, nodeService.getPrimaryParent(systemNodeRef));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ACLEntryAfterInvocationTest.java

示例8: testMethodACL2

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMethodACL2() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("testMethod", new Class[] {});

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_METHOD.BANANA", "ACL_METHOD."
            + PermissionService.ALL_AUTHORITIES)));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    method.invoke(proxy, new Object[] {});
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:ACLEntryVoterTest.java

示例9: createRefreshableProxy

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
/**
    * Create a refreshable proxy for the given AOP TargetSource.
    * 
    * @param ts
    *            the refreshable TargetSource
    * @param interfaces
    *            the proxy interfaces (may be {@code null} to indicate proxying
    *            of all interfaces implemented by the target class)
    * @return the generated proxy
    * @see RefreshableScriptTargetSource
    */
   protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTargetSource(ts);
ClassLoader classLoader = this.beanClassLoader;

if (interfaces == null) {
    interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
}
proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) {
    classLoader = null; // force use of Class.getClassLoader()
    proxyFactory.setProxyTargetClass(true);
}

DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
introduction.suppressInterface(TargetSource.class);
proxyFactory.addAdvice(introduction);

return proxyFactory.getProxy(classLoader);
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:32,代码来源:MyScriptFactoryPostProcessor.java

示例10: createRefreshableProxy

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(true);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ScriptFactoryPostProcessor.java

示例11: testMultiNodeMethodsArg2

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMultiNodeMethodsArg2() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("testManyNodeRef",
            new Class[] { NodeRef.class, NodeRef.class, NodeRef.class, NodeRef.class });

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_NODE.2.sys:base.Read")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    method.invoke(proxy, new Object[] { null, null, null, null });

    try
    {
        method.invoke(proxy, new Object[] { null, null, rootNodeRef, null });
        assertNotNull(null);
    }
    catch (InvocationTargetException e)
    {

    }

    permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ),
            "andy", AccessStatus.ALLOWED));
    method.invoke(proxy, new Object[] { null, null, rootNodeRef, null });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:ACLEntryVoterTest.java

示例12: testBasicFilterInvalidNodeRefs

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void testBasicFilterInvalidNodeRefs() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("echoCollection", new Class[] { Collection.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));
    
    List<Object> answer = (List<Object>) method.invoke(proxy, new Object[] { Collections.singletonList(rootNodeRef) });
    assertEquals("Collection must be intact", 1, answer.size());

    NodeRef invalidNodeRef = new NodeRef("workspace://SpacesStore/noodle");
    answer = (List<Object>) method.invoke(proxy, new Object[] { Collections.singletonList(invalidNodeRef) });
    assertEquals("Invalid NodeRef should not have been filtered out", 1, answer.size());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:ACLEntryAfterInvocationTest.java

示例13: testMultiNodeMethodsArg3

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMultiNodeMethodsArg3() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("testManyNodeRef",
            new Class[] { NodeRef.class, NodeRef.class, NodeRef.class, NodeRef.class });

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_NODE.3.sys:base.Read")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    method.invoke(proxy, new Object[] { null, null, null, null });

    try
    {
        method.invoke(proxy, new Object[] { null, null, null, rootNodeRef });
        assertNotNull(null);
    }
    catch (InvocationTargetException e)
    {

    }

    permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ),
            "andy", AccessStatus.ALLOWED));
    method.invoke(proxy, new Object[] { null, null, null, rootNodeRef });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:ACLEntryVoterTest.java

示例14: testDenyParentAssocNode

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testDenyParentAssocNode() throws Exception
{
    runAs("andy");

    permissionService.setPermission(new SimplePermissionEntry(systemNodeRef, getPermission(PermissionService.READ),
            "andy", AccessStatus.ALLOWED));

    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)
    {

    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:ACLEntryVoterTest.java

示例15: testMultiChildAssocRefMethodsArg2

import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
public void testMultiChildAssocRefMethodsArg2() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod(
            "testManyChildAssociationRef",
            new Class[] { ChildAssociationRef.class, ChildAssociationRef.class, ChildAssociationRef.class,
                    ChildAssociationRef.class });

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_NODE.2.sys:base.Read")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    method.invoke(proxy, new Object[] { null, null, null, null });

    try
    {
        method.invoke(proxy, new Object[] { null, null, nodeService.getPrimaryParent(rootNodeRef), null });
        assertNotNull(null);
    }
    catch (InvocationTargetException e)
    {

    }

    permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ),
            "andy", AccessStatus.ALLOWED));
    method.invoke(proxy, new Object[] { null, null, nodeService.getPrimaryParent(rootNodeRef), null });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:ACLEntryVoterTest.java


注:本文中的org.springframework.aop.framework.ProxyFactory.setTargetSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。