Announcement Announcement Module
No announcement yet.
Do we need Spring on client side when we have AspectJ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do we need Spring on client side when we have AspectJ?

    I had posted this before, but never got a response.... anyone care to comment?

    Recently I've been learning AspectJ and find it extremely powerful. It seems that all the Dependency Injection and AOP I could ever imagine can be done with only a few lines of code! Just as a proof of concept, I created a WireFramework aspect that can inject anything I want into any instance just created without changing the parent class. With the power of AspectJ to help you build rich client applications, why bother with trying to get Spring loaded? I can see that a great deal of work is done for you by Spring on the server side, but now I question the utility of spring on the client side.

    I would enjoy reading everyone's thoughts!

  • #2
    AspectJ provides some excellent mechanisms for hooking into the creation of an object so you can inject some objects into it. However, it doesn't provide any framework features that actually help with the rest of the DI puzzle.

    Creating an aspect every time you want to configure a given object type would seem pointless - rather what you need is generic aspect that allows you to configure any object with a set of collaborators that are configured externally. This external configuration should allow for complex graphs of collaborators and provide the ability to locate collaborators from a variety of locations. This is the kind of funcitonality the Spring and AspectJ team have been working on ready for the Spring 1.3 and AspectJ 5.0 releases.

    Using this new functionality, you will be able to define configurations for your objects using Spring, and have AspectJ invoke Spring to do the wiring every time an instance of one of your objects in instantiated. This gives you the best of both worlds - you are free to create objects as you need in your code plus you get a sophisticated and fully decoupled DI implementation.




    • #3
      Are you saying that the real selling point of using spring on the client side is for dependency injection using an external configuration (ie. context.xml files)?

      That's a tough sell! I can use one very small aspect to wire all of my swing components (etc.) together. If I have to use an IDE to build the application to begin with, why do I need the external configuration?

      I am very excited about AspectJ 5.0 and Spring 1.3. Both these projects are making leading breakthroughs! Also - Good job on your book!