Package org.wicketstuff.nashorn.resource
Class NashornResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.wicketstuff.nashorn.resource.NashornResource
-
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
public class NashornResource extends AbstractResource
A nashorn resource to execute java script on server side.
Please ensure to use theNashornSecurityManager
to restrict class access.- Author:
- Tobias Soloschenko
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ContentRangeType, AbstractResource.ResourceResponse, AbstractResource.WriteCallback
-
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description NashornResource(ScheduledExecutorService scheduledExecutorService, long delay, TimeUnit delayUnit, long wait, TimeUnit waitUnit, long maxScriptMemorySize)
Creates a new nashorn resource
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ClassFilter
getClassFilter()
Gets the class filter to apply to the scripting engineprotected Writer
getErrorWriter()
Gets the writer to which error messages are going to be written to the default is to useNullWriter
protected Writer
getWriter()
Gets the writer to which print outputs are going to be written to the default is to useNullWriter
protected boolean
isDebug()
If debug is enabledprotected AbstractResource.ResourceResponse
newResourceResponse(IResource.Attributes attributes)
Executes the java script code received from the client and returns the responseprotected AbstractResource.ResourceResponse
processError(Exception e)
Customize the error response sent to the clientprotected void
setup(IResource.Attributes attributes, Bindings bindings)
Setup the bindings and make information available to the scripting context-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
NashornResource
public NashornResource(ScheduledExecutorService scheduledExecutorService, long delay, TimeUnit delayUnit, long wait, TimeUnit waitUnit, long maxScriptMemorySize)
Creates a new nashorn resource- Parameters:
scheduledExecutorService
- the scheduled executor service to run scriptsdelay
- the delay until a script execution is going to be terminateddelayUnit
- the unit until a script execution is going to be terminatedwait
- how long to w8 until the next memory check occurswaitUnit
- the unit until the next memory check occursmaxScriptMemorySize
- the memory usage the script process should use - else it will be aborted
-
-
Method Detail
-
newResourceResponse
protected AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Executes the java script code received from the client and returns the response- Specified by:
newResourceResponse
in classAbstractResource
-
processError
protected AbstractResource.ResourceResponse processError(Exception e)
Customize the error response sent to the client- Parameters:
e
- the exception occurred- Returns:
- the error response
-
setup
protected void setup(IResource.Attributes attributes, Bindings bindings)
Setup the bindings and make information available to the scripting context- Parameters:
attributes
- the attributes of the requestbindings
- the bindings to add java objects to
-
getClassFilter
protected ClassFilter getClassFilter()
Gets the class filter to apply to the scripting engine- Returns:
- the class filter to apply to the scripting engine
-
getWriter
protected Writer getWriter()
Gets the writer to which print outputs are going to be written to the default is to useNullWriter
- Returns:
- the writer for output
-
getErrorWriter
protected Writer getErrorWriter()
Gets the writer to which error messages are going to be written to the default is to useNullWriter
- Returns:
- the error writer
-
isDebug
protected boolean isDebug()
If debug is enabled- Returns:
- if debug is enabled
-
-