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


Java ProxyFactory类代码示例

本文整理汇总了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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:EmailServiceRemotable.java

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

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

示例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();
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:24,代码来源:StandardBeanLifecycleDecorator.java

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

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

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

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

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

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

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

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

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

    }

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

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

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

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

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

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

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


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