Announcement Announcement Module
Collapse
No announcement yet.
Context initialization failing due to inner class usage Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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" />
    </bean>

    for a longer explanation check my blog post about this:
    boris-dev.blogspot.com/2008/08/spring-and-inner-classes.html

    Comment


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

      Comment


      • #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

        http://apress.com/book/view/1590599799

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

        Comment

        Working...
        X