Hi,
One of the major pain points i have observed from developers is that
sub-locators return objects and it is necessary to manually pass
contextual information injected on the root resource classes to
resources instantiated and returned by sub-locators.
I have modified things in the trunk so that it is possible for a
sub-locator to return a Class. For example:
@Path("/parent")
static public class Parent {
@GET
public String getMe() {
return "parent";
}
@Path("child")
public Class<Child> getChild() {
return Child.class;
}
}
static public class Child {
@GET
public String getMe() {
return "child";
}
}
The standard life-cycle mechanisms (singleton or per-request) should all
work as before and Jersey will defer to a component provider for
instantiating the returned class. So it should be much easier to work
with Spring.
Another fix i am considering is allowing injection of ComponentProvider:
@Path("/parent")
static public class Parent {
@Context ComponentProvider cp;
@GET
public String getMe() {
return "parent";
}
@Path("child")
public Child getChild() {
Child c = new Child();
// Spring does not support this :-(
cp.inject(c);
return c;
}
}
@Path("/parent")
static public class Parent {
@Context ComponentProvider cp;
@GET
public String getMe() {
return "parent";
}
@Path("child")
public Child getChild() {
return cp.getInstance(c);
}
}
which allows the application to have some extra control over the
instance before it is returned. Is this something people would find useful?
Thanks,
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109