public static byte[] serialize(Object value) { try { ReusableWritable output = new ReusableWritable(); ObjectOutputStream out = new ObjectOutputStream(output); out.writeObject(value); output.close(); return output.copy(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public byte[] renderToBytes(Object model) { RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.templateRenderingOutput(); doRender(locals, out, model); return out.copy(); }
public static byte[] renderPage(ReqImpl req, String content) { PageDecorator pageDecorator = Customization.of(req).pageDecorator(); U.must(pageDecorator != null, "A page decorator wasn't configured!"); ReusableWritable out = Msc.locals().pageRenderingStream(); try { pageDecorator.renderPage(req, content, out); } catch (Exception e) { throw U.rte("Error while rendering page!", e); } return out.copy(); }
@Override public byte[] renderToBytes(Object model) { RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.templateRenderingOutput(); doRender(locals, out, model); return out.copy(); }
public static byte[] renderPage(ReqImpl req, String content) { PageDecorator pageDecorator = Customization.of(req).pageDecorator(); U.must(pageDecorator != null, "A page decorator wasn't configured!"); ReusableWritable out = Msc.locals().pageRenderingStream(); try { pageDecorator.renderPage(req, content, out); } catch (Exception e) { throw U.rte("Error while rendering page!", e); } return out.copy(); }