Class ServiceEngine


public class ServiceEngine extends Object
The core "engine" that drives the Web Service, which has HttpController and WebsocketController interfaces onto it
  • Constructor Details

    • ServiceEngine

      public ServiceEngine()
  • Method Details

    • setSecure

      public void setSecure(boolean secure)
      This method should be called to enable options which would allow various actions (such as allowing access to the filesystem) which would be insecure if they were left unrestricted. Calling this method indicates that the adminstrator is aware of the security implications of allowing thse.
    • isSecure

      public boolean isSecure()
      Return the value of the "secure" flag, as set by setSecure(boolean)
    • addListener

      public void addListener(EventListener listener)
    • removeListener

      public void removeListener(EventListener listener)
    • getHttpController

      public HttpController getHttpController()
    • getWebsocketController

      public WebsocketController getWebsocketController()
    • schedule

      public ScheduledFuture<?> schedule(Runnable task, long ms)
      Schedule a background task to run
    • isPaused

      public boolean isPaused()
      Return true if this ServiceEngine is paused. When paused jobs can be queued, but no new jobs will execute
    • pause

      public void pause(Runnable r, long timeout)
      Pause the ServiceEngine. No new jobs will be executed, although existing jobs will be left to finish. When all the currently executing jobs are completed or when the timeout period is reached (whichever is first), the supplied task will be run.
      r - the Runnable to run when all jobs are completed or the timeout is reached. May be null.
      timeout - the time in milliseconds to wait for jobs to complete before running "r"
    • resume

      public void resume()
      Resume the ServiceEngine after previously being paused
    • cacheClear

      public void cacheClear()
      Clear the Resource cache used by the ReportFactory
    • shutdown

      public void shutdown()
      Shutdown the ServiceEngine
    • getPendingTasks

      public List<org.faceless.publisher.web.ReportHandle> getPendingTasks()
      Get a list of tasks that are pending, waiting for the ExecutorService
    • getRunningTasks

      public List<org.faceless.publisher.web.ReportHandle> getRunningTasks()
      Get a list of tasks that are running currently, waiting for the ExecutorService
    • setStandaloneWebServer

      public void setStandaloneWebServer(org.faceless.publisher.web.StandaloneWebServer server)
      Set the StandaloneWebServer that will be running this ServiceEngine. This is called when the ServiceEngine is set up, and allows the StandaloneWebServer to be configured and controlled remotely. It's optional, and won't be called when the ServiceEngine is not controlling the web server, for example if it's running as part of Apache Tomcat
    • configure

      public boolean configure(Json json)
      Configure this ServiceEngine. If tasks are currently running this method will return false and no configuration takes place. Otherwise the engine is paused, the configuration is applied and the engine resumed if it was resumed when this method was called.
    • toString

      public String toString()
      Return a String value representing this ServiceEngine. Calls toString(false)
      toString in class Object
    • toString

      public String toString(boolean admin)
      Return a String value representing this ServiceEngine
      admin - whether to include admin-only details
    • setStore

      public void setStore(Store store)
      Set the Store on this object and call Store.setServiceEngine(org.faceless.publisher.web.ServiceEngine) on the new object. Any existing store is unchanged, it's the callers responsibility to shut it down cleanly
    • getStore

      public Store getStore()
      Return the Store used by this ServiceEngine
    • getAuthorities

      public List<Authority> getAuthorities()
      Return the list of Authority objects used by this ServiceEngine to allow tasks to be run. The list is live and can be modified
    • getProxyServers

      public List<String> getProxyServers()
      Return the list of IP addresses that will be accepted as valid proxies. Incoming HTTP or WebSocket requests that come from one of these addresses will be checked for an X-Forwarded-For HTTP header, and if found that address will be used instead. The list is live and can be modified. Any IP addresses added should be in lower case, and must be IPv4 or IPv5 addresses, not hostnames.
    • setMaxThreads

      public void setMaxThreads(int numthreads)
      Set the maximum number of threads that can be used to execute tasks
      numthreads - the number of threads, which must be at least one
    • getMaxThreads

      public int getMaxThreads()
      Return the maximum number of threads that can be used to execute tasks, as set by setMaxThreads(int)
      the number of threads
    • setMaxQueueSize

      public void setMaxQueueSize(int queuesize)
      Set the maximum number of tasks that can be queued waiting for an executor. The size may be reduced to below the number of currently queued tasks without error.
      queuesize - the maximum number of tasks to queue, which must be at least one
    • getMaxQueueSize

      public int getMaxQueueSize()
      Return the maximum number of tasks that can be queued, as set by setMaxQueueSize(int)
      the maximum number of tasks to queue
    • setMaxBufferSize

      public void setMaxBufferSize(long buffersize)
      Set the maximum amount of data that can be uploaded.
    • getMaxBufferSize

      public long getMaxBufferSize()
      Return the maximum buffer size, as set by setMaxBufferSize(long)
      the maximum buffer size
    • getReportFactory

      public ReportFactory getReportFactory()
      Return the ReportFactory used by this ServiceEngine
    • getAuthorization

      public Authorization getAuthorization(String accessToken, InetAddress ip)
      Return the list of authorizations for the specified token. If the token is null, invalid or damaged, returns the authorization granted anonymous users. The supplied JWT access tokens must be signed by a key specified by an Authority known to this class (see getAuthorities()
      accessToken - the JWT access token that's claiming to authorize this action, or null for anon
      ip - the IP address the request has come from, or null if that is not available
    • initializeConvert

      public org.faceless.publisher.web.ReportHandle initializeConvert(Json json, Authorization auth) throws IOException
      See docs
    • find

      public org.faceless.publisher.web.ReportHandle find(String folder, Authorization auth)
      Return an active job, one which is currently queued or running. The store is not accessed
      folder - the job folder
      auth - the secret required to access the job, or "*" for admin access
      the handle if it's in any state between "Pending" and "Error", or null if it's not yet enqueued, has been deleted, doesn't exist or if the secret token is incorrect.