View Javadoc

1   /*
2    * Copyright 2002-2005 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  package net.sf.ldaptemplate;
17  
18  import javax.naming.NamingException;
19  import javax.naming.directory.DirContext;
20  
21  /***
22   * Interface for delegating an actual operation to be performed on an
23   * DirContext. For searches, use {@link net.sf.ldaptemplate.SearchExecutor} in
24   * stead. A typical implementation would look like:
25   * 
26   * <pre>
27   * return ctx.lookup(dn);
28   * </pre>
29   * 
30   * @see net.sf.ldaptemplate.LdapTemplate#executeReadOnly(ContextExecutor)
31   * @see net.sf.ldaptemplate.LdapTemplate#executeReadWrite(ContextExecutor)
32   * 
33   * @author Mattias Arthursson
34   */
35  public interface ContextExecutor {
36      /***
37       * Perform any operation on the context.
38       * 
39       * @param ctx
40       *            the DirContext to perform the operation on.
41       * @return any object resulting from the operation - might be null.
42       * @throws NamingException
43       *             if the operation resulted in one.
44       */
45      public Object executeWithContext(DirContext ctx) throws NamingException;
46  }