ejb3/src/main/java/org/jboss/as/ejb3/iiop/stub/DynamicIIOPStub.java
public Object invoke(String operationName, final StubStrategy stubStrategy, Object[] params) throws Throwable {
        if (operationName.equals("_get_handle")
                && this instanceof javax.ejb.EJBObject) {
            if (handle == null) {
                handle = new HandleImplIIOP(this);
            }
            return handle;
        } else if (operationName.equals("_get_homeHandle")
                && this instanceof javax.ejb.EJBHome) {
            if (handle == null) {
                handle = new HomeHandleImplIIOP(this);
            }
            return handle;
        } else {
            //FIXME
            // all invocations are now made using remote invocation
            // local invocations between two different applications cause
            // ClassCastException between Stub and Interface
            // (two different modules are loading the classes)
            // problem was unnoticeable with JacORB because it uses
            // remote invocations to all stubs to which interceptors are
            // registered and a result all that JacORB always used
            // remote invocations

            // 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 {
                try {
                    OutputStream out =
                            (OutputStream) _request(operationName, true);
                    stubStrategy.writeParams(out, params);
                    tracef("sent request: %s", operationName);
                    in = (InputStream) _invoke(out);
                    if (stubStrategy.isNonVoid()) {
                        trace("received reply");
                        final InputStream finalIn = in;
                        return doPrivileged(new PrivilegedAction<Object>() {
                            public Object run() {
                                return stubStrategy.readRetval(finalIn);
                            }
                        });
                    } else {
                        return null;
                    }
                } catch (final ApplicationException ex) {
                    trace("got application exception");
                    in = (InputStream) ex.getInputStream();
                    final InputStream finalIn1 = in;
                    throw doPrivileged(new PrivilegedAction<Exception>() {
                        public Exception run() {
                            return stubStrategy.readException(ex.getId(), finalIn1);
                        }
                    });
                } catch (RemarshalException ex) {
                    trace("got remarshal exception");
                    return invoke(operationName, stubStrategy, params);
                }
            } catch (SystemException ex) {
                if (EjbLogger.EJB3_INVOCATION_LOGGER.isTraceEnabled()) {
                    EjbLogger.EJB3_INVOCATION_LOGGER.trace("CORBA system exception in IIOP stub", ex);
                }
                throw Util.mapSystemException(ex);
            } finally {
                _releaseReply(in);
            }
        }
    }
public Object invoke(String operationName, final StubStrategy stubStrategy, Object[] params) throws Throwable {
        if (operationName.equals("_get_handle")
                && this instanceof javax.ejb.EJBObject) {
            if (handle == null) {
                handle = new HandleImplIIOP(this);
            }
            return handle;
        } else if (operationName.equals("_get_homeHandle")
                && this instanceof javax.ejb.EJBHome) {
            if (handle == null) {
                handle = new HomeHandleImplIIOP(this);
            }
            return handle;
        } else {
            //FIXME
            // all invocations are now made using remote invocation
            // local invocations between two different applications cause
            // ClassCastException between Stub and Interface
            // (two different modules are loading the classes)
            // problem was unnoticeable with JacORB because it uses
            // remote invocations to all stubs to which interceptors are
            // registered and a result all that JacORB always used
            // remote invocations

            // 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 {
                try {
                    OutputStream out =
                            (OutputStream) _request(operationName, true);
                    stubStrategy.writeParams(out, params);
                    tracef("sent request: %s", operationName);
                    in = (InputStream) _invoke(out);
                    if (stubStrategy.isNonVoid()) {
                        trace("received reply");
                        final InputStream finalIn = in;
                        return doPrivileged(new PrivilegedAction<Object>() {
                            public Object run() {
                                return stubStrategy.readRetval(finalIn);
                            }
                        });
                    } else {
                        return null;
                    }
                } catch (final ApplicationException ex) {
                    trace("got application exception");
                    in = (InputStream) ex.getInputStream();
                    final InputStream finalIn1 = in;
                    throw doPrivileged(new PrivilegedAction<Exception>() {
                        public Exception run() {
                            return stubStrategy.readException(ex.getId(), finalIn1);
                        }
                    });
                } catch (RemarshalException ex) {
                    trace("got remarshal exception");
                    return invoke(operationName, stubStrategy, params);
                }
            } catch (SystemException ex) {
                if (EjbLogger.EJB3_INVOCATION_LOGGER.isTraceEnabled()) {
                    EjbLogger.EJB3_INVOCATION_LOGGER.trace("CORBA system exception in IIOP stub", ex);
                }
                throw Util.mapSystemException(ex);
            } finally {
                _releaseReply(in);
            }
        }
    }
Sends a request message to the server, receives the reply from the
server, and returns an <code>Object</code> result to the caller.