public class PlainJSONScreen extends RawScreen
PlainJSONSecureAnnotatedScreen
if you need the user to be
logged in or having a special role in prior to executing the functions you provide.
Here is an example from a subclass:
public void doOutput(PipelineData pipelineData) throws Exception
{
RunData data = pipelineData.getRunData();
JSONStrategy strategy = null;
try
{
strategy = new XYStrategy();
// the result goes into rundata.message
strategy.execute(data, jsonService);
}
catch ( Exception e )
{
log.error( "init failed for "+strategy , e);
String msg = new JSONObject().put("error", e.getMessage()).toString();
data.setMessage( msg );
}
super.doOutput(data);
}
Modifier and Type | Field and Description |
---|---|
protected static int |
BUFFER_SIZE |
protected static String |
JSON_TYPE |
CACHE_SIZE_DEFAULT, CACHE_SIZE_KEY, NAME, PREFIX
Constructor and Description |
---|
PlainJSONScreen() |
Modifier and Type | Method and Description |
---|---|
protected void |
doOutput(PipelineData pipelineData)
Output JSON content set into
RunData.getMessage() . |
protected String |
getContentType(PipelineData pipelineData)
Set the content type.
|
protected static final String JSON_TYPE
protected static final int BUFFER_SIZE
public PlainJSONScreen()
protected String getContentType(PipelineData pipelineData)
RawScreen
getContentType
in class RawScreen
pipelineData
- Turbine information.RawScreen.getContentType(org.apache.turbine.pipeline.PipelineData)
protected void doOutput(PipelineData pipelineData) throws Exception
RunData.getMessage()
.
Encoding is UTF-8. @JSON_TYPE
: "application/json;charset=utf-8".Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.