1 7 8 package com.sun.corba.se.impl.protocol; 9 10 import java.util.Set ; 11 import java.util.HashSet ; 12 import java.util.Map ; 13 import java.util.HashMap ; 14 import java.util.Collections ; 15 16 import com.sun.corba.se.pept.protocol.ClientRequestDispatcher ; 17 18 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher ; 19 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcherFactory ; 20 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ; 21 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ; 22 23 import com.sun.corba.se.spi.oa.ObjectAdapterFactory ; 24 25 import com.sun.corba.se.spi.orb.ORB ; 26 27 import com.sun.corba.se.impl.orbutil.ORBConstants ; 28 import com.sun.corba.se.impl.orbutil.DenseIntMapImpl ; 29 30 35 public class RequestDispatcherRegistryImpl implements RequestDispatcherRegistry { 36 private ORB orb; 37 38 protected int defaultId; private DenseIntMapImpl SDRegistry ; private DenseIntMapImpl CSRegistry ; private DenseIntMapImpl OAFRegistry ; private DenseIntMapImpl LCSFRegistry ; private Set objectAdapterFactories ; private Set objectAdapterFactoriesView ; private Map stringToServerSubcontract ; 51 public RequestDispatcherRegistryImpl(ORB orb, int defaultId ) 52 { 53 this.orb = orb; 54 this.defaultId = defaultId; 55 SDRegistry = new DenseIntMapImpl() ; 56 CSRegistry = new DenseIntMapImpl() ; 57 OAFRegistry = new DenseIntMapImpl() ; 58 LCSFRegistry = new DenseIntMapImpl() ; 59 objectAdapterFactories = new HashSet () ; 60 objectAdapterFactoriesView = Collections.unmodifiableSet( objectAdapterFactories ) ; 61 stringToServerSubcontract = new HashMap () ; 62 } 63 64 public synchronized void registerClientRequestDispatcher( 65 ClientRequestDispatcher csc, int scid) 66 { 67 CSRegistry.set( scid, csc ) ; 68 } 69 70 public synchronized void registerLocalClientRequestDispatcherFactory( 71 LocalClientRequestDispatcherFactory csc, int scid) 72 { 73 LCSFRegistry.set( scid, csc ) ; 74 } 75 76 public synchronized void registerServerRequestDispatcher( 77 CorbaServerRequestDispatcher ssc, int scid) 78 { 79 SDRegistry.set( scid, ssc ) ; 80 } 81 82 public synchronized void registerServerRequestDispatcher( 83 CorbaServerRequestDispatcher scc, String name ) 84 { 85 stringToServerSubcontract.put( name, scc ) ; 86 } 87 88 public synchronized void registerObjectAdapterFactory( 89 ObjectAdapterFactory oaf, int scid) 90 { 91 objectAdapterFactories.add( oaf ) ; 92 OAFRegistry.set( scid, oaf ) ; 93 } 94 95 99 107 public CorbaServerRequestDispatcher getServerRequestDispatcher(int scid) 108 { 109 CorbaServerRequestDispatcher sdel = 110 (CorbaServerRequestDispatcher)(SDRegistry.get(scid)) ; 111 if ( sdel == null ) 112 sdel = (CorbaServerRequestDispatcher)(SDRegistry.get(defaultId)) ; 113 114 return sdel; 115 } 116 117 public CorbaServerRequestDispatcher getServerRequestDispatcher( String name ) 118 { 119 CorbaServerRequestDispatcher sdel = 120 (CorbaServerRequestDispatcher)stringToServerSubcontract.get( name ) ; 121 122 if ( sdel == null ) 123 sdel = (CorbaServerRequestDispatcher)(SDRegistry.get(defaultId)) ; 124 125 return sdel; 126 } 127 128 public LocalClientRequestDispatcherFactory getLocalClientRequestDispatcherFactory( 129 int scid ) 130 { 131 LocalClientRequestDispatcherFactory factory = 132 (LocalClientRequestDispatcherFactory)(LCSFRegistry.get(scid)) ; 133 if (factory == null) { 134 factory = (LocalClientRequestDispatcherFactory)(LCSFRegistry.get(defaultId)) ; 135 } 136 137 return factory ; 138 } 139 140 public ClientRequestDispatcher getClientRequestDispatcher( int scid ) 141 { 142 ClientRequestDispatcher subcontract = 143 (ClientRequestDispatcher)(CSRegistry.get(scid)) ; 144 if (subcontract == null) { 145 subcontract = (ClientRequestDispatcher)(CSRegistry.get(defaultId)) ; 146 } 147 148 return subcontract ; 149 } 150 151 public ObjectAdapterFactory getObjectAdapterFactory( int scid ) 152 { 153 ObjectAdapterFactory oaf = 154 (ObjectAdapterFactory)(OAFRegistry.get(scid)) ; 155 if ( oaf == null ) 156 oaf = (ObjectAdapterFactory)(OAFRegistry.get(defaultId)) ; 157 158 return oaf; 159 } 160 161 public Set getObjectAdapterFactories() 162 { 163 return objectAdapterFactoriesView ; 164 } 165 } 166 | Popular Tags |