01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
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: * Set the JNDI template to use for JNDI lookups.
44: * <p>You can also specify JNDI environment settings via "jndiEnvironment".
45: * @see #setJndiEnvironment
46: */
47: public void setJndiTemplate(JndiTemplate jndiTemplate) {
48: this .jndiTemplate = (jndiTemplate != null ? jndiTemplate
49: : 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 jndiEnvironment) {
65: this .jndiTemplate = new JndiTemplate(jndiEnvironment);
66: }
67:
68: /**
69: * Return the JNDI environment to use for JNDI lookups.
70: */
71: public Properties getJndiEnvironment() {
72: return this.jndiTemplate.getEnvironment();
73: }
74:
75: }
|