User: reverbel Date: 01/11/26 15:41:21 Modified: iiop/src/main/org/jboss/ejb/plugins/iiop/client DynamicStub.java Log: Added implementations of getHandle()/getHomeHandle() to the DynamicStub base class. Added local call path for co-located IIOP invocations. Revision Changes Path 1.4 +89 -29 contrib/iiop/src/main/org/jboss/ejb/plugins/iiop/client/DynamicStub.java Index: DynamicStub.java =================================================================== RCS file: /cvsroot/jboss/contrib/iiop/src/main/org/jboss/ejb/plugins/iiop/client/DynamicStub.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DynamicStub.java 2001/11/21 12:30:24 1.3 +++ DynamicStub.java 2001/11/26 23:41:21 1.4 @@ -14,6 +14,9 @@ import org.omg.CORBA.portable.RemarshalException; import org.omg.CORBA.SystemException; +import org.jboss.ejb.plugins.iiop.HandleImpl; +import org.jboss.ejb.plugins.iiop.HomeHandleImpl; +import org.jboss.ejb.plugins.iiop.LocalInvoker; import org.jboss.proxy.InvocationHandler; /** @@ -30,12 +33,19 @@ * of operation parameters. * * @author <a href="mailto:[EMAIL PROTECTED]">Francisco Reverbel</a> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public abstract class DynamicStub extends javax.rmi.CORBA.Stub { + // Attributes ------------------------------------------------------------- + + /** + * My handle (either a HandleImpl or a HomeHandleImpl). + */ + private Object handle = null; + // Constructor ------------------------------------------------------------- /** @@ -56,43 +66,93 @@ StubStrategy stubStrategy, Object[] params) throws Throwable { - InputStream in = null; - try { + if (operationName.equals("_get_handle") + && this instanceof javax.ejb.EJBObject) { + if (handle == null) { + handle = new HandleImpl(this); + } + return handle; + } + else if (operationName.equals("_get_homeHandle") + && this instanceof javax.ejb.EJBHome) { + if (handle == null) { + handle = new HomeHandleImpl(this); + } + return handle; + } + else if (!_is_local()) { + // remote call path + + // To check whether this is a local stub or not we must call + // org.omg.CORBA.portable.ObjectImpl._is_local(), and _not_ + // javax.rmi.CORBA.Util.isLocal(Stub s), which in Sun's JDK + // always return false. + + InputStream in = null; try { - OutputStream out = + try { + OutputStream out = (OutputStream)_request(operationName, true); - stubStrategy.writeParams(out, params); - System.err.println("sent request: " + operationName); - in = (InputStream)_invoke(out); - if (stubStrategy.isNonVoid()) { - System.err.println("received reply"); - //return stubStrategy.readRetval(in); - Object retval = stubStrategy.readRetval(in); - System.err.println("retval: " + retval); - return retval; + stubStrategy.writeParams(out, params); + //System.err.println("sent request: " + operationName); + in = (InputStream)_invoke(out); + if (stubStrategy.isNonVoid()) { + //System.err.println("received reply"); + return stubStrategy.readRetval(in); + //Object retval = stubStrategy.readRetval(in); + //System.err.println("retval: " + retval); + //return retval; + } + else + return null; } - else - return null; + catch (ApplicationException ex) { + //System.err.println("got application exception"); + in =(InputStream)ex.getInputStream(); + throw stubStrategy.readException(in); + } + catch (RemarshalException ex) { + //System.err.println("got remarshal exception"); + return invoke(operationName, stubStrategy, params); + } } - catch (ApplicationException ex) { - System.err.println("got application exception"); - in =(InputStream)ex.getInputStream(); - throw stubStrategy.readException(in); + catch (SystemException ex) { + //ex.printStackTrace(System.err); + throw Util.mapSystemException(ex); } - catch (RemarshalException ex) { - System.err.println("got remarshal exception"); - return invoke(operationName, stubStrategy, params); + finally { + _releaseReply(in); } - } - catch (SystemException ex) { - ex.printStackTrace(System.err); - throw Util.mapSystemException(ex); } - finally { - _releaseReply(in); + else { + // local call path + org.omg.CORBA.portable.ServantObject so = + _servant_preinvoke(operationName, java.lang.Object.class); + if (so == null) + return invoke(operationName, stubStrategy, params); + try { + params = Util.copyObjects(params, _orb()); + Object retval = + ((LocalInvoker)so.servant).invoke(operationName, + params, + null, /* tx */ + null, /* identity */ + null /* credential */); + return Util.copyObject(retval, _orb()); + } + catch(Throwable e) { + Throwable ex = (Throwable)Util.copyObject(e, _orb()); + if (stubStrategy.isDeclaredException(ex)) + throw ex; + else + throw Util.wrapException(ex); + } + finally { + _servant_postinvoke(so); + } } } - + /** * Sends a request message to the server, receives the reply from the * server, and returns a <code>boolean</code> result to the caller.
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development