forked from eclipse-ee4j/jersey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created FlushedCloseable interface to be passed to Context#setOutputS…
…tream Signed-off-by: jansupol <[email protected]>
- Loading branch information
Showing
5 changed files
with
141 additions
and
14 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
core-common/src/main/java/org/glassfish/jersey/io/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
/** | ||
* Common Jersey core io classes. | ||
*/ | ||
package org.glassfish.jersey.io; |
55 changes: 55 additions & 0 deletions
55
core-common/src/main/java/org/glassfish/jersey/io/spi/FlushedCloseable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.io.spi; | ||
|
||
import java.io.Closeable; | ||
import java.io.Flushable; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* A marker interface that the stream provided to Jersey can implement, | ||
* noting that the stream does not need to call {@link #flush()} prior to {@link #close()}. | ||
* That way, {@link #flush()} method is not called twice. | ||
* | ||
* <p> | ||
* Usable by {@link javax.ws.rs.client.ClientRequestContext#setEntityStream(OutputStream)}. | ||
* Usable by {@link javax.ws.rs.container.ContainerResponseContext#setEntityStream(OutputStream)}. | ||
* </p> | ||
* | ||
* <p> | ||
* This marker interface can be useful for the customer OutputStream to know the {@code flush} did not come from | ||
* Jersey before close. By default, when the entity stream is to be closed by Jersey, {@code flush} is called first. | ||
* </p> | ||
*/ | ||
public interface FlushedCloseable extends Flushable, Closeable { | ||
/** | ||
* Flushes this stream by writing any buffered output to the underlying stream. | ||
* Then closes this stream and releases any system resources associated | ||
* with it. If the stream is already closed then invoking this | ||
* method has no effect. | ||
* | ||
* <p> As noted in {@link AutoCloseable#close()}, cases where the | ||
* close may fail require careful attention. It is strongly advised | ||
* to relinquish the underlying resources and to internally | ||
* <em>mark</em> the {@code Closeable} as closed, prior to throwing | ||
* the {@code IOException}. | ||
* | ||
* @throws IOException if an I/O error occurs | ||
*/ | ||
public void close() throws IOException; | ||
} |
20 changes: 20 additions & 0 deletions
20
core-common/src/main/java/org/glassfish/jersey/io/spi/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
/** | ||
* Common Jersey core io SPI classes. | ||
*/ | ||
package org.glassfish.jersey.io.spi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters