Package org.serviceconnector.cmd

Examples of org.serviceconnector.cmd.ICommand


  /**
   * Instantiates a new service connector command factory.
   */
  public ServiceConnectorCommandFactory() {
    ICommand attachCommand = new AttachCommand();
    this.addCommand(attachCommand.getKey(), attachCommand);
    ICommand detachCommand = new DetachCommand();
    this.addCommand(detachCommand.getKey(), detachCommand);
    ICommand inspectCommand = new InspectCommand();
    this.addCommand(inspectCommand.getKey(), inspectCommand);
    ICommand manageCommand = new ManageCommand();
    this.addCommand(manageCommand.getKey(), manageCommand);
    ICommand clnCreateSessionCommand = new ClnCreateSessionCommand();
    this.addCommand(clnCreateSessionCommand.getKey(), clnCreateSessionCommand);
    ICommand clnDeleteSessionCommand = new ClnDeleteSessionCommand();
    this.addCommand(clnDeleteSessionCommand.getKey(), clnDeleteSessionCommand);
    ICommand cscCreateSessionCommand = new CscCreateSessionCommand();
    this.addCommand(cscCreateSessionCommand.getKey(), cscCreateSessionCommand);
    ICommand cscDeleteSessionCommand = new CscDeleteSessionCommand();
    this.addCommand(cscDeleteSessionCommand.getKey(), cscDeleteSessionCommand);
    ICommand registerServerCommand = new RegisterServerCommand();
    this.addCommand(registerServerCommand.getKey(), registerServerCommand);
    ICommand checkRegistrationCommand = new CheckRegistrationCommand();
    this.addCommand(checkRegistrationCommand.getKey(), checkRegistrationCommand);
    ICommand deRegisterServerCommand = new DeRegisterServerCommand();
    this.addCommand(deRegisterServerCommand.getKey(), deRegisterServerCommand);
    ICommand clnEchoCommand = new EchoCommand();
    this.addCommand(clnEchoCommand.getKey(), clnEchoCommand);
    ICommand clnExecuteCommand = new ClnExecuteCommand();
    this.addCommand(clnExecuteCommand.getKey(), clnExecuteCommand);
    ICommand cscExecuteCommand = new CscExecuteCommand();
    this.addCommand(cscExecuteCommand.getKey(), cscExecuteCommand);
    // publish subscribe commands
    ICommand clnSubscribeCommand = new ClnSubscribeCommand();
    this.addCommand(clnSubscribeCommand.getKey(), clnSubscribeCommand);
    ICommand clnUnsubscribeCommand = new ClnUnsubscribeCommand();
    this.addCommand(clnUnsubscribeCommand.getKey(), clnUnsubscribeCommand);
    ICommand clnChangeSubscriptionCommand = new ClnChangeSubscriptionCommand();
    this.addCommand(clnChangeSubscriptionCommand.getKey(), clnChangeSubscriptionCommand);
    ICommand cscSubscribeCommand = new CscSubscribeCommand();
    this.addCommand(cscSubscribeCommand.getKey(), cscSubscribeCommand);
    ICommand cscUnsubscribeCommand = new CscUnsubscribeCommand();
    this.addCommand(cscUnsubscribeCommand.getKey(), cscUnsubscribeCommand);
    ICommand cscChangeSubscriptionCommand = new CscChangeSubscriptionCommand();
    this.addCommand(cscChangeSubscriptionCommand.getKey(), cscChangeSubscriptionCommand);
    ICommand cscAbortSubscriptionCommand = new CscAbortSubscriptionCommand();
    this.addCommand(cscAbortSubscriptionCommand.getKey(), cscAbortSubscriptionCommand);
    ICommand receivePublicationCommand = new ReceivePublicationCommand();
    this.addCommand(receivePublicationCommand.getKey(), receivePublicationCommand);
    ICommand publishCommand = new PublishCommand();
    this.addCommand(publishCommand.getKey(), publishCommand);
    // file commands
    ICommand fileUploadCommand = new FileUploadCommand();
    this.addCommand(fileUploadCommand.getKey(), fileUploadCommand);
    ICommand fileDownloadCommand = new FileDownloadCommand();
    this.addCommand(fileDownloadCommand.getKey(), fileDownloadCommand);
    ICommand fileListCommand = new FileListCommand();
    this.addCommand(fileListCommand.getKey(), fileListCommand);
  }
