1. /*
  2. * @(#)IdentifiableFactoryFinderBase.java 1.4 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.ior ;
  8. import org.omg.CORBA_2_3.portable.InputStream ;
  9. import java.util.Map ;
  10. import java.util.HashMap ;
  11. import com.sun.corba.se.spi.orb.ORB ;
  12. import com.sun.corba.se.spi.ior.Identifiable ;
  13. import com.sun.corba.se.spi.ior.IdentifiableFactory ;
  14. import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
  15. import com.sun.corba.se.spi.logging.CORBALogDomains ;
  16. import com.sun.corba.se.impl.logging.IORSystemException ;
  17. public abstract class IdentifiableFactoryFinderBase implements
  18. IdentifiableFactoryFinder
  19. {
  20. private ORB orb ;
  21. private Map map ;
  22. protected IORSystemException wrapper ;
  23. protected IdentifiableFactoryFinderBase( ORB orb )
  24. {
  25. map = new HashMap() ;
  26. this.orb = orb ;
  27. wrapper = IORSystemException.get( orb,
  28. CORBALogDomains.OA_IOR ) ;
  29. }
  30. protected IdentifiableFactory getFactory(int id)
  31. {
  32. Integer ident = new Integer( id ) ;
  33. IdentifiableFactory factory = (IdentifiableFactory)(map.get(
  34. ident ) ) ;
  35. return factory ;
  36. }
  37. public abstract Identifiable handleMissingFactory( int id, InputStream is ) ;
  38. public Identifiable create(int id, InputStream is)
  39. {
  40. IdentifiableFactory factory = getFactory( id ) ;
  41. if (factory != null)
  42. return factory.create( is ) ;
  43. else
  44. return handleMissingFactory( id, is ) ;
  45. }
  46. public void registerFactory(IdentifiableFactory factory)
  47. {
  48. Integer ident = new Integer( factory.getId() ) ;
  49. map.put( ident, factory ) ;
  50. }
  51. }