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.Realm;
21: import org.apache.geronimo.gbean.GBeanInfo;
22: import org.apache.geronimo.gbean.GBeanInfoBuilder;
23: import org.apache.geronimo.gbean.GBeanLifecycle;
24:
25: public class RealmGBean extends BaseGBean implements GBeanLifecycle,
26: ObjectRetriever {
27:
28: private final Realm realm;
29:
30: public RealmGBean(String className, Map initParams)
31: throws Exception {
32: super (); // TODO: make it an attribute
33:
34: assert className != null;
35:
36: realm = (Realm) Class.forName(className).newInstance();
37:
38: setParameters(realm, initParams);
39:
40: }
41:
42: public Object getInternalObject() {
43: return realm;
44: }
45:
46: public void doFail() {
47: }
48:
49: public void doStart() throws Exception {
50: }
51:
52: public void doStop() throws Exception {
53: }
54:
55: public static final GBeanInfo GBEAN_INFO;
56:
57: static {
58: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
59: "TomcatRealm", RealmGBean.class);
60: infoFactory.addAttribute("className", String.class, true);
61: infoFactory.addAttribute("initParams", Map.class, true);
62:
63: infoFactory.addOperation("getInternalObject");
64: infoFactory.setConstructor(new String[] { "className",
65: "initParams" });
66: GBEAN_INFO = infoFactory.getBeanInfo();
67: }
68:
69: public static GBeanInfo getGBeanInfo() {
70: return GBEAN_INFO;
71: }
72: }
|