private void shutdownClientController() throws RemoteException {
   try {
     Naming.unbind("rmi://localhost:" + ClientRmiPort + "/Client");
   } catch (MalformedURLException e1) {
     throw new RemoteException("Malformed URL has occurred in ClientController", e1);
   } catch (NotBoundException e1) {
     throw new RemoteException("Unbinding the ClientController failed", e1);
   }
   UnicastRemoteObject.unexportObject(this, true);
   closeClientController(2000);
 }
Esempio n. 2
1
 public void stopServer() {
   try {
     registry.unbind(SERVICE_NAME);
     UnicastRemoteObject.unexportObject(registry, true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public static void main(String[] args) throws Exception {

    System.err.println("\nRegression test for bug 4513223\n");

    Remote impl2 = null;
    try {
      Remote impl = new MarshalAfterUnexport2();
      System.err.println("created impl extending URO (with a UnicastServerRef2): " + impl);

      Receiver stub = (Receiver) RemoteObject.toStub(impl);
      System.err.println("stub for impl: " + stub);

      UnicastRemoteObject.unexportObject(impl, true);
      System.err.println("unexported impl");

      impl2 = new MarshalAfterUnexport2();
      Receiver stub2 = (Receiver) RemoteObject.toStub(impl2);

      System.err.println("marshalling unexported object:");
      MarshalledObject mobj = new MarshalledObject(impl);

      System.err.println("passing unexported object via RMI-JRMP:");
      stub2.receive(stub);

      System.err.println("TEST PASSED");
    } finally {
      if (impl2 != null) {
        try {
          UnicastRemoteObject.unexportObject(impl2, true);
        } catch (Throwable t) {
        }
      }
    }
  }
Esempio n. 4
0
  /** Stop. */
  public void stop() {
    this.lookupTask.stop();

    if (this.stub != null) {
      try {
        this.reg.unbind(this.bindingName);

        this.dist.unexportClients();

        this.dist.unexportServer();

        UnicastRemoteObject.unexportObject(this.dist, true);
      } catch (RemoteException rex) {
        logger.warning(rex.getMessage());
      } catch (NotBoundException nbex) {
        logger.warning(nbex.getMessage());
      }
    }

    try {
      UnicastRemoteObject.unexportObject(this.reg, true);
    } catch (NoSuchObjectException ex) {
      ex.printStackTrace();
    }
  }
Esempio n. 5
0
 public void shutdown() {
   try {
     if (UnicastRemoteObject.unexportObject(this, false)) return;
     Thread.sleep(5000);
     UnicastRemoteObject.unexportObject(this, true);
   } catch (Exception e) {
     // nothing to do .. we're shutting down ...
   }
 }
 /**
  * Removes the Remote obj reference from remote accessiblity. Once this call returns, the obj will
  * not receive any more remote RMI calls. If force is true, the object will be unpublished even if
  * there are pending calls on it.
  *
  * <p>Returns true on successful unpublish, or false if there was some problem.
  */
 public boolean unpublishObject(Remote obj, boolean force) {
   try {
     return UnicastRemoteObject.unexportObject(obj, force);
   } catch (NoSuchObjectException ex) {
     return false;
   }
 }
  @AdviseWith(adviceClasses = {PropsUtilAdvice.class})
  @Test
  public void testShutdownFailWithoutLog() throws NoSuchObjectException {
    UnicastRemoteObject.unexportObject(_getMPIImpl(), true);

    final IOException ioException = new IOException();

    ReflectionTestUtil.setFieldValue(
        MPIHelperUtil.class,
        "_intraband",
        new MockIntraband() {

          @Override
          public void close() throws IOException {
            throw ioException;
          }
        });

    try (CaptureHandler captureHandler =
        JDKLoggerTestUtil.configureJDKLogger(MPIHelperUtil.class.getName(), Level.OFF)) {

      MPIHelperUtil.shutdown();

      List<LogRecord> logRecords = captureHandler.getLogRecords();

      Assert.assertTrue(logRecords.isEmpty());
    }
  }
 /** Unexport the registered RMI object, logging any exception that arises. */
 private void unexportObjectSilently() {
   try {
     UnicastRemoteObject.unexportObject(this.exportedObject, true);
   } catch (NoSuchObjectException ex) {
     if (logger.isWarnEnabled()) {
       logger.warn("RMI object for service '" + this.serviceName + "' isn't exported anymore", ex);
     }
   }
 }
Esempio n. 9
0
 public void release() {
   try {
     UnicastRemoteObject.unexportObject(reg, true);
   } catch (NoSuchObjectException e) {
     e.printStackTrace();
   }
   reg = null;
   System.out.println("服务器端端口已释放");
 }
Esempio n. 10
0
 private void stopRegistry() {
   if (_registry != null) {
     try {
       UnicastRemoteObject.unexportObject(_registry, true);
     } catch (Exception ex) {
       LOG.ignore(ex);
     }
   }
 }
  void shutdownSpi() {
    server.stop();
    try {
      UnicastRemoteObject.unexportObject(this.debugger, true);
    } catch (Exception e) {
    }

    RmiDebuggedEnvironmentImpl.cleanup();
  }
  public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6261402\n");
    System.setProperty(
        "java.rmi.activation.port",
        Integer.toString(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT));
    RMID rmid = null;
    Callback obj = null;
    try {
      /*
       * Export callback object and bind in registry.
       */
      System.err.println("export callback object and bind in registry");
      obj = new CallbackImpl();
      Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0);
      Registry registry =
          LocateRegistry.createRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT);
      registry.bind("Callback", proxy);

      /*
       * Start rmid.
       */
      System.err.println("start rmid with inherited channel");
      RMID.removeLog();
      rmid =
          RMID.createRMID(
              System.out,
              System.err,
              true,
              true,
              TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT);
      rmid.addOptions(
          new String[] {
            "-Djava.nio.channels.spi.SelectorProvider=" + "InheritedChannelNotServerSocket$SP"
          });
      rmid.start();

      /*
       * Get activation system and wait to be notified via callback
       * from rmid's selector provider.
       */
      System.err.println("get activation system");
      ActivationSystem system = ActivationGroup.getSystem();
      System.err.println("ActivationSystem = " + system);
      synchronized (lock) {
        while (!notified) {
          lock.wait();
        }
      }
      System.err.println("TEST PASSED");
    } finally {
      if (obj != null) {
        UnicastRemoteObject.unexportObject(obj, true);
      }
      ActivationLibrary.rmidCleanup(rmid);
    }
  }
Esempio n. 13
0
 public void destroy() {
   try {
     if (registry != null) {
       UnicastRemoteObject.unexportObject(registry, true);
     }
   } catch (Exception ex) {
     log.error("Could not destroy registry", ex);
   }
   log.info("destroy");
 }
Esempio n. 14
0
  public void destroy() {
    try {
      target.destroy();
      HARMIServer.rmiServers.remove(key);
      UnicastRemoteObject.unexportObject(this, true);

    } catch (Exception e) {
      log.error("failed to destroy", e);
    }
  }
Esempio n. 15
0
  public static void main(String[] args) throws Exception {

    System.err.println("\nRegression test for RFE 4010355\n");

    ServerStackTrace impl = new ServerStackTrace();

    try {
      Ping stub = (Ping) UnicastRemoteObject.exportObject(impl);

      StackTraceElement[] remoteTrace;
      try {
        __FOO__(stub);
        throw new RuntimeException("TEST FAILED: no exception caught");
      } catch (PingException e) {
        System.err.println("trace of exception thrown by remote call:");
        e.printStackTrace();
        System.err.println();
        remoteTrace = e.getStackTrace();
      }

      int fooIndex = -1;
      int barIndex = -1;
      for (int i = 0; i < remoteTrace.length; i++) {
        StackTraceElement e = remoteTrace[i];
        if (e.getMethodName().equals("__FOO__")) {
          if (fooIndex != -1) {
            throw new RuntimeException("TEST FAILED: " + "trace contains more than one __FOO__");
          }
          fooIndex = i;
        } else if (e.getMethodName().equals("__BAR__")) {
          if (barIndex != -1) {
            throw new RuntimeException("TEST FAILED: " + "trace contains more than one __BAR__");
          }
          barIndex = i;
        }
      }
      if (fooIndex == -1) {
        throw new RuntimeException("TEST FAILED: trace lacks client-side method __FOO__");
      }
      if (barIndex == -1) {
        throw new RuntimeException("TEST FAILED: trace lacks server-side method __BAR__");
      }
      if (fooIndex < barIndex) {
        throw new RuntimeException(
            "TEST FAILED: trace contains client-side method __FOO__ "
                + "before server-side method __BAR__");
      }
      System.err.println("TEST PASSED");
    } finally {
      try {
        UnicastRemoteObject.unexportObject(impl, true);
      } catch (Exception e) {
      }
    }
  }
 public void unexport(RemoteRemoteObject rro) throws ProActiveException {
   if (rro instanceof RmiRemoteObject) {
     try {
       UnicastRemoteObject.unexportObject((RmiRemoteObject) rro, true);
     } catch (NoSuchObjectException e) {
       throw new ProActiveException(e);
     }
   } else {
     throw new ProActiveException("the remote object is not a rmi remote object");
   }
 }
