Skip to content

Commit

Permalink
Fix #224 - Add NO-OP init() and destroy() methods for Encoder/Decoder
Browse files Browse the repository at this point in the history
Now the minimum Java version is Java 8 we can do this as it is a binary
and source compatible change.

Signed-off-by: Mark Thomas <markt@apache.org>
  • Loading branch information
markt-asf committed May 7, 2020
1 parent 363c757 commit fbaab46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
12 changes: 9 additions & 3 deletions api/client/src/main/java/jakarta/websocket/Decoder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Oracle and/or its affiliates and others.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -36,15 +36,21 @@ public interface Decoder {
* This method is called with the endpoint configuration object of the endpoint this decoder is intended for when it
* is about to be brought into service.
*
* @implSpec The default implementation takes no action.
*
* @param config the endpoint configuration object when being brought into service
*/
void init(EndpointConfig config);
default void init(EndpointConfig config) {
}

/**
* This method is called when the decoder is about to be removed from service in order that any resources the
* decoder used may be closed gracefully.
*
* @implSpec The default implementation takes no action.
*/
void destroy();
default void destroy() {
}

/**
* This interface defines how a custom object (of type T) is decoded from a web socket message in the form of a byte
Expand Down
12 changes: 9 additions & 3 deletions api/client/src/main/java/jakarta/websocket/Encoder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Oracle and/or its affiliates and others.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -38,15 +38,21 @@ public interface Encoder {
* 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.
*
* @implSpec The default implementation takes no action.
*
* @param config the endpoint configuration object when being brought into service
*/
void init(EndpointConfig config);
default void init(EndpointConfig config) {
}

/**
* 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.
*
* @implSpec The default implementation takes no action.
*/
void destroy();
default void destroy() {
}

/**
* This interface defines how to provide a way to convert a custom object into a text message.
Expand Down
7 changes: 7 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
<packages>jakarta.websocket*</packages>
</group>
</groups>
<tags>
<tag>
<name>implSpec</name>
<placement>a</placement>
<head>Implementation Requirements:</head>
</tag>
</tags>
<links>
<link>http://docs.oracle.com/javase/6/docs/api/</link>
</links>
Expand Down

0 comments on commit fbaab46

Please sign in to comment.