當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。