Package org.faceless.publisher.web
Class ServiceEngine
java.lang.Object
org.faceless.publisher.web.ServiceEngine
The core "engine" that drives the Web Service, which has
HttpController
and WebsocketController
interfaces onto it-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the Resource cache used by the ReportFactoryboolean
configure
(Json json) Configure this ServiceEngine.org.faceless.publisher.web.ReportHandle
find
(String folder, Authorization auth) Return an active job, one which is currently queued or running.Return the list of Authority objects used by this ServiceEngine to allow tasks to be run.getAuthorization
(String accessToken, String origin, InetAddress ip) Return the list of authorizations for the specified token.Return the HttpControllerstatic ServiceEngine
Return a shared instance of a ServiceEngine, creating it if necessarylong
Return the maximum buffer size, as set bysetMaxBufferSize(long)
int
Return the maximum number of tasks that can be queued, as set bysetMaxQueueSize(int)
int
Return the maximum number of threads that can be used to execute tasks, as set bysetMaxThreads(int)
List<org.faceless.publisher.web.ReportHandle>
Get a list of tasks that are pending, waiting for the ExecutorServiceReturn the list of IP addresses that will be accepted as valid proxies.Return the ReportFactory used by this ServiceEngineList<org.faceless.publisher.web.ReportHandle>
Get a list of tasks that are running currently, waiting for the ExecutorServicegetStore()
Return the Store used by this ServiceEngineReturn the WebsocketControllerorg.faceless.publisher.web.ReportHandle
initializeConvert
(Json json, Authorization auth) See docsboolean
isPaused()
Return true if this ServiceEngine is paused.boolean
isSecure()
Return the value of the "secure" flag, as set bysetSecure(boolean)
boolean
Return whether the "simple" HTTP API can be used.void
Pause the ServiceEngine.void
resume()
Resume the ServiceEngine after previously being pausedvoid
setMaxBufferSize
(long buffersize) Set the maximum amount of data that can be uploaded.void
setMaxQueueSize
(int queuesize) Set the maximum number of tasks that can be queued waiting for an executor.void
setMaxThreads
(int numthreads) Set the maximum number of threads that can be used to execute tasksvoid
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.void
setSimpleAPI
(boolean simpleapi) Set whether the "simple" HTTP API can be used (default is true)void
Set the Store on this object and callStore.setServiceEngine(org.faceless.publisher.web.ServiceEngine)
on the new object.shutdown
(boolean mayInterrupt) Shutdown the ServiceEnginestart()
Start the server, or if it's alrady started, return the future that can be used to monitor or stop it.toString()
Return a String value representing this ServiceEngine.toString
(boolean admin) Return a String value representing this ServiceEngine
-
Constructor Details
-
ServiceEngine
public ServiceEngine()Create a new ServiceEngine
-
-
Method Details
-
getInstance
Return a shared instance of a ServiceEngine, creating it if necessary- Returns:
- this;
-
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.- Parameters:
secure
- the secure flag
-
isSecure
public boolean isSecure()Return the value of the "secure" flag, as set bysetSecure(boolean)
- Returns:
- the secure flag
-
getHttpController
Return the HttpController -
getWebsocketController
Return the WebsocketController -
isPaused
public boolean isPaused()Return true if this ServiceEngine is paused. When paused jobs can be queued, but no new jobs will execute -
pause
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.- Parameters:
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- Since:
- 1.2
-
start
Start the server, or if it's alrady started, return the future that can be used to monitor or stop it.- Returns:
- a future that can be used to monitor or stop the server
-
shutdown
Shutdown the ServiceEngine- Returns:
- the same future returned from
start()
-
getPendingTasks
Get a list of tasks that are pending, waiting for the ExecutorService -
getRunningTasks
Get a list of tasks that are running currently, waiting for the ExecutorService -
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
Return a String value representing this ServiceEngine. Calls toString(false) -
toString
Return a String value representing this ServiceEngine- Parameters:
admin
- whether to include admin-only details
-
setStore
Set the Store on this object and callStore.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
Return the Store used by this ServiceEngine -
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
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 anX-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.- Since:
- 1.1
-
setSimpleAPI
public void setSimpleAPI(boolean simpleapi) Set whether the "simple" HTTP API can be used (default is true)- Parameters:
simpelapi
- whether the simple API can be used
-
isSimpleAPI
public boolean isSimpleAPI()Return whether the "simple" HTTP API can be used. -
setMaxThreads
public void setMaxThreads(int numthreads) Set the maximum number of threads that can be used to execute tasks- Parameters:
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 bysetMaxThreads(int)
- Returns:
- 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.- Parameters:
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 bysetMaxQueueSize(int)
- Returns:
- 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 bysetMaxBufferSize(long)
- Returns:
- the maximum buffer size
-
getReportFactory
Return the ReportFactory used by this ServiceEngine -
getAuthorization
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 anAuthority
known to this class (seegetAuthorities()
- Parameters:
accessToken
- the JWT access token that's claiming to authorize this action, or null for anonorigin
- the Origin header for the HTTP connection that originated this session, or null if unspecifiedip
- the IP address the request has come from, ornull
if that is not available
-
initializeConvert
public org.faceless.publisher.web.ReportHandle initializeConvert(Json json, Authorization auth) throws IOException See docs- Throws:
IOException
-
find
Return an active job, one which is currently queued or running. The store is not accessed- Parameters:
folder
- the job folderauth
- the secret required to access the job, or "*" for admin access- Returns:
- 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.
-