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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(EventListener listener) void
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, InetAddress ip) Return the list of authorizations for the specified token.long
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 ServiceEngineorg.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)
void
Pause the ServiceEngine.void
removeListener
(EventListener listener) void
resume()
Resume the ServiceEngine after previously being pausedSchedule a background task to runvoid
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
setStandaloneWebServer
(org.faceless.publisher.web.StandaloneWebServer server) Set the StandaloneWebServer that will be running this ServiceEngine.void
Set the Store on this object and callStore.setServiceEngine(org.faceless.publisher.web.ServiceEngine)
on the new object.void
shutdown()
Shutdown the ServiceEnginetoString()
Return a String value representing this ServiceEngine.toString
(boolean admin) Return a String value representing this ServiceEngine
-
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 bysetSecure(boolean)
-
addListener
-
removeListener
-
getHttpController
-
getWebsocketController
-
schedule
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
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
-
shutdown
public void shutdown()Shutdown the ServiceEngine -
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 -
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
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
-
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 anonip
- 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.
-