|
From: Andreas H. <a...@ho...> - 2008-04-09 15:00:18
|
Hello,
> I need more information on this. The spec says that either you put your
> annotations on an interface or on the class/superclass and not both. Can you
> show me more pseudo code?
I have attached some more code below. If the spec says that you either
annotate the interface or the class/superclass that you can mentally
remove the getSelf() defined in Device. It would move into the
concrete implementation.
interface Device {
@GET
Device getSelf();
}
@Path("devices")
class RootResource {
Device getDevice(String id) {
// lookup and return a device, which is either Device1 or Device2
}
}
class Device1 implements Device {
public Device getSelf() {
return this;
}
@GET
@Path("something")
public Object getSomething() {
// Get something
}
}
class Device2 implements Device {
public Device getSelf() {
return this;
}
@GET
@Path("else")
public Object getSomethingElse() {
// Get something else
}
}
> So derivatives of Device are returned from getDevice()? The problem with
> this is a performance one. Resteasy would have to calculate and introspect
> and match the request on every single request. There would be no way to
> optimize.
>
> I guess I'll have to support it... I'll see what I can do today and get
> out a new release.
>
Yes, exactly. Thanks! Take your time with the implementation, I'm not
in a hurry.
>
> Well, I'm in a quandry with this one. Reason? Generic types. Say you
> want to write a multipart provider that matches on List<String>? it is
> impossible to determine the generic type of the object.
>
> I switch it to matching on the returned entity's class.
When looking more into this I realize that I would expect the
following from the
isWriteable(Class, Type, Annotation[]) method:
* Class is the actual class of what would be written
* Type is the defined type (such as Device or List<String>)
Does that make sense?
Thanks for your speedy response!
// Andreas
|