geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcus Malcom" <malc...@community-health.org>
Subject Re: Headless Java Application Deployment?
Date Fri, 26 May 2006 23:09:01 GMT
On Fri, 2006-05-26 at 18:33 -0400, Aaron Mulder wrote:
> OK, well, you could certainly deploy the "headless apps" as GBeans --
> or at least, deploy a GBean that starts the app when the GBean starts
> and stops it when the GBean stops (and perhaps hooks it up to some JMS
> resources or JDBC pools).  You could then create an EAR containing the
> web apps, the JDBC/JMS resources, and the GBean definitions.  Though I
> don't know how you can package an arbitrary JAR (containing the
> headless application code) in an EAR, so it might be easier to put all
> the J2EE and JDBC/JMS stuff in an EAR and put the headless
> applications in a separate JAR that just depends on the EAR.

OK, so I think there's some options for me in there. I think the first
thing will be to work on creating the GBeans (see below).

> If you need help with the GBeans, let's start by sketching out what
> GBeans you need and what each one should do.

For the moment, the only thing that I need is to be able to perform a
stop(), start() and kill().

start():
  public boolean start() {
    initLogging();
    int corePoolSize = 4;
    int maxPoolSize = 30;
    long aliveTime = 60L;
    TimeUnit unit = TimeUnit.SECONDS;
    BlockingQueue<Runnable> workQueue = new
SynchronousQueue<Runnable>();
    ExecutorService service = new ThreadPoolExecutor(corePoolSize,
        maxPoolSize, aliveTime, unit, workQueue);
    ExampleWorkItem workItem = new ExampleWorkItem();
    workItem.setService(service);
    service.submit(workItem);
    setService(service);

    return true;
  }

stop():

  public void stop() {
    ExecutorService service = getService();
    if (service != null) {
      service.shutdown();
    }
  }

kill():
  public void stop() {
    ExecutorService service = getService();
    if (service != null) {
      service.shutdownNow();
    }
  }

My first cut at writing a GBean was to do something like this:

  public class GBeanExample extends AbstractGBeanReference 

but after reading a bit more on GBean's, I'm not so sure this is what I
want. So I guess at this point, I'd love to find out what I need to do
to write and deploy this kind of a GBean (sample descriptors would be
very helpful).

Oh and my "WorkItem" is just this:
public class ExampleWorkItem implements Callable {

...

  public Object call() throws Exception {
    ExecutorService service = getService();
    Logger logger = Logger.getLogger(ExampleWorkItem.class);
    while(! service.isShutdown()) {
      Thread.sleep(10000);
      logger.info("logging a message now.");
    }
    return null;
  }

}

That's pretty much all I need to do for a prototype.

Again thanks for the replies and the help!

--
Marcus

Mime
View raw message