Пример #1
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    boolean isTaskInvoked;
    try {
      // Create the initial context
      InitialContext initialContext = new InitialContext();

      // Obtain the OfficeFloor
      OfficeFloor officeFloor =
          (OfficeFloor) initialContext.lookup(ValidateWork.getOfficeFloorJndiName(false));

      // Invoke the task
      ValidateWork.reset();
      ValidateWork.invokeWork(officeFloor, null);

      // Obtain whether the task was invoked
      isTaskInvoked = ValidateWork.isTaskInvoked();

    } catch (Exception ex) {
      throw new ServletException(ex);
    }

    // Provide response
    PrintWriter body = response.getWriter();
    body.print(String.valueOf(isTaskInvoked));
    body.close();
  }
Пример #2
0
  @Override
  public boolean runOfficeFloor() throws Exception {

    // Obtain the initial context
    Context initialContext = new InitialContext();

    // Obtain the OfficeFloor
    String jndiName = ValidateWork.getOfficeFloorJndiName(false);
    OfficeFloor officeFloor = (OfficeFloor) initialContext.lookup(jndiName);

    // Invoke the Work
    ValidateWork.reset();
    ValidateWork.invokeWork(officeFloor, null);

    // Return whether invoked
    return ValidateWork.isTaskInvoked();
  }