Removing deprecated methods in Jetty 10
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
0b972efc3f
commit
fe051bf392
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
|
||||
|
@ -43,7 +44,7 @@ public class WebSocketServer
|
|||
@OnWebSocketMessage
|
||||
public void onMessage( Session session, String message )
|
||||
{
|
||||
session.getRemote().sendStringByFuture(message);
|
||||
session.getRemote().sendString(message, WriteCallback.NOOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.osgi.test;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
@ -52,7 +51,6 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketClose
|
||||
public void onClose(int statusCode, String reason)
|
||||
{
|
||||
//System.out.printf("Connection closed: %d - %s%n",statusCode,reason);
|
||||
this.session = null;
|
||||
this.closeLatch.countDown(); // trigger latch
|
||||
}
|
||||
|
@ -60,17 +58,10 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketConnect
|
||||
public void onConnect(Session session)
|
||||
{
|
||||
//System.out.printf("Got connect: %s%n",session);
|
||||
this.session = session;
|
||||
try
|
||||
{
|
||||
Future<Void> fut;
|
||||
//System.err.println("Sending Foo!");
|
||||
fut = session.getRemote().sendStringByFuture("Foo");
|
||||
|
||||
fut.get(2,TimeUnit.SECONDS); // wait for send to complete.
|
||||
//System.err.println("Foo complete");
|
||||
|
||||
session.getRemote().sendString("Foo");
|
||||
session.close(StatusCode.NORMAL,"I'm done");
|
||||
}
|
||||
catch (Throwable t)
|
||||
|
@ -82,6 +73,5 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketMessage
|
||||
public void onMessage(String msg)
|
||||
{
|
||||
//System.out.printf("Got msg: %s%n",msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface RemoteEndpoint
|
||||
{
|
||||
|
@ -45,16 +43,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendBytes(ByteBuffer data, WriteCallback callback);
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted.
|
||||
* Developers may use the returned Future object to track progress of the transmission.
|
||||
*
|
||||
* @param data the data being sent
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendBytesByFuture(ByteBuffer data);
|
||||
|
||||
/**
|
||||
* Send a binary message in pieces, blocking until all of the message has been transmitted.
|
||||
* The runtime reads the message in order. Non-final pieces are
|
||||
|
@ -79,20 +67,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendPartialBytes(ByteBuffer fragment, boolean isLast, WriteCallback callback);
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a partial binary message. This method returns before the message is
|
||||
* transmitted.
|
||||
* The runtime reads the message in order. Non-final pieces are sent with isLast
|
||||
* set to false. The final piece must be sent with isLast set to true.
|
||||
* Developers may use the returned Future object to track progress of the transmission.
|
||||
*
|
||||
* @param fragment the data being sent
|
||||
* @param isLast true if this is the last piece of the partial bytes
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendPartialBytesByFuture(ByteBuffer fragment, boolean isLast);
|
||||
|
||||
/**
|
||||
* Send a text message, blocking until all bytes of the message has been transmitted.
|
||||
* <p>
|
||||
|
@ -113,17 +87,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendString(String text, WriteCallback callback);
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a text message. This method may return before the message is
|
||||
* transmitted. Developers may use the returned
|
||||
* Future object to track progress of the transmission.
|
||||
*
|
||||
* @param text the text being sent
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendStringByFuture(String text);
|
||||
|
||||
/**
|
||||
* Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the
|
||||
* message in order. Non-final pieces are sent
|
||||
|
@ -148,20 +111,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendPartialString(String fragment, boolean isLast, WriteCallback callback) throws IOException;
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a partial text message.
|
||||
* This method may return before the message is transmitted.
|
||||
* The runtime reads the message in order. Non-final pieces are sent with isLast
|
||||
* set to false. The final piece must be sent with isLast set to true.
|
||||
* Developers may use the returned Future object to track progress of the transmission.
|
||||
*
|
||||
* @param fragment the text being sent
|
||||
* @param isLast true if this is the last piece of the partial bytes
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendPartialStringByFuture(String fragment, boolean isLast) throws IOException;
|
||||
|
||||
/**
|
||||
* Send a Ping message containing the given application data to the remote endpoint, blocking until all of the
|
||||
* message has been transmitted.
|
||||
|
@ -181,16 +130,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendPing(ByteBuffer applicationData, WriteCallback callback);
|
||||
|
||||
/**
|
||||
* Asynchronously send a Ping message containing the given application data to the remote endpoint.
|
||||
* The corresponding Pong message may be picked up using the MessageHandler.Pong handler.
|
||||
*
|
||||
* @param applicationData the data to be carried in the ping request
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendPingByFuture(ByteBuffer applicationData);
|
||||
|
||||
/**
|
||||
* Allows the developer to send an unsolicited Pong message containing the given application data
|
||||
* in order to serve as a unidirectional heartbeat for the session, this will block until
|
||||
|
@ -210,16 +149,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void sendPong(ByteBuffer applicationData, WriteCallback callback);
|
||||
|
||||
/**
|
||||
* Allows the developer to asynchronously send an unsolicited Pong message containing the given application data
|
||||
* in order to serve as a unidirectional heartbeat for the session.
|
||||
*
|
||||
* @param applicationData the application data to be carried in the pong response.
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
@Deprecated
|
||||
Future<Void> sendPongByFuture(ByteBuffer applicationData);
|
||||
|
||||
/**
|
||||
* @return the batch mode with which messages are sent.
|
||||
* @see #flush()
|
||||
|
@ -234,15 +163,6 @@ public interface RemoteEndpoint
|
|||
*/
|
||||
void setBatchMode(BatchMode mode);
|
||||
|
||||
/**
|
||||
* Get the InetSocketAddress for the established connection.
|
||||
*
|
||||
* @return the InetSocketAddress for the established connection. (or null, if there is none)
|
||||
* @deprecated use {@link #getRemoteAddress()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
InetSocketAddress getInetSocketAddress();
|
||||
|
||||
/**
|
||||
* Get the SocketAddress for the established connection.
|
||||
*
|
||||
|
|
|
@ -48,13 +48,6 @@ public @interface WebSocket
|
|||
*/
|
||||
int maxBinaryMessageSize() default -1;
|
||||
|
||||
/**
|
||||
* The time in ms (milliseconds) that a websocket may be idle before closing.
|
||||
* @deprecated use {@link #idleTimeout()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
int maxIdleTime() default -1;
|
||||
|
||||
/**
|
||||
* The time in ms (milliseconds) that a websocket may be idle before closing.
|
||||
*/
|
||||
|
|
|
@ -296,8 +296,6 @@ public class JettyWebSocketFrameHandlerFactory extends ContainerLifeCycle
|
|||
if (max>=0)
|
||||
metadata.setMaxTextMessageSize(max);
|
||||
max = anno.idleTimeout();
|
||||
if (max<0)
|
||||
max = anno.maxIdleTime();
|
||||
if (max>=0)
|
||||
metadata.setIdleTimeout(Duration.ofMillis(max));
|
||||
metadata.setBatchMode(anno.batchMode());
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
package org.eclipse.jetty.websocket.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.SharedBlockingCallback;
|
||||
import org.eclipse.jetty.websocket.api.BatchMode;
|
||||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
|
@ -101,16 +98,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
isBatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendBytesByFuture(ByteBuffer data)
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
coreSession.sendFrame(new Frame(OpCode.BINARY).setPayload(data),
|
||||
callback,
|
||||
isBatch());
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException
|
||||
{
|
||||
|
@ -127,14 +114,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
sendPartialBytes(fragment, isLast, Callback.from(callback::writeSuccess, callback::writeFailed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendPartialBytesByFuture(ByteBuffer fragment, boolean isLast)
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
sendPartialBytes(fragment, isLast, callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendString(String text) throws IOException
|
||||
{
|
||||
|
@ -148,16 +127,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text), cb, isBatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendStringByFuture(String text)
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text),
|
||||
callback,
|
||||
isBatch());
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPartialString(String fragment, boolean isLast) throws IOException
|
||||
{
|
||||
|
@ -169,19 +138,11 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPartialString(String fragment, boolean isLast, WriteCallback callback) throws IOException
|
||||
public void sendPartialString(String fragment, boolean isLast, WriteCallback callback)
|
||||
{
|
||||
sendPartialText(fragment, isLast, Callback.from(callback::writeSuccess, callback::writeFailed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendPartialStringByFuture(String fragment, boolean isLast) throws IOException
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
sendPartialText(fragment, isLast, callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPing(ByteBuffer applicationData) throws IOException
|
||||
{
|
||||
|
@ -195,14 +156,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
Callback.from(callback::writeSuccess, callback::writeFailed), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendPingByFuture(ByteBuffer applicationData)
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
coreSession.sendFrame(new Frame(OpCode.PING).setPayload(applicationData), callback, false);
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPong(ByteBuffer applicationData) throws IOException
|
||||
{
|
||||
|
@ -216,14 +169,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
Callback.from(callback::writeSuccess, callback::writeFailed), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> sendPongByFuture(ByteBuffer applicationData)
|
||||
{
|
||||
FutureCallback callback = new FutureCallback();
|
||||
coreSession.sendFrame(new Frame(OpCode.PONG).setPayload(applicationData), callback, false);
|
||||
return callback;
|
||||
}
|
||||
|
||||
private void sendPartialBytes(ByteBuffer fragment, boolean isLast, Callback callback)
|
||||
{
|
||||
Frame frame;
|
||||
|
@ -311,16 +256,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
|
|||
return BatchMode.ON == batchMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getInetSocketAddress()
|
||||
{
|
||||
SocketAddress remoteAddress = coreSession.getRemoteAddress();
|
||||
if (remoteAddress instanceof InetSocketAddress)
|
||||
return (InetSocketAddress)remoteAddress;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress()
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
|
|||
import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;
|
||||
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.websocket.tests.CloseTrackingEndpoint;
|
||||
import org.eclipse.jetty.websocket.tests.util.FutureWriteCallback;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -84,7 +85,8 @@ public class ClientCloseTest
|
|||
{
|
||||
// Send message from client to server
|
||||
final String echoMsg = "echo-test";
|
||||
Future<Void> testFut = clientSocket.getRemote().sendStringByFuture(echoMsg);
|
||||
FutureWriteCallback testFut = new FutureWriteCallback();
|
||||
clientSocket.getRemote().sendString(echoMsg, testFut);
|
||||
|
||||
// Wait for send future
|
||||
testFut.get(5, SECONDS);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.tests.client;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -27,6 +26,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
import org.eclipse.jetty.websocket.api.BatchMode;
|
||||
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.tests.util.FutureWriteCallback;
|
||||
|
||||
public class ClientWriteThread extends Thread
|
||||
{
|
||||
|
@ -65,11 +65,12 @@ public class ClientWriteThread extends Thread
|
|||
{
|
||||
LOG.debug("Writing {} messages to connection {}",messageCount);
|
||||
LOG.debug("Artificial Slowness {} ms",slowness);
|
||||
Future<Void> lastMessage = null;
|
||||
FutureWriteCallback lastMessage = null;
|
||||
RemoteEndpoint remote = session.getRemote();
|
||||
while (m.get() < messageCount)
|
||||
{
|
||||
lastMessage = remote.sendStringByFuture(message + "/" + m.get() + "/");
|
||||
lastMessage = new FutureWriteCallback();
|
||||
remote.sendString(message + "/" + m.get() + "/", lastMessage);
|
||||
|
||||
m.incrementAndGet();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
|||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.StatusCode;
|
||||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketContainer;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +54,7 @@ public class ContainerEndpoint extends AbstractCloseEndpoint
|
|||
{
|
||||
ret.append('[').append(idx++).append("] ").append(sess.toString()).append('\n');
|
||||
}
|
||||
session.getRemote().sendStringByFuture(ret.toString());
|
||||
session.getRemote().sendString(ret.toString(), WriteCallback.NOOP);
|
||||
}
|
||||
session.close(StatusCode.NORMAL,"ContainerEndpoint");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue