List of usage examples for org.springframework.util CommonsLogWriter CommonsLogWriter
public CommonsLogWriter(Log logger)
From source file:org.springframework.remoting.caucho.Hessian2SkeletonInvoker.java
public void invoke(final InputStream inputStream, final OutputStream outputStream) throws Throwable { InputStream isToUse = inputStream; OutputStream osToUse = outputStream; if (this.debugLogger != null && this.debugLogger.isDebugEnabled()) { PrintWriter debugWriter = new PrintWriter(new CommonsLogWriter(this.debugLogger)); isToUse = new HessianDebugInputStream(inputStream, debugWriter); if (debugOutputStreamAvailable) { osToUse = DebugStreamFactory.createDebugOutputStream(outputStream, debugWriter); }/*from w ww . ja v a 2 s. co m*/ } Hessian2Input in = new Hessian2Input(isToUse); if (this.serializerFactory != null) { in.setSerializerFactory(this.serializerFactory); } int code = in.read(); if (code != 'c') { throw new IOException("expected 'c' in hessian input at " + code); } AbstractHessianOutput out = null; int major = in.read(); int minor = in.read(); if (major >= 2) { out = new Hessian2Output(osToUse); } else { out = new HessianOutput(osToUse); } if (this.serializerFactory != null) { out.setSerializerFactory(this.serializerFactory); } try { this.skeleton.invoke(in, out); } finally { try { in.close(); isToUse.close(); } catch (IOException ex) { } try { out.close(); osToUse.close(); } catch (IOException ex) { } } }
From source file:org.springframework.remoting.caucho.HessianExporter.java
/** * Actually invoke the skeleton with the given streams. * @param skeleton the skeleton to invoke * @param inputStream the request stream * @param outputStream the response stream * @throws Throwable if invocation failed */// w ww . j av a2 s . co m protected void doInvoke(HessianSkeleton skeleton, InputStream inputStream, OutputStream outputStream) throws Throwable { ClassLoader originalClassLoader = overrideThreadContextClassLoader(); try { InputStream isToUse = inputStream; OutputStream osToUse = outputStream; if (this.debugLogger != null && this.debugLogger.isDebugEnabled()) { try (PrintWriter debugWriter = new PrintWriter(new CommonsLogWriter(this.debugLogger))) { @SuppressWarnings("resource") HessianDebugInputStream dis = new HessianDebugInputStream(inputStream, debugWriter); @SuppressWarnings("resource") HessianDebugOutputStream dos = new HessianDebugOutputStream(outputStream, debugWriter); dis.startTop2(); dos.startTop2(); isToUse = dis; osToUse = dos; } } if (!isToUse.markSupported()) { isToUse = new BufferedInputStream(isToUse); isToUse.mark(1); } int code = isToUse.read(); int major; int minor; AbstractHessianInput in; AbstractHessianOutput out; if (code == 'H') { // Hessian 2.0 stream major = isToUse.read(); minor = isToUse.read(); if (major != 0x02) { throw new IOException("Version " + major + '.' + minor + " is not understood"); } in = new Hessian2Input(isToUse); out = new Hessian2Output(osToUse); in.readCall(); } else if (code == 'C') { // Hessian 2.0 call... for some reason not handled in HessianServlet! isToUse.reset(); in = new Hessian2Input(isToUse); out = new Hessian2Output(osToUse); in.readCall(); } else if (code == 'c') { // Hessian 1.0 call major = isToUse.read(); minor = isToUse.read(); in = new HessianInput(isToUse); if (major >= 2) { out = new Hessian2Output(osToUse); } else { out = new HessianOutput(osToUse); } } else { throw new IOException( "Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code); } in.setSerializerFactory(this.serializerFactory); out.setSerializerFactory(this.serializerFactory); if (this.remoteResolver != null) { in.setRemoteResolver(this.remoteResolver); } try { skeleton.invoke(in, out); } finally { try { in.close(); isToUse.close(); } catch (IOException ex) { // ignore } try { out.close(); osToUse.close(); } catch (IOException ex) { // ignore } } } finally { resetThreadContextClassLoader(originalClassLoader); } }