當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionInvocation.getAction方法代碼示例

本文整理匯總了Java中com.opensymphony.xwork2.ActionInvocation.getAction方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionInvocation.getAction方法的具體用法?Java ActionInvocation.getAction怎麽用?Java ActionInvocation.getAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.opensymphony.xwork2.ActionInvocation的用法示例。


在下文中一共展示了ActionInvocation.getAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(final ActionInvocation invocation) throws Exception {
    try {
        String rtn = invocation.invoke();
        return rtn;
    } catch (Throwable th) {
    	 th.printStackTrace();
        AbstractBaseAction action = (AbstractBaseAction) invocation.getAction();
        if (th instanceof IOException) {
            logger.debug("IOException occured! may the user stop downloading, do not care.");
            logger.error(th.getMessage(), th);
            return null;
        } else {
            logger.error(action, th);
            String errorMsg = action.getText(UNKNOWN_ERROR_KEY);
            action.addActionError(errorMsg);
        }
    }
    if (invocation.getAction() instanceof AbstractAdminBaseAction) {
        return AbstractBaseAction.ADMIN_ERROR;
    } else {
        return AbstractBaseAction.FREEMARKER_ERROR;
    }

}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:26,代碼來源:ErrorInterceptor.java

示例2: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(final ActionInvocation invocation) throws Exception {
    try {
        String rtn = invocation.invoke();
        return rtn;
    } catch (Throwable th) {
        AbstractBaseAction action = (AbstractBaseAction) invocation.getAction();
        if (th instanceof IOException) {
            logger.debug("IOException occured! may the user stop downloading, do not care.");
            logger.error(th.getMessage(), th);
            return null;
        } else {
            logger.error(action, th);
            String errorMsg = action.getText(UNKNOWN_ERROR_KEY);
            action.addActionError(errorMsg);
        }
    }
    if (invocation.getAction() instanceof AbstractAdminBaseAction) {
        return AbstractBaseAction.ADMIN_ERROR;
    } else {
        return AbstractBaseAction.FREEMARKER_ERROR;
    }

}
 
開發者ID:Chihpin,項目名稱:Yidu,代碼行數:25,代碼來源:ErrorInterceptor.java

示例3: execute

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public void execute(ActionInvocation ai) throws Exception {
    FileResultSupport support = (FileResultSupport) ai.getAction();
    HttpServletResponse response = ServletActionContext.getResponse();
    HttpServletRequest request = ServletActionContext.getRequest();

    long ifModifiedSince = request.getDateHeader("If-Modified-Since");
    long now = (new Date()).getTime();
    long expire = now + ONE_MONTH;
    long lastModifiedMillis = now;

    if (ifModifiedSince > 0 && ifModifiedSince <= lastModifiedMillis) {
        response.setStatus(304);
        response.flushBuffer();
        return;
    }
    response.setDateHeader("Date", now);
    response.setDateHeader("Expires", expire);
    response.setDateHeader("Retry-After", expire);
    response.setHeader("Cache-Control", "public");
    response.setDateHeader("Last-Modified", lastModifiedMillis);
    response.setContentType(support.getContentType());
    response.getOutputStream().write(support.getFileInBytes());
    response.getOutputStream().flush();
}
 
開發者ID:robertli0719,項目名稱:ZeroSSH,代碼行數:26,代碼來源:FileResult.java

示例4: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
public String doIntercept(ActionInvocation invocation)
	throws Exception
{
	// ȡ�ñ����ص�Actionʵ��
	LoginAction action = (LoginAction)invocation.getAction();
	// ��ӡִ�п�ʼ��ʱ��
	System.out.println(name + " �������Ķ���---------"
		+ "��ʼִ�е�¼Action��ʱ��Ϊ��" + new Date());
	// ȡ�ÿ�ʼִ��Action��ʱ��
	long start = System.currentTimeMillis();
	// ִ�и��������ĺ�һ��������������ֱ��ָ��Action�ı����ط���
	String result = invocation.invoke();
	// ��ӡִ�н�����ʱ��
	System.out.println(name + " �������Ķ���---------"
		+ "ִ�����¼Action��ʱ��Ϊ��" + new Date());
	long end = System.currentTimeMillis();
	// ��ӡִ�и�Action�����ѵ�ʱ��
	System.out.println(name + " �������Ķ���---------"
		+ "ִ�����Action��ʱ��Ϊ" + (end - start) + "����");
	return result;
}
 
