KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > theme > strategy > StrategyFactory


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.strategy;
9
10 import org.apache.log4j.Logger;
11 import org.jboss.portal.core.theme.strategy.impl.PortletContextImpl;
12 import org.jboss.portal.core.theme.strategy.impl.StrategyContextImpl;
13 import org.jboss.portal.server.Window;
14 import org.jboss.portal.server.theme.PortalLayout;
15 import org.jboss.portal.server.theme.strategy.PortletContext;
16 import org.jboss.portal.server.theme.strategy.StrategyContext;
17 import org.jboss.portal.server.user.UserContext;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import java.util.Collection JavaDoc;
21
22 /**
23  * Factory to find and instantiate Portal Layout Strategies.
24  *
25  * @author <a HREF="mailto:mholzner@novell.com">Martin Holzner</a>.
26  * @version <tt>$Revision: 1.8 $</tt>
27  * @see org.jboss.portal.server.theme.strategy.LayoutStrategy
28  */

29 public class StrategyFactory
30 {
31    private static final Logger log = Logger.getLogger(StrategyFactory.class);
32
33    private StrategyFactory()
34    {
35    }
36
37    /**
38     * Create a strategy context (for this request) that contains all the necessary information
39     * for the strategy to make up its mind.
40     *
41     * @param layout the current layout for the request
42     * @param portlets a collection of all portlets on the current page (of type PortletContext)
43     * @param portalName the name of the current portal (for this request)
44     * @param pageName the name of the current page (for this request)
45     * @param regionNames the names of all available regions on the current page
46     * @return a strategy context a context containing all the provided information to the strategy
47     * @see StrategyContext
48     * @see PortalLayout
49     * @see PortletContext
50     */

51    public static StrategyContext createStrategyContext(HttpServletRequest JavaDoc request, PortalLayout layout, Collection JavaDoc portlets,
52                                                        PortletContext targetPortlet, String JavaDoc portalName,
53                                                        String JavaDoc pageName, String JavaDoc[] regionNames)
54    {
55       log.debug("creating strategy context for: " + (layout.getName() == null ? "[no layout]" : layout.getName()) +
56          " " + portalName + " " + pageName);
57       return new StrategyContextImpl(request, layout, portlets, targetPortlet, portalName, pageName, regionNames);
58    }
59
60    /**
61     * Create a portlet context.
62     * <p>A portlet context represents a portlet on a page and its state. The layout strategy can access
63     * this information about every portlet on the page due to be rendered. </p>
64     *
65     * @param window a handle to the portlet instance that is about to be rendered
66     * @param userContext the user context providing additional information about the state of the portlet instance
67     * (like preferences)
68     * @return a portlet context object that the strategy can use to determine what to do
69     * @see PortletContext
70     * @see Window
71     * @see UserContext
72     */

73    public static PortletContext createPortletContext(Window window, UserContext userContext)
74    {
75       log.debug("creating portlet context for: " + window.getName());
76       return new PortletContextImpl(window, userContext);
77    }
78 }
79
Popular Tags