コード例 #1
0
 static void fillAspectContext(
     AspectContext context, HandlerContext handlerContext, String[] handlerIdList)
     throws SQLException {
   context.put(MAD_TX_MANAGER, handlerContext.getTransaction());
   context.put(Keys.USER_NAME, handlerContext.getUserProfil().getId().getLogin());
   context.put(Keys.USER, handlerContext.getUserProfil());
   context.put(TransactionalPoint.CONNECTION, handlerContext.getTxConnection());
   context.put(TransactionalPoint.ARGUMENT, handlerIdList);
 }
コード例 #2
0
  public String executeRequests(String requests, HandlerContext handlerContext)
      throws RequestFailureException {
    Connection txConnection = null;

    try {
      Document document = parse(requests);
      handlerContext.setUser(extractUser(document));

      txConnection = handlerContext.getTxConnection();
      QueryManager queryManager = queryManagerBuilder.build(document);

      AspectContext aspectContext = new AspectContext();
      fillAspectContext(aspectContext, handlerContext, queryManager.getHandlerIdList());
      aspectContext.put(QueryManager.class.getName(), queryManager);

      ExecuteHandlerPointRunner runner = new ExecuteHandlerPointRunner(handlerContext, document);

      point.run(aspectContext, runner);

      return runner.getResult();
    } catch (PointRunnerException pointRunnerException) {
      if (pointRunnerException.getCause() instanceof RequestFailureException) {
        throw (RequestFailureException) pointRunnerException.getCause();
      } else {
        throw new RequestFailureException(
            "runtimeError", (Exception) pointRunnerException.getCause());
      }
    } catch (Exception exception) {
      throw new RequestFailureException("runtimeError", exception);
    } finally {
      if (txConnection != null) {
        try {
          txConnection.close();
        } catch (SQLException sqlException) {
          throw new RequestFailureException("runtimeError can't close txConnection", sqlException);
        }
      }
    }
  }
コード例 #3
0
 private AspectContext createAspectContext(String handlerId) {
   AspectContext context = new AspectContext();
   context.put(TransactionalPoint.CONNECTION, new ConnectionMock());
   context.put(TransactionalPoint.ARGUMENT, handlerId);
   return context;
 }