開發者ID:wolfogre,項目名稱:CodesOfLightweightJavaEE,代碼行數:22,代碼來源:MyFilterInterceptor.java

示例5: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(ActionInvocation ai) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    String sessionId = request.getSession().getId();

    if (ai.getAction() instanceof SessionIdAware) {
        SessionIdAware action = (SessionIdAware) ai.getAction();
        action.setSessionId(sessionId);
    }

    ActionContext actionContext = ai.getInvocationContext();
    Admin admin = adminService.getCurrentAdmin(sessionId);
    actionContext.put("admin", admin);

    actionContext.put("domain", webConfiguration.getDomain());
    actionContext.put("image_action_url", webConfiguration.getImageActionUrl());
    actionContext.put("google_signin_client_id", webConfiguration.getGoogleSigninClientId());
    return ai.invoke();
}
 
開發者ID:robertli0719,項目名稱:ZeroSSH,代碼行數:20,代碼來源:AdminInjectionInterceptor.java

示例6: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
public String intercept(ActionInvocation invocation)
	throws Exception
{
	// ȡ�ñ����ص�Actionʵ��
	LoginAction action = (LoginAction)invocation.getAction();
	// ��ӡִ�п�ʼ��ʱ��
	System.out.println(name + " �������Ķ���---------" +
		"��ʼִ�е�¼Action��ʱ��Ϊ��" + new Date());
	// ȡ�ÿ�ʼִ��Action��ʱ��
	long start = System.currentTimeMillis();
	// ִ�и��������ĺ�һ��������
	// �������������û����������������ֱ��ִ��Action�ı����ط���
	String result = invocation.invoke();
	// ��ӡִ�н�����ʱ��
	System.out.println(name + " �������Ķ���---------" +
		"ִ�����¼Action��ʱ��Ϊ��" + new Date());
	long end = System.currentTimeMillis();
	System.out.println(name + " �������Ķ���---------" +
		"ִ�����Action��ʱ��Ϊ" + (end - start) + "����");
	return result;
}
 
開發者ID:wolfogre,項目名稱:CodesOfLightweightJavaEE,代碼行數:22,代碼來源:SimpleInterceptor.java

