Hi, Am Dienstag, den 15.03.2011, 14:28 +0000 schrieb Felix Meschberger: > Hi, > > Am Dienstag, den 15.03.2011, 09:16 +0000 schrieb chetan mehrotra: > > One reason for using Inject would be that @Reference is a compile time > > annotation (i.e. RetentionPolicy.SOURCE). And due do that a new > > annotation TestReference is being used in Sling Testing component [1]. > > > > And as Inject is part of JSR 300 we can possibly have reference to > > such a class in the code. > > Good catch ... > > Do we want to support more of JSR 300 ?
Self-answering: @Named might make sense to provide the actual name of the bound variable ... Regards Felix > > > Regards > Felix > > > > > Chetan Mehrotra > > > > [1] > > http://svn.apache.org/viewvc/sling/trunk/testing/junit/core/src/main/java/org/apache/sling/junit/annotations/TestReference.java?view=markup > > > > On Tue, Mar 15, 2011 at 1:45 PM, Markus Joschko > > <[email protected]> wrote: > > > > > > I like the idea. > > > I just wonder if it might be a bit inconsistent to use @Inject when > > > most of the other code in a sling project (OSGI components) uses > > > @Reference. > > > As a developer I would appreciate consistency in how dependency > > > injection is done. > > > > > > Regards, > > > Markus > > > > > > On Tue, Mar 15, 2011 at 2:51 AM, Justin Edelson > > > <[email protected]> wrote: > > > > I was looking at how much code is involved in referencing an OSGi > > > > service from a script built using the scripting.java bundle and think > > > > it's a bit verbose: > > > > > > > > SlingBindings bindings = (SlingBindings) > > > > request.getAttribute(SlingBindings.class.getName()); > > > > SlingScriptHelper sling = bindings.getSling(); > > > > Interface service = sling.getService(Interface.class); > > > > > > > > I was thinking about adding some kind of annotation-based injection > > > > support so that you could replace these lines with just: > > > > > > > > > > > > @Inject > > > > private Interface service; > > > > > > > > public void service(request, response) { > > > > // some code using service > > > > > > > > } > > > > > > > > @Inject seems like the obvious candidate to support for this. WDYT? > > > > > > > > Justin > > > > > >
