1 7 8 package com.sun.corba.se.impl.protocol ; 9 10 import javax.rmi.CORBA.Tie ; 11 12 import org.omg.CORBA.SystemException ; 13 import org.omg.CORBA.NO_IMPLEMENT ; 14 import org.omg.CORBA.OBJECT_NOT_EXIST ; 15 import org.omg.CORBA.CompletionStatus ; 16 import org.omg.CORBA.portable.InputStream ; 17 import org.omg.CORBA.portable.OutputStream ; 18 19 import com.sun.corba.se.spi.oa.ObjectAdapter; 20 import com.sun.corba.se.spi.orb.ORB; 21 22 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 23 24 import com.sun.corba.se.spi.logging.CORBALogDomains; 25 26 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 27 28 import com.sun.corba.se.spi.oa.NullServant ; 29 30 public abstract class SpecialMethod { 31 public abstract boolean isNonExistentMethod() ; 32 public abstract String getName(); 33 public abstract CorbaMessageMediator invoke(java.lang.Object servant, 34 CorbaMessageMediator request, 35 byte[] objectId, 36 ObjectAdapter objectAdapter); 37 38 public static final SpecialMethod getSpecialMethod(String operation) { 39 for(int i = 0; i < methods.length; i++) 40 if (methods[i].getName().equals(operation)) 41 return methods[i]; 42 return null; 43 } 44 45 static SpecialMethod[] methods = { 46 new IsA(), 47 new GetInterface(), 48 new NonExistent(), 49 new NotExistent() 50 }; 51 } 52 53 class NonExistent extends SpecialMethod { 54 public boolean isNonExistentMethod() 55 { 56 return true ; 57 } 58 59 public String getName() { return "_non_existent"; 61 } 62 63 public CorbaMessageMediator invoke(java.lang.Object servant, 64 CorbaMessageMediator request, 65 byte[] objectId, 66 ObjectAdapter objectAdapter) 67 { 68 boolean result = (servant == null) || (servant instanceof NullServant) ; 69 CorbaMessageMediator response = 70 request.getProtocolHandler().createResponse(request, null); 71 ((OutputStream )response.getOutputObject()).write_boolean(result); 72 return response; 73 } 74 } 75 76 class NotExistent extends NonExistent { 77 public String getName() { return "_not_existent"; 79 } 80 } 81 82 class IsA extends SpecialMethod { public boolean isNonExistentMethod() 84 { 85 return false ; 86 } 87 88 public String getName() { 89 return "_is_a"; 90 } 91 public CorbaMessageMediator invoke(java.lang.Object servant, 92 CorbaMessageMediator request, 93 byte[] objectId, 94 ObjectAdapter objectAdapter) 95 { 96 if ((servant == null) || (servant instanceof NullServant)) { 97 ORB orb = (ORB)request.getBroker() ; 98 ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb, 99 CORBALogDomains.OA_INVOCATION ) ; 100 101 return request.getProtocolHandler().createSystemExceptionResponse( 102 request, wrapper.badSkeleton(), null); 103 } 104 105 String [] ids = objectAdapter.getInterfaces( servant, objectId ); 106 String clientId = 107 ((InputStream )request.getInputObject()).read_string(); 108 boolean answer = false; 109 for(int i = 0; i < ids.length; i++) 110 if (ids[i].equals(clientId)) { 111 answer = true; 112 break; 113 } 114 115 CorbaMessageMediator response = 116 request.getProtocolHandler().createResponse(request, null); 117 ((OutputStream )response.getOutputObject()).write_boolean(answer); 118 return response; 119 } 120 } 121 122 class GetInterface extends SpecialMethod { public boolean isNonExistentMethod() 124 { 125 return false ; 126 } 127 128 public String getName() { 129 return "_interface"; 130 } 131 public CorbaMessageMediator invoke(java.lang.Object servant, 132 CorbaMessageMediator request, 133 byte[] objectId, 134 ObjectAdapter objectAdapter) 135 { 136 ORB orb = (ORB)request.getBroker() ; 137 ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb, 138 CORBALogDomains.OA_INVOCATION ) ; 139 140 if ((servant == null) || (servant instanceof NullServant)) { 141 return request.getProtocolHandler().createSystemExceptionResponse( 142 request, wrapper.badSkeleton(), null); 143 } else { 144 return request.getProtocolHandler().createSystemExceptionResponse( 145 request, wrapper.getinterfaceNotImplemented(), null); 146 } 147 } 148 } 149 150 152 | Popular Tags |