Class PlainJSONScreen

  • All Implemented Interfaces:
    Assembler, Screen
    Direct Known Subclasses:
    PlainJSONSecureAnnotatedScreen

    public class PlainJSONScreen
    extends RawScreen
    A Screen class for dealing with JSON requests. Typically you would extend this class and override the doOutput() method to use it by setting the JSON output into rundata.setMessage( serialized ). As convenience you may use inject in your extended class the Turbine service JsonService Use 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); }

    Version:
    $Id$
    Author:
    gk