Author: julien(a)jboss.com
Date: 2007-03-28 12:37:50 -0400 (Wed, 28 Mar 2007)
New Revision: 6867
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
Log:
removed useless code in themetestservlet since the mini server env performs the loading
itself of themes
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-28
14:48:17 UTC (rev 6866)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-28
16:37:50 UTC (rev 6867)
@@ -33,23 +33,14 @@
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
-import org.jboss.portal.theme.RuntimeContext;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.deployment.jboss.PortalLayoutMetaDataFactory;
-import org.jboss.portal.theme.deployment.jboss.PortalThemeMetaDataFactory;
-import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
-import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
-import org.jboss.portal.theme.metadata.PortalThemeMetaData;
-import org.jboss.portal.theme.metadata.RenderSetMetaData;
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -58,21 +49,16 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class TestThemeServlet extends HttpServlet
{
- private PortalRenderSet renderSet;
- private PortalLayout layout;
- private PortalTheme theme;
+
private static final String TEST_PAGE_NAME = "TestPage";
/** How many windows to create on left region * */
@@ -81,69 +67,34 @@
/** How many windows to create on center region * */
private static final int CENTER_WINDOWS = 3;
- /** Set theme api services */
- public void init()
+ /**
+ * Generates a portal page with windows, using the theme api.
+ */
+ protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
try
{
- MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
- LayoutService layoutService = (LayoutService)MBeanProxy.get(LayoutService.class,
new ObjectName("portal:service=LayoutService"), mbeanServer);
- ThemeService themeService = (ThemeService)MBeanProxy.get(ThemeService.class, new
ObjectName("portal:service=ThemeService"), mbeanServer);
- PageService pageService = (PageService)MBeanProxy.get(PageService.class, new
ObjectName("portal:service=PageService"), mbeanServer);
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- RuntimeContext runtimeContext = new RuntimeContext("TestAppId",
getServletContext(), "/theme-test", loader);
-
- // add layouts from metadata
- InputStream in = null;
- in =
getServletContext().getResourceAsStream("/WEB-INF/portal-layouts.xml");
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
- List portalLayouts = (List)unmarshaller.unmarshal(in, new
PortalLayoutMetaDataFactory(), null);
- for (Iterator i = portalLayouts.iterator(); i.hasNext();)
- {
- PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)i.next();
- layoutService.addLayout(runtimeContext, layoutMD);
- }
- layout = layoutService.getLayout("generic", true);
-
- // add rendersets from metadata
- in =
getServletContext().getResourceAsStream("/WEB-INF/layout/portal-renderSet.xml");
- unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- List renderSets = (List)unmarshaller.unmarshal(in, new
RenderSetMetaDataFactory(), null);
- for (Iterator i = renderSets.iterator(); i.hasNext();)
- {
- RenderSetMetaData renderSetMD = (RenderSetMetaData)i.next();
- layoutService.addRenderSet(runtimeContext, renderSetMD);
- }
- renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
-
- // add themes from metadata
- in =
getServletContext().getResourceAsStream("/WEB-INF/portal-themes.xml");
- unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- List themes = (List)unmarshaller.unmarshal(in, new PortalThemeMetaDataFactory(),
null);
- for (Iterator i = themes.iterator(); i.hasNext();)
- {
- PortalThemeMetaData themeMD = (PortalThemeMetaData)i.next();
- themeService.addTheme(runtimeContext, themeMD);
- }
- theme = themeService.getTheme("renaissance", true);
+ proceed(request, response);
}
catch (Exception e)
{
- e.printStackTrace();
+ throw new ServletException(e);
}
}
- /**
- * Generates a portal page with windows, using the theme api.
- *
- * @param httpServletRequest
- * @param httpServletResponse
- * @throws ServletException
- * @throws IOException
- */
- public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException
+ public void proceed(HttpServletRequest request, HttpServletResponse response) throws
Exception
{
+ MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+
+ LayoutService layoutService = (LayoutService)MBeanProxy.get(LayoutService.class,
new ObjectName("portal:service=LayoutService"), mbeanServer);
+ ThemeService themeService = (ThemeService)MBeanProxy.get(ThemeService.class, new
ObjectName("portal:service=ThemeService"), mbeanServer);
+ PageService pageService = (PageService)MBeanProxy.get(PageService.class, new
ObjectName("portal:service=PageService"), mbeanServer);
+
+ PortalRenderSet renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
+ PortalLayout layout = layoutService.getLayout("generic", true);
+ PortalTheme theme = themeService.getTheme("renaissance", true);
+
+
//
Map pageProps = new HashMap();
pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
@@ -178,28 +129,17 @@
// set the renderctx and req/res attr
RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult,
serverRequest);
- httpServletResponse.setContentType(renderCtx.getContentType().toString());
- httpServletResponse.setCharacterEncoding(renderCtx.getCharset());
- httpServletRequest.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
- httpServletRequest.setAttribute(LayoutConstants.ATTR_PAGE, pageResult);
- httpServletRequest.setAttribute(ThemeConstants.ATTR_THEME, theme);
+ response.setContentType(renderCtx.getContentType().toString());
+ response.setCharacterEncoding(renderCtx.getCharset());
+ request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
+ request.setAttribute(LayoutConstants.ATTR_PAGE, pageResult);
+ request.setAttribute(ThemeConstants.ATTR_THEME, theme);
- try
- {
- LayoutDispatcher dispatcher1 = new LayoutDispatcher(renderCtx,
httpServletRequest, httpServletResponse, pageResult);
- dispatcher1.include();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ //
+ LayoutDispatcher dispatcher1 = new LayoutDispatcher(renderCtx, request, response,
pageResult);
+ dispatcher1.include();
}
- public void doPost(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException
- {
- doGet(httpServletRequest, httpServletResponse);
- }
-
/**
* Generates the WindowResult for our windowcontext
*