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


Java ProxyMethodInvocation.getProxy方法代码示例

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


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

示例1: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable
{
    final Object result;
    final Method method = invocation.getMethod();
    final Class<?> declaringClass = method.getDeclaringClass();
    if (Scriptable.class.isAssignableFrom(declaringClass) && invocation instanceof ProxyMethodInvocation)
    {
        final ProxyMethodInvocation pInvocation = (ProxyMethodInvocation) invocation;
        final Object proxy = pInvocation.getProxy();

        final String methodName = method.getName();
        final Object[] arguments = invocation.getArguments();

        // String-switch not supported in Java < 8
        switch (ScriptableMethodName.methodLiteralOf(methodName))
        {
            case GET:
                if (proxy instanceof List<?> && arguments[0] instanceof String && arguments[1] instanceof Scriptable)
                {
                    switch (NativeArrayFunctionName.functionLiteralOf((String) arguments[0]))
                    {
                        case PUSH:
                            result = new ListPushFunction((Scriptable) arguments[1]);
                            break;
                        case POP:
                            result = new ListPopFunction((Scriptable) arguments[1]);
                            break;
                        case SHIFT:
                            result = new ListShiftFunction((Scriptable) arguments[1]);
                            break;
                        case UNSHIFT:
                            result = new ListUnshiftFunction((Scriptable) arguments[1]);
                            break;
                        case SPLICE:
                            result = new ListSpliceFunction((Scriptable) arguments[1]);
                            break;
                        // TODO add additional simulated functions
                        default:
                            result = invocation.proceed();
                    }
                }
                else
                {
                    result = invocation.proceed();
                }
                break;
            default:
                result = invocation.proceed();
        }
    }
    else
    {
        result = invocation.proceed();
    }

    return result;
}
 
开发者ID:AFaust,项目名称:alfresco-enhanced-script-environment,代码行数:62,代码来源:NativeArrayFunctionSimulatingInterceptor.java

示例2: invoke

import org.springframework.aop.ProxyMethodInvocation; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable
{
    final Object result;
    final Method method = invocation.getMethod();
    final Class<?> declaringClass = method.getDeclaringClass();
    if (Scriptable.class.isAssignableFrom(declaringClass) && invocation instanceof ProxyMethodInvocation)
    {
        final ProxyMethodInvocation pInvocation = (ProxyMethodInvocation) invocation;
        final Object proxy = pInvocation.getProxy();

        final String methodName = method.getName();
        final Object[] arguments = invocation.getArguments();

        // String-switch not supported in Java < 8
        switch (ScriptableMethodName.methodLiteralOf(methodName))
        {
        case GETPARENTSCOPE:
            result = this.parentScope.get(proxy);
            break;
        case SETPARENTSCOPE:
            if (arguments.length > 0 && arguments[0] instanceof Scriptable)
            {
                this.parentScope.put(proxy, (Scriptable) arguments[0]);
            }
            // void return type
            result = null;
            break;
        case GETPROTOTYPE:
            result = this.prototype.get(proxy);
            break;
        case SETPROTOTYPE:
            if (arguments.length > 0 && arguments[0] instanceof Scriptable)
            {
                this.prototype.put(proxy, (Scriptable) arguments[0]);
            }
            // void return type
            result = null;
            break;
        case HASINSTANCE:
            // proxies can never be used for hasInstance checks
            result = Boolean.FALSE;
            break;
        case GETDEFAULTVALUE:
            if (arguments.length > 0)
            {
                if (arguments[0] == null || ScriptRuntime.StringClass == arguments[0])
                {
                    result = proxy.toString();
                }
                else
                {
                    result = null;
                }
            }
            else
            {
                result = null;
            }
            break;
        default:
            // simply delegate further
            result = invocation.proceed();
            break;
        }
    }
    else
    {
        result = invocation.proceed();
    }

    return result;
}
 
开发者ID:AFaust,项目名称:alfresco-enhanced-script-environment,代码行数:77,代码来源:ScriptableBaseAdapterInterceptor.java


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