Package javax.websocket
Interface Encoder
- All Known Subinterfaces:
Encoder.Binary<T>
,Encoder.BinaryStream<T>
,Encoder.Text<T>
,Encoder.TextStream<T>
public interface Encoder
The Encoder interface defines how developers can provide a way to convert
their custom objects into web socket messages. The Encoder interface contains
subinterfaces that allow encoding algorithms to encode custom objects to: text,
binary data, character stream and write to an output stream.
The websocket implementation creates a new instance of the encoder per
endpoint instance per connection. This means that each encoder instance has
at most one calling thread at a time.
The lifecycle of the Encoder instance is governed by the container calls to the
init(javax.websocket.EndpointConfig)
and destroy()
methods.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
This interface defines how to provide a way to convert a custom object into a binary message.static interface
This interface may be implemented by encoding algorithms that want to write the encoded object to a binary stream.static interface
This interface defines how to provide a way to convert a custom object into a text message.static interface
This interface may be implemented by encoding algorithms that want to write the encoded object to a character stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
This method is called when the encoder is about to be removed from service in order that any resources the encoder used may be closed gracefully.void
init
(EndpointConfig config) This method is called with the endpoint configuration object of the endpoint this encoder is intended for when it is about to be brought into service.
-
Method Details
-
init
This method is called with the endpoint configuration object of the endpoint this encoder is intended for when it is about to be brought into service.- Parameters:
config
- the endpoint configuration object when being brought into service
-
destroy
void destroy()This method is called when the encoder is about to be removed from service in order that any resources the encoder used may be closed gracefully.
-