01: /* Copyright (c) 2001 - 2008 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.ows;
06:
07: import java.io.IOException;
08: import java.io.OutputStream;
09:
10: /**
11: * A wrapper for a Dispatcher destination output stream that signals
12: * {@link IOException}s thrown while writing to the underlying destination as
13: * ignorable for OWS exception reporting, by throwing a
14: * {@link ClientStreamAbortedException}.
15: *
16: * @author Gabriel Roldan (TOPP)
17: * @version $Id: DispatcherOutputStream.java 8179 2008-01-16 16:56:48Z groldan $
18: * @since 1.6.x
19: */
20: public final class DispatcherOutputStream extends OutputStream {
21: private final OutputStream real;
22:
23: public DispatcherOutputStream(OutputStream real) {
24: this .real = real;
25: }
26:
27: /**
28: * @see OutputStream#flush()
29: */
30: public void flush() throws ClientStreamAbortedException {
31: try {
32: real.flush();
33: } catch (IOException e) {
34: throw new ClientStreamAbortedException(e);
35: }
36: }
37:
38: /**
39: * @see OutputStream#write(byte[], int, int)
40: */
41: public void write(byte b[], int off, int len)
42: throws ClientStreamAbortedException {
43: try {
44: real.write(b, off, len);
45: } catch (IOException e) {
46: throw new ClientStreamAbortedException(e);
47: }
48: }
49:
50: /**
51: * @see OutputStream#write(int)
52: */
53: public void write(int b) throws ClientStreamAbortedException {
54: try {
55: real.write(b);
56: } catch (IOException e) {
57: throw new ClientStreamAbortedException(e);
58: }
59: }
60:
61: /**
62: * @see OutputStream#close()
63: */
64: public void close() throws ClientStreamAbortedException {
65: try {
66: real.close();
67: } catch (IOException e) {
68: throw new ClientStreamAbortedException(e);
69: }
70: }
71:
72: }
|