Esempio n. 17
0
  void unregister() {
    if (_registered) {
      try {
        final ManagementImpl impl = (ManagementImpl) _persistit.getManagement();

        UnicastRemoteObject.unexportObject(impl, true);
        _registered = false;
        _persistit.getLogBase().rmiServerUnregister.log(_registeredHostName);
      } catch (final Exception exception) {
        _persistit.getLogBase().rmiUnregisterException.log(_registeredHostName, exception);
      }
    }
  }
Esempio n. 18
0
  public void run() {
    // idle
    do {
      sleepEL(idleTime);
    } while (invoker.lastAccess() + idleTime > System.currentTimeMillis());

    try {
      reg.unbind(name);
      UnicastRemoteObject.unexportObject(invoker, true);
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }
    public void passivate() throws Exception {
      // Stop connector
      if (connector != null) {
        connector.stop();
        connector = null;
      }

      // Remove registry
      if (registry != null) {
        UnicastRemoteObject.unexportObject(registry, true);
        registry = null;
      }
    }
Esempio n. 20
0
  protected void doStop() throws Exception {
    // close JMX Connector, if it was created
    if (cs != null) {
      try {
        cs.stop();
        LOG.debug("Stopped JMX Connector");
      } catch (IOException e) {
        LOG.debug(
            "Error occurred during stopping JMXConnectorService: "
                + cs
                + ". This exception will be ignored.");
      }
      cs = null;
    }

    // Unexport JMX RMI registry, if it was created
    if (registry != null) {
      try {
        UnicastRemoteObject.unexportObject(registry, true);
        LOG.debug("Unexported JMX RMI Registry");
      } catch (NoSuchObjectException e) {
        LOG.debug(
            "Error occurred while unexporting JMX RMI registry. This exception will be ignored.");
      }
    }

    if (mbeansRegistered.isEmpty()) {
      return;
    }

    // Using the array to hold the busMBeans to avoid the CurrentModificationException
    ObjectName[] mBeans =
        mbeansRegistered.keySet().toArray(new ObjectName[mbeansRegistered.size()]);
    int caught = 0;
    for (ObjectName name : mBeans) {
      try {
        unregister(name);
      } catch (Exception e) {
        LOG.info("Exception unregistering MBean with name " + name, e);
        caught++;
      }
    }
    if (caught > 0) {
      LOG.warn(
          "A number of "
              + caught
              + " exceptions caught while unregistering MBeans during stop operation."
              + " See INFO log for details.");
    }
  }
Esempio n. 21
0
  @Override
  protected synchronized void cleanUp() {
    super.cleanUp();

    if (loggerExported) {
      try {
        UnicastRemoteObject.unexportObject(rmiLogger, true);
      } catch (NoSuchObjectException e) {
        LOG.error("Can't unexport RMI logger", e);
      }

      loggerExported = false;
    }

    if (listenerExported) {
      try {
        UnicastRemoteObject.unexportObject(rmiDownloadListener, true);
      } catch (NoSuchObjectException e) {
        LOG.error("Can't unexport RMI artifact download listener", e);
      }
      listenerExported = false;
    }
  }
 private void terminate(Object object) {
   if (object instanceof Disposable) {
     Disposable disposable = (Disposable) object;
     disposable.dispose();
   }
   if (object instanceof Remote) {
     try {
       Remote remote = (Remote) object;
       UnicastRemoteObject.unexportObject(remote, true);
     } catch (NoSuchObjectException e) {
       // ignore
     } catch (Throwable e) {
       e.printStackTrace();
     }
   }
 }
  /** Ciclo de vida do ZonaDesembarqueRegister */
  public synchronized void run() {
    String entry = "ZonaDesembarque";
    String nameEntryBase = "RegisterHandler";
    Register register = null;

    try {
      register = (Register) registry.lookup(nameEntryBase);
    } catch (RemoteException e) {
      GenericIO.writelnString("RegisterRemoteObject lookup exception: " + e.getMessage());
      e.printStackTrace();
      System.exit(1);
    } catch (NotBoundException e) {
      GenericIO.writelnString("RegisterRemoteObject not bound exception: " + e.getMessage());
      e.printStackTrace();
      System.exit(1);
    }

    try {
      register.bind(entry, desembarqueInterface);
    } catch (RemoteException e) {
      System.exit(1);
    } catch (AlreadyBoundException e) {
      System.exit(1);
    }

    GenericIO.writelnString("O serviço ZonaDesembarque foi estabelecido!");
    GenericIO.writelnString("O servidor esta em escuta.");

    try {
      while (!canEnd) {
        wait();
      }
    } catch (InterruptedException ex) {

    }
    try {
      register.unbind(entry);
    } catch (RemoteException ex) {
      System.exit(1);
    } catch (NotBoundException ex) {
      System.exit(1);
    }
    try {
      UnicastRemoteObject.unexportObject(desembarque, false);
    } catch (NoSuchObjectException ex) {
    }
  }
Esempio n. 24
0
  public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6275081\n");

    Remote impl = new Remote() {};
    long start = System.currentTimeMillis();
    for (int i = 0; i < REPS; i++) {
      System.err.println(i);
      UnicastRemoteObject.exportObject(impl, PORT);
      UnicastRemoteObject.unexportObject(impl, true);
      Thread.sleep(1); // work around BindException (bug?)
    }
    long delta = System.currentTimeMillis() - start;
    System.err.println(REPS + " export/unexport operations took " + delta + "ms");
    if (delta > TIMEOUT) {
      throw new Error("TEST FAILED: took over " + TIMEOUT + "ms");
    }
    System.err.println("TEST PASSED");
  }
