KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc className, Map JavaDoc initParams) throws Exception JavaDoc {
31         super(); // TODO: make it an attribute
32

33         assert className != null;
34         
35         realm = (Realm)Class.forName(className).newInstance();
36         
37         setParameters(realm, initParams);
38         
39     }
40
41     public Object JavaDoc getInternalObject() {
42         return realm;
43     }
44
45     public void doFail() {
46     }
47
48     public void doStart() throws Exception JavaDoc {
49     }
50
51     public void doStop() throws Exception JavaDoc {
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 JavaDoc.class, true);
59         infoFactory.addAttribute("initParams", Map JavaDoc.class, true);
60
61         infoFactory.addOperation("getInternalObject");
62         infoFactory.setConstructor(new String JavaDoc[] { "className", "initParams" });
63         GBEAN_INFO = infoFactory.getBeanInfo();
64     }
65
66     public static GBeanInfo getGBeanInfo() {
67         return GBEAN_INFO;
68     }
69 }
70
Popular Tags