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: */package org.apache.geronimo.pluto;
018:
019: import org.apache.commons.logging.Log;
020: import org.apache.commons.logging.LogFactory;
021: import org.apache.geronimo.gbean.GBeanInfo;
022: import org.apache.geronimo.gbean.GBeanInfoBuilder;
023: import org.apache.geronimo.gbean.GBeanLifecycle;
024: import org.apache.geronimo.kernel.Kernel;
025: import org.apache.geronimo.kernel.KernelRegistry;
026: import org.apache.pluto.driver.config.AdminConfiguration;
027: import org.apache.pluto.driver.config.DriverConfiguration;
028: import org.apache.pluto.driver.services.portal.PropertyConfigService;
029: import org.apache.pluto.driver.services.portal.RenderConfigService;
030: import org.apache.pluto.spi.PortalCallbackService;
031:
032: /*
033: * A GBean that provides access to pluto's container services. The pluto
034: * services are typically configured by spring. The spring config should
035: * create this GBean using the getSingleton() method provided here and
036: * then provide it with references to the pluto services.
037: */
038: public class PortalContainerServicesGBean implements
039: PortalContainerServices, GBeanLifecycle {
040: private static final Log log = LogFactory
041: .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: public void doStart() throws Exception {
050: log.debug("Started PortalContainerServicesGBean");
051: }
052:
053: public void doStop() throws Exception {
054: log.debug("Stopped PortalContainerServicesGBean");
055: }
056:
057: public void doFail() {
058: log.warn("PortalContainerServicesGBean Failed");
059: }
060:
061: public AdminConfiguration getAdminConfiguration() {
062: return adminConfiguration;
063: }
064:
065: public void setAdminConfiguration(
066: AdminConfiguration adminConfiguration) {
067: this .adminConfiguration = adminConfiguration;
068: }
069:
070: public RenderConfigService getRenderConfigService() {
071: return renderConfigService;
072: }
073:
074: public void setRenderConfigService(
075: RenderConfigService renderConfigService) {
076: this .renderConfigService = renderConfigService;
077: }
078:
079: public DriverConfiguration getDriverConfiguration() {
080: return driverConfiguration;
081: }
082:
083: public void setDriverConfiguration(
084: DriverConfiguration driverConfigurion) {
085: this .driverConfiguration = driverConfigurion;
086: }
087:
088: public PortalCallbackService getPortalCallbackService() {
089: return portalCallbackService;
090: }
091:
092: public void setPortalCallbackService(
093: PortalCallbackService portalCallbackService) {
094: this .portalCallbackService = portalCallbackService;
095: }
096:
097: public PropertyConfigService getPropertyConfigService() {
098: return propertyConfigService;
099: }
100:
101: public void setPropertyConfigService(
102: PropertyConfigService propertyConfigService) {
103: this .propertyConfigService = propertyConfigService;
104: }
105:
106: public static PortalContainerServices getSingleton() {
107: Kernel kernel = KernelRegistry.getSingleKernel();
108: PortalContainerServices portalServices = null;
109: try {
110: portalServices = (PortalContainerServices) kernel
111: .getGBean(PortalContainerServices.class);
112: } catch (Exception e) {
113: log
114: .error(
115: "Failed to get PortalContainerServices GBean from kernel",
116: e);
117: }
118: return portalServices;
119: }
120:
121: public static final GBeanInfo GBEAN_INFO;
122:
123: static {
124: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
125: "PortalContainerServicesGBean",
126: PortalContainerServicesGBean.class);
127: infoFactory.addInterface(PortalContainerServices.class);
128: infoFactory.setConstructor(new String[0]);
129: GBEAN_INFO = infoFactory.getBeanInfo();
130: }
131:
132: public static GBeanInfo getGBeanInfo() {
133: return GBEAN_INFO;
134: }
135:
136: }
|