Change By: Grégory Joseph (13/Aug/14 12:00 PM)
Description: With MGNLCACHE-55, one can cache arbitrary objects (that was already the case, but the API was awkward, and the cache could not be configured), but one still has to :
{code:java}
public class FooBar {
  private final Cache cache;
  @Inject
  public FooBar(CacheModule cacheModule) {
    // or keep a ref to module and retrieve the cache when needed
    this.cache = cacheModule.getCacheFactory().getCache("foo-cache");
  }
}
{code}

It'd be *nice* if one could do this instead:
{code:java}
public class FooBar {
  private final Cache cache;
  @Inject
  public FooBar(@Named("foo-cache") Cache cache) {
    this.cache = cache;
  }
}
{code}

Another approach (or additional) would let one inject an unnamed Cache, and the name would, by convention, be the class name of the injectee.

{code:java}
package zim.zam;

public class FooBar {
  private final Cache cache;
  @Inject
  public FooBar(Cache cache) {
    assert cache.getName().equals("zim.zam.FooBar");
    this.cache = cache;
  }
}
{code}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to