Search in sources :

Example 1 with OutputStream

use of org.omg.CORBA_2_3.portable.OutputStream in project wildfly by wildfly.

the class DynamicIIOPStub method invoke.

/**
 * Sends a request message to the server, receives the reply from the
 * server, and returns an <code>Object</code> result to the caller.
 */
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);
        }
    }
}
Also used : InputStream(org.omg.CORBA_2_3.portable.InputStream) OutputStream(org.omg.CORBA_2_3.portable.OutputStream) RemarshalException(org.omg.CORBA.portable.RemarshalException) ApplicationException(org.omg.CORBA.portable.ApplicationException) SystemException(org.omg.CORBA.SystemException) RemarshalException(org.omg.CORBA.portable.RemarshalException) ApplicationException(org.omg.CORBA.portable.ApplicationException) SystemException(org.omg.CORBA.SystemException) HandleImplIIOP(org.jboss.ejb.iiop.HandleImplIIOP) HomeHandleImplIIOP(org.jboss.ejb.iiop.HomeHandleImplIIOP) PrivilegedAction(java.security.PrivilegedAction) HomeHandleImplIIOP(org.jboss.ejb.iiop.HomeHandleImplIIOP)

Aggregations

PrivilegedAction (java.security.PrivilegedAction)1 HandleImplIIOP (org.jboss.ejb.iiop.HandleImplIIOP)1 HomeHandleImplIIOP (org.jboss.ejb.iiop.HomeHandleImplIIOP)1 SystemException (org.omg.CORBA.SystemException)1 ApplicationException (org.omg.CORBA.portable.ApplicationException)1 RemarshalException (org.omg.CORBA.portable.RemarshalException)1 InputStream (org.omg.CORBA_2_3.portable.InputStream)1 OutputStream (org.omg.CORBA_2_3.portable.OutputStream)1