KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jndi > JndiAccessor


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.jndi;
18
19 import java.util.Properties JavaDoc;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 /**
25  * Convenient superclass for JNDI accessors, providing "jndiTemplate"
26  * and "jndiEnvironment" bean properties.
27  *
28  * @author Juergen Hoeller
29  * @since 1.1
30  * @see #setJndiTemplate
31  * @see #setJndiEnvironment
32  */

33 public class JndiAccessor {
34
35     /**
36      * Logger, available to subclasses.
37      */

38     protected final Log logger = LogFactory.getLog(getClass());
39
40     private JndiTemplate jndiTemplate = new JndiTemplate();
41
42
43     /**
44      * Set the JNDI template to use for JNDI lookups.
45      * <p>You can also specify JNDI environment settings via "jndiEnvironment".
46      * @see #setJndiEnvironment
47      */

48     public void setJndiTemplate(JndiTemplate jndiTemplate) {
49         this.jndiTemplate = (jndiTemplate != null ? jndiTemplate : new JndiTemplate());
50     }
51
52     /**
53      * Return the JNDI template to use for JNDI lookups.
54      */

55     public JndiTemplate getJndiTemplate() {
56         return this.jndiTemplate;
57     }
58
59     /**
60      * Set the JNDI environment to use for JNDI lookups.
61      * <p>Creates a JndiTemplate with the given environment settings.
62      * @see #setJndiTemplate
63      */

64     public void setJndiEnvironment(Properties JavaDoc jndiEnvironment) {
65         this.jndiTemplate = new JndiTemplate(jndiEnvironment);
66     }
67
68     /**
69      * Return the JNDI environment to use for JNDI lookups.
70      */

71     public Properties JavaDoc getJndiEnvironment() {
72         return this.jndiTemplate.getEnvironment();
73     }
74
75 }
76
Popular Tags