1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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;
20
21 import org.apache.catalina.Realm;
22 import org.apache.geronimo.gbean.GBeanInfo;
23 import org.apache.geronimo.gbean.GBeanInfoBuilder;
24 import org.apache.geronimo.gbean.GBeanLifecycle;
25
26 public class RealmGBean extends BaseGBean implements GBeanLifecycle, ObjectRetriever {
27
28 private final Realm realm;
29
30 public RealmGBean(String className, Map initParams) throws Exception {
31 super();
32
33 assert className != null;
34
35 realm = (Realm)Class.forName(className).newInstance();
36
37 setParameters(realm, initParams);
38
39 }
40
41 public Object getInternalObject() {
42 return realm;
43 }
44
45 public void doFail() {
46 }
47
48 public void doStart() throws Exception {
49 }
50
51 public void doStop() throws Exception {
52 }
53
54 public static final GBeanInfo GBEAN_INFO;
55
56 static {
57 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("TomcatRealm", RealmGBean.class);
58 infoFactory.addAttribute("className", String.class, true);
59 infoFactory.addAttribute("initParams", Map.class, true);
60
61 infoFactory.addOperation("getInternalObject");
62 infoFactory.setConstructor(new String[] { "className", "initParams" });
63 GBEAN_INFO = infoFactory.getBeanInfo();
64 }
65
66 public static GBeanInfo getGBeanInfo() {
67 return GBEAN_INFO;
68 }
69 }