custom injection resolvers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

custom injection resolvers

Trenton D. Adams
Good day,

I'm a bit confused.  It's not clear to me how I get attribute data from my custom annotations to the factory

I'm just playing around a bit, to make sure I understand how stuff works.  I've got a custom annotation...

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface SessionAttributeInject
{
String attributeName();
}
My injection resolver ends up calling the system injection resolver...
return systemInjectionResolver.resolve(injectee, handle);

Which in turn calls my factory, where my provide() method simply grabs a session attribute and returns it's value.  That all works, but I wanted to use the value of "attributeName" as the parameter to session.getAttribute("attrName").  I don't see an obvious way of getting that data from the injection resolver to the factor.  Ideas?

The example provided in the Jersey documentation does not actually have any annotation elements, and so it's not a valid example for this case. The docs say "such as ability to automatically inject the instances based on the annotation-provided metadata.", indicating the author sees the value in accessing such metadata, but doesn't provide an example of doing so.

I can access the annotation elements just fine inside my injection resolver, I simply don't know how to get it back to the factory.
Loading...