Guice inside of Tomcat, running Apache SOAP, JAX-WS, JSP, JSF

211 views
Skip to first unread message

Marty

unread,
Jul 19, 2012, 4:09:23 AM7/19/12
to google...@googlegroups.com
Hi Guice users.

I have an application which is a colourful mixture of legacy code (JDBC + Apache SOAP Webservices), as well as a lot of newer frameworks, primarily JAX-WS. The application is actually a Java Web Start application, but on the data exchange occurs via the legacy web services as well as newer web services. The application server is Apache Tomcat.

Over the last year I have been slowly rolling out Google Guice accross the entire client, without much difficulty. Since the Server also shares some code, the server has also had is share of injection. However I haven't been using the Guice Servlet on the server, but rather in the main constructors I called injectMembers(this);...simple but effective....until now.

My problem is that I often have need for Providers. These providers should provide different instances based on the user "context" username, mail address, etc. My problem is, the providers doen't have a way of accessing the session...of which there are multiple different sessions. Apache SOAP has (or could have) its own session, JAX-WS has (or could have) its own session, JSF and JSP also have their sessions. My first thought was to store the User Context in the Session and access it.
    
    public  UserContext get() {
        //this is JSF Faces specific
        Map<String, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        UserContext userContext = ( UserContext)sessionMap.get("ATERM_CONTEXT");
        return  userContext;
    }

Here the problem is, JSF hasn't always been instantiated. It is not even a problem that there are 4 different sessions floating around for one User Context. It may not be a beutiful design, but it works. Each Web Service method just needs to update the user context to the current value (or become stateful).

My problem is I just need the Provider to access the UserContext of this session. Regardless of which technology created the session. i.e. I can't access the session using JSF technology as shown above. Null Pointer Exception :( 

My thought is that I could use Google Guice to make a session scope to provide a (new) user context for each session? In my stateless web services, I would need to update this session from the method call....but I could also work towards making the web services stateful. Could such an approch work? Will Google Guice be able to access the state for all of these different technologies?

Thanks

Martin

Martin Cavanagh

unread,
Jul 20, 2012, 3:26:52 PM7/20/12
to google...@googlegroups.com
Hi

Does anyone have any experience with Guice and Sessions in Apache SOAP / JAX-WS / JSP / JSF (all at once)?

Thanks

Martin


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-guice/-/F3O11svH1z0J.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.

Reply all
Reply to author
Forward
0 new messages