3 Replies Latest reply on Oct 3, 2007 8:11 PM by Ales Justin

    dynamic jndiName in @Spring

    sys user Master

      We need to support multiple versions of the same ear in a single JBoss instance.

      In our session bean, we inject a Spring bean:

      @Spring(jndiName="xyzBeanFactory-1.0", bean="manager")
      private Manager manager;

      This is okay as long as someone remembers to update the session bean by changing jndiName to a dfferent name (e.g. xyzBeanFactory-2.0) every time we release a newer version of the ear.

      Instead, we are wondering if jndiName can be dynamic, say get its value from an env-entry in ejb-jar.xml. This will allow us to make our build tool (maven2) to substitute the bean factory version in ejb-jar.xml before packaging the ear.

        • 1. Re: dynamic jndiName in @Spring
          Ales Justin Master

          I guess it could be done - it depends on how much information is there in InvocationContext (via EJB3 interceptor) or Invocation (via JBossAOP).

          And there is only one entry point where we do a jndi name lookup: SpringInjectionSupport.getObjectFromBeanFactory.

          I'll have a look, and let you know.

          • 2. Re: dynamic jndiName in @Spring
            Carlo de Wolf Master

            An idea might be to implement Java EL in the annotation handling.

            Then the code would look like:

            private Manager manager;

            MC should keep a list of possible functions somewhere in xml.

            • 3. Re: dynamic jndiName in @Spring
              Ales Justin Master

              I've extracted the getJndiName method + made jndiName in @Spring optional - having default "".

              So I guess, if you still haven't done it yourself :-), use this extension for all various ways (ThreadLocal, @Resource SessionContext in interceptor + getProperties, Carlo's EL, ...) of 'injecting' dynamic jndi name.