Package org.restlet.engine.connector
Class ConnectionClosingRepresentation
- java.lang.Object
-
- org.restlet.representation.Variant
-
- org.restlet.representation.RepresentationInfo
-
- org.restlet.representation.Representation
-
- org.restlet.util.WrapperRepresentation
-
- org.restlet.engine.connector.ConnectionClosingRepresentation
-
class ConnectionClosingRepresentation extends WrapperRepresentation
Representation that wraps another representation and closes the parentHttpURLConnectionwhen the representation is released.
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.HttpURLConnectionconnectionThe parent connection.-
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
-
-
Constructor Summary
Constructors Constructor Description ConnectionClosingRepresentation(Representation wrappedRepresentation, java.net.HttpURLConnection connection)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrelease()Releases the representation and all associated objects like streams, channels or files which are used to produce its content, transient or not.-
Methods inherited from class org.restlet.util.WrapperRepresentation
exhaust, getAvailableSize, getChannel, getCharacterSet, getDigest, getDisposition, getEncodings, getExpirationDate, getLanguages, getLocationRef, getMediaType, getModificationDate, getRange, getReader, getRegistration, getSize, getStream, getTag, getText, getWrappedRepresentation, isAvailable, isSelectable, isTransient, setAvailable, setCharacterSet, setDigest, setDisposition, setEncodings, setExpirationDate, setLanguages, setLocationRef, setLocationRef, setMediaType, setModificationDate, setRange, setSize, setTag, setTransient, write, write, write
-
Methods inherited from class org.restlet.representation.Representation
append, hasKnownSize, isEmpty, setListener
-
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, hashCode, includes, isCompatible, toString
-
-
-
-
Constructor Detail
-
ConnectionClosingRepresentation
public ConnectionClosingRepresentation(Representation wrappedRepresentation, java.net.HttpURLConnection connection)
Default constructor.- Parameters:
wrappedRepresentation- The wrapped representation.connection- The parent connection.
-
-
Method Detail
-
release
public void release()
Description copied from class:RepresentationReleases the representation and all associated objects like streams, channels or files which are used to produce its content, transient or not. This method must be systematically called when the representation is no longer intended to be used. The framework automatically calls back this method via its connectors on the server-side when sending responses with an entity and on the client-side when sending a request with an entity. By default, it calls theRepresentation.setAvailable(boolean)method with "false" as a value.
Note that for transient socket-bound representations, calling this method after consuming the whole content shouldn't prevent the reuse of underlying socket via persistent connections for example. However, if the content hasn't been read, or has been partially read, the impact should be to discard the remaining content and to close the underlying connections.
Therefore, if you are not interested in the content, or in the remaining content, you should first call theRepresentation.exhaust()method or if this could be too costly, you should instead explicitly abort the parent request and the underlying connections using theRequest.abort()method or a shortcut one likeServerResource.abort()orResponse.abort().- Overrides:
releasein classWrapperRepresentation
-
-