01: /*
02: * Copyright 2002-2005 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 javax.naming.Context;
20: import javax.naming.NamingException;
21:
22: /**
23: * Callback interface to be implemented by classes that need to perform an
24: * operation (such as a lookup) in a JNDI context. This callback approach
25: * is valuable in simplifying error handling, which is performed by the
26: * JndiTemplate class. This is a similar to JdbcTemplate's approach.
27: *
28: * <p>Note that there is hardly any need to implement this callback
29: * interface, as JndiTemplate provides all usual JNDI operations via
30: * convenience methods.
31: *
32: * @see JndiTemplate
33: * @see org.springframework.jdbc.core.JdbcTemplate
34: * @author Rod Johnson
35: */
36: public interface JndiCallback {
37:
38: /**
39: * Do something with the given JNDI context.
40: * Implementations don't need to worry about error handling
41: * or cleanup, as the JndiTemplate class will handle this.
42: * @param ctx the current JNDI context
43: * @throws NamingException if thrown by JNDI methods
44: * @return a result object, or <code>null</code>
45: */
46: Object doInContext(Context ctx) throws NamingException;
47:
48: }
|