Package org.serviceconnector.service

Examples of org.serviceconnector.service.Service


  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();

    // check service is present and enabled
    Service abstractService = this.getService(serviceName);

    String cascSubscriptionId = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID);
    Subscription cascSubscription = this.getSubscriptionById(cascSubscriptionId);
    String cascadedSCMask = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    // enhance ipAddressList
    String ipAddressList = reqMessage.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
    ipAddressList = ipAddressList + Constants.SLASH + request.getRemoteSocketAddress().getAddress().getHostAddress();
    reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      // publish service is cascaded
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      CscChangeSubscriptionCallbackForCasc callback = new CscChangeSubscriptionCallbackForCasc(request, response,
View Full Code Here


  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    // check service is present and enabled
    Service abstractService = this.getService(serviceName);
    if (abstractService.isEnabled() == false) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.SERVICE_DISABLED, "service="
          + abstractService.getName() + " is disabled");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    // enhance ipAddressList
    String ipAddressList = reqMessage.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
    ipAddressList = ipAddressList + Constants.SLASH + request.getRemoteSocketAddress().getAddress().getHostAddress();
    reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);
    String sessionInfo = reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO);
    int eciInSeconds = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.ECHO_INTERVAL);
    int eciInMillis = eciInSeconds * Constants.SEC_TO_MILLISEC_FACTOR;
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      CascadedSC cascadedSC = ((CascadedSessionService) abstractService).getCascadedSC();
      CommandCascCallback callback = new CommandCascCallback(request, response, responderCallback);
      cascadedSC.createSession(reqMessage, callback, oti);
      return;
View Full Code Here

  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage message = request.getMessage();
    String serviceName = message.getServiceName();
    // check service is present
    Service abstractService = this.getService(serviceName);
    int oti = message.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

    switch (abstractService.getType()) {
    case CASCADED_FILE_SERVICE:
      CascadedSC cascadedSC = ((CascadedFileService) abstractService).getCascadedSC();
      CommandCascCallback callback = new CommandCascCallback(request, response, responderCallback);
      cascadedSC.serverUploadFile(message, callback, oti);
      return;
View Full Code Here

  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    String serviceName = reqMessage.getServiceName();
    // check service is present
    Service abstractService = this.getService(serviceName);
    String sessionId = reqMessage.getSessionId();

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      // clears message in cache if in loading state
      AppContext.getCacheManager().clearLoading(sessionId);
      CascadedSC cascadedSC = ((CascadedSessionService) abstractService).getCascadedSC();
      CommandCascCallback callback = new CommandCascCallback(request, response, responderCallback);
      cascadedSC.deleteSession(reqMessage, callback, oti);
      return;
    case CASCADED_FILE_SERVICE:
      cascadedSC = ((CascadedFileService) abstractService).getCascadedSC();
      callback = new CommandCascCallback(request, response, responderCallback);
      cascadedSC.deleteSession(reqMessage, callback, oti);
      return;
    default:
      // code for other types of services is below
      break;
    }

    // lookup session and checks properness
    Session session = this.getSessionById(sessionId);
    synchronized (session) {
      session.setPendingRequest(true); // IMPORTANT - set true because of parallel echo call
      // delete entry from session registry
      this.sessionRegistry.removeSession(session);
    }
    IServer abstractServer = session.getServer();

    switch (abstractServer.getType()) {
    case STATEFUL_SERVER:
      // code for type session service is below switch statement
      break;
    case FILE_SERVER:
      this.sessionRegistry.removeSession(session);
      ((FileServer) abstractServer).removeSession(session);
      // reply to client
      SCMPMessage reply = new SCMPMessage();
      reply.setIsReply(true);
      reply.setMessageType(getKey());
      response.setSCMP(reply);
      responderCallback.responseCallback(request, response);
      return;
    case CASCADED_SC:
    case UNDEFINED:
    default:
      throw new SCMPCommandException(SCMPError.SC_ERROR, "delete session not allowed for service "
          + abstractService.getName());
    }
    StatefulServer statefulServer = (StatefulServer) abstractServer;
    DeleteSessionCommandCallback callback;
    // free server from session
    statefulServer.removeSession(session);
View Full Code Here

   *             service name not found
   */
  private String getServiceConfigurationString(String serviceName) throws NotFoundException {
    StringBuilder sb = new StringBuilder();

    Service service = this.serviceRegistry.getService(serviceName);

    if (service == null) {
      throw new NotFoundException("no service found serviceName=" + serviceName);
    }
    sb.append("serviceType=" + service.getType());
    return sb.toString();
  }
View Full Code Here

  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();

    // check service is present and enabled
    Service abstractService = this.getService(serviceName);
    if (abstractService.isEnabled() == false) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.SERVICE_DISABLED, "service="
          + abstractService.getName() + " is disabled");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }

    // enhance ipAddressList
    String ipAddressList = reqMessage.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
    ipAddressList = ipAddressList + Constants.SLASH + request.getRemoteSocketAddress().getAddress().getHostAddress();
    reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);

    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    // create temporary Subscription for cascaded SC
    String sessionInfo = reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO);
    int noiSecs = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.NO_DATA_INTERVAL);
    int noiInMillis = noiSecs * Constants.SEC_TO_MILLISEC_FACTOR;
    String cscSCMaskString = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    String cascSubscriptionId = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID);
    Subscription cscSubscription = this.subscriptionRegistry.getSubscription(cascSubscriptionId);
    SubscriptionMask cscMask = new SubscriptionMask(cscSCMaskString);
    Subscription tmpCascSCSubscription = new Subscription(cscMask, sessionInfo, ipAddressList, noiInMillis, AppContext
        .getBasicConfiguration().getSubscriptionTimeoutMillis(), true);
    tmpCascSCSubscription.setService(abstractService);

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      // publish service is cascaded
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      // add server to subscription
View Full Code Here

    try {
      Set<Entry<String, Service>> entries = this.registryMap.entrySet();
      Service[] services = new Service[entries.size()];
      int index = 0;
      for (Entry<String, Service> entry : entries) {
        Service service = entry.getValue();
        services[index++] = service;
      }
      return services;
    } catch (Exception e) {
      LOGGER.error("getServices", e);
View Full Code Here

   */
  public void dump(XMLDumpWriter writer) throws Exception {
    writer.writeStartElement("services");
    Set<Entry<String, Service>> serviceEntries = this.registryMap.entrySet();
    for (Entry<String, Service> serviceEntry : serviceEntries) {
      Service service = serviceEntry.getValue();
      service.dump(writer);
    }
    writer.writeEndElement(); // end of services
  }
View Full Code Here

      throw new InvalidParameterException("service parameter missing");
    }
    // load file services and the file list
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    writer.writeStartElement("service");
    Service service = serviceRegistry.getService(serviceName);
    this.writeBean(writer, service);
    if (service instanceof FileService || service instanceof CascadedFileService) {
      SCClient client = null;
      // try to connect client
      client = connectClientToService(service);
View Full Code Here

      throw new InvalidParameterException("service parameter missing");
    }
    // load file services and the file list
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    writer.writeStartElement("service");
    Service service = serviceRegistry.getService(serviceName);
    this.writeBean(writer, service);
    if (service instanceof FileService || service instanceof CascadedFileService) {
      SCClient client = null;
      // try to connect client
      client = connectClientToService(service);
View Full Code Here

TOP

Related Classes of org.serviceconnector.service.Service

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.