Package org.serviceconnector.registry

Examples of org.serviceconnector.registry.ServiceRegistry


    String serviceName = request.getParameter("service");
    if (serviceName == null) {
      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


   * @throws Exception
   *             the exception
   */
  public static void load(ServiceListConfiguration serviceListConfiguration) throws Exception {
    Map<String, ServiceConfiguration> serviceConfigurationMap = serviceListConfiguration.getServiceConfigurations();
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();

    for (ServiceConfiguration serviceConfiguration : serviceConfigurationMap.values()) {
      String serviceTypeString = serviceConfiguration.getType();
      ServiceType serviceType = ServiceType.getType(serviceTypeString);
      RemoteNodeConfiguration remoteNode = serviceConfiguration.getRemoteNodeConfiguration();
      String remotNodeName = null;
      if (remoteNode != null) {
        remotNodeName = remoteNode.getName();
        serviceType = ServiceConfiguration.adaptServiceTypeIfCascService(serviceType, remotNodeName);
      }
      String serviceName = serviceConfiguration.getName();

      // instantiate right type of service
      Service service = null;
      switch (serviceType) {
      case CASCADED_SESSION_SERVICE:
        Server server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new CascadedSessionService(serviceName, (CascadedSC) server);
        break;
      case CASCADED_PUBLISH_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }

        service = new CascadedPublishService(serviceName, (CascadedSC) server, serviceConfiguration
            .getNoDataIntervalSeconds());
        break;
      case CASCADED_FILE_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new CascadedFileService(serviceName, (CascadedSC) server);
        break;
      case SESSION_SERVICE:
        service = new SessionService(serviceName);
        break;
      case PUBLISH_SERVICE:
        service = new PublishService(serviceName);
        break;
      case FILE_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new FileService(serviceName, (FileServer) server, serviceConfiguration.getPath(), serviceConfiguration
            .getUploadScript(), serviceConfiguration.getListScript());
        break;
      case UNDEFINED:
      default:
        throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE,
            "wrong serviceType, serviceName/serviceType=" + serviceName + Constants.SLASH + serviceTypeString);
      }
      service.setEnabled(serviceConfiguration.getEnabled());
      serviceRegistry.addService(service.getName(), service);
    }
  }
View Full Code Here

   */
  public static void setSCEnvironment(boolean scEnvironment) {
    AppContext.scEnvironment = scEnvironment;
    if (AppContext.scEnvironment) {
      AppContext.serverRegistry = new ServerRegistry();
      AppContext.serviceRegistry = new ServiceRegistry();
      AppContext.sessionRegistry = new SessionRegistry();
      AppContext.subscriptionRegistry = new SubscriptionRegistry();
      AppContext.cacheModuleRegistry = new CacheModuleRegistry();
    }
  }
