dev@glassfish.java.net

Re: Webtier APIs for GlassFish Embedded

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Mon, 09 Feb 2009 15:21:46 -0800

On 02/06/09 09:25, Jerome Dochez wrote:
> I could not resist looking at the APIs and it seems very similar to
> the XML inspired way of organization the metadata, wouldn't be more
> java centric to propose APIs like :
>
> Interface Contect {
>
> public Servlet addServlet(String name, Class<? extends
> javax.servlet.Servlet> servletClass);

Would it make more sense to pass a Servlet instance, rather
than a Servlet Class object?

This would give developers more flexibility in how the Servlet is
constructed, rather than limiting them to a zero-arg constructor
(which would be the case when passing in a Class object).

To address Jeanfrancois' comment about missing listener support, i think we
should define methods on Context for adding each of the following
listener types (which may already be declared in web.xml):

  javax.servlet.ServletContextAttributeListener
  javax.servlet.ServletRequestAttributeListener
  javax.servlet.ServletRequestListener
  javax.servlet.ServletContextListener
  javax.servlet.http.HttpSessionAttributeListener
  javax.servlet.http.HttpSessionListener

Again, I suggest we pass listener instances, instead of the underlying
Class objects.


Jan