##### Coverage Report - org.webmacro.servlet.Handler

Classes in this File | Line Coverage | Branch Coverage | Complexity
Handler |
N/A | N/A
N/A | N/A
| 1.0;1

1 |  |
     /*
2 |  |
      * Copyright (C) 1998-2000 Semiotek Inc.  All Rights Reserved.
3 |  |
      *
4 |  |
      * Redistribution and use in source and binary forms, with or without
5 |  |
      * modification, are permitted under the terms of either of the following
6 |  |
      * Open Source licenses:
7 |  |
      *
8 |  |
      * The GNU General Public License, version 2, or any later version, as
9 |  |
      * published by the Free Software Foundation
10 |  |
      * (http://www.fsf.org/copyleft/gpl.html);
11 |  |
      *
12 |  |
      *  or
13 |  |
      *
14 |  |
      * The Semiotek Public License (http://webmacro.org/LICENSE.)
15 |  |
      *
16 |  |
      * This software is provided "as is", with NO WARRANTY, not even the
17 |  |
      * implied warranties of fitness to purpose, or merchantability. You
18 |  |
      * assume all risks and liabilities associated with its use.
19 |  |
      *
20 |  |
      * See www.webmacro.org for more information on the WebMacro project.
21 |  |
      */
22 |  |
23 |  |
24 |  |
     package org.webmacro.servlet;
25 |  |
26 |  |
     import org.webmacro.Template;
27 |  |
28 |  |
29 |  |
     /**
30 |  |
      * Framework for handling template requests, requested by reactor.
31 |  |
      * Anything which implements this interface can be used as a handler
32 |  |
      * to process web requests.
33 |  |
      * <p>
34 |  |
      * How to use:
35 |  |
      * <ol>
36 |  |
      * <li>. Define a name for your new Handler. It must be alphanumeric.
37 |  |
      * <li>. Set that to be a valid servlet name for WebMacro in your
38 |  |
      *    servlet.properties file (if using servletrunner, otherwise
39 |  |
      *    name your servlet this using the interface in your runner)
40 |  |
      * <li>. Set the script prefix to be the prefix added by servletrunner
41 |  |
      *    in the config file. eg: "ScriptName = /servlet/"
42 |  |
      * <li>. Register your Handler against the Reactor class by calling
43 |  |
      *    Reactor.register(handler)
44 |  |
      * </ol>
45 |  |
      * <p>
46 |  |
      * When a request comes in, WebMacro loads the handler that matches
47 |  |
      * the script name of the request. It will search the ClassPath looking
48 |  |
      * for a script with the same fully qualified name as the script name,
49 |  |
      * which more or less means your handler should probably not be in any
50 |  |
      * particular package.
51 |  |
      * <p>
52 |  |
      */
53 |  |
     public interface Handler
54 |  |
     {
55 |  |
56 |  |
         /**
57 |  |
          * This is the primary method you override to create a new handler.
58 |  |
          * Incoming requests ultimately get passed to this method of your
59 |  |
          * handler, at which point it is up to you to decide what to do.
60 |  |
          * You must return a template--which will be used to format the
61 |  |
          * data you have inserted into the supplied WebContext.
62 |  |
          * <p>
63 |  |
          * If you throw an Exception it will be used to provide an explanation
64 |  |
          * to the user of why the failure occurred. The HandlerException class
65 |  |
          * provides you with numerous options for reporting errors.
66 |  |
          * <p>
67 |  |
          * @param contextData contains information about this connection
68 |  |
          * @return A Template which can be used to interpret the connection
69 |  |
          * @exception HandlerException if something went wrong with the handler
70 |  |
          */
71 |  |
         public Template accept (WebContext contextData)
72 |  |
                 throws HandlerException;
73 |  |
74 |  |
         /**
75 |  |
          * Use this method to run any startup initialization that you need
76 |  |
          * to perform. It will be called just before the first use of your
77 |  |
          * Handler.
78 |  |
          * @exception HandlerException if the handler failed to initialize
79 |  |
          */
80 |  |
         public void init () throws HandlerException;
81 |  |
82 |  |
         /**
83 |  |
          * You SHOULD override this method and provide a short name by
84 |  |
          * which your handler is known. This will help you out in logging
85 |  |
          * and debugging messages if for some reason WebMacro needs to
86 |  |
          * identify the handler in a log message.
87 |  |
          */
88 |  |
         public String toString ();
89 |  |
90 |  |
         /**
91 |  |
          * You may use this method to save persistent state on exit.
92 |  |
          * It will be called whenever the servlet is shut down.
93 |  |
          */
94 |  |
         public void destroy ();
95 |  |
96 |  |
     }
97 |  |
98 |  |