KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > tomcat > ManagerGBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17 package org.apache.geronimo.tomcat;
18
19 import java.util.Map JavaDoc;
20
21 import org.apache.catalina.Manager;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.geronimo.gbean.GBeanInfo;
25 import org.apache.geronimo.gbean.GBeanInfoBuilder;
26 import org.apache.geronimo.gbean.GBeanLifecycle;
27
28 public class ManagerGBean extends BaseGBean implements GBeanLifecycle, ObjectRetriever{
29
30     private static final Log log = LogFactory.getLog(ManagerGBean.class);
31     
32     public static final String JavaDoc J2EE_TYPE = "Manager";
33     
34     protected final Manager manager;
35
36     protected ManagerGBean(String JavaDoc className) throws Exception JavaDoc{
37        super();
38        manager = (Manager)Class.forName(className).newInstance();
39     }
40     
41     public ManagerGBean(String JavaDoc className,
42             Map JavaDoc initParams) throws Exception JavaDoc {
43         super(); // TODO: make it an attribute
44
//Validate
45
if (className == null){
46             className = "org.apache.catalina.core.StandardHost";
47         }
48         
49         //Create the Manager object
50
manager = (Manager)Class.forName(className).newInstance();
51         
52         //Set the parameters
53
setParameters(manager, initParams);
54         
55     }
56     
57     public void doStart() throws Exception JavaDoc {
58     }
59
60     public void doStop() throws Exception JavaDoc {
61     }
62
63     public void doFail() {
64     }
65
66     public Object JavaDoc getInternalObject() {
67         // TODO Auto-generated method stub
68
return manager;
69     }
70     
71     public static final GBeanInfo GBEAN_INFO;
72
73     static {
74         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("TomcatManager", ManagerGBean.class, J2EE_TYPE);
75         infoFactory.addAttribute("className", String JavaDoc.class, true);
76         infoFactory.addAttribute("initParams", Map JavaDoc.class, true);
77         infoFactory.addOperation("getInternalObject");
78         infoFactory.setConstructor(new String JavaDoc[] {
79                 "className",
80                 "initParams"});
81         GBEAN_INFO = infoFactory.getBeanInfo();
82     }
83
84     public static GBeanInfo getGBeanInfo() {
85         return GBEAN_INFO;
86     }
87 }
88
Popular Tags