示例7: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(ActionInvocation invocation) throws Exception {
    Object action = invocation.getAction();

    if (action instanceof ModelDriven) {
        ModelDriven modelDriven = (ModelDriven) action;
        ValueStack stack = invocation.getStack();
        Object model = modelDriven.getModel();
        if (model !=  null) {
        	stack.push(model);
        }
        if (refreshModelBeforeResult) {
            invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
        }
    }
    return invocation.invoke();
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:18,代碼來源:ModelDrivenInterceptor.java

示例8: beforeResult

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
/**
 * Invokes any &#64;BeforeResult annotated methods
 *
 * @see com.opensymphony.xwork2.interceptor.PreResultListener#beforeResult(com.opensymphony.xwork2.ActionInvocation,String)
 */
public void beforeResult(ActionInvocation invocation, String resultCode) {
    Object action = invocation.getAction();
    List<Method> methods = new ArrayList<Method>(AnnotationUtils.getAnnotatedMethods(action.getClass(), BeforeResult.class));

    if (methods.size() > 0) {
        // methods are only sorted by priority
        Collections.sort(methods, new Comparator<Method>() {
            public int compare(Method method1, Method method2) {
                return comparePriorities(method1.getAnnotation(BeforeResult.class).priority(),
                            method2.getAnnotation(BeforeResult.class).priority());
            }
        });
        for (Method m : methods) {
            try {
                m.invoke(action, (Object[]) null);
            } catch (Exception e) {
                throw new XWorkException(e);
            }
        }
    }
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:27,代碼來源:AnnotationWorkflowInterceptor.java

示例9: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(final ActionInvocation invocation) throws Exception {
    String rtn = invocation.invoke();

    if (YiDuConstants.yiduConf.getBoolean(YiDuConfig.ENABLE_GENERATE_HTML_FILE, false)) {
        // 如果是閱讀頁的話,同時生成靜態頁麵 並且不生成分卷閱讀
        if (invocation.getAction() instanceof ReaderAction
                && ((ReaderAction) invocation.getAction()).getToChapterno() == 0) {
            ReaderAction action = (ReaderAction) invocation.getAction();
            logger.info("going to Generate Html file." + YiDuConstants.requestUri.get());

            String templatePath = "themes/" + YiDuConstants.yiduConf.getString(YiDuConfig.THEME_NAME) + "/pc/"
                    + action.getTempName() + ".ftl";

            StaticUtils.crateHTML(ServletActionContext.getServletContext(), action, templatePath,
                    YiDuConstants.requestUri.get());

            // 判斷上一章的靜態頁是否存在
            ChapterDTO chapter = action.getChapter();
            if (chapter.getPreChapterno() != 0) {
                // TODO 如果章節ID和小說ID一樣的話,會出現問題,將來改吧
                String preUri = StringUtils.replaceOnce(YiDuConstants.requestUri.get(),
                        String.valueOf(chapter.getChapterno()), String.valueOf(chapter.getPreChapterno()));

                String preChapterPath = ServletActionContext.getServletContext().getRealPath("/") + "/" + preUri;
                File preChpaterHtml = new File(preChapterPath);
                if (preChpaterHtml.exists() && preChpaterHtml.lastModified() < chapter.getPostdate().getTime()) {
                    // 隻有當文件存在,並且最後修改時間比當前章節的發布時間小的情況才生成前一張,因為下一章已經更新啦!
                    action.setChapterno(chapter.getPreChapterno());
                    action.execute();
                    logger.info("going to Generate Html file." + preChapterPath);
                    StaticUtils.crateHTML(ServletActionContext.getServletContext(), action, templatePath, preUri);
                }

            }

        }
    }
    return rtn;
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:41,代碼來源:GenerateHtmlFileInterceptor.java

示例10: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(final ActionInvocation invocation) throws Exception {

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession(true);

    Locale locale = (Locale) session.getAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
    // Locale adminpagelocale = (Locale)
    // session.getAttribute(ADMIN_PAGE_LOCALE);
    // if (locale == null && adminpagelocale == null) {
    if (locale == null) {
        if (request.getLocale().equals(Locale.CHINA) || request.getLocale().equals(Locale.CHINESE)) {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.CHINA);
            logger.debug("Language is set to Chinese. from IP <" + request.getRemoteAddr() + ">");
        } else if (request.getLocale().equals(Locale.JAPAN) || request.getLocale().equals(Locale.JAPANESE)) {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.JAPAN);
            logger.debug("Language is set to Japanese. from IP <" + request.getRemoteAddr() + ">");
        } else {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.US);
            logger.debug("Language is set to English.from IP <" + request.getRemoteAddr() + ">");
        }
    }
    // else if (adminpagelocale != null) {
    // session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE,
    // adminpagelocale);
    // }
    if (invocation.getAction() instanceof AbstractAdminBaseAction
            && (locale == null || !locale.equals(Locale.CHINA))) {
        // 使用中文界麵
        // session.setAttribute(ADMIN_PAGE_LOCALE,
        // session.getAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE));
        session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.CHINA);
        logger.debug("because access page is admin page. Language is set to Chinese. from IP <"
                + request.getRemoteAddr() + ">");
    }
    return invocation.invoke();
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:38,代碼來源:SetLanguageInterceptor.java

示例11: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String intercept(ActionInvocation ai) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    String sessionId = request.getSession().getId();
    Admin admin = adminService.getCurrentAdmin(sessionId);
    if (admin == null && ai.getAction() instanceof AdminLoginAction == false) {
        return "login";
    } else if (isRootAdmin(admin) == false && ai.getAction() instanceof AdminRootPermission) {
        return "login";
    }
    return ai.invoke();
}
 
