本文整理汇总了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;
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
}
示例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";
}
示例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();
}
}
示例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";
}