View Full Code Here

  private void downloadAndReplace(XMLStreamWriter writer, IWebRequest request) throws Exception {
    String serviceName = request.getParameter("service");
    if (serviceName == null) {
      throw new WebCommandException("service is missing");
    }
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    Service service = serviceRegistry.getService(serviceName);
    if (service == null) {
      throw new WebCommandException("service " + serviceName + " not found");
    }
    if (service instanceof FileService == false && service instanceof CascadedFileService == false) {
      throw new WebCommandException("service " + serviceName + " is not a file or cascaded file service");
View Full Code Here

    String sdate = request.getParameter("date");
    Date date = DateTimeUtility.getCurrentDate();
    if (sdate != null && sdate.isEmpty() == false) {
      date = WebUtil.getXMLDateFromString(sdate);
    }
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    Service service = serviceRegistry.getService(serviceName);
    if (service == null) {
      throw new WebCommandException("service " + serviceName + " not found");
    }
    if (service instanceof FileService == false && service instanceof CascadedFileService == false) {
      throw new WebCommandException("service " + serviceName + " is not a file or cascaded file service");
View Full Code Here

    String serviceName = request.getParameter("service");
    if (serviceName == null) {
      this.writeFailure(writer, "Missing service name!");
      return;
    }
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    Service service = serviceRegistry.getService(serviceName);
    if (service == null) {
      this.writeFailure(writer, "Can not enable service " + serviceName + ", not found!");
      return;
    }
    service.setEnabled(true);
View Full Code Here

    String serviceName = request.getParameter("service");
    if (serviceName == null) {
      this.writeFailure(writer, "Missing service name!");
      return;
    }
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    Service service = serviceRegistry.getService(serviceName);
    if (service == null) {
      this.writeFailure(writer, "Can not disable service " + serviceName + ", not found!");
      return;
    }
    service.setEnabled(false);
View Full Code Here

        writer.writeEndElement();
      }
    }
    String serviceParameter = request.getParameter("service");
    if (serviceParameter != null) {
      ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
      Service service = serviceRegistry.getService(serviceParameter);
      if (service != null) {
        writer.writeStartElement("service");
        if (service instanceof IPublishService) {
          IPublishService publishService = (IPublishService) service;
          PublishMessageQueue<SCMPMessage> publishMessageQueue = publishService.getMessageQueue();
View Full Code Here

public class ServicesXMLLoader extends AbstractXMLLoader {

  /** {@inheritDoc} */
  @Override
  public final void loadBody(XMLStreamWriter writer, IWebRequest request) throws Exception {
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();
    writer.writeStartElement("services");
    Service[] services = serviceRegistry.getServices();
    String serviceParameter = request.getParameter("service");
    int simulation = this.getParameterInt(request, "sim", 0);
    if (simulation > 0) {
      Service[] sim = new Service[simulation + services.length];
      System.arraycopy(services, 0, sim, 0, services.length);
View Full Code Here

   * @throws Exception
   *             the exception
   */
  public static void load(ServiceListConfiguration serviceListConfiguration) throws Exception {
    Map<String, ServiceConfiguration> serviceConfigurationMap = serviceListConfiguration.getServiceConfigurations();
    ServiceRegistry serviceRegistry = AppContext.getServiceRegistry();

    for (ServiceConfiguration serviceConfiguration : serviceConfigurationMap.values()) {
      String serviceTypeString = serviceConfiguration.getType();
      ServiceType serviceType = ServiceType.getType(serviceTypeString);
      RemoteNodeConfiguration remoteNode = serviceConfiguration.getRemoteNodeConfiguration();
      String remotNodeName = null;
      if (remoteNode != null) {
        remotNodeName = remoteNode.getName();
        serviceType = ServiceConfiguration.adaptServiceTypeIfCascService(serviceType, remotNodeName);
      }
      String serviceName = serviceConfiguration.getName();

      // instantiate right type of service
      Service service = null;
      switch (serviceType) {
      case CASCADED_SESSION_SERVICE:
        Server server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new CascadedSessionService(serviceName, (CascadedSC) server);
        break;
      case CASCADED_PUBLISH_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }

        service = new CascadedPublishService(serviceName, (CascadedSC) server,
            serviceConfiguration.getNoDataIntervalSeconds());
        break;
      case CASCADED_CACHE_GUARDIAN:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for cache guardian =" + serviceName + " is not configured");
        }

        service = new CascadedCacheGuardian(serviceName, (CascadedSC) server,
            serviceConfiguration.getNoDataIntervalSeconds());
        break;
      case CASCADED_FILE_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new CascadedFileService(serviceName, (CascadedSC) server);
        break;
      case SESSION_SERVICE:
        service = new SessionService(serviceName);
        break;
      case PUBLISH_SERVICE:
        service = new PublishService(serviceName);
        break;
      case CACHE_GUARDIAN:
        service = new CacheGuardian(serviceName);
        break;
      case FILE_SERVICE:
        server = AppContext.getServerRegistry().getServer(remotNodeName);
        if (server == null) {
          throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, " host=" + remotNodeName
              + " configured for service=" + serviceName + " is not configured");
        }
        service = new FileService(serviceName, (FileServer) server, serviceConfiguration.getPath(),
            serviceConfiguration.getUploadScript(), serviceConfiguration.getListScript());
        break;
      case UNDEFINED:
      default:
        throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE,
            "wrong serviceType, serviceName/serviceType=" + serviceName + Constants.SLASH + serviceTypeString);
      }
      service.setEnabled(serviceConfiguration.getEnabled());
      serviceRegistry.addService(service.getName(), service);
    }
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.registry.ServiceRegistry

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.