Hi,
Please see comments below.
On 21/08/14 13:26, jordan wrote:
Hi Sergey,
Great thanks for your quickly response! :)
I see you opened two defects yesterday:
1. Application context injection:
https://issues.apache.org/jira/browse/CXF-5964
2. Configuration injection
https://issues.apache.org/jira/browse/CXF-5899
Sorry, I may not see any spec says "contexts can be injected into
Application". But I see that I can inject @Context resource into Singleton
Constructor in this link:
https://jersey.java.net/documentation/latest/jaxrs-resources.html
Example 3.25. Injection of proxies into singleton
@Path("resource")
@Singleton
public static class MySingletonResource {
@Context
Request request; // this is ok: the proxy of Request will be injected
into this singleton
public MySingletonResource(@Context SecurityContext securityContext) {
// this is ok too: the proxy of SecurityContext will be injected
}
If I use this Constructor for Singleton, I really don't know how to init it
in Application getSingletons() method, and how to pass any @Context to
getSingletons() in Application class (because any @Context injection in
Application is null)?. :)
I pasted a fragment from a 9.2 section of the spec which says that
"contexts are available to Application sub-classes" too, hence the
injection directly into Application has to be supported.
In fact, CXF did support it already, but it was done too late, so your
use case was not directly supported.
Right now, you can have either of the following done:
- Have contexts injected into Application as above but pass your custom
Application to singleton constructors or have @Context Application
injected into singletons and then when needed do
myApplication.getUriInfo(), etc;
- Do not do anything in the Application at all, and have field contexts
in singleton service classes, do not pass anything to their
constructors, and CXF will inject the contexts
That said, I've just fixed CXF-5964, and in 3.0.2/3.1.0 your original
code will work
I see you opened these two defects, can I think these are two confirmed
problems which will be fixed in future?
And btw, if yes, do you know when these will be fixed and which version will
include these fixes?
CXF-5964 fix will be in 3.0.2/3.1.0 snapshots shortly.
CXF-5899 fix will be there too soon enough
Thanks, Sergey
Thanks a lot for your help & good day! :)
--
View this message in context:
http://cxf.547215.n5.nabble.com/Configuration-and-Constructor-Context-Injection-problem-when-using-CXF-tp5747973p5748033.html
Sent from the cxf-dev mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com