View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
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.apache.ldap.server.interceptor;
18  
19  
20  import java.util.ArrayList;
21  import java.util.HashMap;
22  import java.util.Iterator;
23  import java.util.List;
24  import java.util.ListIterator;
25  import java.util.Map;
26  
27  import javax.naming.ConfigurationException;
28  import javax.naming.Name;
29  import javax.naming.NamingEnumeration;
30  import javax.naming.NamingException;
31  import javax.naming.directory.Attributes;
32  import javax.naming.directory.ModificationItem;
33  import javax.naming.directory.SearchControls;
34  
35  import org.apache.ldap.common.filter.ExprNode;
36  import org.apache.ldap.server.configuration.InterceptorConfiguration;
37  import org.apache.ldap.server.configuration.MutableInterceptorConfiguration;
38  import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
39  import org.apache.ldap.server.partition.ContextPartitionNexus;
40  
41  
42  /***
43   * Manages the chain of {@link Interceptor}s.
44   *
45   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
46   * @version $Rev: 226451 $, $Date: 2005-07-29 20:54:58 -0400 (Fri, 29 Jul 2005) $
47   */
48  public class InterceptorChain
49  {
50      private final Interceptor FINAL_INTERCEPTOR = new Interceptor()
51      {
52          private ContextPartitionNexus nexus;
53  
54          public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg )
55          {
56              this.nexus = factoryCfg.getPartitionNexus();
57          }
58  
59  
60          public void destroy()
61          {
62              // unused
63          }
64  
65  
66          public Attributes getRootDSE( NextInterceptor next ) throws NamingException
67          {
68              return nexus.getRootDSE();
69          }
70  
71  
72          public Name getMatchedName( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
73          {
74              return ( Name ) nexus.getMatchedName( dn, normalized ).clone();
75          }
76  
77  
78          public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
79          {
80              return ( Name ) nexus.getSuffix( dn, normalized ).clone();
81          }
82  
83  
84          public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
85          {
86              return nexus.listSuffixes( normalized );
87          }
88  
89  
90          public void delete( NextInterceptor next, Name name ) throws NamingException
91          {
92              nexus.delete( name );
93          }
94  
95  
96          public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
97          {
98              nexus.add( upName, normName, entry );
99          }
100 
101 
102         public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
103         {
104             nexus.modify( name, modOp, mods );
105         }
106 
107 
108         public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
109         {
110             nexus.modify( name, mods );
111         }
112 
113 
114         public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
115         {
116             return nexus.list( base );
117         }
118 
119 
120         public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
121         {
122             return nexus.search( base, env, filter, searchCtls );
123         }
124 
125 
126         public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
127         {
128             return ( Attributes ) nexus.lookup( name ).clone();
129         }
130 
131 
132         public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
133         {
134             return ( Attributes ) nexus.lookup( dn, attrIds ).clone();
135         }
136 
137 
138         public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
139         {
140             return nexus.hasEntry( name );
141         }
142 
143 
144         public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
145         {
146             return nexus.isSuffix( name );
147         }
148 
149 
150         public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
151         {
152             nexus.modifyRn( name, newRn, deleteOldRn );
153         }
154 
155 
156         public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
157         {
158             nexus.move( oriChildName, newParentName );
159         }
160 
161 
162         public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
163         {
164             nexus.move( oriChildName, newParentName, newRn, deleteOldRn );
165         }
166     };
167 
168     private final Map name2entry = new HashMap();
169 
170     private final Entry tail;
171 
172     private Entry head;
173 
174     private ContextFactoryConfiguration factoryCfg;
175 
176     /***
177      * Create a new interceptor chain.
178      */
179     public InterceptorChain()
180     {
181         MutableInterceptorConfiguration tailCfg = new MutableInterceptorConfiguration();
182         tailCfg.setName( "tail" );
183         tailCfg.setInterceptor( FINAL_INTERCEPTOR );
184         tail = new Entry( null, null, tailCfg );
185         head = tail;
186     }
187 
188 
189     /***
190      * Initializes and registers all interceptors according to the specified
191      * {@link ContextFactoryConfiguration}.
192      */
193     public synchronized void init( ContextFactoryConfiguration factoryCfg ) throws NamingException
194     {
195         this.factoryCfg = factoryCfg;
196 
197         // Initialize tail first.
198         FINAL_INTERCEPTOR.init( factoryCfg, null );
199         
200         // And register and initialize all interceptors
201         ListIterator i = factoryCfg.getStartupConfiguration().getInterceptorConfigurations().listIterator();
202         Interceptor interceptor = null;
203         try
204         {
205             while( i.hasNext() )
206             {
207                 InterceptorConfiguration cfg = ( InterceptorConfiguration ) i.next();
208                 register( cfg );
209             }
210         }
211         catch ( Throwable t )
212         {
213             // destroy if failed to initialize all interceptors.
214             destroy();
215 
216             if ( t instanceof NamingException )
217             {
218                 throw ( NamingException ) t;
219             }
220             else
221             {
222                 throw new InterceptorException( interceptor, "Failed to initialize interceptor chain.", t );
223             }
224         }
225     }
226 
227 
228     /***
229      * Deinitializes and deregisters all interceptors this chain contains.
230      */
231     public synchronized void destroy()
232     {
233         List entries = new ArrayList();
234         Entry e = tail;
235         do
236         {
237             entries.add( e );
238             e = e.prevEntry;
239         }
240         while ( e != null );
241 
242         Iterator i = entries.iterator();
243         while ( i.hasNext() )
244         {
245             e = ( Entry ) i.next();
246             if( e != tail )
247             {
248                 try
249                 {
250                     deregister( e.configuration );
251                 }
252                 catch ( Throwable t )
253                 {
254                     t.printStackTrace();
255                 }
256             }
257         }
258     }
259     
260     
261     /***
262      * Returns the registered interceptor with the specified name.
263      * @return <tt>null</tt> if the specified name doesn't exist.
264      */
265     public Interceptor get( String interceptorName )
266     {
267         Entry e = (Entry) name2entry.get( interceptorName );
268         if( e == null )
269         {
270             return null;
271         }
272         
273         return e.configuration.getInterceptor();
274     }
275     
276     /***
277      * Returns the list of all registered interceptors.
278      */
279     public List getAll()
280     {
281         List result = new ArrayList();
282         Entry e = head;
283         do
284         {
285             result.add( e.configuration.getInterceptor() );
286             e = e.nextEntry;
287         }
288         while ( e != tail );
289         
290         return result;
291     }
292 
293 
294     /***
295      * Adds and initializes an interceptor with the specified configuration.
296      */
297     private void register( InterceptorConfiguration cfg ) throws NamingException
298     {
299         checkAddable( cfg );
300         register0( cfg, tail );
301     }
302 
303 
304     /***
305      * Removes and deinitializes the interceptor with the specified configuration.
306      */
307     private void deregister( InterceptorConfiguration cfg ) throws ConfigurationException
308     {
309         String name = cfg.getName();
310         Entry entry = checkOldName( name );
311         Entry prevEntry = entry.prevEntry;
312         Entry nextEntry = entry.nextEntry;
313 
314         if( nextEntry == null )
315         {
316             // Don't deregister tail
317             return;
318         }
319 
320         if ( prevEntry == null )
321         {
322             nextEntry.prevEntry = null;
323             head = entry;
324         }
325         else
326         {
327             prevEntry.nextEntry = nextEntry;
328             nextEntry.prevEntry = prevEntry;
329         }
330 
331         name2entry.remove( name );
332         entry.configuration.getInterceptor().destroy();
333     }
334 
335 
336     private void register0( InterceptorConfiguration cfg, Entry nextEntry ) throws NamingException
337     {
338         String name = cfg.getName();
339         Interceptor interceptor = cfg.getInterceptor();
340         interceptor.init( factoryCfg, cfg );
341         
342         Entry newEntry;
343         if( nextEntry == head )
344         {
345             newEntry = new Entry( null, head, cfg );
346             head.prevEntry = newEntry;
347             head = newEntry;
348         }
349         else if( head == tail )
350         {
351             newEntry = new Entry( null, tail, cfg );
352             tail.prevEntry = newEntry;
353             head = newEntry;
354         }
355         else
356         {
357             newEntry = new Entry( nextEntry.prevEntry, nextEntry, cfg );
358             nextEntry.prevEntry.nextEntry = newEntry;
359             nextEntry.prevEntry = newEntry;
360         }
361         
362         name2entry.put( name, newEntry );
363     }
364 
365 
366     /***
367      * Throws an exception when the specified interceptor name is not registered in this chain.
368      *
369      * @return An interceptor entry with the specified name.
370      */
371     private Entry checkOldName( String baseName ) throws ConfigurationException
372     {
373         Entry e = ( Entry ) name2entry.get( baseName );
374 
375         if ( e == null )
376         {
377             throw new ConfigurationException( "Unknown interceptor name:" + baseName );
378         }
379 
380         return e;
381     }
382 
383 
384     /***
385      * Checks the specified interceptor name is already taken and throws an exception if already taken.
386      */
387     private void checkAddable( InterceptorConfiguration cfg ) throws ConfigurationException
388     {
389         if ( name2entry.containsKey( cfg.getName() ) )
390         {
391             throw new ConfigurationException( "Other interceptor is using name '" + cfg.getName() + "'" );
392         }
393     }
394 
395 
396     public Attributes getRootDSE() throws NamingException
397     {
398         Interceptor head = this.head.configuration.getInterceptor();
399         NextInterceptor next = this.head.nextInterceptor;
400         try
401         {
402             return head.getRootDSE( next );
403         }
404         catch ( NamingException ne )
405         {
406             throw ne;
407         }
408         catch ( Throwable e )
409         {
410             throwInterceptorException( head, e );
411             throw new InternalError(); // Should be unreachable
412         }
413     }
414 
415 
416     public Name getMatchedName( Name name, boolean normalized ) throws NamingException
417     {
418         Interceptor head = this.head.configuration.getInterceptor();
419         NextInterceptor next = this.head.nextInterceptor;
420         try
421         {
422             return head.getMatchedName( next, name, normalized );
423         }
424         catch ( NamingException ne )
425         {
426             throw ne;
427         }
428         catch ( Throwable e )
429         {
430             throwInterceptorException( head, e );
431             throw new InternalError(); // Should be unreachable
432         }
433     }
434 
435 
436     public Name getSuffix( Name name, boolean normalized ) throws NamingException
437     {
438         Interceptor head = this.head.configuration.getInterceptor();
439         NextInterceptor next = this.head.nextInterceptor;
440         try
441         {
442             return head.getSuffix( next, name, normalized );
443         }
444         catch ( NamingException ne )
445         {
446             throw ne;
447         }
448         catch ( Throwable e )
449         {
450             throwInterceptorException( head, e );
451             throw new InternalError(); // Should be unreachable
452         }
453     }
454 
455 
456     public Iterator listSuffixes( boolean normalized ) throws NamingException
457     {
458         Interceptor head = this.head.configuration.getInterceptor();
459         NextInterceptor next = this.head.nextInterceptor;
460         try
461         {
462             return head.listSuffixes( next, normalized );
463         }
464         catch ( NamingException ne )
465         {
466             throw ne;
467         }
468         catch ( Throwable e )
469         {
470             throwInterceptorException( head, e );
471             throw new InternalError(); // Should be unreachable
472         }
473     }
474 
475 
476     public void delete( Name name ) throws NamingException
477     {
478         Interceptor head = this.head.configuration.getInterceptor();
479         NextInterceptor next = this.head.nextInterceptor;
480         try
481         {
482             head.delete( next, name );
483         }
484         catch ( NamingException ne )
485         {
486             throw ne;
487         }
488         catch ( Throwable e )
489         {
490             throwInterceptorException( head, e );
491         }
492     }
493 
494 
495     public void add( String upName, Name normName, Attributes entry ) throws NamingException
496     {
497         Interceptor head = this.head.configuration.getInterceptor();
498         NextInterceptor next = this.head.nextInterceptor;
499         try
500         {
501             head.add( next, upName, normName, entry );
502         }
503         catch ( NamingException ne )
504         {
505             throw ne;
506         }
507         catch ( Throwable e )
508         {
509             throwInterceptorException( head, e );
510         }
511     }
512 
513 
514     public void modify( Name name, int modOp, Attributes mods ) throws NamingException
515     {
516         Interceptor head = this.head.configuration.getInterceptor();
517         NextInterceptor next = this.head.nextInterceptor;
518         try
519         {
520             head.modify( next, name, modOp, mods );
521         }
522         catch ( NamingException ne )
523         {
524             throw ne;
525         }
526         catch ( Throwable e )
527         {
528             throwInterceptorException( head, e );
529         }
530     }
531 
532 
533     public void modify( Name name, ModificationItem[] mods ) throws NamingException
534     {
535         Interceptor head = this.head.configuration.getInterceptor();
536         NextInterceptor next = this.head.nextInterceptor;
537         try
538         {
539             head.modify( next, name, mods );
540         }
541         catch ( NamingException ne )
542         {
543             throw ne;
544         }
545         catch ( Throwable e )
546         {
547             throwInterceptorException( head, e );
548         }
549     }
550 
551 
552     public NamingEnumeration list( Name base ) throws NamingException
553     {
554         Interceptor head = this.head.configuration.getInterceptor();
555         NextInterceptor next = this.head.nextInterceptor;
556         try
557         {
558             return head.list( next, base );
559         }
560         catch ( NamingException ne )
561         {
562             throw ne;
563         }
564         catch ( Throwable e )
565         {
566             throwInterceptorException( head, e );
567             throw new InternalError(); // Should be unreachable
568         }
569     }
570 
571 
572     public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
573     {
574         Interceptor head = this.head.configuration.getInterceptor();
575         NextInterceptor next = this.head.nextInterceptor;
576         try
577         {
578             return head.search( next, base, env, filter, searchCtls );
579         }
580         catch ( NamingException ne )
581         {
582             throw ne;
583         }
584         catch ( Throwable e )
585         {
586             throwInterceptorException( head, e );
587             throw new InternalError(); // Should be unreachable
588         }
589     }
590 
591 
592     public Attributes lookup( Name name ) throws NamingException
593     {
594         Interceptor head = this.head.configuration.getInterceptor();
595         NextInterceptor next = this.head.nextInterceptor;
596         try
597         {
598             return head.lookup( next, name );
599         }
600         catch ( NamingException ne )
601         {
602             throw ne;
603         }
604         catch ( Throwable e )
605         {
606             throwInterceptorException( head, e );
607             throw new InternalError(); // Should be unreachable
608         }
609     }
610 
611 
612     public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
613     {
614         Interceptor head = this.head.configuration.getInterceptor();
615         NextInterceptor next = this.head.nextInterceptor;
616         try
617         {
618             return head.lookup( next, dn, attrIds );
619         }
620         catch ( NamingException ne )
621         {
622             throw ne;
623         }
624         catch ( Throwable e )
625         {
626             throwInterceptorException( head, e );
627             throw new InternalError(); // Should be unreachable
628         }
629     }
630 
631 
632     public boolean hasEntry( Name name ) throws NamingException
633     {
634         Interceptor head = this.head.configuration.getInterceptor();
635         NextInterceptor next = this.head.nextInterceptor;
636         try
637         {
638             return head.hasEntry( next, name );
639         }
640         catch ( NamingException ne )
641         {
642             throw ne;
643         }
644         catch ( Throwable e )
645         {
646             throwInterceptorException( head, e );
647             throw new InternalError(); // Should be unreachable
648         }
649     }
650 
651 
652     public boolean isSuffix( Name name ) throws NamingException
653     {
654         Interceptor head = this.head.configuration.getInterceptor();
655         NextInterceptor next = this.head.nextInterceptor;
656         try
657         {
658             return head.isSuffix( next, name );
659         }
660         catch ( NamingException ne )
661         {
662             throw ne;
663         }
664         catch ( Throwable e )
665         {
666             throwInterceptorException( head, e );
667             throw new InternalError(); // Should be unreachable
668         }
669     }
670 
671 
672     public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
673     {
674         Interceptor head = this.head.configuration.getInterceptor();
675         NextInterceptor next = this.head.nextInterceptor;
676         try
677         {
678             head.modifyRn( next, name, newRn, deleteOldRn );
679         }
680         catch ( NamingException ne )
681         {
682             throw ne;
683         }
684         catch ( Throwable e )
685         {
686             throwInterceptorException( head, e );
687         }
688     }
689 
690 
691     public void move( Name oriChildName, Name newParentName ) throws NamingException
692     {
693         Interceptor head = this.head.configuration.getInterceptor();
694         NextInterceptor next = this.head.nextInterceptor;
695         try
696         {
697             head.move( next, oriChildName, newParentName );
698         }
699         catch ( NamingException ne )
700         {
701             throw ne;
702         }
703         catch ( Throwable e )
704         {
705             throwInterceptorException( head, e );
706         }
707     }
708 
709 
710     public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
711     {
712         Interceptor head = this.head.configuration.getInterceptor();
713         NextInterceptor next = this.head.nextInterceptor;
714         try
715         {
716             head.move( next, oriChildName, newParentName, newRn, deleteOldRn );
717         }
718         catch ( NamingException ne )
719         {
720             throw ne;
721         }
722         catch ( Throwable e )
723         {
724             throwInterceptorException( head, e );
725         }
726     }
727 
728 
729     /***
730      * Represents an internal entry of this chain.
731      */
732     private class Entry
733     {
734         private Entry prevEntry;
735 
736         private Entry nextEntry;
737 
738         private final InterceptorConfiguration configuration;
739 
740         private final NextInterceptor nextInterceptor;
741 
742 
743         private Entry( Entry prevEntry, Entry nextEntry,
744                        InterceptorConfiguration configuration )
745         {
746             if ( configuration == null )
747             {
748                 throw new NullPointerException( "configuration" );
749             }
750 
751             this.prevEntry = prevEntry;
752 
753             this.nextEntry = nextEntry;
754 
755             this.configuration = configuration;
756 
757             this.nextInterceptor = new NextInterceptor()
758             {
759                 public Attributes getRootDSE() throws NamingException
760                 {
761                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
762 
763                     try
764                     {
765                         return interceptor.getRootDSE( Entry.this.nextEntry.nextInterceptor );
766                     }
767                     catch ( NamingException ne )
768                     {
769                         throw ne;
770                     }
771                     catch ( Throwable e )
772                     {
773                         throwInterceptorException( interceptor, e );
774                         throw new InternalError(); // Should be unreachable
775                     }
776                 }
777 
778                 public Name getMatchedName( Name dn, boolean normalized ) throws NamingException
779                 {
780                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
781 
782                     try
783                     {
784                         return interceptor.getMatchedName( Entry.this.nextEntry.nextInterceptor, dn, normalized );
785                     }
786                     catch ( NamingException ne )
787                     {
788                         throw ne;
789                     }
790                     catch ( Throwable e )
791                     {
792                         throwInterceptorException( interceptor, e );
793                         throw new InternalError(); // Should be unreachable
794                     }
795                 }
796 
797                 public Name getSuffix( Name dn, boolean normalized ) throws NamingException
798                 {
799                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
800 
801                     try
802                     {
803                         return interceptor.getSuffix( Entry.this.nextEntry.nextInterceptor, dn, normalized );
804                     }
805                     catch ( NamingException ne )
806                     {
807                         throw ne;
808                     }
809                     catch ( Throwable e )
810                     {
811                         throwInterceptorException( interceptor, e );
812                         throw new InternalError(); // Should be unreachable
813                     }
814                 }
815 
816                 public Iterator listSuffixes( boolean normalized ) throws NamingException
817                 {
818                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
819 
820                     try
821                     {
822                         return interceptor.listSuffixes( Entry.this.nextEntry.nextInterceptor, normalized );
823                     }
824                     catch ( NamingException ne )
825                     {
826                         throw ne;
827                     }
828                     catch ( Throwable e )
829                     {
830                         throwInterceptorException( interceptor, e );
831                         throw new InternalError(); // Should be unreachable
832                     }
833                 }
834 
835                 public void delete( Name name ) throws NamingException
836                 {
837                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
838 
839                     try
840                     {
841                         interceptor.delete( Entry.this.nextEntry.nextInterceptor, name );
842                     }
843                     catch ( NamingException ne )
844                     {
845                         throw ne;
846                     }
847                     catch ( Throwable e )
848                     {
849                         throwInterceptorException( interceptor, e );
850                     }
851                 }
852 
853                 public void add( String upName, Name normName, Attributes entry ) throws NamingException
854                 {
855                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
856 
857                     try
858                     {
859                         interceptor.add( Entry.this.nextEntry.nextInterceptor, upName, normName, entry );
860                     }
861                     catch ( NamingException ne )
862                     {
863                         throw ne;
864                     }
865                     catch ( Throwable e )
866                     {
867                         throwInterceptorException( interceptor, e );
868                     }
869                 }
870 
871                 public void modify( Name name, int modOp, Attributes mods ) throws NamingException
872                 {
873                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
874 
875                     try
876                     {
877                         interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, modOp, mods );
878                     }
879                     catch ( NamingException ne )
880                     {
881                         throw ne;
882                     }
883                     catch ( Throwable e )
884                     {
885                         throwInterceptorException( interceptor, e );
886                     }
887                 }
888 
889                 public void modify( Name name, ModificationItem[] mods ) throws NamingException
890                 {
891                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
892 
893                     try
894                     {
895                         interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, mods );
896                     }
897                     catch ( NamingException ne )
898                     {
899                         throw ne;
900                     }
901                     catch ( Throwable e )
902                     {
903                         throwInterceptorException( interceptor, e );
904                     }
905                 }
906 
907                 public NamingEnumeration list( Name base ) throws NamingException
908                 {
909                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
910 
911                     try
912                     {
913                         return interceptor.list( Entry.this.nextEntry.nextInterceptor, base );
914                     }
915                     catch ( NamingException ne )
916                     {
917                         throw ne;
918                     }
919                     catch ( Throwable e )
920                     {
921                         throwInterceptorException( interceptor, e );
922                         throw new InternalError(); // Should be unreachable
923                     }
924                 }
925 
926                 public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
927                 {
928                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
929 
930                     try
931                     {
932                         return interceptor.search( Entry.this.nextEntry.nextInterceptor, base, env, filter, searchCtls );
933                     }
934                     catch ( NamingException ne )
935                     {
936                         throw ne;
937                     }
938                     catch ( Throwable e )
939                     {
940                         throwInterceptorException( interceptor, e );
941                         throw new InternalError(); // Should be unreachable
942                     }
943                 }
944 
945                 public Attributes lookup( Name name ) throws NamingException
946                 {
947                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
948 
949                     try
950                     {
951                         return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, name );
952                     }
953                     catch ( NamingException ne )
954                     {
955                         throw ne;
956                     }
957                     catch ( Throwable e )
958                     {
959                         throwInterceptorException( interceptor, e );
960                         throw new InternalError(); // Should be unreachable
961                     }
962                 }
963 
964                 public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
965                 {
966                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
967 
968                     try
969                     {
970                         return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, dn, attrIds );
971                     }
972                     catch ( NamingException ne )
973                     {
974                         throw ne;
975                     }
976                     catch ( Throwable e )
977                     {
978                         throwInterceptorException( interceptor, e );
979                         throw new InternalError(); // Should be unreachable
980                     }
981                 }
982 
983                 public boolean hasEntry( Name name ) throws NamingException
984                 {
985                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
986 
987                     try
988                     {
989                         return interceptor.hasEntry( Entry.this.nextEntry.nextInterceptor, name );
990                     }
991                     catch ( NamingException ne )
992                     {
993                         throw ne;
994                     }
995                     catch ( Throwable e )
996                     {
997                         throwInterceptorException( interceptor, e );
998                         throw new InternalError(); // Should be unreachable
999                     }
1000                 }
1001 
1002                 public boolean isSuffix( Name name ) throws NamingException
1003                 {
1004                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1005 
1006                     try
1007                     {
1008                         return interceptor.isSuffix( Entry.this.nextEntry.nextInterceptor, name );
1009                     }
1010                     catch ( NamingException ne )
1011                     {
1012                         throw ne;
1013                     }
1014                     catch ( Throwable e )
1015                     {
1016                         throwInterceptorException( interceptor, e );
1017                         throw new InternalError(); // Should be unreachable
1018                     }
1019                 }
1020 
1021                 public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
1022                 {
1023                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1024 
1025                     try
1026                     {
1027                         interceptor.modifyRn( Entry.this.nextEntry.nextInterceptor, name, newRn, deleteOldRn );
1028                     }
1029                     catch ( NamingException ne )
1030                     {
1031                         throw ne;
1032                     }
1033                     catch ( Throwable e )
1034                     {
1035                         throwInterceptorException( interceptor, e );
1036                     }
1037                 }
1038 
1039                 public void move( Name oriChildName, Name newParentName ) throws NamingException
1040                 {
1041                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1042 
1043                     try
1044                     {
1045                         interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName );
1046                     }
1047                     catch ( NamingException ne )
1048                     {
1049                         throw ne;
1050                     }
1051                     catch ( Throwable e )
1052                     {
1053                         throwInterceptorException( interceptor, e );
1054                     }
1055                 }
1056 
1057                 public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
1058                 {
1059                     Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1060 
1061                     try
1062                     {
1063                         interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName, newRn, deleteOldRn );
1064                     }
1065                     catch ( NamingException ne )
1066                     {
1067                         throw ne;
1068                     }
1069                     catch ( Throwable e )
1070                     {
1071                         throwInterceptorException( interceptor, e );
1072                     }
1073                 }
1074             };
1075         }
1076     }
1077 
1078 
1079     private static void throwInterceptorException( Interceptor interceptor, Throwable e ) throws InterceptorException
1080     {
1081         throw new InterceptorException( interceptor, "Unexpected exception.", e );
1082     }
1083 }