Hi, I am busy developing an application in Tapestry and it has mostly been a good experience so far.
I struggled with dependency injection for last few days, but I think I finally got it right. However, while trying to get it to work, I made the following observations: First, You cannot inject dependencies into fields of a service class. Now this is mentioned in the documentation very clearly, it took me some time to get my head around it. No matter what you do or customise or override, you cannot inject field values into a service class. I tried contributing to injectionProvider and MasterObjectProvider, no luck. One interesting observation was when I contribute to MasterObjectProvider - my injection method was invoked and I was able to return the right object from my custom objectProvider, but the field with @Inject annotation was always set to null. The constructor injection method works like a charm - without issues. Next, it seems like InjectionProvider only comes into existence after all services have been initialised so you CAN inject dependencies into you components etc. using InjectionProvider. Then, @Inject is not same as @InjectService. @Inject falls back on masterObject provider amongst other things to try and find the required dependency. This may lead to issues circular dependencies in certain instances e.g. if you are contributing object providers which in turn, require other services. If you use @Inject for injecting dependencies in your object providers, this will fail. However, if you use @InjectService, this will succeed. I haven't had a chance to look at the code, but I do remember reading it somewhere in documentation that @Inject uses several techniques to inject the dependencies, MasterObjectProvider being one of them. Which would explain the circular dependency issue I guess. Lastly, (and I am not so sure about this one) - because tapestry proxies access to all objects, you do not need to create/use singleton patterns explicitly in you services or patters - i.e. provide a static getInstance method..? Is that a correct? Best Regards, Sanket