Repository: cxf Updated Branches: refs/heads/master 35639ab59 -> 938183d7b
[CXF-6882] Making NioInputStream and NioOutputStream concrete classes as it is now a CXF extension, making the names more consistent (Read vs Reader, Write vs Writer) Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/938183d7 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/938183d7 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/938183d7 Branch: refs/heads/master Commit: 938183d7b5f2ca238ce48af2934dd78282a871be Parents: 35639ab Author: Sergey Beryozkin <[email protected]> Authored: Tue Aug 8 14:15:51 2017 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Tue Aug 8 14:15:51 2017 +0100 ---------------------------------------------------------------------- .../cxf/jaxrs/nio/DelegatingNioInputStream.java | 84 -------------------- .../jaxrs/nio/DelegatingNioOutputStream.java | 55 ------------- .../cxf/jaxrs/nio/NioCompletionHandler.java | 25 ------ .../apache/cxf/jaxrs/nio/NioInputStream.java | 72 ++++++++++++++--- .../apache/cxf/jaxrs/nio/NioOutputStream.java | 37 +++++++-- .../cxf/jaxrs/nio/NioReadCompletionHandler.java | 25 ++++++ .../org/apache/cxf/jaxrs/nio/NioReadEntity.java | 10 +-- .../apache/cxf/jaxrs/nio/NioReadHandler.java | 35 ++++++++ .../cxf/jaxrs/nio/NioReadListenerImpl.java | 4 +- .../apache/cxf/jaxrs/nio/NioReaderHandler.java | 35 -------- .../apache/cxf/jaxrs/nio/NioWriteEntity.java | 6 +- .../apache/cxf/jaxrs/nio/NioWriteHandler.java | 34 ++++++++ .../cxf/jaxrs/nio/NioWriteListenerImpl.java | 4 +- .../apache/cxf/jaxrs/nio/NioWriterHandler.java | 34 -------- .../cxf/jaxrs/provider/BinaryDataProvider.java | 9 +-- 15 files changed, 203 insertions(+), 266 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioInputStream.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioInputStream.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioInputStream.java deleted file mode 100644 index 65c97be..0000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioInputStream.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxrs.nio; - -import java.io.IOException; - -import javax.servlet.ServletInputStream; - -public class DelegatingNioInputStream extends NioInputStream { - private final ServletInputStream in; - - public DelegatingNioInputStream(final ServletInputStream in) { - this.in = in; - } - - @Override - public boolean isFinished() { - return in.isFinished(); - } - - @Override - public int read() throws IOException { - return in.read(); - } - - @Override - public int read(byte[] b, int off, int len) throws IOException { - return in.read(b, off, len); - } - - @Override - public int read(byte[] b) throws IOException { - return in.read(b); - } - - @Override - public synchronized void reset() throws IOException { - in.reset(); - } - - @Override - public void close() throws IOException { - in.close(); - } - - @Override - public long skip(long n) throws IOException { - return in.skip(n); - } - @Override - public int available() throws IOException { - return in.available(); - } - - @Override - public synchronized void mark(int readlimit) { - in.mark(readlimit); - } - - @Override - public boolean markSupported() { - return in.markSupported(); - } - - public boolean isReady() { - return in.isReady(); - } -} http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioOutputStream.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioOutputStream.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioOutputStream.java deleted file mode 100644 index ec066be..0000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/DelegatingNioOutputStream.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxrs.nio; - -import java.io.IOException; -import java.io.OutputStream; - -public class DelegatingNioOutputStream extends NioOutputStream { - private final OutputStream out; - - public DelegatingNioOutputStream(final OutputStream out) { - this.out = out; - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - out.write(b, off, len); - } - - @Override - public void write(byte[] b) throws IOException { - out.write(b); - } - - @Override - public void write(int b) throws IOException { - out.write(b); - } - - @Override - public void flush() throws IOException { - out.flush(); - } - - @Override - public void close() throws IOException { - out.close(); - } -} http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioCompletionHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioCompletionHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioCompletionHandler.java deleted file mode 100644 index 534dca9..0000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioCompletionHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxrs.nio; - -@FunctionalInterface -public interface NioCompletionHandler { - void complete(NioInputStream in); -} - http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioInputStream.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioInputStream.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioInputStream.java index f75b890..7bc8b52 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioInputStream.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioInputStream.java @@ -18,17 +18,67 @@ */ package org.apache.cxf.jaxrs.nio; +import java.io.IOException; import java.io.InputStream; -/** - * Class NioReader. - */ -public abstract class NioInputStream extends InputStream { - /** - * Checks if the the input stream has been consumed. - * - * @return outcome of test. - */ - public abstract boolean isFinished(); -} +import javax.servlet.ServletInputStream; + +public class NioInputStream extends InputStream { + private final ServletInputStream in; + + public NioInputStream(final ServletInputStream in) { + this.in = in; + } + + public boolean isFinished() { + return in.isFinished(); + } + + @Override + public int read() throws IOException { + return in.read(); + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + return in.read(b, off, len); + } + @Override + public int read(byte[] b) throws IOException { + return in.read(b); + } + + @Override + public synchronized void reset() throws IOException { + in.reset(); + } + + @Override + public void close() throws IOException { + in.close(); + } + + @Override + public long skip(long n) throws IOException { + return in.skip(n); + } + @Override + public int available() throws IOException { + return in.available(); + } + + @Override + public synchronized void mark(int readlimit) { + in.mark(readlimit); + } + + @Override + public boolean markSupported() { + return in.markSupported(); + } + + public boolean isReady() { + return in.isReady(); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioOutputStream.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioOutputStream.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioOutputStream.java index 3ac1fdf..38915f1 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioOutputStream.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioOutputStream.java @@ -18,11 +18,38 @@ */ package org.apache.cxf.jaxrs.nio; +import java.io.IOException; import java.io.OutputStream; -/** - * Class NioReader. - */ -public abstract class NioOutputStream extends OutputStream { -} +public class NioOutputStream extends OutputStream { + private final OutputStream out; + + public NioOutputStream(final OutputStream out) { + this.out = out; + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + out.write(b, off, len); + } + @Override + public void write(byte[] b) throws IOException { + out.write(b); + } + + @Override + public void write(int b) throws IOException { + out.write(b); + } + + @Override + public void flush() throws IOException { + out.flush(); + } + + @Override + public void close() throws IOException { + out.close(); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadCompletionHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadCompletionHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadCompletionHandler.java new file mode 100644 index 0000000..c889a0d --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadCompletionHandler.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.jaxrs.nio; + +@FunctionalInterface +public interface NioReadCompletionHandler { + void complete(NioInputStream in); +} + http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadEntity.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadEntity.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadEntity.java index 8804401..a7b17fe 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadEntity.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadEntity.java @@ -27,11 +27,11 @@ import org.apache.cxf.message.Message; import org.apache.cxf.transport.http.AbstractHTTPDestination; public class NioReadEntity { - private final NioReaderHandler reader; - private final NioCompletionHandler completion; + private final NioReadHandler reader; + private final NioReadCompletionHandler completion; private final NioErrorHandler error; - public NioReadEntity(NioReaderHandler reader, NioCompletionHandler completion, NioErrorHandler error) { + public NioReadEntity(NioReadHandler reader, NioReadCompletionHandler completion, NioErrorHandler error) { this.reader = reader; this.completion = completion; this.error = error; @@ -49,11 +49,11 @@ public class NioReadEntity { } } - public NioReaderHandler getReader() { + public NioReadHandler getReader() { return reader; } - public NioCompletionHandler getCompletion() { + public NioReadCompletionHandler getCompletion() { return completion; } http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadHandler.java new file mode 100644 index 0000000..b5c6674 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadHandler.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.jaxrs.nio; + +/** + * Class NioReader. + */ +@FunctionalInterface +public interface NioReadHandler { + /** + * Called every time it is possible to read from the input stream without blocking. The last + * time this method is called, the value of {@code in.isFinished()} must be {@code true} to + * indicate that all the stream has been read. + * + * @param in input stream. + */ + void read(NioInputStream in); +} + http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadListenerImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadListenerImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadListenerImpl.java index d51cc97..c39ab36 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadListenerImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReadListenerImpl.java @@ -30,11 +30,11 @@ import org.apache.cxf.jaxrs.utils.ExceptionUtils; public final class NioReadListenerImpl implements ReadListener { private static final Logger LOG = LogUtils.getL7dLogger(NioReadListenerImpl.class); private final NioReadEntity entity; - private final DelegatingNioInputStream in; + private final NioInputStream in; public NioReadListenerImpl(NioReadEntity entity, ServletInputStream in) { this.entity = entity; - this.in = new DelegatingNioInputStream(in); + this.in = new NioInputStream(in); } @Override http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReaderHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReaderHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReaderHandler.java deleted file mode 100644 index 912684f..0000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioReaderHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxrs.nio; - -/** - * Class NioReader. - */ -@FunctionalInterface -public interface NioReaderHandler { - /** - * Called every time it is possible to read from the input stream without blocking. The last - * time this method is called, the value of {@code in.isFinished()} must be {@code true} to - * indicate that all the stream has been read. - * - * @param in input stream. - */ - void read(NioInputStream in); -} - http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteEntity.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteEntity.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteEntity.java index 1f09f92..32874e3 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteEntity.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteEntity.java @@ -19,15 +19,15 @@ package org.apache.cxf.jaxrs.nio; public final class NioWriteEntity { - private final NioWriterHandler writer; + private final NioWriteHandler writer; private final NioErrorHandler error; - public NioWriteEntity(final NioWriterHandler writer, final NioErrorHandler error) { + public NioWriteEntity(final NioWriteHandler writer, final NioErrorHandler error) { this.writer = writer; this.error = error; } - public NioWriterHandler getWriter() { + public NioWriteHandler getWriter() { return writer; } http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteHandler.java new file mode 100644 index 0000000..8d26589 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteHandler.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.jaxrs.nio; + +/** + * Class NioWriterHandler. + */ +@FunctionalInterface +public interface NioWriteHandler { + /** + * Method called when it is possible to write some data without blocking. + * + * @param out output stream. + * @return {@code true} if there is more data to write, {@code false} otherwise. + */ + boolean write(NioOutputStream out); +} + http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java index 2ed86dc..d20133f 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java @@ -32,12 +32,12 @@ public final class NioWriteListenerImpl implements WriteListener { private static final Logger LOG = LogUtils.getL7dLogger(NioWriteListenerImpl.class); private Continuation cont; private final NioWriteEntity entity; - private final DelegatingNioOutputStream out; + private final NioOutputStream out; public NioWriteListenerImpl(Continuation cont, NioWriteEntity entity, OutputStream out) { this.cont = cont; this.entity = entity; - this.out = new DelegatingNioOutputStream(out); + this.out = new NioOutputStream(out); } @Override http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriterHandler.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriterHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriterHandler.java deleted file mode 100644 index 920b3a1..0000000 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriterHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxrs.nio; - -/** - * Class NioWriterHandler. - */ -@FunctionalInterface -public interface NioWriterHandler { - /** - * Method called when it is possible to write some data without blocking. - * - * @param out output stream. - * @return {@code true} if there is more data to write, {@code false} otherwise. - */ - boolean write(NioOutputStream out); -} - http://git-wip-us.apache.org/repos/asf/cxf/blob/938183d7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java index dcead64..dc4987f 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java @@ -54,11 +54,10 @@ import org.apache.cxf.continuations.ContinuationProvider; import org.apache.cxf.helpers.FileUtils; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.jaxrs.impl.HttpHeadersImpl; -import org.apache.cxf.jaxrs.nio.DelegatingNioOutputStream; import org.apache.cxf.jaxrs.nio.NioOutputStream; import org.apache.cxf.jaxrs.nio.NioWriteEntity; +import org.apache.cxf.jaxrs.nio.NioWriteHandler; import org.apache.cxf.jaxrs.nio.NioWriteListenerImpl; -import org.apache.cxf.jaxrs.nio.NioWriterHandler; import org.apache.cxf.jaxrs.utils.AnnotationUtils; import org.apache.cxf.jaxrs.utils.ExceptionUtils; import org.apache.cxf.jaxrs.utils.JAXRSUtils; @@ -215,7 +214,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, new NioWriteEntity(getNioHandler(is), null), - new DelegatingNioOutputStream(os)); + new NioOutputStream(os)); Message m = JAXRSUtils.getCurrentMessage(); m.put(WriteListener.class, listener); cont.suspend(0); @@ -261,9 +260,9 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider this.bufferSize = bufferSize; } - protected NioWriterHandler getNioHandler(final InputStream in) { + protected NioWriteHandler getNioHandler(final InputStream in) { - return new NioWriterHandler() { + return new NioWriteHandler() { final byte[] buffer = new byte[bufferSize]; @Override public boolean write(NioOutputStream out) {
