View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.services.webpage;
18  
19  // javax.servlet
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  import javax.servlet.http.HttpServlet;
23  import javax.servlet.ServletConfig;
24  import javax.servlet.ServletException;
25  
26  // java.io
27  import java.io.IOException;
28  
29  // java.util
30  import java.util.Collection;
31  
32  /***
33   * <P>This is a commodity static accessor class around the
34   * <code>WebPageService</code> interface</P>
35   *
36   * @see org.apache.jetspeed.services.webpage.WebPageService
37   * 
38   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
39   * @version $Id: WebPageManager.java,v 1.2 2004/02/23 03:46:26 jford Exp $
40   */
41  
42  public class WebPageManager
43  {
44  
45      // the singleton service reference
46      private static WebPageService service = null;
47     
48  
49      /*** 
50       * Commodity method for getting a reference to the service
51       * singleton
52       */
53      private static WebPageService getService()
54      {        
55          if (service == null)
56          {
57              // TODO: load from configuration
58              service = new JetspeedWebPageService();
59          }
60          return service;
61      }
62      
63      /***
64       * @see WebPageService#isInit
65       */
66      public static boolean isInit()
67      {
68         return getService().isInit();
69      }
70  
71      /***
72       * @see WebPageService#get
73       */
74      public static void get(HttpServlet servlet, 
75                             HttpServletRequest request, 
76                             HttpServletResponse response)
77                             throws ServletException, IOException    
78      {
79         getService().get(servlet, request, response);
80      }
81  
82      /***
83       * @see WebPageService#post
84       */
85      public static void post(HttpServlet servlet, 
86                              HttpServletRequest request, 
87                              HttpServletResponse response)
88          throws ServletException, IOException
89      {
90         getService().post(servlet, request, response);
91      }
92  
93  
94      /***
95       * @see WebPageService#init
96       */
97      public static void init(ServletConfig config)
98              throws ServletException, IOException
99      {
100         getService().init(config);
101     }
102 
103     /***
104      * @see WebPageService#destroy
105      */
106     public static void destroy()
107     {
108         getService().destroy();
109     }
110 
111     /***
112      * @see WebPageService#getSessions
113      */
114     public static Collection getSessions()
115     {
116         return getService().getSessions();
117     }
118 
119     /***
120      * @see WebPageService#getSession
121      */
122     public static SessionMap getSession(String id)
123     {
124         return getService().getSession(id);
125     }
126 
127     /***
128      * @see WebPageService#getNetworkElements
129      */
130     public static Collection getSites()
131     {
132         return getService().getSites();
133     }
134 
135     /***
136      * @see WebPageService#getErrorString
137      */
138     public static String getErrorString()
139     {
140         return getService().getErrorString();
141     }
142 
143 }