001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.pluto.driver.services.impl.resource;
018:
019: import java.io.InputStream;
020: import java.util.List;
021: import java.util.Set;
022:
023: import javax.servlet.ServletContext;
024:
025: import org.apache.pluto.driver.config.DriverConfigurationException;
026: import org.apache.pluto.driver.services.portal.PageConfig;
027: import org.apache.pluto.driver.services.portal.RenderConfigService;
028: import org.apache.pluto.driver.services.portal.admin.RenderConfigAdminService;
029:
030: /**
031: * Default implementation of all of the portal Services.
032: * Utilizes resource configuration from
033: * <code>pluto-portal-driver-config.xml</code>
034: *
035: * @since Aug 10, 2005
036: */
037: public class RenderConfigServiceImpl implements RenderConfigService,
038: RenderConfigAdminService {
039:
040: private ResourceConfig config;
041:
042: //
043: // Lifecycle Methods
044: //
045: /**
046: * Initialization Lifecycle Method
047: * @param ctx
048: */
049: public void init(ServletContext ctx) {
050: try {
051: InputStream in = ctx
052: .getResourceAsStream(ResourceConfigReader.CONFIG_FILE);
053: config = ResourceConfigReader.getFactory().parse(in);
054: } catch (Exception e) {
055: throw new DriverConfigurationException(e);
056: }
057: }
058:
059: /**
060: * Shutdown the ResourceService.
061: */
062: public void destroy() {
063: config = null;
064: }
065:
066: public String getPortalName() {
067: return config.getPortalName();
068: }
069:
070: public String getPortalVersion() {
071: return config.getPortalVersion();
072: }
073:
074: public String getContainerName() {
075: return config.getContainerName();
076: }
077:
078: public Set getSupportedPortletModes() {
079: return config.getSupportedPortletModes();
080: }
081:
082: public Set getSupportedWindowStates() {
083: return config.getSupportedWindowStates();
084: }
085:
086: public List getPages() {
087: return config.getRenderConfig().getPages();
088: }
089:
090: public PageConfig getDefaultPage() {
091: return config.getRenderConfig().getPageConfig(null);
092: }
093:
094: public PageConfig getPage(String id) {
095: return config.getRenderConfig().getPageConfig(id);
096: }
097:
098: public void addPage(PageConfig pageConfig) {
099: config.getRenderConfig().addPage(pageConfig);
100: }
101:
102: public void removePage(PageConfig pageConfig) {
103: config.getRenderConfig().removePage(pageConfig);
104: }
105: }
|