001    /**
002     *
003     * Licensed to the Apache Software Foundation (ASF) under one or more
004     * contributor license agreements.  See the NOTICE file distributed with
005     * this work for additional information regarding copyright ownership.
006     * The ASF licenses this file to You under the Apache License, Version 2.0
007     * (the "License"); you may not use this file except in compliance with
008     * the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    
019    package org.apache.geronimo.pluto;
020    
021    import org.apache.commons.logging.Log;
022    import org.apache.commons.logging.LogFactory;
023    import org.apache.geronimo.gbean.GBeanInfo;
024    import org.apache.geronimo.gbean.GBeanInfoBuilder;
025    import org.apache.geronimo.gbean.GBeanLifecycle;
026    import org.apache.geronimo.kernel.Kernel;
027    import org.apache.geronimo.kernel.KernelRegistry;
028    import org.apache.pluto.driver.config.AdminConfiguration;
029    import org.apache.pluto.driver.config.DriverConfiguration;
030    import org.apache.pluto.driver.services.portal.PropertyConfigService;
031    import org.apache.pluto.driver.services.portal.RenderConfigService;
032    import org.apache.pluto.spi.PortalCallbackService;
033    
034    /*
035     * A GBean that provides access to pluto's container services.  The pluto
036     * services are typically configured by spring.  The spring config should
037     * create this GBean using the getSingleton() method provided here and
038     * then provide it with references to the pluto services.
039     */
040    public class PortalContainerServicesGBean implements PortalContainerServices, GBeanLifecycle {
041        private static final Log log = LogFactory.getLog(PortalContainerServicesGBean.class);
042        
043        private RenderConfigService renderConfigService;
044        private PortalCallbackService portalCallbackService;
045        private PropertyConfigService propertyConfigService;
046        private DriverConfiguration driverConfiguration;
047        private AdminConfiguration adminConfiguration;
048    
049    
050        public void doStart() throws Exception {
051            log.debug("Started PortalContainerServicesGBean");
052        }
053        
054        public void doStop() throws Exception {
055            log.debug("Stopped PortalContainerServicesGBean");
056        }
057        
058        public void doFail() {
059            log.warn("PortalContainerServicesGBean Failed");
060        }
061        
062        public AdminConfiguration getAdminConfiguration() {
063            return adminConfiguration;
064        }
065    
066        public void setAdminConfiguration(AdminConfiguration adminConfiguration) {
067            this.adminConfiguration = adminConfiguration;
068        }
069        
070        public RenderConfigService getRenderConfigService() {
071            return renderConfigService;
072        }
073    
074        public void setRenderConfigService(RenderConfigService renderConfigService) {
075            this.renderConfigService = renderConfigService;
076        }
077    
078        public DriverConfiguration getDriverConfiguration() {
079            return driverConfiguration;
080        }
081    
082        public void setDriverConfiguration(DriverConfiguration driverConfigurion) {
083            this.driverConfiguration = driverConfigurion;
084        }
085    
086        public PortalCallbackService getPortalCallbackService() {
087            return portalCallbackService;
088        }
089    
090        public void setPortalCallbackService(
091                PortalCallbackService portalCallbackService) {
092            this.portalCallbackService = portalCallbackService;
093        }
094    
095        public PropertyConfigService getPropertyConfigService() {
096            return propertyConfigService;
097        }
098    
099        public void setPropertyConfigService(
100                PropertyConfigService propertyConfigService) {
101            this.propertyConfigService = propertyConfigService;
102        }
103    
104        public static PortalContainerServices getSingleton() {
105            Kernel kernel = KernelRegistry.getSingleKernel();
106            PortalContainerServices portalServices = null;
107            try {
108                portalServices = (PortalContainerServices) kernel.getGBean(PortalContainerServices.class);
109            } catch (Exception e) {
110                log.error("Failed to get PortalContainerServices GBean from kernel", e);
111            }
112            return portalServices;
113        }
114    
115        public static final GBeanInfo GBEAN_INFO;
116    
117        static {
118            GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("PortalContainerServicesGBean", PortalContainerServicesGBean.class);
119            infoFactory.addInterface(PortalContainerServices.class);
120            infoFactory.setConstructor(new String[0]);
121            GBEAN_INFO = infoFactory.getBeanInfo();
122        }
123    
124        public static GBeanInfo getGBeanInfo() {
125            return GBEAN_INFO;
126        }
127    
128    }