click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dennis M. J. Yerger" <>
Subject Page factory service
Date Thu, 25 Apr 2013 20:13:00 GMT
After examining the ClickServlet class, I noticed the newPageInstance() method, which is where
new instances of Page objects are created. By default, newPageInstance() calls Class.newInstance()
on the given class. This can be overridden by subclassing ClickServlet. However, I believe
this functionality should be factored out into a separate class. A separate page factory would
allow page objects to be created in more flexible ways (e.g., from Spring contexts or Tapestry
IoC registries) without altering the ClickServlet. I imagine an interface like the following:

interface PageFactoryService {

    void onInit(ServletContext servletContext) throws Exception;

    Page newPageInstance(String path, Class<? extends Page> pageClass, HttpServletRequest
request) throws Exception;

    void onDestroy();

The ConfigService API would be revised to support this new service:

interface ConfigService {
    PageFactoryService getPageFactoryService();

This interface would have a default implementation, which could be overidden with the help
of ConfigService. ClickServlet.newInstance() could then delegate to this page factory.
View raw message