1 7 8 package com.sun.corba.se.spi.servicecontext; 9 10 import org.omg.CORBA.BAD_PARAM ; 11 import java.util.Vector ; 12 import java.util.Enumeration ; 13 import com.sun.corba.se.spi.servicecontext.ServiceContext ; 14 import com.sun.corba.se.spi.servicecontext.ServiceContextData ; 15 import com.sun.corba.se.spi.orb.ORB ; 16 import com.sun.corba.se.impl.orbutil.ORBUtility ; 17 18 public class ServiceContextRegistry { 19 private ORB orb ; 20 private Vector scCollection ; 21 22 private void dprint( String msg ) 23 { 24 ORBUtility.dprint( this, msg ) ; 25 } 26 27 public ServiceContextRegistry( ORB orb ) 28 { 29 scCollection = new Vector () ; 30 this.orb = orb ; 31 } 32 33 44 public void register( Class cls ) 45 { 46 if (ORB.ORBInitDebug) 47 dprint( "Registering service context class " + cls ) ; 48 49 ServiceContextData scd = new ServiceContextData( cls ) ; 50 51 if (findServiceContextData(scd.getId()) == null) 52 scCollection.addElement( scd ) ; 53 else 54 throw new BAD_PARAM ( "Tried to register duplicate service context" ) ; 55 } 56 57 public ServiceContextData findServiceContextData( int scId ) 58 { 59 if (ORB.ORBInitDebug) 60 dprint( "Searching registry for service context id " + scId ) ; 61 62 Enumeration enumeration = scCollection.elements() ; 63 while (enumeration.hasMoreElements()) { 64 ServiceContextData scd = 65 (ServiceContextData)(enumeration.nextElement()) ; 66 if (scd.getId() == scId) { 67 if (ORB.ORBInitDebug) 68 dprint( "Service context data found: " + scd ) ; 69 70 return scd ; 71 } 72 } 73 74 if (ORB.ORBInitDebug) 75 dprint( "Service context data not found" ) ; 76 77 return null ; 78 } 79 } 80 | Popular Tags |