1 | /* |
2 | * Copyright 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.pluto.driver.config.impl; |
17 | |
18 | import java.util.Collection; |
19 | |
20 | import javax.servlet.ServletContext; |
21 | |
22 | import org.apache.pluto.driver.config.DriverConfiguration; |
23 | import org.apache.pluto.driver.services.portal.PageConfig; |
24 | import org.apache.pluto.driver.services.portal.PortletApplicationConfig; |
25 | import org.apache.pluto.driver.services.portal.PortletRegistryService; |
26 | import org.apache.pluto.driver.services.portal.PortletWindowConfig; |
27 | import org.apache.pluto.driver.services.portal.PropertyConfigService; |
28 | import org.apache.pluto.driver.services.portal.RenderConfigService; |
29 | import org.apache.pluto.spi.PortalCallbackService; |
30 | import org.apache.pluto.spi.optional.PortletPreferencesService; |
31 | |
32 | /** |
33 | * Encapsulation of the Pluto Driver ResourceConfig. |
34 | * |
35 | * @author <a href="ddewolf@apache.org">David H. DeWolf</a> |
36 | * @version 1.0 |
37 | * @since Sep 23, 2004 |
38 | */ |
39 | public class DriverConfigurationImpl implements DriverConfiguration { |
40 | |
41 | private PropertyConfigService propertyService; |
42 | private PortletRegistryService registryService; |
43 | private RenderConfigService renderService; |
44 | |
45 | // Container Services |
46 | private PortalCallbackService portalCallbackService; |
47 | private PortletPreferencesService portletPreferencesService; |
48 | |
49 | public DriverConfigurationImpl(PropertyConfigService propertyService, |
50 | PortletRegistryService registryService, |
51 | RenderConfigService renderService, |
52 | PortalCallbackService portalCallback) { |
53 | this.propertyService = propertyService; |
54 | this.registryService = registryService; |
55 | this.renderService = renderService; |
56 | this.portalCallbackService = portalCallback; |
57 | } |
58 | |
59 | /** |
60 | * Standard Getter. |
61 | * @return the name of the portal. |
62 | */ |
63 | public String getPortalName() { |
64 | return propertyService.getPortalName(); |
65 | } |
66 | |
67 | /** |
68 | * Standard Getter. |
69 | * @return the portal version. |
70 | */ |
71 | public String getPortalVersion() { |
72 | return propertyService.getPortalVersion(); |
73 | } |
74 | |
75 | /** |
76 | * Standard Getter. |
77 | * @return the name of the container. |
78 | */ |
79 | public String getContainerName() { |
80 | return propertyService.getContainerName(); |
81 | } |
82 | |
83 | /** |
84 | * Standard Getter. |
85 | * @return the names of the supported portlet modes. |
86 | */ |
87 | public Collection getSupportedPortletModes() { |
88 | return propertyService.getSupportedPortletModes(); |
89 | } |
90 | |
91 | /** |
92 | * Standard Getter. |
93 | * @return the names of the supported window states. |
94 | */ |
95 | public Collection getSupportedWindowStates() { |
96 | return propertyService.getSupportedWindowStates(); |
97 | } |
98 | |
99 | /** |
100 | * Standard Getter. |
101 | * @return the configuration data of all configured portlet applications. |
102 | */ |
103 | public Collection getPortletApplications() { |
104 | return registryService.getPortletApplications(); |
105 | } |
106 | |
107 | /** |
108 | * Retrieve the portlet application with the given id. |
109 | * @param id the id of the portlet application. |
110 | * @return the portlet application configuration data. |
111 | */ |
112 | public PortletApplicationConfig getPortletApp(String id) { |
113 | return registryService.getPortletApplication(id); |
114 | } |
115 | |
116 | /** |
117 | * Retrieve the window configuration associated with the given id. |
118 | * @param id the id of the portlet window. |
119 | * @return the portlet window configuration data. |
120 | */ |
121 | public PortletWindowConfig getPortletWindowConfig(String id) { |
122 | return registryService.getPortlet(id); |
123 | } |
124 | |
125 | /** |
126 | * Standard Getter. |
127 | * @return the render configuration. |
128 | */ |
129 | public Collection getPages() { |
130 | return renderService.getPages(); |
131 | } |
132 | |
133 | public PageConfig getPageConfig(String pageId) { |
134 | return renderService.getPage(pageId); |
135 | } |
136 | |
137 | public void init(ServletContext context) { |
138 | this.propertyService.init(context); |
139 | this.registryService.init(context); |
140 | this.renderService.init(context); |
141 | } |
142 | |
143 | public void destroy() { |
144 | if(propertyService != null) |
145 | propertyService.destroy(); |
146 | |
147 | if(registryService != null) |
148 | registryService.destroy(); |
149 | |
150 | if(renderService != null) |
151 | renderService.destroy(); |
152 | } |
153 | |
154 | |
155 | // |
156 | // Container Services |
157 | // |
158 | public PortalCallbackService getPortalCallbackService() { |
159 | return portalCallbackService; |
160 | } |
161 | |
162 | public void setPortalCallbackService(PortalCallbackService portalCallbackService) { |
163 | this.portalCallbackService = portalCallbackService; |
164 | } |
165 | |
166 | public PortletPreferencesService getPortletPreferencesService() { |
167 | return portletPreferencesService; |
168 | } |
169 | |
170 | public void setPortletPreferencesService(PortletPreferencesService portletPreferencesService) { |
171 | this.portletPreferencesService = portletPreferencesService; |
172 | } |
173 | } |
174 | |