dev@jsr311.java.net

RE: Inheritance of Java classes

From: Jerome Louvel <jerome.louvel_at_noelios.com>
Date: Sat, 19 May 2007 15:58:53 +0200

Hi Dhanji,

> For the identification, the annotation @ResourceRef
> could be inherited
> indeed, but if it is overridden in a subclass, the
> subclass's annotation
> should have priority.
>
> What if it is overridden without any annotation--is that
> considered a hiding override or an error?

The @ResourceRef annotation is set on the class itself, so a subclass
without annotation, should inherit the parent annotation.

> Also, it seems natural to inherit the representations.
> In my example, that
> means that ClientsResource would inherit the representation from
> AccountResource (getAccount), which seems unwanted. I
> will change the
> AccountResource to not have the @Output anno on its
> getAccount() method.
>
>
> I take your point about inheriting resources, though in this
> case I would argue it is antipatternistic; if Account is not
> a generalization of Clients (Clients are not Accounts), then
> we're just extending Account to grab its functionality (like
> a mixin), which is ugly =( when really we should be injecting
> it as a dependency.

The AccountResource just provide access to the parent account which is
shared by all the resources. It should be renamed to BaseResource instead to
prevent the confusion that you describe.

> But no objection to the method in general =)

OK.

Best regards,
Jerome

PS: Find attached an updated version of the proposed API