Esempio n. 25
0
  @AdviseWith(adviceClasses = {PropsUtilAdvice.class})
  @Test
  public void testShutdownFailWithLog() throws NoSuchObjectException {
    UnicastRemoteObject.unexportObject(_getMPIImpl(), true);

    final IOException ioException = new IOException();

    ReflectionTestUtil.setFieldValue(
        MPIHelperUtil.class,
        "_intraband",
        new MockIntraband() {

          @Override
          public void close() throws IOException {
            throw ioException;
          }
        });

    try (CaptureHandler captureHandler =
        JDKLoggerTestUtil.configureJDKLogger(MPIHelperUtil.class.getName(), Level.WARNING)) {

      MPIHelperUtil.shutdown();

      List<LogRecord> logRecords = captureHandler.getLogRecords();

      Assert.assertEquals(2, logRecords.size());

      LogRecord logRecord = logRecords.get(0);

      logRecord = logRecords.get(0);

      Assert.assertEquals("Unable to unexport " + _getMPIImpl(), logRecord.getMessage());

      Throwable throwable = logRecord.getThrown();

      Assert.assertSame(NoSuchObjectException.class, throwable.getClass());

      logRecord = logRecords.get(1);

      Assert.assertEquals("Unable to close intraband", logRecord.getMessage());
      Assert.assertSame(ioException, logRecord.getThrown());
    }
  }
  public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4457683\n");

    verifyPortFree(PORT);
    Registry registry = LocateRegistry.createRegistry(PORT);
    System.err.println("- exported registry: " + registry);
    verifyPortInUse(PORT);
    UnicastRemoteObject.unexportObject(registry, true);
    System.err.println("- unexported registry");
    Thread.sleep(1); // work around BindException (bug?)
    verifyPortFree(PORT);

    /*
     * The follow portion of this test is disabled temporarily
     * because 4457683 was partially backed out because of
     * 6269166; for now, only server sockets originally opened for
     * exports on non-anonymous ports will be closed when all of
     * the corresponding remote objects have been exported.  A
     * separate bug will be filed to represent the remainder of
     * 4457683 for anonymous-port exports.
     */

    //      SSF ssf = new SSF();
    //      Remote impl = new CloseServerSocket();
    //      Remote stub = UnicastRemoteObject.exportObject(impl, 0, null, ssf);
    //      System.err.println("- exported object: " + stub);
    //      UnicastRemoteObject.unexportObject(impl, true);
    //      System.err.println("- unexported object");
    //      synchronized (ssf) {
    //          if (!ssf.serverSocketClosed) {
    //              throw new RuntimeException("TEST FAILED: " +
    //                                         "server socket not closed");
    //          }
    //      }

    System.err.println("TEST PASSED");
  }
