Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Daemon for polling directory for files and uploading the files

 
Sheetal Tiwari
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wanted to code for a daemon that would check the directory for files with particular naming continuously.
Once it finds those files it should upload those into DB.

One of the approaches that I thought of is to create a servlet that would start a thread which would start polling for the files.
Once the file is found it would invoke a stateless session Bean that would handle the upload logic.

Please suggest/ comment about the approach.Also if you have some references regarding this functionality, kindly share it across.

Thank you.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Where are these files located? On the client machine? Or do they arrive on the server? If it's the former, you would need to have a client select the file for upload and press a button that would submit the request. If it's the later, a program local to the server and that executes the main method is sufficient.

ram.
 
Sheetal Tiwari
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The files will be put onto the server through FTP.
The purpose is to automate the loading part of the files. This would be a daemon that would conntinuously look for files and send them for upload.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A main method which has an infinite loop polling the directory with a sleep() in between would be simple and sufficient enough.
You could even move that logic to a thread and have the main method kick it off.

But servlets and ejbs for this? Why do you have to make it complicated? Is there a control that does not allow stand alone programs on a production server box?

ram.
 
Sheetal Tiwari
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes there is a limitiation on use of stand alone applications on production.
Also there is a requirement to prevent direct access to load functionality.That is why thought of shielding it with stateless session beans.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also there is a requirement to prevent direct access to load functionality.That is why thought of shielding it with stateless session beans.


Spawn the thread from a ServletContextListener.

ram.
 
Mark Kiami
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use an EJB Timer in this case?
An EJB Timer is a SLSB that can run a business logic periodically, they are managed by the Timer Server of the EJB Container.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic