001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/portal/tags/sakai_2-4-1/portal-render-api/api/src/java/org/sakaiproject/portal/render/cover/ToolRenderService.java $
003: * $Id: ToolRenderService.java 21708 2007-02-18 21:59:28Z ian@caret.cam.ac.uk $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.portal.render.cover;
021:
022: import java.io.IOException;
023:
024: import javax.servlet.ServletContext;
025: import javax.servlet.http.HttpServletRequest;
026: import javax.servlet.http.HttpServletResponse;
027:
028: import org.sakaiproject.component.cover.ComponentManager;
029: import org.sakaiproject.portal.render.api.RenderResult;
030: import org.sakaiproject.site.api.ToolConfiguration;
031:
032: /**
033: * ToolRenderService is a static cover for the
034: * {@link org.sakaiproject.portal.render.api.ToolRenderService}
035: *
036: * @since Sakai 2.2.4
037: * @version $Rev: 21708 $
038: */
039: public class ToolRenderService {
040:
041: /** Possibly cached component instance. */
042: private static org.sakaiproject.portal.render.api.ToolRenderService m_instance = null;
043:
044: /**
045: * Access the component instance: special cover only method.
046: *
047: * @return the component instance.
048: */
049: public static org.sakaiproject.portal.render.api.ToolRenderService getInstance() {
050: if (ComponentManager.CACHE_COMPONENTS) {
051: if (m_instance == null)
052: m_instance = (org.sakaiproject.portal.render.api.ToolRenderService) ComponentManager
053: .get(org.sakaiproject.portal.render.api.ToolRenderService.class);
054: return m_instance;
055: } else {
056: return (org.sakaiproject.portal.render.api.ToolRenderService) ComponentManager
057: .get(org.sakaiproject.portal.render.api.ToolRenderService.class);
058: }
059: }
060:
061: /**
062: * Preprocess the given request. Instructs the service to perform any
063: * preprocessing which may affect the state of the portlets (e.g. how they
064: * are rendered).
065: *
066: * @param request
067: * the current servlet request
068: * @param response
069: * the current servlet response
070: * @param context
071: * the application context
072: * @return true, if and only if processing should continue.
073: * @throws IOException
074: * if an error occurs during preprocessing
075: */
076: public static boolean preprocess(HttpServletRequest request,
077: HttpServletResponse response, ServletContext context)
078: throws IOException {
079: org.sakaiproject.portal.render.api.ToolRenderService service = getInstance();
080: if (service == null)
081: return true;
082:
083: return service.preprocess(request, response, context);
084: }
085:
086: /**
087: * @param configuration
088: * the tool which should be rendered
089: * @param request
090: * the current servlet request
091: * @param response
092: * the current servlet response
093: * @param context
094: * the application context
095: * @return a rendered(able) content
096: * @throws IOException
097: * if an error occurs during processing.
098: */
099: public static RenderResult render(ToolConfiguration configuration,
100: HttpServletRequest request, HttpServletResponse response,
101: ServletContext context) throws IOException {
102: org.sakaiproject.portal.render.api.ToolRenderService service = getInstance();
103: if (service == null)
104: return null;
105:
106: return service
107: .render(configuration, request, response, context);
108: }
109:
110: }
|