Package org.structr.websocket.command

Examples of org.structr.websocket.command.AbstractCommand


      }

      // process message
      try {

        AbstractCommand abstractCommand = (AbstractCommand) type.newInstance();

        abstractCommand.setWebSocket(this);
        abstractCommand.setSession(session);
        abstractCommand.setIdProperty(idProperty);

        // The below blocks allow a websocket command to manage its own
        // transactions in case of bulk processing commands etc.

        if (abstractCommand.requiresEnclosingTransaction()) {

          try (final Tx tx = app.tx()) {

            // store authenticated-Flag in webSocketData
            // so the command can access it
            webSocketData.setSessionValid(isAuthenticated());

            abstractCommand.processMessage(webSocketData);

            // commit transaction
            tx.success();
          }

        } else {

          try (final Tx tx = app.tx()) {

            // store authenticated-Flag in webSocketData
            // so the command can access it
            webSocketData.setSessionValid(isAuthenticated());

            // commit transaction
            tx.success();
          }

          // process message without transaction context!
          abstractCommand.processMessage(webSocketData);

        }

      } catch (FrameworkException | InstantiationException | IllegalAccessException t) {
View Full Code Here


  public static void addCommand(final Class command) {

    try {

      AbstractCommand msg = (AbstractCommand) command.newInstance();

      commandSet.put(msg.getCommand(), command);

    } catch (Throwable t) {

      logger.log(Level.SEVERE, "Unable to add command {0}", command.getName());
View Full Code Here

TOP

Related Classes of org.structr.websocket.command.AbstractCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.