Don't quite understand the mechanism of Dependancy Injection in Struts2 XWork

161 Views Asked by At

I'm new to IOC and learning from source code of Struts2 framework currently. Through learning, I've got some basic understanding of the framework like how ActionInvocation handlers interceptors etc.

But when I was trying to figure out the mysterious (to me at least) Dependency Injection part, I got completely lost.

The inject mechanism specified in package com.opensymphony.xwork2.inject is hard to comprehend. How exactly does the ContainerImpl.inject(Object) do all the work? Or, where should I start in order to understand DI?

1

There are 1 best solutions below

0
On BEST ANSWER

Personally I found this resource useful. For others who like to dig old, very old user guide can download Guice 1.0 User's Guide.pdf. As Dave mentioned

S2 uses an old (old!), hacked version of Guice for its DI.

So, you can use this page as a starting point for Dependency Injection with Struts2.

P.S.:

About ContainerImpl.inject(Object)

Injects dependencies into the fields and methods of an existing object.

It's not mysterious because Guice like Spring autowires a bean. Spring like Guice can use annotations to wire object dependencies.