Class KodexRestService<I,​O>

  • Type Parameters:
    I - the input type
    O - the output type
    All Implemented Interfaces:
    de.iip_ecosphere.platform.services.environment.MonitoringService, de.iip_ecosphere.platform.services.environment.ParameterConfigurerProvider, de.iip_ecosphere.platform.services.environment.Service, de.iip_ecosphere.platform.services.environment.switching.ServiceBase
    Direct Known Subclasses:
    MultiKodexRestService.ExKodexRestService

    public class KodexRestService<I,​O>
    extends de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>
    Integration of KIPROTECT KODEX as a service.
    Author:
    Holger Eichelberger, SSE
    • Nested Class Summary

      • Nested classes/interfaces inherited from class de.iip_ecosphere.platform.services.environment.AbstractProcessService

        de.iip_ecosphere.platform.services.environment.AbstractProcessService.RunnableWithStop
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String bearerToken  
      private java.lang.String dataSpec  
      private static boolean DEBUG  
      private java.io.File home  
      private java.lang.String host  
      private int port  
      static java.lang.String VERSION  
      static int WAITING_TIME_OTHER  
      static int WAITING_TIME_WIN  
      • Fields inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase

        APPLICATION_SEPARATOR, DEFAULT_APPLICATION_INSTANCE_ID
    • Constructor Summary

      Constructors 
      Constructor Description
      KodexRestService​(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I,​java.lang.String> inTrans, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​O> outTrans, de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<O> callback, de.iip_ecosphere.platform.services.environment.YamlService yaml)
      Creates an instance of the service with the required type translators to/from JSON.
      KodexRestService​(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I,​java.lang.String> inTrans, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​O> outTrans, de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<O> callback, de.iip_ecosphere.platform.services.environment.YamlService yaml, java.lang.String dataSpec)
      Creates an instance of the service with the required type translators to/from JSON.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String adjustRestQuery​(java.lang.String input, java.lang.String inTypeName)  
      protected java.lang.String adjustRestResponse​(java.lang.String response)  
      protected void configure​(java.lang.ProcessBuilder builder)  
      protected java.lang.String getApiPath()  
      protected java.lang.String getBearerToken()  
      protected int getWaitTimeBeforeDestroy()  
      protected void handleInputStream​(java.io.InputStream in)  
      void migrate​(java.lang.String resourceId)  
      void reconfigure​(java.util.Map<java.lang.String,​java.lang.String> values)  
      private void setNetworkDefaults()
      Sets network settings to KODEX defaults.
      protected de.iip_ecosphere.platform.services.environment.ServiceState start()  
      void switchTo​(java.lang.String targetId)  
      void update​(java.net.URI location)  
      • Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService

        getConnection, getNewConnectionInstance, getNewConnectionInstanceQuiet, handleReception, process, process, setupConnectionManager, stop, toSendString, waitForConnection
      • Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractProcessService

        addProcessSpecCmdArg, attachIngestor, attachMetricsProvider, createAndConfigureProcess, createProcess, createProcess, getCallbacks, getExecutableName, getExecutableName, getExecutablePrefix, getExecutablePrefix, getExecutableSuffix, getInputTranslator, getOsArch, getOutputTranslator, getPid, getProcessId, getProcessSpec, getServiceIn, getServiceSpec, handleErrorStream, handleOutputStream, notifyCallbacks, processQuiet, redirectIO, selectNotNull, selectNotNull, setInheritIo, waitAndDestroy, waitAndDestroy
      • Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractRunnablesService

        register
      • Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractService

        activate, addConfigurer, addConfigurer, addConfigurer, createInstance, createInstance, createInstance, getDescription, getId, getKind, getName, getNetMgtKeyAddress, getResourceAsStream, getState, getVersion, initializeFrom, isDeployable, isTopLevel, notifyReconfigured, passivate, reconf, reconfigure, rollbackReconfigurationOnFailure, setLibJars, setState
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface de.iip_ecosphere.platform.services.environment.Service

        activate, getDescription, getKind, getName, getNetMgtKeyAddress, getParameterConfigurer, getParameterNames, getVersion, isDeployable, isTopLevel, passivate
      • Methods inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase

        getId, getState, setState
    • Field Detail

      • dataSpec

        private java.lang.String dataSpec
      • bearerToken

        private java.lang.String bearerToken
      • home

        private java.io.File home
      • port

        private int port
      • host

        private java.lang.String host
    • Constructor Detail

      • KodexRestService

        public KodexRestService​(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I,​java.lang.String> inTrans,
                                de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​O> outTrans,
                                de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<O> callback,
                                de.iip_ecosphere.platform.services.environment.YamlService yaml)
        Creates an instance of the service with the required type translators to/from JSON. Data file is "data.yml".
        Parameters:
        inTrans - the input translator
        outTrans - the output translator
        callback - called when a processed item is received from the service
        yaml - the service description
      • KodexRestService

        public KodexRestService​(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I,​java.lang.String> inTrans,
                                de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​O> outTrans,
                                de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<O> callback,
                                de.iip_ecosphere.platform.services.environment.YamlService yaml,
                                java.lang.String dataSpec)
        Creates an instance of the service with the required type translators to/from JSON.
        Parameters:
        inTrans - the input translator
        outTrans - the output translator
        callback - called when a processed item is received from the service
        yaml - the service description
        dataSpec - name of the data spec file (within the process home path) to pass to KODEX; related files such as api or actions must be there as well and referenced from the data spec file
    • Method Detail

      • setNetworkDefaults

        private void setNetworkDefaults()
        Sets network settings to KODEX defaults.
      • start

        protected de.iip_ecosphere.platform.services.environment.ServiceState start()
                                                                             throws java.util.concurrent.ExecutionException
        Overrides:
        start in class de.iip_ecosphere.platform.services.environment.AbstractService
        Throws:
        java.util.concurrent.ExecutionException
      • configure

        protected void configure​(java.lang.ProcessBuilder builder)
        Overrides:
        configure in class de.iip_ecosphere.platform.services.environment.AbstractProcessService<I,​java.lang.String,​java.lang.String,​O>
      • getApiPath

        protected java.lang.String getApiPath()
        Specified by:
        getApiPath in class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>
      • getBearerToken

        protected java.lang.String getBearerToken()
        Specified by:
        getBearerToken in class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>
      • adjustRestQuery

        protected java.lang.String adjustRestQuery​(java.lang.String input,
                                                   java.lang.String inTypeName)
        Specified by:
        adjustRestQuery in class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>
      • adjustRestResponse

        protected java.lang.String adjustRestResponse​(java.lang.String response)
        Specified by:
        adjustRestResponse in class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>
      • getWaitTimeBeforeDestroy

        protected int getWaitTimeBeforeDestroy()
        Overrides:
        getWaitTimeBeforeDestroy in class de.iip_ecosphere.platform.services.environment.AbstractProcessService<I,​java.lang.String,​java.lang.String,​O>
      • migrate

        public void migrate​(java.lang.String resourceId)
                     throws java.util.concurrent.ExecutionException
        Throws:
        java.util.concurrent.ExecutionException
      • update

        public void update​(java.net.URI location)
                    throws java.util.concurrent.ExecutionException
        Throws:
        java.util.concurrent.ExecutionException
      • switchTo

        public void switchTo​(java.lang.String targetId)
                      throws java.util.concurrent.ExecutionException
        Throws:
        java.util.concurrent.ExecutionException
      • reconfigure

        public void reconfigure​(java.util.Map<java.lang.String,​java.lang.String> values)
                         throws java.util.concurrent.ExecutionException
        Specified by:
        reconfigure in interface de.iip_ecosphere.platform.services.environment.Service
        Overrides:
        reconfigure in class de.iip_ecosphere.platform.services.environment.AbstractService
        Throws:
        java.util.concurrent.ExecutionException
      • handleInputStream

        protected void handleInputStream​(java.io.InputStream in)
        Overrides:
        handleInputStream in class de.iip_ecosphere.platform.services.environment.AbstractRestProcessService<I,​O>