Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Where to initialise Spring in EJB Container? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where to initialise Spring in EJB Container?

    Hi,

    Hopefully this isn't too daft a question, but I've drawn a major blank. My team and I currently use Spring dependency injection in various Spring MVC applications, without issue.

    We want to begin doing similar within our service layer of stateless session EJBs (deployed in Weblogic), but I've been frustrated in my attempts to unearth a best-practice of where/how to initialise Spring.

    Virtually all tutorials/samples are either...

    a) web applications, wherein Spring is initialised alongside the servlet

    ...or....

    b) simplistic examples that demonstrate calling....

    JavaConfigApplicationContext ctx = new JavaConfigApplicationContext(AppConfig.class);

    ...from a static void main() method. Obviously, within an EJB container, I have no such 'static void main' to work from, nor a servlet to hitch my IOC initialisation onto.

    So where should I create my JavaConfigApplicationContext? I've toyed with the idea of static initialistion blocks, setSessionContext() in our EJB base class, JVM hooks, bootstraping etc. But I don't want to go off the beaten track. Am I missing something simple?

    Note* - it isn't the EJBs themselves I'm specifically looking to 'wire', but rather various bits'n'bobs lie beneath the EJBs. Therefore, the Spring documentation on "Enterprise Java Beans (EJB) integration" is not what I'm looking for. I just want to initialise Spring within an EJB container, but I have no scope (nor need, frankly) to refactor the EJBs themselves to, for example, extend classes like Spring's AbstractStatelessSessionBean.

    Any advice, much appreciated,

    Cheers,
    Al

  • #2
    Well I still suggest the reference guide as that also explains how to initialize/use a context from EJBs, especially the part that explains about the EJB base classes. Basically it tells you about the BeanFactoryLocator (interface) and several implementations. That is basically in charge of loading the context.

    You could load it (and reuse it within several other EJBs) in the ejbCreate or setSessionContext method. I would suggest the ejbCreate, because that feels better.

    Comment


    • #3
      Hey Marten, thanks for the reply.

      Comment


      • #4
        thanks marten You helped me a lot.

        Comment

        Working...
        X