I managed to configure a custom implementation of the CommonJ − JSR 237 Timer & WorkManager API (http://commonj.myfoo.de) as a JNDI resource on Jetty 6 and 8, but it only works in a global scope.
With this solution JNDI name of the resource is wm/WorkManager, I need it to be java:comp/env/wm/WorkManager, but due to restrictions, I cannot use java:comp/env in a global JNDI name because it's reserved to application scoped resources.
I've created a new configuration file called {jetty.home}/etc/jetty-wtm.xml and added to {jetty.home}/start.ini.
Here is jetty-wtm.xmlcontent for Jetty 6, for greater versions it's a bit different, but works too:
<!-- =============================================================== -->
<!-- Configure Server Time and Work Managers -->
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.jetty.Server">
<New id="WorkManager" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>wm/WorkManager</Arg>
<Arg>
<New class="de.myfoo.commonj.work.FooWorkManager">
<Arg>
<New id="threadPool" class="de.myfoo.commonj.util.ThreadPool">
<Arg type="int">0</Arg>
<Arg type="int">10</Arg>
<Arg type="int">2</Arg>
</New>
</Arg>
</New>
</Arg>
</New>
<New id="TimeManager" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>tm/TimeManager</Arg>
<Arg>
<New class="de.myfoo.commonj.timers.FooTimerManager">
<Arg>
<New id="threadPool" class="de.myfoo.commonj.util.ThreadPool">
<Arg type="int">0</Arg>
<Arg type="int">10</Arg>
<Arg type="int">2</Arg>
</New>
</Arg>
</New>
</Arg>
</New>
</Configure>
I need to mantain standard JNDI naming java:comp/env/{RESOURCE} specifically java:comp/env/wm/MyWorkManageracross servers, but standard WEB-INF\jetty-env.xml configuration file doesn't work.
Any ideas?
UPDATE:
I've tested the jetty-env.xml local configuration file in Jetty 9 and it works as expected. It seems in versions under 9 JNDI it's not fully supported. Here is the configuration file contents:
<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
<New id="WorkManager" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref id="wac"/></Arg>
<Arg>wm/MyWorkManager</Arg>
<Arg>
<New class="de.myfoo.commonj.work.FooWorkManager">
<Arg>
<New id="threadPool" class="de.myfoo.commonj.util.ThreadPool">
<Arg type="int">0</Arg>
<Arg type="int">10</Arg>
<Arg type="int">2</Arg>
</New>
</Arg>
</New>
</Arg>
</New>
</Configure>