KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > plugins > page > Page


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.plugins.page;
10
11 import java.util.Collection JavaDoc;
12 import java.util.HashMap JavaDoc;
13 import java.util.Iterator JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.jboss.portal.core.metadata.PageMetaData;
17 import org.jboss.portal.core.metadata.WindowLocationMetaData;
18 import org.jboss.portal.server.PortalServer;
19 import org.jboss.portal.server.ServerObject;
20 import org.jboss.portal.server.ServerObjectID;
21 import org.jboss.portal.server.ServerURL;
22 import org.jboss.portal.server.kernel.Service;
23 import org.jboss.portal.server.kernel.ServiceImplementation;
24 import org.jboss.portal.server.metadata.ServerObjectMetaData;
25
26 /**
27  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
28  * @version $Revision: 1.7 $
29  */

30 public class Page
31    extends ServerObject
32 {
33
34    private PageRepository repository;
35    private PageMetaData pageMD;
36    private Map JavaDoc locations;
37 // private ServerObjectID defaultWindow;
38

39    public Page(PageMetaData pageMD)
40    {
41       super(pageMD.getName());
42       this.pageMD = pageMD;
43       this.locations = new HashMap JavaDoc();
44    }
45
46    public String JavaDoc getName()
47    {
48       return name;
49    }
50
51    public PageRepository getRepository()
52    {
53       return repository;
54    }
55
56 /*
57    public ServerObjectID getDefaultWindow()
58    {
59       return defaultWindow;
60    }
61
62    void setDefaultWindow(ServerObjectID defaultWindow)
63    {
64       this.defaultWindow = defaultWindow;
65    }
66 */

67
68    public Collection JavaDoc getLocations()
69    {
70       return locations.values();
71    }
72    
73    public WindowLocation getLocation(ServerObjectID id)
74    {
75       return (WindowLocation)locations.get(id);
76    }
77    
78    public PortalServer getServer()
79    {
80       throw new UnsupportedOperationException JavaDoc("todo");
81    }
82
83    public ServerObjectMetaData getMetaData()
84    {
85       return pageMD;
86    }
87
88    public void start() throws Exception JavaDoc
89    {
90       // Process all the windows
91
for (Iterator JavaDoc j = pageMD.getWindowSet().iterator();j.hasNext();)
92       {
93          WindowLocationMetaData windowMDLocation = (WindowLocationMetaData)j.next();
94          WindowLocation location = new WindowLocation(windowMDLocation);
95          locations.put(location.getID(), location);
96       }
97
98       // Process the default window of this page
99
/*
100       WindowLocationMetaData defaultWindowMDLocation = pageMD.getDefaultWindow();
101       WindowLocation defaultLocation = new WindowLocation(defaultWindowMDLocation);
102       defaultWindow = defaultLocation.getID();
103       locations.put(defaultLocation.getID(), defaultLocation);
104 */

105
106       //
107
repository.addPage(this);
108    }
109
110    public void stop()
111    {
112       //
113
repository.removePage(this);
114
115       //
116
// defaultWindow = null;
117
locations.clear();
118    }
119
120    public void addIDependOn(ServiceImplementation implementation)
121    {
122       Service service = implementation.getService();
123       if (service instanceof PageRepository)
124       {
125          repository = (PageRepository)service;
126       }
127    }
128
129    public void removeIDependOn(ServiceImplementation implementation)
130    {
131       Service service = implementation.getService();
132       if (service instanceof PageRepository)
133       {
134          repository = null;
135       }
136    }
137
138    public ServerURL createURL()
139    {
140       ServerURL url = new ServerURL(getID());
141       return url;
142    }
143 }
144
Popular Tags