1 17 package org.apache.ldap.server.schema.bootstrap; 18 19 20 import org.apache.ldap.server.jndi.ServerDirStateFactory; 21 import org.apache.ldap.server.schema.StateFactoryRegistry; 22 23 import javax.naming.NamingException ; 24 import java.util.HashMap ; 25 26 27 33 public class BootstrapStateFactoryRegistry implements StateFactoryRegistry 34 { 35 36 private final HashMap byClass = new HashMap (); 37 38 39 public ServerDirStateFactory getStateFactories( Object obj ) throws NamingException 40 { 41 Class c = obj.getClass(); 42 43 45 if ( byClass.containsKey( c ) ) 46 { 47 return ( ServerDirStateFactory ) byClass.get( c ); 48 } 49 50 while ( ( c = c.getSuperclass() ) != null ) 51 { 52 if ( byClass.containsKey( c ) ) 53 { 54 return ( ServerDirStateFactory ) byClass.get( c ); 55 } 56 } 57 58 60 Class [] interfaces = c.getInterfaces(); 61 62 for ( int ii = 0; ii < interfaces.length; ii++ ) 63 { 64 if ( byClass.containsKey( interfaces[ii] ) ) 65 { 66 return ( ServerDirStateFactory ) byClass.get( interfaces[ii] ); 67 } 68 } 69 70 return null; 71 } 72 73 74 public void register( ServerDirStateFactory factory ) 75 { 76 byClass.put( factory.getAssociatedClass(), factory ); 77 } 78 } 79 | Popular Tags |