views:

173

answers:

2

I want to declare a worker manager to perform some work in managed thread.

Weblogic documentation tells that we can
- declare a global worker manager using the admin console
- declare a local it in an ejb-jar.xml config file.

I want to use the second option. But my ejb-jar.xml is generated by the ejbgen tool.

There is no tag in ejbgen that would allow me to declare a worker manager.

So how should I create a local worker manager declaration ?

I have gathered some interesting answers, posted as an answer to my own question.

+1  A: 

I assume you defined your Work Manager as documented here in ejb-jar.xml as a resource-ref, example below -

... 
<resource-ref> 
   <res-ref-name>wm/MyWorkManager</res-ref-name> 
   <res-type>commonj.work.WorkManager</res-type> 
   <res-auth>Container</res-auth> 
   <res-sharing-scope>Shareable</res-sharing-scope> 
</resource-ref> 

...

So you can use the @ejbgen:resource-ref task to generate this in the ejb-jar.xml, as documented here

JoseK
As said in my question, ejb-jar.xml is generated by the ejbgen tool. So I can not add the work manager definition here...
Guillaume
A: 

I have gotsome useful answers for this question:

  • use the default work manager
    WorkManager wm = (WorkManager) new InitialContext().lookup("java:comp/env/wm/default";

  • use the weblogic-application.xml to configure the work manager instead of configuring it in the ejb-jar.xml

  • use a shared library (weblogic 9+ feature) that will contains the worker manager declaration.

Guillaume