@Test public void doNothingInNonTransactionRequest() throws Exception { when(request.getHeader(OmegaContext.GLOBAL_TX_ID_KEY)).thenReturn(null); when(request.getHeader(OmegaContext.LOCAL_TX_ID_KEY)).thenReturn(null); requestInterceptor.preHandle(request, response, null); assertThat(omegaContext.globalTxId(), is(nullValue())); assertThat(omegaContext.localTxId(), is(nullValue())); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (omegaContext != null) { String globalTxId = request.getHeader(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(request.getHeader(LOCAL_TX_ID_KEY)); omegaContext.setCategory(request.getHeader(GLOBAL_TX_CATEGORY_KEY)); } } return true; }
TransactionHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (omegaContext != null) { String globalTxId = request.getHeader(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(request.getHeader(LOCAL_TX_ID_KEY)); omegaContext.setCategory(request.getHeader(GLOBAL_TX_CATEGORY_KEY)); } } return true; } }
TransactionHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (omegaContext != null) { String globalTxId = request.getHeader(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(request.getHeader(LOCAL_TX_ID_KEY)); omegaContext.setCategory(request.getHeader(GLOBAL_TX_CATEGORY_KEY)); } } return true; } TransactionHandlerInterceptor(OmegaContext omegaContext); }
TransactionHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (omegaContext != null) { String globalTxId = request.getHeader(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(request.getHeader(LOCAL_TX_ID_KEY)); omegaContext.setCategory(request.getHeader(GLOBAL_TX_CATEGORY_KEY)); } } return true; } TransactionHandlerInterceptor(OmegaContext omegaContext); @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override void postHandle(HttpServletRequest request, HttpServletResponse response, Object o, ModelAndView mv); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e); }
TransactionHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (omegaContext != null) { String globalTxId = request.getHeader(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(request.getHeader(LOCAL_TX_ID_KEY)); omegaContext.setCategory(request.getHeader(GLOBAL_TX_CATEGORY_KEY)); } } return true; } TransactionHandlerInterceptor(OmegaContext omegaContext); @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override void postHandle(HttpServletRequest request, HttpServletResponse response, Object o, ModelAndView mv); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e);  }