KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > databasemanager > wizard > DatabaseDriverGBean


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.console.databasemanager.wizard;
19
20 import org.apache.geronimo.kernel.repository.Artifact;
21 import org.apache.geronimo.gbean.GBeanInfo;
22 import org.apache.geronimo.gbean.GBeanInfoBuilder;
23
24 import java.util.regex.Pattern JavaDoc;
25 import java.util.regex.Matcher JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.ArrayList JavaDoc;
28
29 /**
30  * Implementation of DatabaseDriver that contains database driver information
31  * contained in the console's deployment plan.
32  *
33  * @version $Rev: 472167 $ $Date: 2006-11-07 12:00:18 -0500 (Tue, 07 Nov 2006) $
34  */

35 public class DatabaseDriverGBean implements DatabaseDriver {
36     private final static Pattern JavaDoc PARAM_PATTERN = Pattern.compile("\\{.+?\\}");
37     private String JavaDoc name;
38     private String JavaDoc URLPrototype;
39     private String JavaDoc driverClassName;
40     private int defaultPort;
41     private boolean XA;
42     private Artifact RAR;
43
44     public String JavaDoc getName() {
45         return name;
46     }
47
48     public void setName(String JavaDoc name) {
49         this.name = name;
50     }
51
52     public String JavaDoc getURLPrototype() {
53         return URLPrototype;
54     }
55
56     public void setURLPrototype(String JavaDoc URLPrototype) {
57         this.URLPrototype = URLPrototype;
58     }
59
60     public String JavaDoc getDriverClassName() {
61         return driverClassName;
62     }
63
64     public void setDriverClassName(String JavaDoc driverClassName) {
65         this.driverClassName = driverClassName;
66     }
67
68     public int getDefaultPort() {
69         return defaultPort;
70     }
71
72     public void setDefaultPort(int defaultPort) {
73         this.defaultPort = defaultPort;
74     }
75
76     public boolean isXA() {
77         return XA;
78     }
79
80     public void setXA(boolean XA) {
81         this.XA = XA;
82     }
83
84     public Artifact getRAR() {
85         return RAR;
86     }
87
88     public void setRARName(String JavaDoc name) {
89         RAR = Artifact.create(name);
90     }
91
92     public String JavaDoc[] getURLParameters() {
93         Matcher JavaDoc m = PARAM_PATTERN.matcher(URLPrototype);
94         List JavaDoc list = new ArrayList JavaDoc();
95         while(m.find()) {
96             list.add(URLPrototype.substring(m.start()+1, m.end()-1));
97         }
98         return (String JavaDoc[]) list.toArray(new String JavaDoc[list.size()]);
99     }
100
101     public static final GBeanInfo GBEAN_INFO;
102
103     static {
104         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Database Driver Info", DatabaseDriverGBean.class);
105         infoFactory.addAttribute("name", String JavaDoc.class, true, true);
106         infoFactory.addAttribute("URLPrototype", String JavaDoc.class, true, true);
107         infoFactory.addAttribute("driverClassName", String JavaDoc.class, true, true);
108         infoFactory.addAttribute("defaultPort", int.class, true, true);
109         infoFactory.addAttribute("XA", boolean.class, true, true);
110         infoFactory.addAttribute("RARName", String JavaDoc.class, true, true);
111         infoFactory.addInterface(DatabaseDriver.class);
112
113         infoFactory.setConstructor(new String JavaDoc[0]);
114
115         GBEAN_INFO = infoFactory.getBeanInfo();
116     }
117
118     public static GBeanInfo getGBeanInfo() {
119         return GBEAN_INFO;
120     }
121 }
122
Popular Tags