01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.tomcat;
17:
18: import java.util.Map;
19:
20: import org.apache.catalina.Manager;
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.apache.geronimo.gbean.GBeanInfo;
24: import org.apache.geronimo.gbean.GBeanInfoBuilder;
25: import org.apache.geronimo.gbean.GBeanLifecycle;
26:
27: public class ManagerGBean extends BaseGBean implements GBeanLifecycle,
28: ObjectRetriever {
29:
30: private static final Log log = LogFactory
31: .getLog(ManagerGBean.class);
32:
33: public static final String J2EE_TYPE = "Manager";
34:
35: protected final Manager manager;
36:
37: // no-arg constructor required for gbean refs
38: public ManagerGBean() {
39: manager = null;
40: }
41:
42: protected ManagerGBean(String className) throws Exception {
43: super ();
44: manager = (Manager) Class.forName(className).newInstance();
45: }
46:
47: public ManagerGBean(String className, Map initParams)
48: throws Exception {
49: super (); // TODO: make it an attribute
50: //Validate
51: if (className == null) {
52: className = "org.apache.catalina.core.StandardHost";
53: }
54:
55: //Create the Manager object
56: manager = (Manager) Class.forName(className).newInstance();
57:
58: //Set the parameters
59: setParameters(manager, initParams);
60:
61: }
62:
63: public void doStart() throws Exception {
64: }
65:
66: public void doStop() throws Exception {
67: }
68:
69: public void doFail() {
70: }
71:
72: public Object getInternalObject() {
73: // TODO Auto-generated method stub
74: return manager;
75: }
76:
77: public static final GBeanInfo GBEAN_INFO;
78:
79: static {
80: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
81: "TomcatManager", ManagerGBean.class, J2EE_TYPE);
82: infoFactory.addAttribute("className", String.class, true);
83: infoFactory.addAttribute("initParams", Map.class, true);
84: infoFactory.addOperation("getInternalObject");
85: infoFactory.setConstructor(new String[] { "className",
86: "initParams" });
87: GBEAN_INFO = infoFactory.getBeanInfo();
88: }
89:
90: public static GBeanInfo getGBeanInfo() {
91: return GBEAN_INFO;
92: }
93: }
|