• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Daemon for polling directory for files and uploading the files

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic