[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Quartz Session  XML
Forum Index -> Quartz
Author Message
xtotal

neo

Joined: 03/02/2010 08:11:56
Messages: 4
Offline

How to get the session in a JOB?

I'm Brazilian...

QrtzHelp

journeyman

Joined: 01/16/2010 09:44:00
Messages: 37
Offline

What do you mean by "the session"?

If you mean the scheduler API, then it's simple: jobExecutionContext.getScheduler().

xtotal

neo

Joined: 03/02/2010 08:11:56
Messages: 4
Offline

I want an object of type HttpSession!
ezapata

journeyman

Joined: 12/09/2009 05:47:43
Messages: 12
Offline

It would probably depend on your application, as to when the job requiring the HttpSession object is scheduled. If some user action schedules the job, you would probably have to pass the session as part of the JobDataMap.

Otherwise, you would probably need an HttpSessionListener to track created/destroyed session in a list of some sort, and this list would have to be available to your job.
jhouse

seraphim
[Avatar]
Joined: 11/06/2009 15:29:56
Messages: 1703
Offline


It would definitely depend on your application, and would almost certainly be a VERY BAD IDEA.

HttpSessions are controlled by the web application framework. Their lifecycle controlled by the container. If you stick it in a job data map it is going to get cloned and serialized and at best end up a disconnected copy of the session that the Job sees. There are good reasons the Java EE specs don't give any access to HttpSession outside of request.getSession().


Rather than giving the job a handle to the session, you should take whatever the job actually needs (what it would be fishing around in the session for), and stick THAT in the JobDataMap.
xtotal

neo

Joined: 03/02/2010 08:11:56
Messages: 4
Offline

Then you can leave what I wanted was to get the physical path of the context. I put in a variable ...

String caminhoFisico = this.getServletContext().getRealPath("/");



Obrigado a todos!
xtotal

neo

Joined: 03/02/2010 08:11:56
Messages: 4
Offline

I used the session object for other actions, but for the specific location I needed only the physical path of the context ....

: p
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team