KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > test > jnditester > JndiProperties


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.test.jnditester;
21
22 import java.io.*;
23 import java.util.Properties JavaDoc;
24
25
26 public class JndiProperties {
27     private static JndiProperties instance = new JndiProperties(
28             "com\\openi\\test\\jnditester\\jndi.properties");
29     private String JavaDoc contextFactory = null;
30     private String JavaDoc connectionURL = null;
31     private String JavaDoc connectionName = null;
32     private String JavaDoc connectionPassword = null;
33     private String JavaDoc searchFilter = null;
34     private String JavaDoc searchBase = null;
35     private String JavaDoc returnAttibutes = null;
36     private boolean searchScope = false;
37     private String JavaDoc referal = null;
38     private Properties JavaDoc properties = null;
39
40     JndiProperties(String JavaDoc propertyFile) {
41         readProperty(propertyFile);
42     }
43
44     private void readProperty(String JavaDoc propertyFile) {
45         properties = new Properties JavaDoc();
46
47         try {
48             properties.load(new FileInputStream(propertyFile));
49
50             setConnectionName(properties.getProperty("ConnectionName", null));
51             setConnectionPassword(properties.getProperty("ConnectionPassword",
52                     null));
53             setConnectionURL(properties.getProperty("ConnectionURL", null));
54             setContextFactory(properties.getProperty("ContextFactory", null));
55             setReferal(properties.getProperty("Referal", null));
56             setReturnAttibutes(properties.getProperty("ReturnAttibutes", null));
57             setSearchBase(properties.getProperty("SearchBase", null));
58             setSearchFilter(properties.getProperty("SearchFilter", null));
59             setSearchScope(properties.getProperty("SearchScope", null)
60                                      .equalsIgnoreCase("true") ? true : false);
61         } catch (Exception JavaDoc ex) {
62             System.out.println(ex.getMessage());
63         }
64     }
65
66     public static JndiProperties getInstance() {
67         return instance;
68     }
69
70     public String JavaDoc getConnectionName() {
71         return connectionName;
72     }
73
74     public String JavaDoc getConnectionPassword() {
75         return connectionPassword;
76     }
77
78     public String JavaDoc getConnectionURL() {
79         return connectionURL;
80     }
81
82     public String JavaDoc getContextFactory() {
83         return contextFactory;
84     }
85
86     public String JavaDoc getReferal() {
87         return referal;
88     }
89
90     public String JavaDoc getReturnAttibutes() {
91         return returnAttibutes;
92     }
93
94     public String JavaDoc getSearchBase() {
95         return searchBase;
96     }
97
98     public String JavaDoc getSearchFilter() {
99         return searchFilter;
100     }
101
102     public boolean getSearchScope() {
103         return searchScope;
104     }
105
106     public void setConnectionName(String JavaDoc connectionName) {
107         this.connectionName = connectionName;
108     }
109
110     public void setConnectionPassword(String JavaDoc connectionPassword) {
111         this.connectionPassword = connectionPassword;
112     }
113
114     public void setConnectionURL(String JavaDoc connectionURL) {
115         this.connectionURL = connectionURL;
116     }
117
118     public void setContextFactory(String JavaDoc contextFactory) {
119         this.contextFactory = contextFactory;
120     }
121
122     public void setReferal(String JavaDoc referal) {
123         this.referal = referal;
124     }
125
126     public void setReturnAttibutes(String JavaDoc returnAttibutes) {
127         this.returnAttibutes = returnAttibutes;
128     }
129
130     public void setSearchBase(String JavaDoc searchBase) {
131         this.searchBase = searchBase;
132     }
133
134     public void setSearchFilter(String JavaDoc searchFilter) {
135         this.searchFilter = searchFilter;
136     }
137
138     public void setSearchScope(boolean searchScope) {
139         this.searchScope = searchScope;
140     }
141 }
142
Popular Tags