Announcement Announcement Module
No announcement yet.
Context initialization failing due to inner class usage Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    It is possible to instanciate non static inner classes with spring

    I had a similar problem like the first post in this thread, but the solution making the class static was not valid for my problem. I wanted to call methods of the outer class directly from the inner class.
    Spring instantiates beans with reflection not with new, and with reflection you have a constructor for non static inner classes that takes an instance of the outer class as parameter.
    so the config should work for this example.

    <bean id="customerBean" class="com.models.CustomerBean" />
    <bean id="customerFormValidator" class="com.models.CustomerBean$CustomerBeanValidat or">
    <constructor-arg ref="customerBean" />

    for a longer explanation check my blog post about this:


    • #17
      Boris, you've replied to a thread that's just a few days away from being a year old!


      • #18
        And regarding your blog entry about being able to extend two classes, there's something you can do with Spring's AOP to get the same or similar effect. I've never used it and only know about it because I'm reading

        and he goes over it in one of the chapters on AOP.