Re: @SpringBean vs getApplication().getDao()

2009-02-18 Thread Martijn Reuvers
Hey Sergey, As far as I know it should create only a single instance for each spring bean (if they are singletons that is). Thus always the same bean should be injected into your wicket classes. Does this problem occur with the @SpringBean or using the proxy approach? I've been using @SpringBean

RE: @SpringBean vs getApplication().getDao()

2009-02-18 Thread Kai Mütz
Sergey Podatelev mailto:brightnesslev...@gmail.com wrote: Thanks for your insight, Patrick. But I'm stuck in my dumbness: setting the component's fields -- does this mean a new instance of that particular annotated bean is created, or that singleton is accessed somehow (proxy)? Also, it's

Re: @SpringBean vs getApplication().getDao()

2009-02-18 Thread James Carman
Well, in order for the reference to be set, the object used must adhere to the same API. The object is, indeed a proxy. So, the proxy either implements the same interface as the type of the field or extends the class of the type of the field (you should be using interfaces if at all possible).

@SpringBean vs getApplication().getDao()

2009-02-17 Thread Sergey Podatelev
Okay, this question might actually be more related to Spring, but I'm completely lost here, and my question on Spring forums usually don't get any replies, so I hope Wicket community might help as it usually does. I'm using JCR, and have a RepositoryDao bean configured in applicationContext.xml.

Re: @SpringBean vs getApplication().getDao()

2009-02-17 Thread Martijn Reuvers
Hello, I am not entirely sure if I understand your question correctly. But I usually use Spring like this: YourDao (either defined in applicationContext.xml or in separate spring-config files, or annotation-driven e.g. with @Repository. The template you mention I usually autowire into the dao so

Re: @SpringBean vs getApplication().getDao()

2009-02-17 Thread James Perry
As far as I am aware, the main internal differential is that annotations provides a quick, safe way to access your spring beans and ensure that the whole container does not get serialized via a proxy. However the magic comes at a cost that it will serial the bean id (as a string) - which can be

Re: @SpringBean vs getApplication().getDao()

2009-02-17 Thread Sergey Podatelev
Okay, thanks for you replies, my question was poorly formulated. There are two issues here. First problem is that I apparently don't understand some very basic principles behind Spring-configured beans handling. I assume that a DAO configured in Spring are created on application deployment,

Re: @SpringBean vs getApplication().getDao()

2009-02-17 Thread Patrick Angeles
To answer your question, yes spring beans are singleton by default. The @SpringBean annotation works roughly like this: in your Application class, you set a ComponentInstantiationListener which gets called every time a Wicket page/component is instantiated. The particular listener that gets set

Re: @SpringBean vs getApplication().getDao()

2009-02-17 Thread Sergey Podatelev
Thanks for your insight, Patrick. But I'm stuck in my dumbness: setting the component's fields -- does this mean a new instance of that particular annotated bean is created, or that singleton is accessed somehow (proxy)? Also, it's not the injected beans that are null, it's their dependencies,