On 8/24/05, Ken Weiner <[EMAIL PROTECTED]> wrote:
> Martin, yes, I will file this as an issue in Jira and reference this
> email thread.
> 
> Craig, thank you so much for your response.  I now understand the
> relationship between a java spec and the physical API source code much
> better.  You brought up an interesting point about JSF being different
> in that there is more executable code than in other frameworks.  What
> was the reason that classes like javax.faces.render.Renderer were
> defined as abstract classes rather than interfaces?

Trust me ... you don't want to read all the EG threads on that topic
:-).  But the short answer is, consider what happens in a future
version of JSF, when (for good reason) a new method signature is added
to the Renderer API.  If it were an interface, you've just broken
every current implementation in the world.  As an abstract base class,
you can add a default implementation that mirrors the previous
behavior, so the only potential breakage is if an implementation had
their own version of that very same method signature.

Breakage like this is not totally prohibited -- consider what has
happened in servlet (when new methods get added to the
HttpServletRequest interface) or JDBC (where there has been lots of
changes over the versions).  But that kind of breakage affects
relatively small audiences (app server and database vendors) versus
the potential for breaking every JSF component written by every
component developer in the world.

>  In Section 8.2,
> the spec refers to what an "instance" of Renderer should do.  Does the
> word "instance" imply a class rather than interface or is it up to the
> implementation?

No, "instance" is used in the O-O sense of the word, referring to how
many objects are instantiated into the JVM's memory.  In JSF, a
Renderer is an application-level singleton that is shared by all the
instances of the components (just like a Servlet is an application
level singleton that is shared by all requests mapped to the same URI
pattern).  With UIComponents, for example, there is a separate object
instance for every component on your page -- but if you have four text
fields, the four component instances will all share the same renderer
instance.

An actual instance, of course, must be of a concrete class that can be
instantiated.  But whether that concrete class extends an abstract
base class, or implements an interface, is irrelevant to how many
copies there are.  In this particular case, it simply has to be that
"instanceof Renderer" returns true, since the JSF implementation is
going to cast it to this before calling its methods.

> 
> -Ken
> 

Craig

Reply via email to