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
Issue with Proxy Generation for multiple interfaces Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with Proxy Generation for multiple interfaces

    I run into an issue attempting to directly implement multiple unrelated interfaces in a JavaConfig managed bean:

    public class MyServiceImpl implements MyService, ApplicationListener {
    ...
    }

    @Bean(scope=DefaultScopes.SINGLETON)
    public MyService myService() {
    return new MyServiceImpl();
    }

    While above setup works fine to expose the business interface of my service, it does not make it available as event listener.

    When changing (in an attempt to make the event listener portion work) the return type:

    @Bean(scope=DefaultScopes.SINGLETON)
    public MyServiceImpl myService() {
    return new MyServiceImpl();
    }

    An error is raised that the generated proxy cannot be cast to the expected return type. That's because a JDK proxy is generated for the interfaces, but not the implementation class. That's OK, I do not want the implementation to be exposed in any case.

    As workaround, I extended MyService from ApplicationListener and things work as expected. The bean is now found in the bean factory as an event listener a receives events.

    It seems a bit odd having to mingle interfaces like this through, there must be a better way to do this.

    What's the recommended approach to implement multiple interfaces and have them all exposed within the app context?

  • #2
    Hi, thanks for posting this. It's possible there is an issue/bug going on here, but I'll need a little more info. Please create a bug report at http://jira.springsource.org (under the Spring Framework project, not under Spring JavaConfig). Be sure to note whether you're seeing this behavior against Spring JavaConfig 1.0.0.M4 or the Spring 3.0 milestones (I don't know which you're using right now).

    If you can attach a working example (preferably built with Maven) that demonstrates the issues, that will be most helpful. Thanks!

    Comment


    • #3
      http://jira.springsource.org/browse/SPR-6060

      Comment

      Working...
      X