Sample Application Client
Written by Joseph Ottinger
Getting an application client running in Orion is pretty easy, but has a few steps that have to be followed. Along the way, you'll get an application client that schedules events, handy for doing things like sending mail, serving as a simple watchdog process, etc.
schedulersrc.jar is a tree that builds a scheduler, org.adjacency.faq.Scheduler. This class reads a property file (scheduler.properties), and calls Thread.start() for each property value that resolves to a Thread or Runnable implementation name. A sample class, org.adjacency.faq.Marker, is included as a default, which outputs \--MARK\-- to the standard output stream (System.out) every fifteen minutes. Note that Marker's timing is imprecise, relying on Thread.sleep(), so it can't be used as an example of "start a process every fifteen minutes." For that you'd want a Timer instead.
You can compile that tree with Ant, and it will create dist/scheduler.jar. Copy that file to your .EAR base directory (i.e., the same directory your web-apps and EJBs are in.) Now, modify META-INF/application.xml to include the external client, by adding the following lines:
<module>
<java>scheduler.jar</java>
</module>
Now, you'll need to make sure that your application has a valid user, which depends entirely on your user manager configuration. The application will run as that user, so pick wisely.
The last thing to do: modify META-INF/orion-application.xml to autostart the application. Add the following lines (presuming a "joeo" user):
<client-module
auto-start="true"
path="scheduler.jar"
user="joeo" />
Now, when you redeploy the application, you will see the scheduler running.
Copyright © 2007 IronFlare AB