protected void finish(final Pipeline<SAXPipelineComponent> pipeline, final HttpServletResponse response) throws ServletException, IOException { pipeline.addComponent(XMLSerializer.createHTML4Serializer()); pipeline.setup(response.getOutputStream()); try { pipeline.execute(); } catch (Exception e) { throw new ServletException(e); } }
@GET @Path("schema/json") public Response schemaJson(@Context final HttpServletRequest request, @Context final HttpServletResponse response) throws Exception { final Pipeline<SAXPipelineComponent> pipeline = new CachingPipeline<SAXPipelineComponent>(); pipeline.addComponent(new XMLGenerator(applicationWADL())); final XSLTTransformer schemaXSLT = new XSLTTransformer(getClass().getResource("/jsonxsd.xsl")); final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("contextPath", request.getContextPath()); parameters.put("schema-position", 1); parameters.put("schema-prefix", "schema"); schemaXSLT.setParameters(parameters); pipeline.addComponent(schemaXSLT); pipeline.addComponent(XMLSerializer.createHTML4Serializer()); pipeline.setup(response.getOutputStream()); pipeline.execute(); return Response.ok().build(); }
@GET public Response doGet(@Context final HttpServletRequest request, @Context final HttpServletResponse response) throws Exception { final Pipeline<SAXPipelineComponent> pipeline = new CachingPipeline<SAXPipelineComponent>(); pipeline.addComponent(new XMLGenerator(applicationWADL())); final XSLTTransformer xslt = new XSLTTransformer(getClass().getResource("/indexnew.xsl")); final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("contextPath", request.getContextPath()); parameters.put("application", "application"); xslt.setParameters(parameters); pipeline.addComponent(xslt); pipeline.addComponent(XMLSerializer.createHTML4Serializer()); pipeline.setup(response.getOutputStream()); pipeline.execute(); return Response.ok().build(); }
@GET @Path("schema") public Response schema(@Context final HttpServletRequest request, @Context final HttpServletResponse response) throws Exception { final Pipeline<SAXPipelineComponent> pipeline = new CachingPipeline<SAXPipelineComponent>(); pipeline.addComponent(new XMLGenerator(applicationWADL())); final XSLTTransformer schemaXSLT = new XSLTTransformer(getClass().getResource("/schemanew.xsl")); final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("contextPath", request.getContextPath()); parameters.put("schema-position", 1); parameters.put("schema-prefix", "schema"); schemaXSLT.setParameters(parameters); pipeline.addComponent(schemaXSLT); pipeline.addComponent(XMLSerializer.createHTML4Serializer()); pipeline.setup(response.getOutputStream()); pipeline.execute(); return Response.ok().build(); }
/** * {@inheritDoc} * * @see org.apache.cocoon.sitemap.Invocation#execute() */ public void execute() throws Exception { if (this.pipeline == null) { throw new IllegalStateException("InvocationImpl has been executed without having a pipeline."); } // first setup everything for (final Action action : this.actions) { action.setup(this.parameters); } this.pipeline.setup(this.outputStream, this.parameters); // then execute for (final Action action : this.actions) { action.execute(); } this.pipeline.execute(); }
public byte[] applicationWADL() throws Exception { final ByteArrayOutputStream baos; final Pipeline<SAXPipelineComponent> pipeline = new CachingPipeline<SAXPipelineComponent>(); final Application application = wadlContext.getApplication(uriInfo, false).getApplication(); /* * Get the current XML WADL into a byte array. */ final Marshaller marshaller = wadlContext.getJAXBContext().createMarshaller(); final ByteArrayOutputStream os = new ByteArrayOutputStream(); marshaller.marshal(application, os); final byte[] wadlXmlRepresentation = os.toByteArray(); final XMLGenerator pipelineComponent = new XMLGenerator(wadlXmlRepresentation); pipeline.addComponent(pipelineComponent); pipeline.addComponent(new XSLTTransformer(getClass().getResource("/prepare-includenew.xsl"))); pipeline.addComponent(new XIncludeTransformer(getClass().getResource("/"))); pipeline.addComponent(XMLSerializer.createXMLSerializer()); baos = new ByteArrayOutputStream(); pipeline.setup(baos); pipeline.execute(); return baos.toByteArray(); }
pipeline.setup(os); pipeline.execute();
pipeline.setup(outputStream, null); pipeline.execute();