1 7 8 package com.sun.corba.se.impl.protocol ; 9 10 import java.util.Iterator ; 11 12 import org.omg.CORBA.SystemException ; 13 14 import com.sun.corba.se.pept.protocol.MessageMediator; 15 16 import com.sun.corba.se.spi.ior.IOR ; 17 import com.sun.corba.se.spi.ior.ObjectKey ; 18 import com.sun.corba.se.spi.orb.ORB ; 19 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ; 20 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 21 22 import com.sun.corba.se.impl.encoding.MarshalInputStream ; 23 import com.sun.corba.se.impl.encoding.MarshalOutputStream ; 24 25 import com.sun.corba.se.spi.logging.CORBALogDomains ; 26 27 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 28 29 42 public class BootstrapServerRequestDispatcher 43 implements CorbaServerRequestDispatcher 44 { 45 private ORB orb; 46 47 ORBUtilSystemException wrapper ; 48 49 private static final boolean debug = false; 50 51 public BootstrapServerRequestDispatcher(ORB orb ) 52 { 53 this.orb = orb; 54 this.wrapper = ORBUtilSystemException.get( orb, 55 CORBALogDomains.RPC_PROTOCOL ) ; 56 } 57 58 62 public void dispatch(MessageMediator messageMediator) 63 { 64 CorbaMessageMediator request = (CorbaMessageMediator) messageMediator; 65 CorbaMessageMediator response = null; 66 67 try { 68 MarshalInputStream is = (MarshalInputStream) 69 request.getInputObject(); 70 String method = request.getOperationName(); 71 response = request.getProtocolHandler().createResponse(request, null); 72 MarshalOutputStream os = (MarshalOutputStream) 73 response.getOutputObject(); 74 75 if (method.equals("get")) { 76 String serviceKey = is.read_string(); 78 79 org.omg.CORBA.Object serviceObject = 81 orb.getLocalResolver().resolve( serviceKey ) ; 82 83 os.write_Object(serviceObject); 85 } else if (method.equals("list")) { 86 java.util.Set keys = orb.getLocalResolver().list() ; 87 os.write_long( keys.size() ) ; 88 Iterator iter = keys.iterator() ; 89 while (iter.hasNext()) { 90 String obj = (String )iter.next() ; 91 os.write_string( obj ) ; 92 } 93 } else { 94 throw wrapper.illegalBootstrapOperation( method ) ; 95 } 96 97 } catch (org.omg.CORBA.SystemException ex) { 98 response = request.getProtocolHandler().createSystemExceptionResponse( 100 request, ex, null); 101 } catch (java.lang.RuntimeException ex) { 102 SystemException sysex = wrapper.bootstrapRuntimeException( ex ) ; 104 response = request.getProtocolHandler().createSystemExceptionResponse( 105 request, sysex, null ) ; 106 } catch (java.lang.Exception ex) { 107 SystemException sysex = wrapper.bootstrapException( ex ) ; 109 response = request.getProtocolHandler().createSystemExceptionResponse( 110 request, sysex, null ) ; 111 } 112 113 return; 114 } 115 116 121 public IOR locate( ObjectKey objectKey) { 122 return null; 123 } 124 125 128 public int getId() { 129 throw wrapper.genericNoImpl() ; 130 } 131 } 132 | Popular Tags |