public Object rollback(Object obj) throws StorageException, CommunicationException {

    try {

      testStorage();

      return storage.rollback(obj);

    } // try
    catch (CommunicationException error) {

      writeLog("Erro de comunicacao: " + error.getMessage());

      for (int counter = 0; counter < getTryNumber(); counter++) {

        try {

          sleep();

          createStorage();

          return storage.rollback(obj);

        } // try
        catch (CommunicationException error1) {

          writeLog("Erro de comunicacao: " + error.getMessage());
        } // catch
      } // for

      throw error;
    } // catch
  }
Ejemplo n.º 2
0
  public static void main(String args[]) {

    try {

      ParameterFile config = new ParameterFile(args);

      StorageFactory run = new StorageCreator(config);

      Storage storage = run.produce();

      System.out.println("storage: " + storage);

      if (args.length > 1) {

        String command = args[1];

        if (command.endsWith("commit")) {

          storage.commit(null);

        } // if
        else if (command.equals("rollback")) {

          storage.rollback(null);

        } // else
        else if (command.equals("finalize")) {

          storage.finalize(null);

        } // else
        else if (command.equals("ping")) {

          storage.ping(null);

        } // else
        else if (command.equals("remove")) {

          storage.remove(null);

        } // else
        else if (command.equals("select")) {

          System.out.println("Select " + args[2] + "=" + storage.select(args[2]));

        } // else
        else if (command.equals("selectArray")) {

          String[] str = new String[args.length - 2];

          System.arraycopy(args, 2, str, 0, str.length);

          Object[] obj = storage.selectArray(str);

          System.out.println("SelectArray:");

          for (int i = 0; i < obj.length; i++) {

            System.out.println("Select " + str[i] + "=" + obj[i]);
          }
        } // else
      } // if

    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }