• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ActionProxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ActionProxy类属于com.opensymphony.xwork2包,在下文中一共展示了ActionProxy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createActionProxy

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
public ActionProxy createActionProxy(String namespace, String actionName, String methodName,
                                     Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {

    String uri = namespace + (namespace.endsWith("/") ? actionName : "/" + actionName);
    for (int lastIndex = uri.lastIndexOf('/'); lastIndex > (-1); lastIndex = uri.lastIndexOf('/', lastIndex - 1)) {
        String key = uri.substring(0, lastIndex);
        ActionProxyFactory actionProxyFactory = actionProxyFactories.get(key);
        if (actionProxyFactory != null) {
            LOG.debug("Using ActionProxyFactory [{}] for prefix [{}]", actionProxyFactory, key);
            return actionProxyFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext);
        } else {
            LOG.debug("No ActionProxyFactory defined for [{}]", key);
        }
    }
    LOG.debug("Cannot find any matching ActionProxyFactory, falling back to [{}]", defaultFactory);
    return defaultFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:18,代码来源:PrefixBasedActionProxyFactory.java


示例2: testUpload

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * This method tests uploading MS. Project file.
 * The file path: is set in MS_PROJECT_FILES_PATH constant
 */
@Test
public void testUpload() throws Exception {
	File msProjectFolder = new File(MS_PROJECT_FILES_PATH);
	File[] listOfFiles = msProjectFolder.listFiles();
	
	for (File fileToUpload : listOfFiles) {
	    if (fileToUpload.isFile()) {
			request.setParameter("uploadFileFileName", fileToUpload.getName());
			request.setParameter("projectOrReleaseID", PROJECT_OR_RELEASE_ID.toString());
			ActionProxy actionProxy = getActionProxy("/msProjectUpload.action") ;
			MsProjectUploadAction action = (MsProjectUploadAction) actionProxy.getAction();
			action.setUploadFile(fileToUpload);
			actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);
			String result = actionProxy.execute();
			String responseText = response.getContentAsString();
			System.out.println("Test method name: msProjectUpload result: " + result + " response: " + responseText);
			assertEquals(result, MsProjectUploadAction.MSPROJECT_IMPORT);
	    }
	}
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:25,代码来源:MsProjectImportActionTest.java


示例3: testExecute

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * Run the String execute() method test
 */
@Test
public void testExecute()  throws Exception{
	File msProjectFolder = new File(MS_PROJECT_FILES_PATH);
	File[] listOfFiles = msProjectFolder.listFiles();
	
	
	for (File fileToUpload : listOfFiles) {
	    if (fileToUpload.isFile()) {
			ActionProxy actionProxy = getActionProxy("/msProjectImport.action") ;
			actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);
			MsProjectImportAction action = (MsProjectImportAction) actionProxy.getAction();
			File uploadedFilesLocation = new File(AttachBL.getMsProjectImportDirBase() + PROJECT_OR_RELEASE_ID + "/" + fileToUpload.getName());
			Files.copy(fileToUpload, uploadedFilesLocation);
			action.setFileName(fileToUpload.getName());
			action.setProjectOrReleaseID(PROJECT_OR_RELEASE_ID);
			String result = actionProxy.execute();
			String responseText = response.getContentAsString();
			System.out.println("Test method name: msProjectImport result: " + result + " response: " + responseText);
			assertTrue(responseText.length() > 0);
			assertNotNull(responseText);
	    }
	}
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:27,代码来源:MsProjectImportActionTest.java


示例4: testExecute_2

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * Run the String execute() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 05.01.15 23:18
 */
@Test
public void testExecute_2()
	throws Exception {

	request.setParameter("j_username", "admin");
	request.setParameter("password", "tissi");
	request.setParameter("testMode", "true");

	ActionProxy actionProxy = getActionProxy("/logon!login.action") ;
	LogonAction action = (LogonAction) actionProxy.getAction();
	assertNotNull("The action is null but should not be.", action);
	String result = actionProxy.execute();
	// System.err.println(result);
	// assertEquals("The execute method did not return " + "forwardToLogin" + " but should have.", "forwardToLogin", result);
	assertEquals("The execute method did not return " + "loading" + " but should have.", "loading", result);

}
 
开发者ID:trackplus,项目名称:Genji,代码行数:25,代码来源:LogonActionTest.java


示例5: testExecute_3

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * Run the String execute() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 05.01.15 23:18
 */
@Test
public void testExecute_3()
	throws Exception {

	request.setParameter("j_username", "admin");
	request.setParameter("password", "tissi");
	request.setParameter("testMode", "");
	request.setParameter("isMobileApplication", "true");
	request.setParameter("mobileApplicationVersionNo", "2");
	
	ActionProxy actionProxy = getActionProxy("/logon!login.action") ;
	LogonAction action = (LogonAction) actionProxy.getAction();
	assertNotNull("The action is null but should not be.", action);
	String result = actionProxy.execute();
	assertEquals("The execute method did not return " + "loading" + " but should have.", "loading", result);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:24,代码来源:LogonActionTest.java


示例6: testFailLogin_1

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * Run the String failLogin() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 05.01.15 23:18
 */
@Test
public void testFailLogin_1()
	throws Exception {

	request.setParameter("j_username", "admin");
	request.setParameter("password", "FFFFF");
	request.setParameter("testMode", "true");
	request.setParameter("isMobileApplication", "false");
	request.setParameter("mobileApplicationVersionNo", "2");
	
	ActionProxy actionProxy = getActionProxy("/logon!login.action") ;
	LogonAction action = (LogonAction) actionProxy.getAction();
	assertNotNull("The action is null but should not be.", action);
	String result = actionProxy.execute();
	assertEquals("The execute method did not return " + "loading" + " but should have.", "loading", result);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:24,代码来源:LogonActionTest.java


示例7: testSanity

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@Test
public void testSanity() throws Exception{
    //pre requirements
    request.setParameter("xml", "this is the xml");

    //kinda of replay()
    ActionProxy proxy = getActionProxy("/testing");
    Testing testingAction = (Testing) proxy.getAction();

    String result = proxy.execute();


    assertEquals("XML entered should be the same in SESSION after execution", "this is the xml", request.getSession().getAttribute("xml"));
    assertEquals("XML entered should be the same after execution", "this is the xml", testingAction.getXml());
    assertNotNull("Request attribute 'res' shouldn't be null", request.getAttribute("res"));
    assertTrue("There shouldn't be any field error.", testingAction.getFieldErrors().size() == 0);
    assertEquals("Result returned when there is an XML should have been 'null'.", null, result);

    //assertTrue("Problem field account.userName not present in fieldErrors but it should have been",
    //        testingAction.getFieldErrors().containsKey("xml") );

}
 
开发者ID:leonardoanalista,项目名称:java2word,代码行数:23,代码来源:TestingTest.java


示例8: getResult

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * If the DefaultActionInvocation has been executed before and the Result is
 * an instance of ActionChainResult, this method will walk down the chain of
 * ActionChainResults until it finds a non-chain result, which will be
 * returned. If the DefaultActionInvocation's result has not been executed
 * before, the Result instance will be created and populated with the result
 * params.
 * 
 * @return a Result instance
 * @throws Exception
 */
@Override
public Result getResult() throws Exception {
	Result returnResult = result;

	// If we've chained to other Actions, we need to find the last result
	while (returnResult instanceof ActionChainResult) {
		ActionProxy aProxy = ((ActionChainResult) returnResult).getProxy();

		if (aProxy != null) {
			Result proxyResult = aProxy.getInvocation().getResult();

			if ((proxyResult != null) && (aProxy.getExecuteResult())) {
				returnResult = proxyResult;
			} else {
				break;
			}
		} else {
			break;
		}
	}

	return returnResult;
}
 
开发者ID:cenobites,项目名称:struts2-json-plugin,代码行数:35,代码来源:JsonActionInvocation.java


示例9: testNotActionFlowAction

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@Test
public void testNotActionFlowAction() throws Exception {
    final Integer stepCount = 1;

    ActionProxy ap = getActionProxy("/correctFlow/correctFlow");

    Assert.assertNotNull(ap);
    Assert.assertNotNull(ap.getAction());
    Assert.assertTrue(ap.getAction() instanceof MockActionFlowAction);
    Assert.assertTrue(ap.getAction() instanceof ActionFlowStepsAware);

    MockActionFlowAction action = (MockActionFlowAction) ap.getAction();

    ap.getInvocation().getInvocationContext()
            .setSession(new HashMap<String, Object>());

    ap.execute();

    Assert.assertNotNull(action.getStepsData());
    Assert.assertEquals(new Integer(1), action.getStepsData().getSteps()
            .firstKey());

    Assert.assertEquals(stepCount, action.getStepsData().getStepIndex());
}
 
开发者ID:aleksandr-m,项目名称:struts2-actionflow,代码行数:25,代码来源:ActionFlowStepsAwareTest.java


示例10: getKey

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
private String getKey(ActionInvocation invocation) {
    ActionProxy proxy = invocation.getProxy();
    if (key == null || "CLASS".equals(key)) {
        return "struts.ScopeInterceptor:" + proxy.getAction().getClass();
    } else if ("ACTION".equals(key)) {
        return "struts.ScopeInterceptor:" + proxy.getNamespace() + ":" + proxy.getActionName();
    }
    return key;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:ScopeInterceptor.java


示例11: createActionProxy

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@Override
public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) {
    
    StrutsActionProxy proxy = new StrutsActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext);
    container.inject(proxy);
    proxy.prepare();
    return proxy;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:9,代码来源:StrutsActionProxyFactory.java


示例12: getRequestName

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
protected String getRequestName(ActionInvocation invocation) {
	// final String actionName = invocation.getInvocationContext().getName();
	final String actionName;
	final ActionProxy proxy = invocation.getProxy();
	final String action = proxy.getActionName();
	final String method = proxy.getMethod();
	final String namespace = proxy.getNamespace();
	if (method == null || "execute".equals(method)) {
		actionName = namespace + '/' + action;
	} else {
		actionName = namespace + '/' + action + '!' + method;
	}
	return actionName;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:15,代码来源:StrutsInterceptor.java


示例13: intercept

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
public String intercept(ActionInvocation actionInvocation) throws Exception
{
	String result = null;
	try
	{
		if (!disable)
		{
			//被攔截的context
			ActionContext actionContext = actionInvocation.getInvocationContext();
			//action
			Object action = actionInvocation.getAction();
			//
			ActionProxy proxy = actionInvocation.getProxy();
			//
			result = intercept(actionInvocation, actionContext, action);
			log(LOGGER, proxy);
		}
		else
		{
			result = actionInvocation.invoke();
		}
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:29,代码来源:BaseWebInterceptorSupporter.java


示例14: testMsProjectUploadRender

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * This method tests returning project tree as target form import.
 *When importing was executed from toolbar menu not from drag drop. 
 */
@Test
public void testMsProjectUploadRender() throws Exception {
	ActionProxy actionProxy = getActionProxy("/msProjectUploadRender.action") ;
	actionProxy.getInvocation().getInvocationContext().setSession(sessionMap);

	String result = actionProxy.execute();
	String responseText = response.getContentAsString();
	System.out.println("Test method name: msProjectUploadRender result: " + result + " response: " + responseText);
	assertNotNull(responseText);
	assertTrue(responseText.length() > 0);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:16,代码来源:MsProjectImportActionTest.java


示例15: testServices

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * This method iterate through the Set which contains all action names used by Teamgeist.
 * If an action missing the test fails.
 */
@Test
public void testServices() {
	LinkedHashSet<String>actionNamesSet = getActinNames();
	if(actionNamesSet != null && actionNamesSet.size() > 0) {
		for (String actionName : actionNamesSet) {
			try {
				ActionProxy actionProxy = getActionProxy("/" + actionName);
				assertNotNull(actionProxy);
				Class<?> actionClass = Class.forName(actionProxy.getAction().getClass().getName());									
				actionClass.getMethod(actionProxy.getMethod());
			}catch(NoSuchMethodException noMethodEX) {
				fail("No such method exception at: " + actionName);
				System.out.println("No such method: " + actionName);
			}
			catch(ClassNotFoundException noClassEx) {
				fail("Class not found exception at: " + actionName);
				System.out.println("No such class: " + actionName);
			}catch(NullPointerException nullEx) {
				fail("Null pointer exception at: " + actionName);
				System.out.println("Null pointer at: " + actionName);
			}
		}
		System.out.println("Number of actions: " + actionNamesSet.size() + ". " + "The test was executed successfully!");
	}else {
		fail("Error while parsing Services file!");
	}
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:32,代码来源:TeamgeistServicesTest.java


示例16: testExecute_1

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
/**
 * Run the String execute() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 05.01.15 23:18
 */
@Test
public void testExecute_1()
	throws Exception {

	request.setParameter("j_username", "XXX");
	request.setParameter("password", "XXX");
	request.setParameter("testMode", "true");
	
	ActionProxy actionProxy = getActionProxy("/logon!login.action") ;
	LogonAction action = (LogonAction) actionProxy.getAction();
	assertNotNull("The action is null but should not be.", action);
	String result = actionProxy.execute();
	assertEquals("The execute method did not return " + "loading" + " but should have.", "loading", result);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:22,代码来源:LogonActionTest.java


示例17: testExecute_1_1

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@Test
public void testExecute_1_1()
	throws Exception {

	request.setParameter("j_username", "");
	request.setParameter("password", "");
	request.setParameter("testMode", "");
	
	ActionProxy actionProxy = getActionProxy("/logon.action") ;
	LogonAction action = (LogonAction) actionProxy.getAction();
	assertNotNull("The action is null but should not be.", action);
	String result = actionProxy.execute();
	assertEquals("The execute method did not return " + "forwardToLogin" + " but should have.", "forwardToLogin", result);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:15,代码来源:LogonActionTest.java


示例18: createActionProxy

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
public ActionProxy createActionProxy(String namespace, String actionName, String methodName,
        Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {

    ActionInvocation inv = new JsonActionInvocation(extraContext, true);
    container.inject(inv);
    return createActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext);
}
 
开发者ID:cenobites,项目名称:struts2-json-plugin,代码行数:8,代码来源:JsonActionProxyFactory.java


示例19: init

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@Override
public void init(ActionProxy proxy) {
	this.proxy = proxy;
	Map<String, Object> contextMap = createContextMap();

	// Setting this so that other classes, like object factories, can use
	// the ActionProxy and other
	// contextual information to operate
	ActionContext actionContext = ActionContext.getContext();

	if (actionContext != null) {
		actionContext.setActionInvocation(this);
	}

	createAction(contextMap);

	if (pushAction) {
		stack.push(action);
		contextMap.put("action", action);
	}

	invocationContext = new ActionContext(contextMap);
	invocationContext.setName(proxy.getActionName());

	// get a new List so we don't get problems with the iterator if someone
	// changes the list
	List<InterceptorMapping> interceptorList = new ArrayList<InterceptorMapping>(proxy.getConfig()
			.getInterceptors());
	interceptors = interceptorList.iterator();
}
 
开发者ID:cenobites,项目名称:struts2-json-plugin,代码行数:31,代码来源:JsonActionInvocation.java


示例20: doIntercept

import com.opensymphony.xwork2.ActionProxy; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
    Validator validator = this.jsr303ValidationManager.getValidator();
    if (validator == null) {

        if (LOG.isDebugEnabled()) {
            LOG.debug("There is no Bean Validator configured in class path. Skipping Bean validation..");
        }
        return invocation.invoke();

    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Starting bean validation using " + validator.getClass());
    }

    Object action = invocation.getAction();
    ActionProxy actionProxy = invocation.getProxy();
    String methodName = actionProxy.getMethod();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Validating [#0/#1] with method [#2]", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName(), methodName);
    }

    Collection<Method> annotatedMethods = AnnotationUtils.getAnnotatedMethods(action.getClass(),
            SkipValidation.class);

    if (!annotatedMethods.contains(getActionMethod(action.getClass(), methodName))) {
        // performing jsr303 bean validation
        performBeanValidation(action, validator);
    }

    return invocation.invoke();


}
 
开发者ID:umeshawasthi,项目名称:jsr303-validator-plugin,代码行数:38,代码来源:JSR303ValidationInterceptor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IORImpl类代码示例发布时间:2022-05-22
下一篇:
Java EntityTree类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap