aspose file tools
The moose likes Other Application Frameworks and the fly likes Spring - http session Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Reply Bookmark "Spring - http session" Watch "Spring - http session" New topic
Author

Spring - http session

Gigi Kent
Ranch Hand

Joined: Nov 30, 2004
Posts: 40
Hi.

I'm searching a solution for my problem.
Here it is:

I have an web application, with spring, for connecting the layers and other stuff.
So, when a user connects into the appplication,based on a username/password, I'm putting this informations into the http session.
The problem is that I don't know hot to 'inject' this information in my service layer (I need to trace every action).

Anyone, any ideas?

Thanks.
Corneliu.
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

Hi,

If at all you're able to inject the user info to service layer, an instance of service-object will be needed to be dedicated for a request at any given point in time.

This means, for catering N simultaneous requests, you'll need N instances of service-objects, as they will be aware of the request context. This is certainly possible with scope as 'request' and calling beanFactory.getBean(..) in web-layer to get a (possibly new) instance of service-object.

Possible, but may not be desired... I would say. If your service-object is not having any other state (instance-specific fields) to maintain, there is no point in instantiating it more than once.

I would suggest you go the Transfer-Object way, wherein you 'pass' the user-info to service-object along with other information (wrapped in a Transfer-Object) every time you invoke a service-method.

Second option could also be to use ThreadLocal contexts just like Spring does (custom scopes also depend on these). This, however, assuming that there is no remote-call (to EJBs etc.) in the request flow.

Best regards,

- Aditya Jha
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17224
    
    1

Um, why not just use Spring Security? It will handle all that stuff for you. It can even pass down the Principle to your service layer and your service layer can have security automatically.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Spring - http session
 
Similar Threads
Using OpenSessionInViewFilter in Spring-Hib-Wicket
Does Spring Web Flow 2 have role based authorization to execute flow feature?
How to pre-populate Spring session bean with Spring MVC annotation
Passing the session to JSF
bean.xml ConnectException-Connection timed out: connect