You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mat wang <ca...@gmail.com> on 2007/08/17 11:42:43 UTC
Extends & Implements
The following is just what I thought, no offense.
"extends" = "is a " relationship between subclass and superclass
a digital clock is a clock (DigitalClock extends)
"implements" = "has a"
a digital clock has an alarm function (DigitalClock implements Alarm)
In Camel, something made me feel uncomfortable. Such as:
public abstract class DefaultComponent<E extends Exchange> extends
ServiceSupport implements Component<E>
Is DefaultComponent supposed to be a Component and has ServiceSupport
function (start, stop)?
Re: Extends & Implements
Posted by James Strachan <ja...@gmail.com>.
On 8/17/07, mat wang <ca...@gmail.com> wrote:
> The following is just what I thought, no offense.
None taken :)
> "extends" = "is a " relationship between subclass and superclass
> a digital clock is a clock (DigitalClock extends)
> "implements" = "has a"
> a digital clock has an alarm function (DigitalClock implements Alarm)
>
> In Camel, something made me feel uncomfortable. Such as:
> public abstract class DefaultComponent<E extends Exchange> extends
> ServiceSupport implements Component<E>
>
> Is DefaultComponent supposed to be a Component and has ServiceSupport
> function (start, stop)?
Yes. In Java you cannot have multiple inheritence; so in this case we
are inheriting the base start/stop lifecycle code from ServiceSupport,
but really a DefaultComponent is-a Component. (It just so happens it
also "is a" Service)
Currently its optional whether a Component implementation "is-a"
Service (just like lifecycle APIs/ annotations are optional in Spring
and EJB3); I guess we could make that mandatory.
--
James
-------
http://macstrac.blogspot.com/