public MessageExchange getMessageExchange(final String mexId) throws BpelEngineException { final MessageExchangeDAO inmemdao = getInMemMexDAO(mexId); Callable<MessageExchange> loadMex = new Callable<MessageExchange>() { public MessageExchange call() { MessageExchangeDAO mexdao = (inmemdao == null) ? mexdao = _contexts.dao.getConnection().getMessageExchange(mexId) : inmemdao; if (mexdao == null) return null; ProcessDAO pdao = mexdao.getProcess(); ODEProcess process = pdao == null ? null : _registeredProcesses.get(pdao.getProcessId()); if (process == null) { String errmsg = __msgs.msgProcessNotActive(pdao.getProcessId()); __log.error(errmsg); // TODO: Perhaps we should define a checked exception for this // condition. throw new BpelEngineException(errmsg); } InvocationStyle istyle = mexdao.getInvocationStyle(); if (istyle == InvocationStyle.RELIABLE || istyle == InvocationStyle.TRANSACTED) assertTransaction(); switch (mexdao.getDirection()) { case MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE: return process.createPartnerRoleMex(mexdao); case MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE: return process.lookupMyRoleMex(mexdao); default: String errmsg = "BpelEngineImpl: internal error, invalid MexDAO direction: " + mexId; __log.fatal(errmsg); throw new BpelEngineException(errmsg); } } }; try { if (inmemdao != null || _contexts.isTransacted()) return loadMex.call(); else return enqueueTransaction(loadMex).get(); } catch (ContextException e) { throw new BpelEngineException(e); } catch (Exception e) { throw new BpelEngineException(e); } }
protected void assertNoTransaction() { if (_contexts.isTransacted()) throw new BpelEngineException("Operation must be performed outside of a transaction!"); }
protected void assertTransaction() { if (!_contexts.isTransacted()) throw new BpelEngineException("Operation must be performed in a transaction!"); }