View Full Code Here


      // needs to set a key in thread local to identify thread later and get access to the responder
      ResponderRegistry responderRegistry = AppContext.getResponderRegistry();
      int port = request.getLocalSocketAddress().getPort();
      responderRegistry.setThreadLocal(port);

      ICommand command = AppContext.getCommandFactory().getCommand(request.getKey());
      // gets the command
      if (command == null) {
        this.sendBadRequestError(response, scmpReq);
        return;
      }

      if (command.isPassThroughPartMsg() == false) {
        // large messages needs to be handled
        SCMPCompositeSender largeResponse = NettyResponderRequestHandlerTask.compositeRegistry
            .getSCMPLargeResponse(sessionId);

        if (largeResponse != null && scmpReq.isPart()) {
          // sending of a large response has already been started and incoming scmp is a pull request
          if (largeResponse.hasNext()) {
            // there are still parts to send to complete request
            SCMPMessage nextSCMP = largeResponse.getNext();
            // handling msgSequenceNr
            msgSequenceNr.incrementAndGetMsgSequenceNr();
            nextSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
            response.setSCMP(nextSCMP);
            response.write();
            return;
          }
          NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);
        }
        // gets the large request or creates a new one if necessary
        SCMPCompositeReceiver largeRequest = this.getSCMPLargeRequest(request, response);

        if (largeRequest != null && largeRequest.isComplete() == false) {
          // request is not complete yet
          response.write();
          return;
        }
        // removes largeResponse - request is complete don't need to know preceding messages any more
        NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeRequest(sessionId);
      }
      // validate request and run command
      if (Constants.COMMAND_VALIDATION_ENABLED) {
        command.validate(request);
      }
      PerformanceLogger.beginThreadBound();
      command.run(request, response, this);
      PerformanceLogger.endThreadBound(command.getKey().getValue());
    } catch (HasFaultResponseException ex) {
      // exception carries response inside
      LOGGER.warn("run " + ex.toString());
      ex.setSessionIdAndServiceName(request);
      ex.setFaultResponse(response);
View Full Code Here

  /**
   * Instantiates a new server command factory.
   */
  public ServerCommandFactory() {
    ICommand srvCreateSessionCommand = new SrvCreateSessionCommand();
    this.addCommand(srvCreateSessionCommand.getKey(), srvCreateSessionCommand);
    ICommand srvDeleteSessionCommand = new SrvDeleteSessionCommand();
    this.addCommand(srvDeleteSessionCommand.getKey(), srvDeleteSessionCommand);
    ICommand srvExecuteCommand = new SrvExecuteCommand();
    this.addCommand(srvExecuteCommand.getKey(), srvExecuteCommand);
    ICommand srvAbortSessionCommand = new SrvAbortSessionCommand();
    this.addCommand(srvAbortSessionCommand.getKey(), srvAbortSessionCommand);
    ICommand srvAbortSubscriptionCommand = new SrvAbortSubscriptionCommand();
    this.addCommand(srvAbortSubscriptionCommand.getKey(), srvAbortSubscriptionCommand);

    ICommand srvSubscribeCommand = new SrvSubscribeCommand();
    this.addCommand(srvSubscribeCommand.getKey(), srvSubscribeCommand);
    ICommand srvUnsubscribeCommand = new SrvUnsubscribeCommand();
    this.addCommand(srvUnsubscribeCommand.getKey(), srvUnsubscribeCommand);
    ICommand srvChangeSubscriptionCommand = new SrvChangeSubscriptionCommand();
    this.addCommand(srvChangeSubscriptionCommand.getKey(), srvChangeSubscriptionCommand);
  }
View Full Code Here

      // needs to set a key in thread local to identify thread later and get access to the responder
      ResponderRegistry responderRegistry = AppContext.getResponderRegistry();
      int port = request.getLocalSocketAddress().getPort();
      responderRegistry.setThreadLocal(port);

      ICommand command = AppContext.getCommandFactory().getCommand(request.getKey());
      // gets the command
      if (command == null) {
        this.sendBadRequestError(response, scmpReq);
        return;
      }

      if (command.isPassThroughPartMsg() == false) {
        // large messages needs to be handled
        SCMPCompositeSender largeResponse = NettyResponderRequestHandlerTask.compositeRegistry
            .getSCMPLargeResponse(sessionId);

        if (largeResponse != null && scmpReq.isPart()) {
          // sending of a large response has already been started and incoming scmp is a pull request
          if (largeResponse.hasNext()) {
            // there are still parts to send to complete request
            SCMPMessage nextSCMP = largeResponse.getNext();
            // handling msgSequenceNr
            msgSequenceNr.incrementAndGetMsgSequenceNr();
            nextSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
            response.setSCMP(nextSCMP);
            response.write();
            return;
          }
          NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);
        }
        // gets the large request or creates a new one if necessary
        SCMPCompositeReceiver largeRequest = this.getSCMPLargeRequest(request, response);

        if (largeRequest != null && largeRequest.isComplete() == false) {
          // request is not complete yet
          response.write();
          return;
        }
        // removes largeResponse - request is complete don't need to know preceding messages any more
        NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeRequest(sessionId);
      }
      // validate request and run command
      if (Constants.COMMAND_VALIDATION_ENABLED) {
        command.validate(request);
      }
      PerformanceLogger.beginThreadBound();
      command.run(request, response, this);
      PerformanceLogger.endThreadBound(command.getKey().getValue());
    } catch (HasFaultResponseException ex) {
      // exception carries response inside
      LOGGER.warn("run " + ex.toString());
      ex.setSessionIdAndServiceName(request);
      ex.setFaultResponse(response);
View Full Code Here

TOP

Related Classes of org.serviceconnector.cmd.ICommand

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.