/**
  * Register all the names for the same instance.
  *
  * @param iServerCommandInstance
  */
 public void registerCommand(final OServerCommand iServerCommandInstance) {
   for (String name : iServerCommandInstance.getNames())
     if (OStringSerializerHelper.contains(name, '{')) {
       restCommands.put(name, iServerCommandInstance);
     } else if (OStringSerializerHelper.contains(name, '*'))
       wildcardCommands.put(name, iServerCommandInstance);
     else exactCommands.put(name, iServerCommandInstance);
   iServerCommandInstance.configure(server);
 }
 public OServerNetworkListener unregisterStatelessCommand(
     final Class<? extends OServerCommand> iCommandClass) {
   for (OServerCommand c : statelessCommands) {
     if (c.getClass().equals(iCommandClass)) {
       statelessCommands.remove(c);
       break;
     }
   }
   return this;
 }
  public Object getCommand(final Class<?> iCommandClass) {
    // SEARCH IN STATELESS COMMANDS
    for (OServerCommand cmd : statelessCommands) {
      if (cmd.getClass().equals(iCommandClass)) return cmd;
    }

    // SEARCH IN STATEFUL COMMANDS
    for (OServerCommandConfiguration cmd : statefulCommands) {
      if (cmd.implementation.equals(iCommandClass.getName())) return cmd;
    }

    return null;
  }
 @SuppressWarnings("unchecked")
 public static OServerCommand createCommand(
     final OServer server, final OServerCommandConfiguration iCommand) {
   try {
     final Constructor<OServerCommand> c =
         (Constructor<OServerCommand>)
             Class.forName(iCommand.implementation)
                 .getConstructor(OServerCommandConfiguration.class);
     final OServerCommand cmd = c.newInstance(new Object[] {iCommand});
     cmd.configure(server);
     return cmd;
   } catch (Exception e) {
     throw new IllegalArgumentException(
         "Cannot create custom command invoking the constructor: "
             + iCommand.implementation
             + "("
             + iCommand
             + ")",
         e);
   }
 }