Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring bean injection without explicit dependency declaration?
    primarykey
    data
    text
    <p>I was working for a few months on the project without even noticing this, and yesterday, after editing a class file (inserting new dependency bean with its getter/setter), I forgot to explicitly add:</p> <pre><code>&lt;property name="deviceService" ref="deviceService"/&gt; </code></pre> <p>in the appropriate spring context xml.<br> I publshed my web app to tomcat, entered debug, and the moment I saw the line of code using this service bean, I realized that I forgot to declare it as the dependecy.<br> But then, strange thing happend - the bean was injected nevertheless...<br> This behaviour confuses me a bit. I'm surely not a spring expert, I've been using it for the past several months, however this is not something that I expected to be possible. The name of the class field, as it can be seen, is the same as bean that is being injected, if that matters. In the debugger I saw something like this for the dependency field:</p> <pre><code>deviceService=$Proxy5 (id=107) * h=JdkDynamicAopProxy (id=147) </code></pre> <p>so I'm guessing it has to do something with spring AOP.</p> <p>I must add that I didn't start this project form scratch, it was already configured, it uses spring-aop for transactions demarcation, and some logging purposes. </p> <p><strong>EDIT</strong><br> Some additional info: project integrates ZK Ajax and Hibernate as well. This service bean is basically a wrapper around a DAO bean; DAO bean is in turn a wrapper around spring's HibernateTemplate. Service and DAO beans are singleton-scoped. Service that is being injected is injected into the prototype-scoped MVC controller bean. Service bean is from the package used for DB transaction demarcation:</p> <pre><code>&lt;tx:advice id="serviceTxAdvice" transaction-manager="transactionManager"&gt; &lt;tx:attributes&gt; &lt;tx:method name="*" propagation="REQUIRED" /&gt; &lt;/tx:attributes&gt; &lt;/tx:advice&gt; &lt;aop:config&gt; &lt;aop:pointcut id="serviceMethodsRMS" expression="execution(* org.irvas.amregina.backend.service.*.*(..))" /&gt; &lt;aop:advisor advice-ref="serviceTxAdvice" pointcut-ref="serviceMethodsRMS" /&gt; &lt;/aop:config&gt; </code></pre> <p>So, can anyone explain to me what is going on, or what could be the reason for this?<br> Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload