|
From: Martin A. <sp...@ma...> - 2008-07-18 15:16:56
|
But thinking about this, it makes me question this part of the spec.
"An implementation is only required to set the annotated field and
bean property values of instances created by the implementation
runtime. Objects returned by sub-resource locators (see section 3.4.1)
are expected to be initialized by their creator and field and bean
properties are not modified by the implementation runtime."
Why does the spec use an injection style way of initialisation in the
first place? I guess because it's kinda new, cool, and less to write.
public class OldStyleResource implements UriInfoAware {
private UriInfo uriInfo;
// Called by framework to give us uriInfo.
public void setUriInfo( UriInfo uriInfo ) {
this.uriInfo = uriInfo;
}
public SubResource getSubResrouce() {...}
}
vs
public class ModernStyleResource {
@Context
private UriInfo uriInfo;
}
But why doesn't the same logic apply to subresoures? The fact that
they've been instantiated by something else that in theory could pass
all the wanted references through doesn't seem to be adequate, what if
there's a whole heap of stuff to pass through? Doesn't the same
neatness logic apply?... I'm not saying that we should traverse the
whole object graph of the subresource and inject everywhere, just the
top level. if we're trying to do nice new ways of initialising why not
do it across the board?
M
|