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


Java ActionInvocation.invoke方法代码示例

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


在下文中一共展示了ActionInvocation.invoke方法的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: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
/**
 * Intercept {@link ActionInvocation} and returns a <code>inputResultName</code>
 * when action / field errors is found registered.
 *
 * @param invocation the action invocation
 * @return String result name
 */
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
    Object action = invocation.getAction();

    if (action instanceof ValidationAware) {
        ValidationAware validationAwareAction = (ValidationAware) action;

        if (validationAwareAction.hasErrors()) {
            LOG.debug("Errors on action [{}], returning result name [{}]", validationAwareAction, inputResultName);

            String resultName = inputResultName;
            resultName = processValidationWorkflowAware(action, resultName);
            resultName = processInputConfig(action, invocation.getProxy().getMethod(), resultName);
            resultName = processValidationErrorAware(action, resultName);

            return resultName;
        }
    }

    return invocation.invoke();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:29,代码来源:DefaultWorkflowInterceptor.java

示例4: 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

示例5: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept( ActionInvocation invocation )
    throws Exception
{
    Map<String, MenuState> menuStateMap = new HashMap<>( 1 );

    MenuState menuState = menuStateManager.getMenuState();

    if ( menuState == null )
    {
        menuState = MenuState.VISIBLE;
    }

    menuStateMap.put( KEY_MENU_STATE, menuState );

    invocation.getStack().push( menuStateMap );

    return invocation.invoke();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:20,代码来源:XWorkPortalMenuInterceptor.java

示例6: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept( ActionInvocation invocation )
    throws Exception
{
    Map<String, Object> map = new HashMap<>();
    
    map.put( DATE_FORMAT, calendarService.getSystemDateFormat() );
    map.put( SettingKey.CONFIGURATION.getName(), configurationService.getConfiguration() );
    map.put( SettingKey.FLAG_IMAGE.getName(), systemSettingManager.getFlagImage() );
    map.put( SettingKey.CREDENTIALS_EXPIRES.getName(), systemSettingManager.credentialsExpires() );
    map.put( SettingKey.SELF_REGISTRATION_NO_RECAPTCHA.getName(), systemSettingManager.selfRegistrationNoRecaptcha() );
    map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
    
    map.putAll( systemSettingManager.getSystemSettings( SETTINGS ) );
    
    invocation.getStack().push( map );

    return invocation.invoke();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:20,代码来源:SystemSettingInterceptor.java

示例7: 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

示例8: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	Map<String, Object> session = invocation.getInvocationContext().getSession();
	String userName = (String) session.get("userName");
	
	System.out.println(this.getClass().getSimpleName()
			+ ": userName=" + userName + " action=" + invocation.getInvocationContext().getName());
	
	if(null == userName) {
		return Action.LOGIN;
	}
	else return invocation.invoke();
}
 
开发者ID:wrayzheng,项目名称:webpage-update-subscribe,代码行数:14,代码来源:LoginInterceptor.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: doIntercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String doIntercept(ActionInvocation invocation) throws Exception {
	Customer cus = (Customer) WebApplication.getSession().getAttribute(Const.CUSTOMER);
		
	String namespace = invocation.getProxy().getNamespace();
	String actionName = invocation.getProxy().getActionName();
	String privUrl = namespace + actionName; // 对应的权限URL
	System.out.println("actionName" + " -->" + actionName );

	// 如果未登录
	if (cus == null ) {
		if (actionName.startsWith("toLogin") || actionName.startsWith("login")
				||actionName.startsWith("sendVerification") || actionName.startsWith("mobileLogin") 
				|| actionName.startsWith("updateRoom") || actionName.startsWith("activePassword")
				|| actionName.startsWith("updateRoomInfo") || actionName.startsWith("updateRoomTypeInfo"))		{ 					
	// 如果是去登录,就放行
			return invocation.invoke();
		} else {
			//如果不是,则转为登陆页面
			WebApplication.getResponse().sendRedirect(WebApplication.getRequest().getContextPath()+"/customer/toLogin");
			return null;
		}
	}
	
	
	return invocation.invoke();
			
	
}
 
开发者ID:liuxuanhai,项目名称:WeiXing_xmu-2016-MrCode,代码行数:30,代码来源:CheckPrivilegeInterceptor.java

示例12: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	ActionContext actionContext = ActionContext.getContext();
	UserBean user = (UserBean) actionContext.getSession().get(WebConstant.USER);
	AuthorityBean authority = (AuthorityBean) actionContext.getSession().get(WebConstant.AUTHORITY);
	if (user == null || authority == null) {
		actionContext.getSession().put(WebConstant.INTERCEPT, "Please login first");
		return Action.LOGIN;
	} else if (authority.getId() < 2) {
		actionContext.getSession().put(WebConstant.INTERCEPT, "Permission denied");
		return WebConstant.PERMISSION_DENIED;
	} else {
		return invocation.invoke();
	}
}
 
开发者ID:CongBao,项目名称:baozijuan.com,代码行数:16,代码来源:LvOneInterceptor.java

示例13: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
 Map sessionMap = ServletActionContext.getContext().getSession();
	 
	 Object obj = sessionMap.get("admin");
	 if(obj!=null && obj instanceof Admin){
		 Admin admin = (Admin) obj;
		 Authorization authorization = admin.getAuthorization();
		 if(authorization.getReaderSet()==1 || authorization.getSuperSet()==1){
			 return invocation.invoke(); 
		 }
	 }
	return "nopass";
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:15,代码来源:ReaderInterceptor.java

示例14: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	ActionContext actionContext = ActionContext.getContext();
	UserBean user = (UserBean) actionContext.getSession().get(WebConstant.USER);
	AuthorityBean authority = (AuthorityBean) actionContext.getSession().get(WebConstant.AUTHORITY);
	if (user == null || authority == null) {
		actionContext.getSession().put(WebConstant.INTERCEPT, "Please login first");
		return Action.LOGIN;
	} else if (authority.getId() < 3) {
		actionContext.getSession().put(WebConstant.INTERCEPT, "Permission denied");
		return WebConstant.PERMISSION_DENIED;
	} else {
		return invocation.invoke();
	}
}
 
开发者ID:CongBao,项目名称:baozijuan.com,代码行数:16,代码来源:LvTwoInterceptor.java

示例15: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	
	 Map sessionMap = ServletActionContext.getContext().getSession();
	 
	 Object obj = sessionMap.get("admin");
	 if(obj!=null && obj instanceof Admin){
		 Admin admin = (Admin) obj;
		 Authorization authorization = admin.getAuthorization();
		 if(authorization.getForfeitSet()==1 || authorization.getSuperSet()==1){
			 return invocation.invoke(); 
		 }
	 }
	return "nopass";
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:16,代码来源:ForfeitInterceptor.java


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