Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

delegation of injected depencies  RSS feed

 
Jaromir Herloma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im doing a web app, and my setup is
-jboss5.0.0
-three stateless session beans which each access one database hosted by common database process
-stateless mailer for sending administrative emails
-front controller servlet which creates custom model updates(i guess they could be called command objects etc) using factory method according to the params
-front controller gets database injections

I found the dependency injection very useful as I am quite new to Java. At the moment Im delegating references of all stateless session beans to model-update-objects using static setter method in the baseclass of the model-update-classes. This seems not so elegant to me, have I done something wrong? Another way I can think of is to create the model-update object and give explictly stateless session bean refs. Or should I make all my model-update(or command) classes inherit from some servlet-based class in order to utilize depency injection in cleaner way?

-jh



 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36441
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaromir,
That's fine. The "clean" alternative is to look up the resources from JNDI directly "the old fashioned way."
 
Jaromir Herloma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I can't get annotated depency injection work with plain java class, unless I make it inherit container managed classes like servlet or stateless session bean?
Meaning that certain code does not run under certain container unless it inherits certain class, meaning a servlet or a stateless session bean or what ever container-classes there may be? Huuh quite difficult sentence.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!