KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > PortletDefinitionListImpl


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.pluto.om;
17
18 import java.util.Iterator JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.Vector JavaDoc;
21
22 import org.apache.cocoon.portal.pluto.om.common.AbstractSupportSet;
23 import org.apache.cocoon.portal.pluto.om.common.Support;
24 import org.apache.pluto.om.common.ObjectID;
25 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
26 import org.apache.pluto.om.portlet.PortletDefinition;
27 import org.apache.pluto.om.portlet.PortletDefinitionList;
28 import org.apache.pluto.om.servlet.ServletDefinition;
29
30 /**
31  *
32  *
33  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
34  *
35  * @version CVS $Id: PortletDefinitionListImpl.java 123407 2004-12-27 13:51:59Z cziegeler $
36  */

37 public class PortletDefinitionListImpl extends AbstractSupportSet
38 implements PortletDefinitionList, java.io.Serializable JavaDoc, Support {
39
40     // PortletDefinitionList implementation.
41

42     public PortletDefinition get(ObjectID objectId) {
43         Iterator JavaDoc iterator = this.iterator();
44         while (iterator.hasNext()) {
45             PortletDefinition portletDefinition = (PortletDefinition)iterator.next();
46             if (portletDefinition.getId().equals(objectId)) {
47                 return portletDefinition;
48             }
49         }
50         return null;
51     }
52
53     // Support implementation.
54

55     public void preBuild(Object JavaDoc parameter) throws Exception JavaDoc {
56         Vector JavaDoc structure = (Vector JavaDoc)parameter;
57         PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0);
58         Map JavaDoc servletMap = (Map JavaDoc)structure.get(1);
59
60         Iterator JavaDoc iterator = this.iterator();
61         while (iterator.hasNext()) {
62             PortletDefinition portlet = (PortletDefinition)iterator.next();
63
64             ((Support)portlet).preBuild(portletApplication);
65
66             ServletDefinition servlet = null;
67             if (servletMap != null) {
68                 servlet = (ServletDefinition)servletMap.get(portlet.getId().toString());
69             }
70
71             ((Support)portlet).postBuild(servlet);
72
73         }
74     }
75     
76
77     public void postBuild(Object JavaDoc parameter) throws Exception JavaDoc {
78         // nothing to do
79
}
80
81     public void postLoad(Object JavaDoc parameter) throws Exception JavaDoc {
82         Iterator JavaDoc iterator = this.iterator();
83         while (iterator.hasNext()) {
84             ((PortletDefinitionImpl)iterator.next()).postLoad(parameter);
85         }
86     }
87
88     public void postStore(Object JavaDoc parameter) throws Exception JavaDoc {
89         // nothing to do
90
}
91
92     public void preStore(Object JavaDoc parameter) throws Exception JavaDoc {
93         // nothing to do
94
}
95
96     // additional methods.
97

98     public PortletDefinition get(String JavaDoc objectId) {
99         Iterator JavaDoc iterator = this.iterator();
100         while (iterator.hasNext()) {
101             PortletDefinition portletDefinition = (PortletDefinition)iterator.next();
102             if (portletDefinition.getId().toString().equals(objectId)) {
103                 return portletDefinition;
104             }
105         }
106         return null;
107     }
108
109 }
110
Popular Tags