com.go.teaservlet
Interface Application

All Known Subinterfaces:
AdminApp

public interface Application

The main hook into the TeaServlet framework. Implement this interface for instantiating other required components and for providing functions to templates.

Version:
44 , 9/07/00
Author:
Reece Wilton

Method Summary
 java.lang.Object createContext(ApplicationRequest request, ApplicationResponse response)
          Creates a context, which defines functions that are callable by templates.
 void destroy()
          Called by the TeaServlet when the application is no longer needed.
 java.lang.Class getContextType()
          The class of the object that the createContext method will return, which does not need to implement any special interface or extend any special class.
 void init(ApplicationConfig config)
          Initializes resources used by the Application.
 

Method Detail

init

public void init(ApplicationConfig config)
          throws javax.servlet.ServletException
Initializes resources used by the Application.
Parameters:
config - the application's configuration object

destroy

public void destroy()
Called by the TeaServlet when the application is no longer needed.

createContext

public java.lang.Object createContext(ApplicationRequest request,
                                      ApplicationResponse response)
Creates a context, which defines functions that are callable by templates. Any public method in the context is a callable function, except methods defined in Object. A context may receive a request and response, but it doesn't need to use any of them. They are provided only in the event that a function needs access to these objects.

Unless the getContextType method returns null, the createContext method is called once for every request to the TeaServlet, so context creation should have a fairly quick initialization. One way of accomplishing this is to return the same context instance each time. The drawback to this technique is that functions will not be able to access the current request and response.

The recommended technique is to construct a new context that simply references this Application and any of the passed in parameters. This way, the Application contains all the resources and "business logic", and the context just provides templates access to it.

Parameters:
request - the client's HTTP request
response - the client's HTTP response
Returns:
an object context for the templates

getContextType

public java.lang.Class getContextType()
The class of the object that the createContext method will return, which does not need to implement any special interface or extend any special class. Returning null indicates that this Application defines no context, and createContext will never be called.
Returns:
the class that the createContext method will return