Announcement Announcement Module
Collapse
No announcement yet.
Accessing ApplicationContext / Beanfactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I think we are talking at cross purposes, you're talking about applicationContext.xml, I'm talking about instances of the applicationContext. As in every call to new ClassPathXmlApplicationContext is going to create you a new instance.
    Last edited by karldmoore; Aug 30th, 2007, 05:35 AM.

    Comment


    • #17
      Originally posted by mdeinum View Post
      Just wondering wouldn't it possible to create a FactoryBean which wraps your third party tool? That way you could inject your objects instead of looking them up each time.
      As far as I understand you, it won't work.

      For Example. Quartz can store jobs in the database. The Job is stored only with its full qualified class name. When it starts a new Job, it propably does something like

      Code:
      Class<name = Class.forName("com.example.ClassWithNeedOfInjection");
      ((Job)name.newInstance()).execute();
      For Quartz we got already the solution that we can define our own factory and plug it into quartz. Now, we can get our jobs out of Spring.

      Hibernate Validators does not support the possibility to plugin in a BeanFactory, so it instanciateit on its own. Thats why the ClassWithNeedOfInjection looks like:

      Code:
      class ClassWithNeedOfInjection implements Validator{
       
        ....
      
        isValid(Object o){
          UserDAO userDAO = (UserDAO) BeanfactoryAccessor.getBeanFactory().getBean("userDAO");
          ...
        } 
      
      }
      I hope, I can express myself clearer :-D
      Last edited by sneumi; Jun 13th, 2007, 02:40 PM.

      Comment


      • #18
        Originally posted by karldmoore View Post
        I think we are talking at cross purposes, you're talking about applicationContext.xml, I'm talking about instances of the applicationContext. As in every call to new ClassPathXmlApplicationContext is going to create you a new instance.
        We are talking nearly about the same thing ;-)

        I am just saying that the SingletonBeanFactoryLocator is not as perfect as on the first look, since you have to create a new instance of the applicationContext to use it in the SingletonBeanFactoryLocator.

        But ok. I really appreciate your and the help of the others. It helped a lot to understand all different solutions.

        Thanks

        Stefan

        Comment

        Working...
        X