Results 1 to 6 of 6

Thread: Dynamic Dependency Injection

  1. #1
    Join Date
    Feb 2012
    Posts
    3

    Default Dynamic Dependency Injection

    Good morning,

    I've worked with JBoss Seam, and a functionality that I miss in Spring is the use of injection dynamics.

    I find this feature very useful in some situations. In the Spring we could, for example, in a web context, have an Application scoped bean, which has a dependency on Session scope. Or a bean Session scoped, with a reliance on scoped Request.

    And these dependencies would be reinjected in the beans whenever the container to be created, not just once (at the time of creation of the bean), such as Spring does today.

    Today my solution to this type of scenario are the lookup-methods. It is an approach that does not please me much, with all respect.

    They consider this useful feature? I'm thinking to hold a fork of Spring to develop, but only if the community is in agreement.

    If not, could, please show me another solution?

    Forgive my bad English.

    Thanks!
    Last edited by ljtfreitas; Mar 15th, 2012 at 10:50 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    And how isn't that covered by session, request scoped beans?

    Disclaimer:
    As a note I really disliked the way injection works in JBoss Seam (reinjected each time when needed) but I'm probably biased by all my spring knowledge (or spring way of thinking).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Feb 2012
    Posts
    3

    Default

    Thanks for the reply.

    Personally, I see value in how Seam Injection is dynamic, because there are cases where it is necessary to reinject a smaller scope bean in a bean of wider scope.

    That is my question / problem / issue, the injection of objects with shorter life, in other longer-lived objects.

    Today I found this excerpt from the Spring documentation:

    http://static.springsource.org/sprin...ther-injection

    This use of AOP would be equivalent to the injection dynamics in the Spring? I did not know this feature, and is apparently a solution.

    (By the way, I also love Spring!)

    Again, forgive my poor English.

    Thanks!

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    This use of AOP would be equivalent to the injection dynamics in the Spring? I did not know this feature, and is apparently a solution.
    That is indeed the solution. It looks like if the normal object is injected but actually it is a proxy which operates on the actual scoped object (or first creates it when needed).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    This use of AOP would be equivalent to the injection dynamics in the Spring? I did not know this feature, and is apparently a solution.
    That is indeed the solution. It looks like if the normal object is injected but actually it is a proxy which operates on the actual scoped object (or first creates it when needed).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Feb 2012
    Posts
    3

    Default

    I will try. It is a very elegant feature ... Spring is great!

    Thanks!

Posting Permissions

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