<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=ramnivas" rel="nofollow">Ramnivas Laddad</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4306?redirect=false" rel="nofollow">SPR-4306</a></strong> and commented</p>
<p dir="auto">Currently, the base aspect for domain object dependency injection -- AbstractBeanConfigurerAspect -- is not really capable of doing many interesting things that its subaspect AnnotationBeanConfigurerAspect does. Especially important capability is injecting dependencies after deserialization. This precludes users from creating useful subaspect of AbstractBeanConfigurerAspect unless they duplicate the functionality in AnnotationBeanConfigurerAspect. This, in turn, precludes some interesting possibilities such as:</p>
<ul dir="auto">
<li>Injecting dependencies based on user-specific annotations.</li>
<li>Injecting based on user-specified interfaces (e.g. Injecting MailServer for objects implementing MailClient).</li>
<li>User specified configuration strategy (that can bypass Spring's reflection based strategy).</li>
</ul>
<p dir="auto">While making backwards compatible changes is ideal in some respect, it is probably going to end up making the design too complex (already we have some complexities such as non-abstract pointcut that must be overriden). So perhaps a better choice is to:</p>
<ol dir="auto">
<li>Create a new aspect, say, AbstractDependencyInjectionAspect with consideration for all things mentioned above.</li>
<li>Deprecate AbstractBeanConfigurerAspect.<br>
This shouldn't be a real issue for any existing users as their subaspects of AbstractDependencyInjectionAspect, if any, will continue to work the same way.</li>
<li>Refactor AnnotationBeanConfigurerAspect to extend AbstractDependencyInjectionAspect.<br>
Since AnnotationBeanConfigurerAspect is a concrete aspect (which cannot be extended further), there is no issue with user extensions to it. Further, most (all?) Spring users use this aspect to aop:spring-configured/ or context:spring-configured/ anyway, making internal details umimportant to them.</li>
</ol>
<hr>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398084313" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8980" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8980/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8980">#8980</a> Deserialization not reinjecting for <code class="notranslate">@Configurable</code> with preConstruction</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398084334" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8981" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8981/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8981">#8981</a> Repeated configuration for <code class="notranslate">@Configurable</code> with preConstruction</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=baronludwig" rel="nofollow">Marc Ludwig</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-6121?redirect=false" rel="nofollow">SPR-6121</a></strong> and commented</p>
<h4 dir="auto">Overview</h4>
<p dir="auto">We have a large number of unit/integration tests that assert behavior within our system and rely upon injection of dependencies into configurable domain objects.</p>
<p dir="auto">These tests all work when executed individually; however, when executed within a suite (either through the IDE or Ant) certain tests fail as dependencies have not been injected into the <code class="notranslate">@Configurable</code> objects. We have also seen dependencies that were configured for test <em>X</em> being injected into test <em>Y</em> rather than the dependencies for test <em>Y</em>; but I have no test case for this.</p>
<hr>
<h4 dir="auto">Steps to Reproduce</h4>
<p dir="auto">I have created a set of three tests -- tests 1 and 3 are basically identical. If these are executed in a suite the third test will fail as the dependency is not injected into the <code class="notranslate">@Configurable</code> object even though it is available to the test. This only occurs if test 2 is a Spring test.</p>
<p dir="auto">See attached zip file.</p>
<hr>
<h4 dir="auto">Further Resources</h4>
<ul dir="auto">
<li><a href="http://www.javacodegeeks.com/2014/04/spring-test-context-caching-aspectj-transactional-ehcache-pain.html" rel="nofollow">Spring Test Context Caching + AspectJ @Transactional + Ehcache pain</a> blog by Java Code Geeks</li>
</ul>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.6, 3.0.5</p>
<p dir="auto"><strong>Reference URL:</strong> <a href="http://forum.springsource.org/showthread.php?t=77980" rel="nofollow">http://forum.springsource.org/showthread.php?t=77980</a></p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15724/springtest.zip" rel="nofollow">springtest.zip</a> (<em>3.15 MB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398165009" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/15989" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/15989/hovercard" href="https://github.com/spring-projects/spring-framework/issues/15989">#15989</a> SpringContexts not properly closed after test-class is finished (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398099177" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/11019" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/11019/hovercard" href="https://github.com/spring-projects/spring-framework/issues/11019">#11019</a> TestContext framework should support one AspectJ instance per ApplicationContext</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398174513" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/17123" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/17123/hovercard" href="https://github.com/spring-projects/spring-framework/issues/17123">#17123</a> AnnotationTransactionAspect retains reference to JpaTransactionManager from closed context</li>
</ul>
<p dir="auto">11 votes, 14 watchers</p>