private synchronized void createStorage() throws CommunicationException {

    try {

      this.storage = factory.produce();

    } // try
    catch (StorageFactoryException error) {

      throw new CommunicationException("Nao conseguiu criar objeto: " + error.getMessage());
    } // catch
  } // createStorage
Esempio 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();
    }
  }