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


Java ActionInvocation.getProxy方法代码示例

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


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

示例1: getKey

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
private String getKey(ActionInvocation invocation) {
    ActionProxy proxy = invocation.getProxy();
    if (key == null || "CLASS".equals(key)) {
        return "struts.ScopeInterceptor:" + proxy.getAction().getClass();
    } else if ("ACTION".equals(key)) {
        return "struts.ScopeInterceptor:" + proxy.getNamespace() + ":" + proxy.getActionName();
    }
    return key;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:ScopeInterceptor.java

示例2: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
    ActionProxy proxy = actionInvocation.getProxy();
    String name = getBackgroundProcessName(proxy);
    ActionContext context = actionInvocation.getInvocationContext();
    Map session = context.getSession();
    HttpSession httpSession = ServletActionContext.getRequest().getSession(true);

    Boolean secondTime  = true;
    if (executeAfterValidationPass) {
        secondTime = (Boolean) context.get(KEY);
        if (secondTime == null) {
            context.put(KEY, true);
            secondTime = false;
        } else {
            secondTime = true;
            context.put(KEY, null);
        }
    }

    //sync on the real HttpSession as the session from the context is a wrap that is created
    //on every request
    synchronized (httpSession) {
        BackgroundProcess bp = (BackgroundProcess) session.get(KEY + name);

        if ((!executeAfterValidationPass || secondTime) && bp == null) {
            bp = getNewBackgroundProcess(name, actionInvocation, threadPriority);
            session.put(KEY + name, bp);
            performInitialDelay(bp); // first time let some time pass before showing wait page
            secondTime = false;
        }

        if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) {
            actionInvocation.getStack().push(bp.getAction());

final String token = TokenHelper.getToken();
if (token != null) {
	TokenHelper.setSessionToken(TokenHelper.getTokenName(), token);
            }

            Map results = proxy.getConfig().getResults();
            if (!results.containsKey(WAIT)) {
            	LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " +
                        "Defaulting to a plain built-in wait page. It is highly recommend you " +
                        "provide an action-specific or global result named '{}'.", WAIT);
                // no wait result? hmm -- let's try to do dynamically put it in for you!

                //we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer
                //an option, see WW-3068
                FreemarkerResult waitResult = new FreemarkerResult();
                container.inject(waitResult);
                waitResult.setLocation("/org/apache/struts2/interceptor/wait.ftl");
                waitResult.execute(actionInvocation);

                return Action.NONE;
            }

            return WAIT;
        } else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) {
            session.remove(KEY + name);
            actionInvocation.getStack().push(bp.getAction());

            // if an exception occured during action execution, throw it here
            if (bp.getException() != null) {
                throw bp.getException();
            }

            return bp.getResult();
        } else {
            // this is the first instance of the interceptor and there is no existing action
            // already run in the background, so let's just let this pass through. We assume
            // the action invocation will be run in the background on the subsequent pass through
            // this interceptor
            return actionInvocation.invoke();
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:77,代码来源:ExecuteAndWaitInterceptor.java

示例3: doBeforeInvocation

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
/**
 * Gets the current action and its context and delegates to {@link ActionValidatorManager} proper validate method.
 *
 * @param invocation  the execution state of the Action.
 * @throws Exception if an error occurs validating the action.
 */
protected void doBeforeInvocation(ActionInvocation invocation) throws Exception {
    Object action = invocation.getAction();
    ActionProxy proxy = invocation.getProxy();

    //the action name has to be from the url, otherwise validators that use aliases, like
    //MyActio-someaction-validator.xml will not be found, see WW-3194
    //UPDATE:  see WW-3753
    String context = this.getValidationContext(proxy);
    String method = proxy.getMethod();

    if (log.isDebugEnabled()) {
        log.debug("Validating {}/{} with method {}.", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName(), method);
    }
    

    if (declarative) {
       if (validateAnnotatedMethodOnly) {
           actionValidatorManager.validate(action, context, method);
       } else {
           actionValidatorManager.validate(action, context);
       }
   }    
    
    if (action instanceof Validateable && programmatic) {
        // keep exception that might occured in validateXXX or validateDoXXX
        Exception exception = null; 
        
        Validateable validateable = (Validateable) action;
        LOG.debug("Invoking validate() on action {}", validateable);

        try {
            PrefixMethodInvocationUtil.invokePrefixMethod(invocation, new String[]{VALIDATE_PREFIX, ALT_VALIDATE_PREFIX});
        }
        catch(Exception e) {
            // If any exception occurred while doing reflection, we want 
            // validate() to be executed
            LOG.warn("an exception occured while executing the prefix method", e);
            exception = e;
        }
        
        
        if (alwaysInvokeValidate) {
            validateable.validate();
        }
        
        if (exception != null) { 
            // rethrow if something is wrong while doing validateXXX / validateDoXXX 
            throw exception;
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:58,代码来源:ValidationInterceptor.java


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