Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Unexpected behaviour with @Configurable and Eclipse RCP Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unexpected behaviour with @Configurable and Eclipse RCP

    I developed an application in Eclipse RCP technologies using Spring DM (I try1.1 & 1.2M2).
    Eclipse kernel is responsible to instantiate the views and the perspective and I cannot modify that mechanism. So I've used a Configurable-approach as explained by Martin Lippert here: martinlippert [dot] blogspot [dot] com [slash] 2008 [slash] 07 [slash] dependency-injection-for-extensions [dot] html (...sorry: forum validation doesn't allow me to post url)

    All works fine. The views creation is intercepted by Spring DM and related components are injected correctly.

    But we have found an unexpected behaviour that we are unable to explain. We have two views (View1 and View2) and two RCP perspective (perspective1, perspective2) in two different bundles (view1->perspective1->bundle1, view2->perspective2->bundle2). The bundles are standard RCP bundles configured as in Martin Lippert above.
    If I run the application with both bundles installed and I open perspective1, then the view1 is opened and components injected correctly. Then if I switch to perspective2 all works fine for view2 too. But If I switch back to perspective1 and close and reopen the view1 Spring DM stop working. The view is recreated, but nothing is injected.

    We try to debug what happens and we realize that Spring DM try to use in View1 initialization (of bundle1) the context associated with the last active perspective (the perspective2 of bundle2).

    We are able to workaround this behavior, in a very dirty way, searching for correct context in OSGi registry.

    Is this a bug or a designed behaviour?
    If it is correct which is the architectural approach to resolve our issue?

  • #2
    Hello Frederico,

    I am not 100% familiar with what Martin Lippert suggests, but your observations remind me of similar problems we had some time ago. See:

    --- Jens


    • #3
      We solve the problem using the SpringExtensionFactory mechanism implemented by Martin Lippert here:
      and here:

      The impact in our project is low and the architecture remain clear, so we can take this way (it doesn't use aspects). I think the answers to the questions about @Configurable, Context and RCP are strictly related to the issue reported by jborrmann.


      • #4
        Great to read that the spring extension factory implementation works for your setting and does workaround the LTW issue. That sounds indeed a lot like the problem discussed in the other thread. Would be interesting to hear how the spring dm server solves this...


        • #5
          I think the problem is a bug in the spring aspects. I can reproduce the behavior with the examples from Martin and Jens. As Jens pointed out in his last post in The aspect "org.springframework.beans.factory.aspectj.Annotat ionBeanConfigurerAspect" is instantiated only once as singleton. Spring calls the setter for the Beanfactory property of the Aspect for each ApplicationContext with <context:spring-configured> entry. The last one who gets initialized wins. The Beans from the others Contexts can't get initialized. You can reproduce the bug with the (very good) example from Martin. If you duplicate the View project with name "org.eclipse.example.springdm.rcpview2" and add a new open view action to the CoolBar in "org.eclipse.example.springdm.rcp.ApplicationActio nBarAdvisor" for this new View.
          Then you can create message windows with both Views. Because of the lazy initialization the new View is created correctly. But after creating the first new View I can't create an old View anymore.



          • #6
            Are there any plans to change this mechanism within spring (or spring-aspects) to solve this issue?


            • #7
              I've raised an issue at: Feel free to add more information and follow it.



              • #8
                Hi Costin!

                Thanks for the jira entry. Will follow and comment on it, if necessary. Thanks again for your help!