@Override
  protected void manageTransaction() throws Throwable {
    // first associate the tx on this thread, by resuming the tx
    final Transaction transaction =
        this.transactionsRepository.getImportedTransaction(this.xidTransactionID);
    if (transaction == null) {
      if (EjbLogger.EJB3_INVOCATION_LOGGER.isDebugEnabled()) {
        // this happens if no ejb invocations where made within the TX
        EjbLogger.EJB3_INVOCATION_LOGGER.debug(
            "Not forgetting transaction "
                + this.xidTransactionID
                + " as is was not found on the server");
      }
      return;
    }
    this.resumeTransaction(transaction);

    // "forget"
    final Xid xid = this.xidTransactionID.getXid();
    try {
      // get the subordinate tx
      final SubordinateTransaction subordinateTransaction =
          SubordinationManager.getTransactionImporter().getImportedTransaction(xid);

      if (subordinateTransaction == null) {
        throw new XAException(XAException.XAER_INVAL);
      }
      // invoke forget
      subordinateTransaction.doForget();

    } catch (Exception ex) {
      final XAException xaException = new XAException(XAException.XAER_RMERR);
      xaException.initCause(ex);
      throw xaException;

    } finally {
      SubordinationManager.getTransactionImporter().removeImportedTransaction(xid);
      // disassociate the tx that was associated (resumed) on this thread.
      // This needs to be done explicitly because the SubOrdinationManager isn't responsible
      // for clearing the tx context from the thread
      this.transactionsRepository.getTransactionManager().suspend();
    }
  }
Пример #2
0
  /**
   * 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, 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 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 {
        try {
          OutputStream out = (OutputStream) _request(operationName, true);
          stubStrategy.writeParams(out, params);
          trace("sent request: " + operationName);
          in = (InputStream) _invoke(out);
          if (stubStrategy.isNonVoid()) {
            trace("received reply");
            return stubStrategy.readRetval(in);
            // Object retval = stubStrategy.readRetval(in);
            // trace("retval: " + retval);
            // return retval;
          } else return null;
        } catch (ApplicationException ex) {
          trace("got application exception");
          in = (InputStream) ex.getInputStream();
          throw stubStrategy.readException(ex.getId(), in);
        } 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);
      }
    } else {
      // local call path
      org.omg.CORBA.portable.ServantObject so = _servant_preinvoke(operationName, Object.class);
      if (so == null) return invoke(operationName, stubStrategy, params);
      try {
        // params = Util.copyObjects(params, _orb());
        Object retval =
            ((LocalIIOPInvoker) so.servant)
                .invoke(
                    operationName,
                    params,
                    null, /* tx */
                    null, /* identity */
                    null /* credential */);
        return stubStrategy.convertLocalRetval(retval);
        // retval = stubStrategy.convertLocalRetval(retval);
        // return Util.copyObject(retval, _orb());
      } catch (Throwable e) {
        // Throwable ex = (Throwable)Util.copyObject(e, _orb());
        Throwable ex = e;
        if (stubStrategy.isDeclaredException(ex)) throw ex;
        else throw Util.wrapException(ex);
      } finally {
        _servant_postinvoke(so);
      }
    }
  }
Пример #3
0
 private static void trace(final String msg) {
   if (EjbLogger.EJB3_INVOCATION_LOGGER.isTraceEnabled())
     EjbLogger.EJB3_INVOCATION_LOGGER.trace(msg);
 }