public MultiPRODelegate() throws RemoteException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.MultiPRODelegate()"); } try { initProtocols(); } catch (Exception e) { String msg = "MultiPRODelegate, init protocols fail"; TraceCarol.error(msg,e); throw new RemoteException(msg); } }
if (!ri.hasContexts()) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper send request without contexts"); out.writeInt(k); if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper send request with local contexts id("+k+")"); TraceCarol.debugRmiCarol("ctx:" + i.next()); TraceCarol.debugRmiCarol("JClientInterceptorHelper send request with remote contexts"); TraceCarol.debugRmiCarol("ctx:" + i.next());
if (!ri.hasContexts()) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send without contexts"); out.writeInt(k); if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send with local contexts id("+k+")"); TraceCarol.debugRmiCarol("JServerInterceptorHelper send with remote contexts");
if (ctxValue==NO_CTX) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper receive no context"); TraceCarol.debugRmiCarol("JServerInterceptorHelper receive remote contexts"); TraceCarol.debugRmiCarol("ctx:" + i.next()); TraceCarol.debugRmiCarol("JServerInterceptorHelper receive local contexts id("+id+")"); TraceCarol.debugRmiCarol("ctx:" + i.next());
if (ctxValue==NO_CTX) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper getObjectFromInput no context"); TraceCarol.debugRmiCarol("JClientInterceptorHelper getObjectFromInput remote"); TraceCarol.debugRmiCarol("JClientInterceptorHelper getObjectFromInput local id("+id+")");
/** * Connection method all available protocols * @param target a remote object; * @param source another remote object; * @exception RemoteException if the connection fail */ public void connect(Remote target,Remote source) throws RemoteException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.connect("+simpleClass(target.getClass().getName()) + " target," +simpleClass(source.getClass().getName()) +" source)"); } try { if (!init) { initProtocols(); } for (Enumeration e = activesProtocols.elements(); e.hasMoreElements() ;) { ((PortableRemoteObjectDelegate)e.nextElement()).connect(target, source); } } catch (Exception e) { String msg = "MultiPRODelegate.connect(Remote target,Remote source) fail"; TraceCarol.error(msg,e); throw new RemoteException(msg); } }
/** * Private method for orb intanciation */ private void initProtocols() throws Exception { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.initProtocols()"); } pcur = ProtocolCurrent.getCurrent(); activesProtocols = pcur.getPortableRemoteObjectHashtable(); init = true; }
/** * Export a Remote Object on all available protocols * @param Remote object to export * @exception RemoteException exporting remote object problem */ public void exportObject(Remote obj) throws RemoteException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.exportObject(" +simpleClass(obj.getClass().getName()) +" obj)"); } try { if (!init) { initProtocols(); } for (Enumeration e = activesProtocols.elements(); e.hasMoreElements() ;) { ((PortableRemoteObjectDelegate)e.nextElement()).exportObject(obj); } if (TraceCarol.isDebugExportCarol()) { TraceCarol.debugExportCarol("Export object "+obj.getClass().getName()); addObject(obj.getClass().getName()); } } catch (Exception ex) { String msg = "MultiPRODelegate.exportObject(Remote obj) fail"; TraceCarol.error(msg,ex); throw new RemoteException(msg); } }
public static void receive_other(ObjectInput in, JClientRequestInterceptor [] cis) throws IOException { try { int ctxValue= in.readInt(); JClientRequestInfo jrc = new JRMPClientRequestInfoImpl(); if ((cis == null)||(cis.length==0)) { // no interceptions if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper receive other without interceptors"); } getClientRequestContextFromInput(in, ctxValue, jrc); } else { // context and interception if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper receive other contexts"); } JClientRequestInfo ri = getClientRequestContextFromInput(in, ctxValue,jrc); for (int i = 0; i < cis.length; i++) { cis[i].receive_other(ri); } } } catch (ClassNotFoundException cnfe) { throw new IOException("" +cnfe); } }
TraceCarol.debugRmiCarol("JClientInterceptorHelper receive exception without interceptors"); TraceCarol.debugRmiCarol("JClientInterceptorHelper receive exception contexts");
/** * Receive request * @param ObjectInput in * @param JServerRequestInterceptor All interceptor for this context * @exception IOException if an exception occur with the ObjectOutput */ public static void receive_request(ObjectInput in, JServerRequestInterceptor [] sis) throws IOException { try { int ctxValue= in.readInt(); JServerRequestInfo jsr = new JRMPServerRequestInfoImpl(); if ((sis==null)||(sis.length==0)) { // no interceptions if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper receive request without interceptors"); } getRequestServerContextFromInput(in, ctxValue, jsr); } else { // context and interception if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper receive request contexts"); } JServerRequestInfo ri = getRequestServerContextFromInput(in, ctxValue, jsr); for (int i = 0; i < sis.length; i++) { sis[i].receive_request(ri); } } } catch (ClassNotFoundException cnfe) { throw new IOException("" + cnfe); } }
/** * Receive reply interception * @param ObjectInput in * @param ClientRequestInterceptor All interceptor for this context * @exception IOException if an exception occur with the ObjectOutput */ public static void receive_reply(ObjectInput in, JClientRequestInterceptor [] cis)throws IOException { try { int ctxValue= in.readInt(); JClientRequestInfo jrc = new JRMPClientRequestInfoImpl(); if ((cis == null)||(cis.length==0)) { // no interceptions if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper receive reply without interceptors"); } getClientRequestContextFromInput(in, ctxValue, jrc); } else { // context and interception if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper receive reply contexts"); } JClientRequestInfo ri = getClientRequestContextFromInput(in, ctxValue, jrc); for (int i = 0; i < cis.length; i++) { cis[i].receive_reply(ri); } } } catch (ClassNotFoundException cnfe) { throw new IOException("" + cnfe); } }
/** * send exception with context * @param ObjectOutput out * @param JServerRequestInterceptor All interceptor for this context * @exception IOException if an exception occur with the ObjectOutput */ public static void send_exception(ObjectOutput out, JServerRequestInterceptor [] sis) throws IOException { if ((sis == null)||(sis.length==0)) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send exception without context"); } // send no service context out.writeInt(NO_CTX); } else { JServerRequestInfo jsr = new JRMPServerRequestInfoImpl(); if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send exception contexts"); } for (int i = 0; i < sis.length; i++) { sis[i].send_exception(jsr); } setServerContextInOutput(out, jsr, isLocal()); threadCtx.set(null); } // flush and reset output stream for garbage collection out.flush(); }
/** * Method for unexport object on all available protocols * @param Remote obj object to unexport * @exception NoSuchObjectException if the object is not currently exported */ public void unexportObject(Remote obj) throws NoSuchObjectException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.unexportObject(" +simpleClass(obj.getClass().getName()) +" obj)"); } try { if (!init) { initProtocols(); } for (Enumeration e = activesProtocols.elements(); e.hasMoreElements() ;) { ((PortableRemoteObjectDelegate)e.nextElement()).unexportObject(obj); } if (TraceCarol.isDebugExportCarol()) { TraceCarol.debugExportCarol("Unexport object "+obj.getClass().getName()); TraceCarol.debugExportCarol("UnExported objects list:\n"+getUnexportedObjects()); removeObject(obj.getClass().getName()); } } catch (Exception ex) { String msg = "MultiPRODelegate.unexportObject(Remote obj) fail"; TraceCarol.error(msg,ex); throw new NoSuchObjectException(msg); } }
public static void send_other(ObjectOutput out, JServerRequestInterceptor [] sis) throws IOException { if ((sis == null)||(sis.length==0)) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send other with no contexts"); } // send no service context out.writeInt(NO_CTX); } else { JServerRequestInfo jsr = new JRMPServerRequestInfoImpl(); for (int i = 0; i < sis.length; i++) { sis[i].send_other(jsr); } setServerContextInOutput(out, jsr, isLocal()); threadCtx.set(null); } // flush and reset output stream for garbage collection out.flush(); }
/** * send reply with context * @param ObjectOutput out * @param JServerRequestInterceptor All interceptor for this context * @exception IOException if an exception occur with the ObjectOutput */ public static void send_reply(ObjectOutput out, JServerRequestInterceptor [] sis) throws IOException { if ((sis==null)||(sis.length==0)) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JServerInterceptorHelper send reply without context"); } // send no service context out.writeInt(NO_CTX); } else { JServerRequestInfo jsr = new JRMPServerRequestInfoImpl(); for (int i = 0; i < sis.length; i++) { sis[i].send_reply(jsr); } setServerContextInOutput(out, jsr, isLocal()); threadCtx.set(null); } // flush and reset output stream for garbage collection out.flush(); }
/** * send client context with the request. The sendingRequest method of the PortableInterceptors * is called prior to marshalling arguments and contexts * @param ObjectOutput out * @param ClientRequestInterceptor All interceptor for this context * @exception IOException if an exception occur with the ObjectOutput */ public static void send_request(ObjectOutput out, JClientRequestInterceptor [] cis, boolean localRef) throws IOException { if ((cis==null)||(cis.length==0)) { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("JClientInterceptorHelper send request without interceptors"); } // send no service context out.writeInt(NO_CTX); } else { JClientRequestInfo jrc = new JRMPClientRequestInfoImpl(); for (int i = 0; i < cis.length; i++) { cis[i].send_request(jrc); } setClientContextInOutput(out, jrc, localRef); } // flush and reset output stream for garbage collection out.flush(); }
/** * Narrow method on the default protocol * @param Remote obj the object to narrow * @param Class newClass the expected type of the result * @return an object of type newClass * @exception ClassCastException if the obj class is not compatible with a newClass cast */ public Object narrow(Object obj, Class newClass ) throws ClassCastException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.narrow("+simpleClass(obj.getClass().getName()) + " obj," +simpleClass(newClass.getName()) +" class)/rmi name=\""+ pcur.getCurrentRMIName()+"\""); } try { if (init) { return pcur.getCurrentPortableRemoteObject().narrow(obj, newClass); } else { initProtocols(); return pcur.getCurrentPortableRemoteObject().narrow(obj, newClass); } } catch (Exception e) { String msg = "MultiPRODelegate.narrow(Object obj, Class newClass) fail"; TraceCarol.error(msg,e); throw new ClassCastException (msg); } }
/** * To stub method on the iiop protocol * @return the stub object * @param Remote object to unexport * @exception NoSuchObjectException if the object is not currently exported */ public Remote toStub(Remote obj) throws NoSuchObjectException { if (TraceCarol.isDebugRmiCarol()) { TraceCarol.debugRmiCarol("MultiPRODelegate.toStub(" +simpleClass(obj.getClass().getName()) +" obj)/rmi name=\"" +pcur.getCurrentRMIName()+"\""); } try { if (init) { return pcur.getCurrentPortableRemoteObject().toStub(obj); } else { initProtocols(); return pcur.getCurrentPortableRemoteObject().toStub(obj); } } catch (Exception e) { String msg = "MultiPRODelegate.toStub(Remote obj) fail"; TraceCarol.error(msg,e); throw new NoSuchObjectException(msg); } }