Results 1 to 4 of 4

Thread: Recomposition of Spring ApplicationContext missing for Prism

  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Arrow Recomposition of Spring ApplicationContext missing for Prism

    Hi,

    The problem with Prism is that individual modules may have own spring configurations and should be able to be loaded at run time.
    More than that, the majority of the Prism services expect ServiceLocator to be able to access all the object definitions from the loaded modules.

    The problem that I've noticed, that Spring has no ApplicationContext, supporting reconfiguring on the fly.

    The XmlApplicationContext expects all the locations to be given in the constructor and it is not possible to add some ObjectDefinitions programmatically (or they will be forgotten on Refresh).

    The GenericApplicationContext doesn't support multiple calls of Refresh(). And without it you aren't even able to define "simple" circular dependency in the modules (cause you have to use lazy-init, which isn't finished till Refresh()).

    Using Hierarchical Contexts doesn't help much, cause you are not able to express the fact, that some module can be dependent on more then one another...

    So, as for me, the only way to solve the problem is to implement some kind of ReconfigurableApplicationContext, where the internal ObjectFactory will not be destroyed on the Refresh() and on registering ObjectDefinitions they will be added to a list of objects to consider on refreshing. On the end of Refresh() the list should be cleared...

    That's the way I gonna try it.

    I would be glad to know you opinions.

    (I've already made a Quickstart/Modularity/ModularityWithSpring for Prism, which works, but my SpringExtentions are not ready to be used in the real-world applications)

    BR
    Konstantin

  2. #2
    Join Date
    Apr 2009
    Posts
    7

    Default Run time object regisration in container

    Konstantin, See this for how objects can be registered in the container at run time. I have been using spring 1.3 with WPF/Prism for over a year with no issues.

  3. #3
    Join Date
    Apr 2009
    Posts
    7

    Default Follow on

    I use the DefaultListableObjectFactory in my spring bootrapper for Prism to facilitate the RegisterTypeIfMissing functionality.

    Code:
    Container.RegisterSingleton(name, target);
    or

    Code:
    var objectDefinitionFactory = new DefaultObjectDefinitionFactory();
    var builder = ObjectDefinitionBuilder.RootObjectDefinition(objectDefinitionFactory, target.GetType());
    builder.SetSingleton(false).SetAutowireMode(AutoWiringMode.Constructor);
    Container.RegisterObjectDefinition(name, builder.ObjectDefinition);
    Obviously the choice to autowire is mine and is my personal pref.

  4. #4
    Join Date
    Jul 2009
    Posts
    5

    Default

    Quote Originally Posted by Konstantin View Post

    (I've already made a Quickstart/Modularity/ModularityWithSpring for Prism, which works, but my SpringExtentions are not ready to be used in the real-world applications)

    BR
    Konstantin
    Hi, i've been using Spring for a couple years now and LOVE IT as a dependancy injection container. We are now in the process of building a touchscreen WPF app and I was looking to use PRISM. I can see by the content of the conversation here there is A LOT that I still don't know about Spring. Anyway, I would love to see someone's SpringBootstrapper implementation. Or even some "hacks" at a SpringExtentions that you mentioned. I just need something to get me started or i'm afraid I will be stuck using UNITY... yuck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •