KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > theme > render > impl > RenderSetImpl


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.portal.core.theme.render.impl;
9
10 import org.apache.log4j.Logger;
11 import org.jboss.portal.common.MediaType;
12 import org.jboss.portal.server.theme.PortalRenderSet;
13 import org.jboss.portal.server.theme.render.DecorationRenderer;
14 import org.jboss.portal.server.theme.render.PortletRenderer;
15 import org.jboss.portal.server.theme.render.RegionRenderer;
16 import org.jboss.portal.server.theme.render.WindowRenderer;
17
18 import javax.activation.MimeTypeParseException JavaDoc;
19
20 /**
21  * Implementation of a portal render set.
22  *
23  * @author <a HREF="mailto:mholzner@novell.com">Martin Holzner</a>.
24  * @version <tt>$Revision: 1.3 $</tt>
25  * @see PortalRenderSet
26  */

27 public class RenderSetImpl implements PortalRenderSet
28 {
29    private static final Logger log = Logger.getLogger(RenderSetImpl.class);
30    private final RegionRenderer regionRenderer;
31    private final WindowRenderer windowRenderer;
32    private final PortletRenderer portletRenderer;
33    private final DecorationRenderer decorationRenderer;
34    private final MediaType contentType;
35    private final String JavaDoc appName;
36    private final String JavaDoc name;
37
38    /**
39     * Create a new instance of a render set.
40     *
41     * @param loader the class loader to use to load the renderer implementations
42     * @param contentType the media/content/mime type for this render set
43     * @param regionRenderer the class name of the region renderer implementation
44     * @param windowRenderer the class name of the window renderer implementation
45     * @param portletRenderer the class name of the portlet renderer implementation
46     * @param decorationRenderer the class name of the decoration renderer implementation
47     * @throws MimeTypeParseException
48     * @throws ClassNotFoundException
49     * @throws IllegalAccessException
50     * @throws InstantiationException
51     */

52    public RenderSetImpl(String JavaDoc appName, String JavaDoc setName, ClassLoader JavaDoc loader, String JavaDoc contentType, String JavaDoc regionRenderer,
53                         String JavaDoc windowRenderer, String JavaDoc portletRenderer, String JavaDoc decorationRenderer)
54       throws MimeTypeParseException JavaDoc, ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
55    {
56       if (appName == null || loader == null || regionRenderer == null || windowRenderer == null ||
57          portletRenderer == null || decorationRenderer == null || contentType == null)
58       {
59          throw new IllegalArgumentException JavaDoc("arguments must not be null");
60       }
61       this.regionRenderer = (RegionRenderer)loader.loadClass(regionRenderer).newInstance();
62       this.windowRenderer = (WindowRenderer)loader.loadClass(windowRenderer).newInstance();
63       this.portletRenderer = (PortletRenderer)loader.loadClass(portletRenderer).newInstance();
64       this.decorationRenderer = (DecorationRenderer)loader.loadClass(decorationRenderer).newInstance();
65       this.contentType = MediaType.parseMimeType(contentType);
66       this.appName = appName;
67       this.name = setName;
68
69       log.debug("created a FactoryRenderSet for: " + contentType + " " + regionRenderer + " " + windowRenderer +
70          " " + portletRenderer + " " + decorationRenderer);
71    }
72
73    /**
74     * @see PortalRenderSet#getRegionRenderer
75     */

76    public RegionRenderer getRegionRenderer()
77    {
78       return regionRenderer;
79    }
80
81    /**
82     * @see PortalRenderSet#getWindowRenderer
83     */

84    public WindowRenderer getWindowRenderer()
85    {
86       return windowRenderer;
87    }
88
89    /**
90     * @see PortalRenderSet#getPortletRenderer
91     */

92    public PortletRenderer getPortletRenderer()
93    {
94       return portletRenderer;
95    }
96
97    /**
98     * @see PortalRenderSet#getDecorationRenderer
99     */

100    public DecorationRenderer getDecorationRenderer()
101    {
102       return decorationRenderer;
103    }
104
105    /**
106     * @see PortalRenderSet#getMediaType
107     */

108    public MediaType getMediaType()
109    {
110       return contentType;
111    }
112
113    /**
114     * Get the name of the application (the WAR) that contains this render set.
115     *
116     * @return the name of the application (the WAR) that contains this render set
117     */

118    public String JavaDoc getAppName()
119    {
120       return appName;
121    }
122
123    /**
124     * Get the name of this render set.
125     *
126     * @return the name of this render set
127     */

128    public String JavaDoc getName()
129    {
130       return name;
131    }
132
133    /**
134     * @see java.lang.Object#toString
135     */

136    public String JavaDoc toString()
137    {
138       return "RenderSetImpl: " + getAppName() + "." + (getName() == null ? "<from layout>" : getName()) + ": " +
139          getMediaType() + " [" + getRegionRenderer() + "][" + getWindowRenderer() + "][" + getDecorationRenderer() +
140          "][" + getPortletRenderer() + "]";
141    }
142 }
143
Popular Tags