Hi guys,
quick question:
I configure a Factory binding in my Jersey Application like this:
bindFactory(BraveFactory.class).to(Brave.class).withMetadata("serviceName",
webappName).in(Singleton.class);
(within an AbstractBinder in my ResourceConfig)
and I want to make use of the metadata within the factory to set a property
of the newly created class.
But how can I access the metadata within the Factory?
The Factory Interface doesn't provide anything except provide and dispose.
I have tried to inject the Descriptor like this:
@Inject
@Self
private ActiveDescriptor<?> myOwnDescriptor;
But the descriptor seems not to get injected (null).
The Javadoc of the .withMetadata Method says "If this is for
org.glassfish.hk2.api.Factory
<eclipse-javadoc:%E2%98%82=ugc-common/C:%5C/Users%5C/nro%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.glassfish.hk2%5C/hk2-api%5C/2.4.0-b31%5C/c4b5f6c426f8e412e606332b93b7cf745a9a12c5%5C/hk2-api-2.4.0-b31.jar%3Corg.glassfish.hk2.utilities.binding(ServiceBindingBuilder.class%E2%98%83ServiceBindingBuilder~withMetadata~Ljava.lang.String;~Ljava.lang.String;%E2%98%82org.glassfish.hk2.api.Factory>
descriptors the metadata will be placed on both the Factory as a service
and on the Factories org.glassfish.hk2.api.Factory.provide()
<eclipse-javadoc:%E2%98%82=ugc-common/C:%5C/Users%5C/nro%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.glassfish.hk2%5C/hk2-api%5C/2.4.0-b31%5C/c4b5f6c426f8e412e606332b93b7cf745a9a12c5%5C/hk2-api-2.4.0-b31.jar%3Corg.glassfish.hk2.utilities.binding(ServiceBindingBuilder.class%E2%98%83ServiceBindingBuilder~withMetadata~Ljava.lang.String;~Ljava.lang.String;%E2%98%82org.glassfish.hk2.api.Factory%E2%98%82provide%E2%98%82>
method" so I think it should be possible, but how?
Could anybody please give me a hint? ;o)
Thanks in Advance!
Nico