Package org.serviceconnector.service

Examples of org.serviceconnector.service.SubscriptionMask


            writer.writeEndElement();
            continue;
          }
          if (value instanceof SubscriptionMask) {
            writer.writeStartElement("subscriptionMask");
            SubscriptionMask subscriptionMask = (SubscriptionMask) value;
            writer.writeCData(subscriptionMask.getValue());
            writer.writeEndElement();
            continue;
          }
          if (value instanceof PublishMessageQueue<?>) {
            writer.writeStartElement("subscriptionQueue");
View Full Code Here


        publishMessageQueue.unsubscribe(cascSubscription.getId());
        cascSubscription.getServer().removeSession(cascSubscription);
        SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
      } else {
        // unsubscribe made by cascaded SC on behalf of his clients
        SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
        publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
        cascSubscription.setMask(cascSCMask);
        SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
      }
      CscUnsubscribeCallbackForCasc callback = new CscUnsubscribeCallbackForCasc(request, response, responderCallback,
          cascSubscription);
      cascadedSC.cascadedSCUnsubscribe(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      // delete unreferenced nodes in queue
      publishMessageQueue.removeNonreferencedNodes();
      return;
    default:
      // code for other types of services is below
      break;
    }

    if (cascadedSCMask == null) {
      // unsubscribe made by cascaded SC on behalf of his last client
      this.subscriptionRegistry.removeSubscription(cascSubscription.getId());
      publishMessageQueue.unsubscribe(cascSubscription.getId());
      cascSubscription.getServer().removeSession(cascSubscription);
      SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());

      if (reqMessage.getSessionId() == null) {
        // no session id set, cascadedSC unsubscribe on his own because of an error
        SCMPMessage reply = new SCMPMessage();
        reply.setIsReply(true);
        reply.setServiceName(serviceName);
        reply.setMessageType(getKey());
        // no need to forward to server
        response.setSCMP(reply);
        responderCallback.responseCallback(request, response);
        // delete unreferenced nodes in queue
        publishMessageQueue.removeNonreferencedNodes();
        this.abortCascSubscriptions(cascSubscription);
        return;
      }
    } else {
      // unsubscribe made by cascaded SC on behalf of his clients
      SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
      publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
      cascSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
    }
    // use server of cascaded client to unsubscribe
View Full Code Here

        queue.unsubscribe(cascSubscription.getId());
        cascSubscription.getServer().removeSession(cascSubscription);
        SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
      } else {
        // unsubscribe made by cascaded SC on behalf of a clients, others are left
        SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
        queue.changeSubscription(cascSubscription.getId(), cascSCMask);
        cascSubscription.setMask(cascSCMask);
        SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
      }
      CscAbortSubscriptionCommandCallback callback = new CscAbortSubscriptionCommandCallback(request, response,
          responderCallback, cascSubscription);
      cascadedSC.cascadedSCAbortSubscription(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      return;
    default:
      // code for other types of services is below
      break;
    }
    StatefulServer server = (StatefulServer) cascSubscription.getServer();

    PublishMessageQueue<SCMPMessage> publishMessageQueue = ((IPublishService) cascSubscription.getService()).getMessageQueue();
    if (cascadedSCMask == null) {
      // subscription abort made by cascaded SC on behalf of his last client
      this.subscriptionRegistry.removeSubscription(cascSubscription.getId());
      publishMessageQueue.unsubscribe(cascSubscription.getId());
      cascSubscription.getServer().removeSession(cascSubscription);
      SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
    } else {
      // unsubscribe made by cascaded SC on behalf of a clients, others are left
      SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
      publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
      cascSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
    }
    // set up abort message
View Full Code Here

      boolean rejectSubscriptionFlag = reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION);
      if (rejectSubscriptionFlag == false) {
        // session has not been rejected
        String newMask = reqMessage.getHeader(SCMPHeaderAttributeKey.MASK);
        PublishMessageQueue<SCMPMessage> queue = ((IPublishService) subscription.getService()).getMessageQueue();
        SubscriptionMask mask = new SubscriptionMask(newMask);
        SubscriptionLogger.logChangeSubscribe(serviceName, subscriptionId, newMask);
        queue.changeSubscription(subscriptionId, mask);
        subscription.setMask(mask);
      }
    }
