1 7 8 package com.sun.corba.se.impl.ior ; 9 10 import org.omg.CORBA_2_3.portable.InputStream ; 11 12 import java.util.Map ; 13 import java.util.HashMap ; 14 15 import com.sun.corba.se.spi.orb.ORB ; 16 17 import com.sun.corba.se.spi.ior.Identifiable ; 18 import com.sun.corba.se.spi.ior.IdentifiableFactory ; 19 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ; 20 21 import com.sun.corba.se.spi.logging.CORBALogDomains ; 22 23 import com.sun.corba.se.impl.logging.IORSystemException ; 24 25 public abstract class IdentifiableFactoryFinderBase implements 26 IdentifiableFactoryFinder 27 { 28 private ORB orb ; 29 private Map map ; 30 protected IORSystemException wrapper ; 31 32 protected IdentifiableFactoryFinderBase( ORB orb ) 33 { 34 map = new HashMap () ; 35 this.orb = orb ; 36 wrapper = IORSystemException.get( orb, 37 CORBALogDomains.OA_IOR ) ; 38 } 39 40 protected IdentifiableFactory getFactory(int id) 41 { 42 Integer ident = new Integer ( id ) ; 43 IdentifiableFactory factory = (IdentifiableFactory)(map.get( 44 ident ) ) ; 45 return factory ; 46 } 47 48 public abstract Identifiable handleMissingFactory( int id, InputStream is ) ; 49 50 public Identifiable create(int id, InputStream is) 51 { 52 IdentifiableFactory factory = getFactory( id ) ; 53 54 if (factory != null) 55 return factory.create( is ) ; 56 else 57 return handleMissingFactory( id, is ) ; 58 } 59 60 public void registerFactory(IdentifiableFactory factory) 61 { 62 Integer ident = new Integer ( factory.getId() ) ; 63 map.put( ident, factory ) ; 64 } 65 } 66 | Popular Tags |