Michael Müller [
http://community.jboss.org/people/sirwayne] created the discussion
"RESTEasy stateful beans(SessionScoped)"
To view the discussion, visit:
http://community.jboss.org/message/606028#606028
--------------------------------------------------------------
Hello,
Does anybody know how i can use SessionScopes beans?
Example:
Client
public class RestClient {
private static final String uri = "http://localhost:8080/xxRest";
public static void main(String[] args) {
// this initialization only needs to be done once per VM
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
Service1 service1 = ProxyFactory.create(Service1.class, uri);
Service2 service2 = ProxyFactory.create(Service2.class, uri);
service1.putName("Hallo Welt");
System.out.println( service1.getName());
System.out.println(service2.getName());
}
}
Server side:
Service 1
public class Service1Impl implements Service1{
@Inject
private ParamBean bean;
@Override
public String getName() {
return bean.getName();
}
@Override
public void putName(String name) {
bean.setName(name);
}
}
Service 2
public class Service2Impl implements Service2{
@Inject
private ParamBean bean;
@Override
public String getName() {
return bean.getName();
}
}
Bean
@SessionScoped
public class ParamBean implements Serializable{
private static final long serialVersionUID = -3890162219225972547L;
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
But i get always a new ParamBean in Service 2. So the log output is:
Hallo Welt
null
=(
Does anybody know how i can inject the session scoped param bean in a second serivce?
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/606028#606028]
Start a new discussion in JBoss Web Services at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]