View Full Code Here

        this.commandCallback.receive(reply);
        // adding client subscription id to cascaded client
        this.cascClient.addClientSubscriptionId(cscScSubscription.getId(), cscScSubscription.getMask());
        if (cscScSubscription.isCascaded() == true) {
          // update csc subscription id list for cascaded subscription
          cscScSubscription.addCscSubscriptionId(this.request.getMessage().getSessionId(), new SubscriptionMask(request
              .getMessage().getHeader(SCMPHeaderAttributeKey.MASK)));
        }
        this.cascClient.setSubscriptionMask(new SubscriptionMask(this.request.getMessage().getHeader(
            SCMPHeaderAttributeKey.CASCADED_MASK)));
        // release permit
        this.cascClient.getCascClientSemaphore().release();
        return;
      } catch (Exception e) {
View Full Code Here

      try {
        // forward reply to client
        this.commandCallback.receive(reply);
        // adding client subscription id to cascaded client
        this.cascClient.addClientSubscriptionId(cscScSubscription.getId(), cscScSubscription.getMask());
        this.cascClient.setSubscriptionMask(new SubscriptionMask(this.request.getMessage().getHeader(
            SCMPHeaderAttributeKey.CASCADED_MASK)));
        // release permit
        this.cascClient.getCascClientSemaphore().release();
        return;
      } catch (Exception e) {
View Full Code Here

    if (reply.isFault() == false && reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION) == false) {
      if (cascSCSubscription.isCascaded() == true) {
        // update csc subscription id list for cascaded subscription
        cascSCSubscription.addCscSubscriptionId(reqMessage.getSessionId(),
            new SubscriptionMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK)));
      }
      // change subscription for cascaded SC
      PublishMessageQueue<SCMPMessage> queue = ((IPublishService) cascSCSubscription.getService()).getMessageQueue();
      SubscriptionMask cascSCMask = new SubscriptionMask(cascSCMaskString);
      queue.changeSubscription(this.cascSCSubscription.getId(), cascSCMask);
      cascSCSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, this.cascSCSubscription.getId(), cascSCMaskString);
    }
    // forward reply to client
View Full Code Here

  @Override
  public void receive(SCMPMessage reply) {
    SCMPMessage reqMessage = request.getMessage();
    // only if service cascaded update cascaded client with new subscription mask
    String newMask = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    this.cascClient.setSubscriptionMask(new SubscriptionMask(newMask));
    // only if service is cascaded - release permit
    this.cascClient.getCascClientSemaphore().release();
    try {
      this.commandCallback.receive(reply);
    } catch (Exception e) {
View Full Code Here

        this.cascClient.setSubscriptionId(reply.getSessionId());
        // forward reply to client
        this.commandCallback.receive(reply);
        // subscription successfully created
        this.cascClient.setSubscribed(true);
        this.cascClient.setSubscriptionMask(new SubscriptionMask(tmpCscMask));
        this.cascClient.receivePublication();
        // adding client subscription id to cascaded client
        this.cascClient.addClientSubscriptionId(cscScSubscription.getId(), cscScSubscription.getMask());
        if (cscScSubscription.isCascaded() == true) {
          // update csc subscription id list for cascaded subscription
          cscScSubscription.addCscSubscriptionId(this.commandCallback.getRequest().getMessage().getSessionId(),
              new SubscriptionMask(this.tmpCscMask));
        }
        // release permit
        this.cascClient.getCascClientSemaphore().release();
        return;
      } catch (Exception e) {
View Full Code Here

      boolean rejectSubscriptionFlag = reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION);
      if (rejectSubscriptionFlag == false) {
        if (tempSubscription.isCascaded() == true) {
          // update csc subscription id list for cascaded subscription
          tempSubscription.addCscSubscriptionId(this.reqMessage.getSessionId(),
              new SubscriptionMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK)));
        }
        // subscription has not been rejected, add server to subscription
        PublishMessageQueue<SCMPMessage> publishMessageQueue = ((IPublishService) this.tempSubscription.getService())
            .getMessageQueue();
        ReceivePublicationTimeout crpTimeout = new ReceivePublicationTimeout(publishMessageQueue, noDataIntervalMillis);
        SubscriptionMask subscriptionMask = tempSubscription.getMask();
        publishMessageQueue.subscribe(tempSubscription.getId(), subscriptionMask, crpTimeout);
        // finally add subscription to the registry & schedule subscription timeout internal
        this.subscriptionRegistry.addSubscription(tempSubscription.getId(), tempSubscription);
        SubscriptionLogger.logSubscribe(serviceName, tempSubscription.getId(), subscriptionMask.getValue());
        // forward local subscription no matter what server sends
        reply.setSessionId(tempSubscription.getId());
      } else {
        // subscription has been rejected - remove subscription id from header
        reply.removeHeader(SCMPHeaderAttributeKey.SESSION_ID);
View Full Code Here

TOP

Related Classes of org.serviceconnector.service.SubscriptionMask

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.