0 Replies Latest reply on Dec 12, 2012 10:22 AM by Steve van den Buys

    How are @EJB injections handled in JBoss 5.1 and can I somehow hook into it?

    Steve van den Buys Newbie



      I would like to be able to intercept the moment when an EJB instance is created and its @EJB dependencies are being resolved. The reason I would like to do this is the following: we have worked hard to create an environment-independent EAR (that is: the same EAR can be deployed on dev, tst, acc, ... without any modifications to the EAR itself). However: on development machines some EJBs should be replaced by mock implementations (because these EJBs integrate with remote systems that are not available in development).


      So, we were thinking of doing something like this:


      - wire in a system property (eg. developmentMode = true) using JBoss' SystemPropertiesService

      - create a custom annotation that accompanies an @EJB annotation and that indicates that this resource can have a mock injected instead of the real thing (eg. @EJBMock(mock = "eg.bla.BeanMock")

      - somehow intercept the moment a bean is instantiated and its @EJB references resolved so that we can check for the presence of @EJBMock and, if present and system property developmentMode = true, wire in the mock implementation defined in "mock" instead of the real thing


      Anybody any idea if I can somehow hook into that precise moment (perhaps overriding the default implementation in JBoss 5.1)?