Cleanup (Imports / StandardCharset / Dead APIs)
This commit is contained in:
parent
eb2f3acfbd
commit
120e0e59ca
|
@ -19,8 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.MessageHandler.Partial;
|
||||
import javax.websocket.MessageHandler.Whole;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.MessageHandlerMetadata;
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@ import java.lang.annotation.Annotation;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.MessageType;
|
||||
|
||||
|
|
|
@ -28,10 +28,6 @@ import java.util.Map;
|
|||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.RemoteEndpoint;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
|
|||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.ByteArrayDecoder;
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.annotations;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.annotations;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.OnClose;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.annotations;
|
||||
|
||||
import javax.websocket.OnError;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.annotations;
|
||||
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnOpen;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
|
|||
|
||||
import java.io.Reader;
|
||||
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.BooleanDecoder;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.lang.reflect.Method;
|
|||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.CloseReason.CloseCodes;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnClose;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnError;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.lang.reflect.Method;
|
|||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.lang.reflect.Method;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.PongMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrPongMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
|
|
|
@ -18,12 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.annotations;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.lang.reflect.Method;
|
|||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.lang.reflect.Method;
|
|||
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnOpen;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.MessageHandler.Whole;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.messages;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageAppender;
|
||||
import org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.messages;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.websocket.OnMessage;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageAppender;
|
||||
import org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.metadata;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.MessageType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,10 +24,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
|
||||
|
||||
/**
|
||||
* An durable collection of {@link CoderMetadata}.
|
||||
* <p>
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.metadata;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.ClientEndpointConfig.Configurator;
|
||||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.Session;
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.websocket.server.ServerEndpoint;
|
|||
public class GetHttpSessionSocket
|
||||
{
|
||||
private Session wsSession;
|
||||
@SuppressWarnings("unused")
|
||||
private HttpSession httpSession;
|
||||
|
||||
@OnOpen
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
|
@ -70,7 +70,7 @@ public class LargeAnnotatedTest
|
|||
// The message size should be bigger than default, but smaller than the limit that LargeEchoSocket specifies
|
||||
byte txt[] = new byte[100 * 1024];
|
||||
Arrays.fill(txt,(byte)'o');
|
||||
String msg = new String(txt,StringUtil.__UTF8_CHARSET);
|
||||
String msg = new String(txt,StandardCharsets.UTF_8);
|
||||
clientEcho.sendMessage(msg);
|
||||
Queue<String> msgs = clientEcho.awaitMessages(1);
|
||||
Assert.assertEquals("Expected message",msg,msgs.poll());
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
|
@ -70,7 +70,7 @@ public class LargeContainerTest
|
|||
// The message size should be bigger than default, but smaller than the limit that LargeEchoSocket specifies
|
||||
byte txt[] = new byte[100 * 1024];
|
||||
Arrays.fill(txt,(byte)'o');
|
||||
String msg = new String(txt,StringUtil.__UTF8_CHARSET);
|
||||
String msg = new String(txt,StandardCharsets.UTF_8);
|
||||
clientEcho.sendMessage(msg);
|
||||
Queue<String> msgs = clientEcho.awaitMessages(1);
|
||||
Assert.assertEquals("Expected message",msg,msgs.poll());
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -18,16 +18,13 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server.blockhead;
|
||||
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
@ -43,8 +40,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.jsr356.server.samples.echo;
|
|||
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
|
||||
|
||||
/**
|
||||
* Indicating that the provided Class is not a valid WebSocket as defined by the API.
|
||||
* <p>
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
||||
|
||||
/**
|
||||
* Session represents an active link of communications with a Remote WebSocket Endpoint.
|
||||
* <p>
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* Annotation for tagging methods to receive connection close events.
|
||||
* <p>
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* Annotation for tagging methods to receive connection open events.
|
||||
* <p>
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* Annotation for receiving websocket errors (exceptions) that have occurred internally in the websocket implementation.
|
||||
* <p>
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* (ADVANCED) Annotation for tagging methods to receive frame events.
|
||||
* <p>
|
||||
|
|
|
@ -18,15 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.api.annotations;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* Annotation for tagging methods to receive Binary or Text Message events.
|
||||
* <p>
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
/**
|
||||
* For working with the {@link Session} in a blocking technique.
|
||||
* <p>
|
||||
* This is an end-user accessible class.
|
||||
*/
|
||||
public class WebSocketBlockingConnection
|
||||
{
|
||||
private final RemoteEndpoint remote;
|
||||
|
||||
public WebSocketBlockingConnection(Session session)
|
||||
{
|
||||
this.remote = session.getRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a binary message.
|
||||
* <p>
|
||||
* Basic usage, results in a blocking write.
|
||||
*/
|
||||
public void write(byte[] data, int offset, int length) throws IOException
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.wrap(data,offset,length);
|
||||
remote.sendBytes(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send text message.
|
||||
* <p>
|
||||
* Basic usage, results in a blocking write.
|
||||
*/
|
||||
public void write(String message) throws IOException
|
||||
{
|
||||
remote.sendString(message);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
public class WebSocketOutputStream extends OutputStream
|
||||
{
|
||||
private final Session session;
|
||||
|
||||
public WebSocketOutputStream(Session session)
|
||||
{
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
|
||||
public class WebSocketWriter extends Writer
|
||||
{
|
||||
private final Session session;
|
||||
|
||||
public WebSocketWriter(Session session)
|
||||
{
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char[] cbuf, int off, int len) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
/**
|
||||
* Jetty WebSocket API : I/O Classes
|
||||
*/
|
||||
package org.eclipse.jetty.websocket.api.io;
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.websocket.common.annotations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
|
@ -34,7 +35,7 @@ public class MyEchoBinarySocket extends MyEchoSocket
|
|||
{
|
||||
try
|
||||
{
|
||||
getConnection().write(buf,offset,length);
|
||||
getRemote().sendBytes(ByteBuffer.wrap(buf,offset,length));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
@ -20,12 +20,12 @@ package org.eclipse.jetty.websocket.common.annotations;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.websocket.api.io.WebSocketBlockingConnection;
|
||||
|
||||
/**
|
||||
* The most common websocket implementation.
|
||||
|
@ -36,11 +36,11 @@ import org.eclipse.jetty.websocket.api.io.WebSocketBlockingConnection;
|
|||
public class MyEchoSocket
|
||||
{
|
||||
private Session session;
|
||||
private WebSocketBlockingConnection blocking;
|
||||
private RemoteEndpoint remote;
|
||||
|
||||
public WebSocketBlockingConnection getConnection()
|
||||
public RemoteEndpoint getRemote()
|
||||
{
|
||||
return blocking;
|
||||
return remote;
|
||||
}
|
||||
|
||||
@OnWebSocketClose
|
||||
|
@ -53,7 +53,7 @@ public class MyEchoSocket
|
|||
public void onConnect(Session session)
|
||||
{
|
||||
this.session = session;
|
||||
this.blocking = new WebSocketBlockingConnection(session);
|
||||
this.remote = session.getRemote();
|
||||
}
|
||||
|
||||
@OnWebSocketMessage
|
||||
|
@ -68,7 +68,7 @@ public class MyEchoSocket
|
|||
|
||||
try
|
||||
{
|
||||
blocking.write(message);
|
||||
remote.sendString(message);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.common.message;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.websocket.common.io.LocalWebSocketConnection;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
@ -37,8 +36,6 @@ import org.junit.rules.TestName;
|
|||
|
||||
public class MessageInputStreamTest
|
||||
{
|
||||
private static final Charset UTF8 = StringUtil.__UTF8_CHARSET;
|
||||
|
||||
@Rule
|
||||
public TestName testname = new TestName();
|
||||
|
||||
|
@ -50,7 +47,7 @@ public class MessageInputStreamTest
|
|||
try (MessageInputStream stream = new MessageInputStream(conn))
|
||||
{
|
||||
// Append a single message (simple, short)
|
||||
ByteBuffer payload = BufferUtil.toBuffer("Hello World",UTF8);
|
||||
ByteBuffer payload = BufferUtil.toBuffer("Hello World",StandardCharsets.UTF_8);
|
||||
System.out.printf("payload = %s%n",BufferUtil.toDetailString(payload));
|
||||
boolean fin = true;
|
||||
stream.appendMessage(payload,fin);
|
||||
|
@ -58,7 +55,7 @@ public class MessageInputStreamTest
|
|||
// Read entire message it from the stream.
|
||||
byte buf[] = new byte[32];
|
||||
int len = stream.read(buf);
|
||||
String message = new String(buf,0,len,UTF8);
|
||||
String message = new String(buf,0,len,StandardCharsets.UTF_8);
|
||||
|
||||
// Test it
|
||||
Assert.assertThat("Message",message,is("Hello World"));
|
||||
|
@ -87,12 +84,12 @@ public class MessageInputStreamTest
|
|||
startLatch.countDown();
|
||||
boolean fin = false;
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
stream.appendMessage(BufferUtil.toBuffer("Saved",UTF8),fin);
|
||||
stream.appendMessage(BufferUtil.toBuffer("Saved",StandardCharsets.UTF_8),fin);
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
stream.appendMessage(BufferUtil.toBuffer(" by ",UTF8),fin);
|
||||
stream.appendMessage(BufferUtil.toBuffer(" by ",StandardCharsets.UTF_8),fin);
|
||||
fin = true;
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
stream.appendMessage(BufferUtil.toBuffer("Zero",UTF8),fin);
|
||||
stream.appendMessage(BufferUtil.toBuffer("Zero",StandardCharsets.UTF_8),fin);
|
||||
}
|
||||
catch (IOException | InterruptedException e)
|
||||
{
|
||||
|
@ -108,7 +105,7 @@ public class MessageInputStreamTest
|
|||
// Read it from the stream.
|
||||
byte buf[] = new byte[32];
|
||||
int len = stream.read(buf);
|
||||
String message = new String(buf,0,len,UTF8);
|
||||
String message = new String(buf,0,len,StandardCharsets.UTF_8);
|
||||
|
||||
// Test it
|
||||
Assert.assertThat("Error when appending",hadError.get(),is(false));
|
||||
|
@ -135,7 +132,7 @@ public class MessageInputStreamTest
|
|||
boolean fin = true;
|
||||
// wait for a little bit before populating buffers
|
||||
TimeUnit.MILLISECONDS.sleep(400);
|
||||
stream.appendMessage(BufferUtil.toBuffer("I will conquer",UTF8),fin);
|
||||
stream.appendMessage(BufferUtil.toBuffer("I will conquer",StandardCharsets.UTF_8),fin);
|
||||
}
|
||||
catch (IOException | InterruptedException e)
|
||||
{
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.common.message;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class Utf8CharBufferTest
|
|||
|
||||
private static byte[] asUTF(String str)
|
||||
{
|
||||
return str.getBytes(StringUtil.__UTF8_CHARSET);
|
||||
return str.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue