mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
example on how to wire session scoped spring beans prio spring-test 3.2 with the junit plugin
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1420928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -21,10 +21,14 @@
|
||||
package org.apache.struts2;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class JUnitTestAction extends ActionSupport {
|
||||
private String name;
|
||||
|
||||
@Autowired
|
||||
private MySessionBean mySessionBean;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2;
|
||||
|
||||
public class MySessionBean {
|
||||
|
||||
public void doSomething() {
|
||||
// do Something
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,17 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
|
||||
<property name="scopes">
|
||||
<map>
|
||||
<entry key="session">
|
||||
<bean class="org.springframework.context.support.SimpleThreadScope"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="testAction" class="org.apache.struts2.JUnitTestAction"/>
|
||||
<bean id="mySessionBean" class="org.apache.struts2.MySessionBean" scope="session" />
|
||||
</beans>
|
||||
Reference in New Issue
Block a user