1 Reply Latest reply on Mar 7, 2005 2:01 PM by Tim Morrow

    Do I need an app server for this simple  hooha?

    Marc Newbie

      HI All,
      What I'm trying to do should be very simple, but I'm afraid I might need to turn a nice, sweet, small app into a server-run app just to get a few bells and whistles. I'm looking for some advice on how to proceed. Right now, this app runs as a command line app. i start it with a batch file and it runs until i stop it or something bad happens.
      This is simple: I have a TaskRunner class that creates a TimerTask, passing MyTask to the Task runner. MyTask then runs every 5 seconds or so, does some stuff, spawns some threads, does some more stuff, then waits for its next run. It's a simple timer app, except that it spawns buttloads of threads that do other work and connects heavily to a database.

      Currently, each thread creates its own database connection, which means there's the possibility of dozens -- up to a hundred or so -- of new connections being created and closed at any time. This seems silly.

      so all I want to do is avail myself of a database connection pool in my main class (the one that spawns the timertask), and have the objects/threads created in MyTask to get connections from that pool and return connections. I'd also like to have some other objects in the main class available to the stuff spawned by the TimerTask (some Collections objects and such). When I think of this, I think of it like a web developer: i want Request scope, but i'm not in a server environment. I want initial context, but i'm nto in a server environment.

      So...here's the rub: how do I create objects that are available to objects spawned by the main class without passing them all around? Is this java 101 stuff? or do i really need an app server for this?

      it's been years since i've even done java web app development, so I don't even know how one runs a simple command line within the context of a server, if that's what i need to do to create objects that are available in a scoped manner. is that even possible to do in an app server?

      Thanks for any and all advice on this.