当前位置: 首页>>代码示例>>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;未经允许,请勿转载。