開發者ID:robertli0719,項目名稱:ZeroSSH,代碼行數:13,代碼來源:AdminPermissionInterceptor.java

示例12: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
protected String doIntercept(ActionInvocation invocation) throws Exception {

        Object action = invocation.getAction();
        if (action != null) {
            Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod());
            Collection<Method> annotatedMethods = AnnotationUtils.getAnnotatedMethods(action.getClass(), SkipValidation.class);
            if (annotatedMethods.contains(method))
                return invocation.invoke();

            //check if method overwites an annotated method
            Class clazz = action.getClass().getSuperclass();
            while (clazz != null) {
                annotatedMethods = AnnotationUtils.getAnnotatedMethods(clazz, SkipValidation.class);
                if (annotatedMethods != null) {
                    for (Method annotatedMethod : annotatedMethods) {
                        if (annotatedMethod.getName().equals(method.getName())
                                && Arrays.equals(annotatedMethod.getParameterTypes(), method.getParameterTypes())
                                && Arrays.equals(annotatedMethod.getExceptionTypes(), method.getExceptionTypes()))
                            return invocation.invoke();
                    }
                }
                clazz = clazz.getSuperclass();
            }
        }

        return super.doIntercept(invocation);
    }
 
開發者ID:txazo,項目名稱:struts2,代碼行數:28,代碼來源:AnnotationValidationInterceptor.java

示例13: getErrorMessage

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
protected String getErrorMessage(ActionInvocation invocation) {
    Object action = invocation.getAction();
    if (action instanceof TextProvider) {
        return ((TextProvider) action).getText(INVALID_TOKEN_MESSAGE_KEY, DEFAULT_ERROR_MESSAGE);
    }
    return textProvider.getText(INVALID_TOKEN_MESSAGE_KEY, DEFAULT_ERROR_MESSAGE);
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:8,代碼來源:TokenInterceptor.java

示例14: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
@Override
public String doIntercept(ActionInvocation invocation) throws Exception {
    Object action = invocation.getAction();
    if (!(action instanceof NoParameters)) {
        ActionContext ac = invocation.getInvocationContext();
        final Map<String, Object> parameters = retrieveParameters(ac);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Setting params {}", getParameterLogMap(parameters));
        }

        if (parameters != null) {
            Map<String, Object> contextMap = ac.getContextMap();
            try {
                ReflectionContextState.setCreatingNullObjects(contextMap, true);
                ReflectionContextState.setDenyMethodExecution(contextMap, true);
                ReflectionContextState.setReportingConversionErrors(contextMap, true);

                ValueStack stack = ac.getValueStack();
                setParameters(action, stack, parameters);
            } finally {
                ReflectionContextState.setCreatingNullObjects(contextMap, false);
                ReflectionContextState.setDenyMethodExecution(contextMap, false);
                ReflectionContextState.setReportingConversionErrors(contextMap, false);
            }
        }
    }
    return invocation.invoke();
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:30,代碼來源:ParametersInterceptor.java

示例15: intercept

import com.opensymphony.xwork2.ActionInvocation; //導入方法依賴的package包/類
/**
 * Decide if the parameter should be removed from the parameter map based on
 * <code>paramNames</code> and <code>paramValues</code>.
 * 
 * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor
 */
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	if (!(invocation.getAction() instanceof NoParameters)
			&& (null != this.paramNames)) {
		ActionContext ac = invocation.getInvocationContext();
		final Map<String, Object> parameters = ac.getParameters();

		if (parameters != null) {
               for (String removeName : paramNames) {
                   // see if the field is in the parameter map
                   if (parameters.containsKey(removeName)) {

                       try {
						String[] values = (String[]) parameters.get(removeName);
						String value = values[0];
						if (null != value && this.paramValues.contains(value)) {
                               parameters.remove(removeName);
                           }
                       } catch (Exception e) {
						LOG.error("Failed to convert parameter to string", e);
					}
				}
               }
		}
	}
	return invocation.invoke();
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:34,代碼來源:ParameterRemoverInterceptor.java


注:本文中的com.opensymphony.xwork2.ActionInvocation.getAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。