Results 1 to 2 of 2

Thread: how to initialize a bean with the current class loader?

  1. #1
    Join Date
    Feb 2010
    Location
    Italy
    Posts
    4

    Default how to initialize a bean with the current class loader?

    Hi all,
    I'm configuring spring to generate a bean (each time different) that should accept a parameter in the constructor that is the class loader of the entity that requires the bean. At least the class loader of the beanfactory should suffice. However I've no idea on how to do this, any suggestion?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    I can't imagine why you would want this, but I suppose if your constructor takes an "ApplicationContext" parameter, and is autowired, that would do it. You could also have it "implements ApplicationContextAware", but that wouldn't give it to you in the constructor.

    Obviously, once you have the ApplicationContext, you can do "context.getClass().getClassLoader()".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •