Autowiring a decorator in Spring
<p>I am using the decorator pattern to decorate a service class with a caching service class.</p>

<p>Without Spring, I would inject it as follows:</p>

<pre><code>private IService is = new CachingService( new RoleService());
</code></pre>

<p>Note that, consistent with the Decorator pattern, both <code>CachingService</code> and <code>RoleService</code> implement the <code>IService</code> interface.    <code>CachingService</code>, as a decorator of an <code>IService</code> has a constructor that takes an <code>IService</code> argument.</p>

<p>Is there a way to autowire this using Spring annotations?</p>

<p>In case it would help, I imagine something LIKE this:</p>

<pre><code> @Autowire(with=CachingService, constructor-arg-ref=RoleService)
 private IService is;
</code></pre>