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


Java ActionInvocation类代码示例

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


ActionInvocation类属于com.opensymphony.xwork2包,在下文中一共展示了ActionInvocation类的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: beforeResult

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
public void beforeResult(ActionInvocation invocation
		,String resultCode)
	{
		// ��ӡ��ִ�н��
		System.out.println("���ص��߼���ͼΪ:" + resultCode);
//		try
//		{
//			invocation.invoke();
//		}
//		catch (Exception ex)
//		{
//			ex.printStackTrace();
//		}
//		finally
//		{
//		}
	}
 
开发者ID:wolfogre,项目名称:CodesOfLightweightJavaEE,代码行数:18,代码来源:MyPreResultListener.java

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

示例5: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
@Override
public String intercept(ActionInvocation ai) throws Exception {
    HttpServletRequest req = ServletActionContext.getRequest();
    String ip = req.getRemoteAddr();

    int dayNumber = dayRecode.checkIp(ip);
    int minNumber = minRecode.checkIp(ip);
    if (dayNumber > 2000) {
        return "firewall_out";
    } else if (minNumber > 100) {
        return "firewall_out";
    }

    String result = ai.invoke();
    return result;
}
 
开发者ID:robertli0719,项目名称:ZeroSSH,代码行数:17,代码来源:FireWallInterceptor.java

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

示例7: doExecute

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
	HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);
	try {

		File file = null;
		String title = null;
		data = invocation.getStack().findValue("data");
		if (data instanceof File) {
			file = (File) data;
			title = file.getName();
		} else if (data instanceof DataRow) {
			DataRow row = (DataRow) data;
			file = new File(row.getString("PATH"));
			title = row.getString("NM");
		}
		if (null != file && file.exists()) {
			WebUtil.writeFile(response, file, title);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:23,代码来源:ImageResult.java

示例8: getStandardContext

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
public static Map getStandardContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
    HashMap map = new HashMap();
    map.put(REQUEST, req);
    map.put(REQUEST2, req);
    map.put(RESPONSE, res);
    map.put(RESPONSE2, res);
    map.put(SESSION, req.getSession(false));
    map.put(BASE, req.getContextPath());
    map.put(STACK, stack);
    map.put(OGNL, ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(OgnlTool.class));
    map.put(STRUTS, new StrutsUtil(stack, req, res));

    ActionInvocation invocation = (ActionInvocation) stack.getContext().get(ActionContext.ACTION_INVOCATION);
    if (invocation != null) {
        map.put(ACTION, invocation.getAction());
    }
    return map;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:ContextUtil.java

示例9: lock

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
static void lock(Object o, ActionInvocation invocation) throws Exception {
    synchronized (o) {
        int count = 3;
        Object previous;
        while ((previous = locks.get(o)) != null) {
            if (previous == invocation) {
                return;
            }
            if (count-- <= 0) {
                locks.remove(o);
                o.notify();

                throw new StrutsException("Deadlock in session lock");
            }
            o.wait(10000);
        }
        locks.put(o, invocation);
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:20,代码来源:ScopeInterceptor.java

示例10: readStoredLocale

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
@Override
protected Locale readStoredLocale(ActionInvocation invocation, Map<String, Object> session) {
    Locale locale = this.readStoredLocalFromSession(invocation, session);

    if (locale != null) {
        return locale;
    }

    Cookie[] cookies = ServletActionContext.getRequest().getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (DEFAULT_COOKIE_ATTRIBUTE.equals(cookie.getName())) {
                return getLocaleFromParam(cookie.getValue());
            }
        }
    }

    return this.readStoredLocalFromCurrentInvocation(invocation);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:20,代码来源:I18nInterceptor.java

示例11: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
@Override
public final String intercept( ActionInvocation actionInvocation ) throws Exception
{
    actionInvocation.addPreResultListener( this );

    executePreResultListener = true;

    try
    {
        return actionInvocation.invoke();
    }
    catch ( Exception e )
    {
        executePreResultListener = false;
        throw e;
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:18,代码来源:AbstractPreResultListener.java

示例12: intercept

import com.opensymphony.xwork2.ActionInvocation; //导入依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
    String result;

    try {
        result = invocation.invoke();
    } catch (Exception e) {
        if (isLogEnabled()) {
            handleLogging(e);
        }
        List<ExceptionMappingConfig> exceptionMappings = invocation.getProxy().getConfig().getExceptionMappings();
        ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e);
        if (mappingConfig != null && mappingConfig.getResult()!=null) {
            Map parameterMap = mappingConfig.getParams();
            // create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable
            invocation.getInvocationContext().setParameters(new HashMap<String, Object>(parameterMap));
            result = mappingConfig.getResult();
            publishException(invocation, new ExceptionHolder(e));
        } else {
            throw e;
        }
    }

    return result;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:26,代码来源:ExceptionMappingInterceptor.java

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

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

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


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