Esempio n. 27
0
  public static void main(final String[] args)
      throws DaoFactoryException, IOException, NotBoundException, AccountException {

    StockExchange exchange = ExchangeFactory.newTestStockExchange();
    ((StockExchangeSpi) exchange).open();

    DaoFactory daoFactory = new DaoFactoryImpl();
    AccountDao dao = daoFactory.getAccountDao();
    dao.reset();

    AccountManagerFactory acctMgrFactory = new AccountManagerFactoryImpl();
    AccountManager acctMgr = acctMgrFactory.newAccountManager(dao);
    logger.debug("Account MGR: " + acctMgr.toString());
    BrokerFactory brokerFactory = new BrokerFactoryImpl();
    Broker broker = brokerFactory.newBroker(BROKER_NAME, acctMgr, exchange);

    RemoteBrokerGateway remoteGateway = new RemoteBrokerGatewayImpl(broker);
    logger.debug(String.format("Remote Gateway: %s", remoteGateway.toString()));

    Registry reg = null;

    reg = LocateRegistry.createRegistry(RMI_SERVICE_PORT);
    logger.info("RMI Server listening on port: " + RMI_SERVICE_PORT);

    reg.rebind(BROKER_NAME, remoteGateway);

    logger.info(String.format("Registry: %s", reg.lookup(BROKER_NAME)));
    logger.info("Remote broker is available for processing.");

    InputStream is = System.in;
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    System.out.println("***** Press Enter to quit *****");
    br.readLine();

    UnicastRemoteObject.unexportObject(remoteGateway, true);
  }
 private void unexport(Remote obj, boolean force) throws NoSuchObjectException {
   RMIExporter exporter = (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
   if (exporter == null) UnicastRemoteObject.unexportObject(obj, force);
   else exporter.unexportObject(obj, force);
 }
  public static void main(String[] args) {

    System.err.println("\nRegression test for bug 4404702\n");

    /*
     * HACK: Work around the fact that java.util.logging.LogManager's
     * (singleton) construction also has this bug-- it will register a
     * "shutdown hook", i.e. a thread, which will inherit and pin the
     * current thread's context class loader for the lifetime of the VM--
     * by causing the LogManager to be initialized now, instead of by
     * RMI when our special context class loader is set.
     */
    java.util.logging.LogManager.getLogManager();

    /*
     * HACK: Work around the fact that the non-native, thread-based
     * SecureRandom seed generator (ThreadedSeedGenerator) seems to
     * have this bug too (which had been causing this test to fail
     * when run with jtreg on Windows XP-- see 4910382).
     */
    (new java.security.SecureRandom()).nextInt();

    RuntimeThreadInheritanceLeak obj = new RuntimeThreadInheritanceLeak();

    try {
      ClassLoader loader = URLClassLoader.newInstance(new URL[0]);
      ReferenceQueue refQueue = new ReferenceQueue();
      Reference loaderRef = new WeakReference(loader, refQueue);
      System.err.println("created loader: " + loader);

      Thread.currentThread().setContextClassLoader(loader);
      UnicastRemoteObject.exportObject(obj);
      Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
      System.err.println("exported remote object with loader as context class loader");

      loader = null;
      System.err.println("nulled strong reference to loader");

      UnicastRemoteObject.unexportObject(obj, true);
      System.err.println("unexported remote object");

      /*
       * HACK: Work around the fact that the sun.misc.GC daemon thread
       * also has this bug-- it will have inherited our loader as its
       * context class loader-- by giving it a chance to pass away.
       */
      Thread.sleep(2000);
      System.gc();

      System.err.println("waiting to be notified of loader being weakly reachable...");
      Reference dequeued = refQueue.remove(TIMEOUT);
      if (dequeued == null) {
        System.err.println("TEST FAILED: loader not deteced weakly reachable");
        dumpThreads();
        throw new RuntimeException("TEST FAILED: loader not detected weakly reachable");
      }

      System.err.println("TEST PASSED: loader detected weakly reachable");
      dumpThreads();

    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException("TEST FAILED: unexpected exception", e);
    } finally {
      try {
        UnicastRemoteObject.unexportObject(obj, true);
      } catch (RemoteException e) {
      }
    }
  }
Esempio n. 30
0
  public static void main(String args[]) throws Exception {

    checkArguments(args);
    scanner = new Scanner(System.in);
    String line = "";
    IBillingServer billRef = null;
    IAnalyticsServer analyticsRef = null;
    IBillingServerSecure ibss = null;

    ManagementClient self = null;

    Properties regProp = ReadProp.readRegistry();

    if (regProp == null) {
      System.out.println("Reg.Properties file could not be found!");
    } else {
      try {
        self = new ManagementClient();

        String registryHost = regProp.getProperty("registry.host");
        Integer registryPort = Integer.parseInt(regProp.getProperty("registry.port"));
        Registry registry = LocateRegistry.getRegistry(registryHost, registryPort);
        billRef = (IBillingServer) registry.lookup(bindingBilling);
        analyticsRef = (IAnalyticsServer) registry.lookup(bindingAnalytics);

        boolean active = true;

        System.out.println("hello management client");

        // Falls generischer Zugriff - Subscription setzen
        if (args.length > 0) {
          if (args[2].equals("generic")) {
            if (self.subscription.isEmpty()) {
              analyticsRef.subscribe(self);
            }
            self.setSubscription("(.*)");

            while (active) {
              Thread.sleep(100);
            }

            active = false;
          }
        }

        String userInput = "";
        StringTokenizer st;

        while (active) {

          line = scanner.nextLine();
          st = new StringTokenizer(line);
          userInput = st.nextToken();

          if (userInput.startsWith("!login")) {
            if (ibss == null) {
              String name = "";
              String pwd = "";
              if (st.countTokens() < 2) {
                Debug.printError("username/password missing");
              } else {
                name = st.nextToken();
                pwd = st.nextToken();

                ibss = billRef.login(name, pwd);

                if (ibss == null) {
                  Debug.printError("username/password is not valid!");
                } else {
                  Debug.printInfo(name + " successfully logged in");
                }
              }
            } else {
              Debug.printError("you are already logged in");
            }
          }

          /*
           * ! BILLING:
           */

          // List all existing price steps
          else if (userInput.startsWith("!steps")) {
            if (ibss != null) {
              PriceSteps steps;
              try {
                steps = ibss.getPriceSteps();
                System.out.println("Price Steps\r\n" + steps.toString());
              } catch (Exception e) {
                Debug.printError("could not print PriceSteps");
              }
            } else {
              System.out.println("ERROR: You are currently not logged in.");
            }
          } else if (userInput.startsWith("!addStep")) {
            Double start, end, fixed, variable;
            if (st.countTokens() < 4) {
              Debug.printError("start/end/fixed/variable missing");
            } else {
              try {
                start = Double.parseDouble(st.nextToken());
                end = Double.parseDouble(st.nextToken());
                fixed = Double.parseDouble(st.nextToken());
                variable = Double.parseDouble(st.nextToken());

                if (ibss != null) {
                  ibss.createPriceStep(start, end, fixed, variable);
                  if (end == 0) {
                    String inf = "INFINITY";
                    System.out.println("Step [" + start + " " + inf + "] successfully added");
                  } else {
                    System.out.println("Step [" + start + " " + end + "] successfully added");
                  }
                } else {
                  System.out.println("ERROR: You are currently not logged in.");
                }
              } catch (RemoteException re) {
                Debug.printError("values are not valid");
              } catch (Exception e) {
                Debug.printError("only numbers!");
              }
            }
          } else if (userInput.startsWith("!removeStep")) {
            Double start = null, end = null;
            if (st.countTokens() < 2) {
              Debug.printError("start/end missing");
            } else {
              try {
                start = Double.parseDouble(st.nextToken());
                end = Double.parseDouble(st.nextToken());
                if (ibss != null) {
                  ibss.deletePriceStep(start, end);
                  System.out.println("Price step [" + start + " " + end + "] successfully removed");
                } else {
                  System.out.println("ERROR: You are currently not logged in.");
                }
              } catch (RemoteException re) {
                Debug.printError("PriceStep [" + start + " " + end + "] does not exist!");
              } catch (Exception e) {
                Debug.printError("only numbers!");
              }
            }
          }
          // shows the bill for a certain user name
          else if (userInput.startsWith("!bill")) {
            String username;
            if (st.countTokens() < 1) {
              Debug.printError("username is missing");
            } else {
              try {
                username = st.nextToken();
                if (ibss != null) {
                  Bill bill = ibss.getBill(username);
                  if (bill != null) {
                    System.out.println(bill.toString());
                  } else {
                    Debug.printError("could not print bill");
                  }
                } else {
                  System.out.println("ERROR: You are currently not logged in.");
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
          // set the client into "logged out" state
          else if (userInput.startsWith("!logout")) {
            if (ibss != null) {
              ibss = null;
              System.out.println("Successfully logged out");
            } else {
              Debug.printInfo("you have to log in first!");
            }
          }

          /*
           *  ! ANALYTICS:
           */

          // !subscribe <filterRegex>
          else if (userInput.startsWith("!subscribe")) {
            if (st.hasMoreTokens()) {
              String filter = st.nextToken();
              int id = 0;
              filter = filter.replace("\'", "");

              if (self.subscription.isEmpty()) {
                analyticsRef.subscribe(self);
              }

              id = self.setSubscription(filter);

              Debug.printInfo(
                  "Created subscription with ID "
                      + id
                      + " for events "
                      + "using filter "
                      + filter
                      + " .");
            } else {
              Debug.printError("Filter is missing");
            }
          }
          // !unsubscribe <subscriptionID>
          else if (userInput.startsWith("!unsubscribe")) {
            int id;
            if (st.countTokens() < 1) {
              System.out.println("ID missing");
            } else {
              try {
                id = Integer.parseInt(st.nextToken());
                self.removeSubscription(id);
                if (self.subscription.isEmpty()) {
                  analyticsRef.unsubscribe(self);
                }
                Debug.printInfo("subscription " + id + " terminated");
              } catch (Exception e) {
                Debug.printError("ID has to be a number");
              }
            }
          } else if (userInput.startsWith("!auto")) {
            self.status = Status.AUTO;
            Debug.printInfo("enabled the automatic printing of events");

          } else if (userInput.startsWith("!hide")) {
            self.status = Status.HIDE;
            Debug.printInfo("disabled the automatic printing of events");

          } else if (userInput.startsWith("!print")) {
            Debug.printInfo("print events on buffer");
            self.printBuffer();
          } else if (userInput.startsWith("!exit")) {
            Debug.printDebug("Shutdown M.Client");
            ibss = null;
            active = false;
            UnicastRemoteObject.unexportObject(self, true);
          } else {
            Debug.printError("unknown command!");
          }
        }

      } catch (ConnectException ce) {
        Debug.printError("could not connect to server");
      } catch (IOException io) {
        io.printStackTrace();
      } catch (NotBoundException nbe) {
        Debug.printError("could not bind, sever is not available");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    scanner.close();
  }