-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
User Experience
-
%
Even when using @Factory, one has to define the @Protocol annotation on the Injection point.
e.g.
@Factory @ServiceName public FooHttpClient create(@ServiceName String url) { return new FooHttpClient(url); } @Inject @Protocol("http") @ServiceName("foo-service") FooHttpClient fooClient;
This doesn't make much sense, since the protocol information is usually tied to the factory and client implementation.
It would be nicer to be able to do this instead:
@Factory @ServiceName public FooHttpClient create(@Protocol("http") @ServiceName String url) { return new FooHttpClient(url); } @Inject @ServiceName("foo-service") FooHttpClient fooClient;
The current workaround used in the fabric8-cdi tests is to use Configuration to configure the port and hack it like the following ugly example:
@Factory @ServiceName public URL toUrl(@ServiceName String service, @Configuration ProtocolConfig protocolConfig) throws MalformedURLException { String protocol = protocolConfig.getProtocol(); return new URL(protocol+"://" + service.substring(service.lastIndexOf("/"))); }