JSR-356, fixing build
This commit is contained in:
parent
12d414c9fc
commit
dc0a8a5d40
|
@ -116,7 +116,23 @@ public class JsrAnnotatedEventDriver extends AbstractEventDriver implements Even
|
|||
if (activeMessage == null)
|
||||
{
|
||||
LOG.debug("Binary Message InputStream");
|
||||
activeMessage = new MessageInputStream(this);
|
||||
final MessageInputStream stream = new MessageInputStream(session.getConnection());
|
||||
activeMessage = stream;
|
||||
dispatch(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
events.callBinaryStream(websocket,stream);
|
||||
}
|
||||
catch (DecodeException | IOException e)
|
||||
{
|
||||
onFatalError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +280,25 @@ public class JsrAnnotatedEventDriver extends AbstractEventDriver implements Even
|
|||
if (activeMessage == null)
|
||||
{
|
||||
LOG.debug("Text Message Writer");
|
||||
activeMessage = new MessageReader(this);
|
||||
|
||||
final MessageReader stream = new MessageReader(new MessageInputStream(session.getConnection()));
|
||||
activeMessage = stream;
|
||||
|
||||
dispatch(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
events.callTextStream(websocket,stream);
|
||||
}
|
||||
catch (DecodeException | IOException e)
|
||||
{
|
||||
onFatalError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import javax.websocket.CloseReason.CloseCodes;
|
|||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.MessageHandler.Whole;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -40,18 +42,18 @@ import org.eclipse.jetty.websocket.common.CloseInfo;
|
|||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
import org.eclipse.jetty.websocket.common.events.AbstractEventDriver;
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageInputStream;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageReader;
|
||||
import org.eclipse.jetty.websocket.jsr356.ContainerService;
|
||||
import org.eclipse.jetty.websocket.jsr356.Decoders;
|
||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||
import org.eclipse.jetty.websocket.jsr356.MessageHandlers;
|
||||
import org.eclipse.jetty.websocket.jsr356.MessageType;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.BinaryPartialMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.BinaryStreamMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.BinaryWholeMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.MessageHandlerMetadataFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.MessageHandlerWrapper;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.TextPartialMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.TextStreamMessage;
|
||||
import org.eclipse.jetty.websocket.jsr356.messages.TextWholeMessage;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +90,7 @@ public class JsrEndpointEventDriver extends AbstractEventDriver implements Event
|
|||
{
|
||||
if (activeMessage == null)
|
||||
{
|
||||
MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.BINARY);
|
||||
final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.BINARY);
|
||||
if (wrapper == null)
|
||||
{
|
||||
LOG.debug("No BINARY MessageHandler declared");
|
||||
|
@ -100,7 +102,18 @@ public class JsrEndpointEventDriver extends AbstractEventDriver implements Event
|
|||
}
|
||||
else if (wrapper.wantsStreams())
|
||||
{
|
||||
activeMessage = new BinaryStreamMessage(this,wrapper);
|
||||
final MessageInputStream stream = new MessageInputStream(session.getConnection());
|
||||
activeMessage = stream;
|
||||
dispatch(new Runnable()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
MessageHandler.Whole<InputStream> handler = (Whole<InputStream>)wrapper.getHandler();
|
||||
handler.onMessage(stream);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -181,7 +194,7 @@ public class JsrEndpointEventDriver extends AbstractEventDriver implements Event
|
|||
{
|
||||
if (activeMessage == null)
|
||||
{
|
||||
MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.TEXT);
|
||||
final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.TEXT);
|
||||
if (wrapper == null)
|
||||
{
|
||||
LOG.debug("No TEXT MessageHandler declared");
|
||||
|
@ -193,7 +206,19 @@ public class JsrEndpointEventDriver extends AbstractEventDriver implements Event
|
|||
}
|
||||
else if (wrapper.wantsStreams())
|
||||
{
|
||||
activeMessage = new TextStreamMessage(this,wrapper);
|
||||
final MessageReader stream = new MessageReader(new MessageInputStream(session.getConnection()));
|
||||
activeMessage = stream;
|
||||
|
||||
dispatch(new Runnable()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
MessageHandler.Whole<Reader> handler = (Whole<Reader>)wrapper.getHandler();
|
||||
handler.onMessage(stream);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,41 +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.jsr356.messages;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.MessageHandler.Whole;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageInputStream;
|
||||
|
||||
public class BinaryStreamMessage extends MessageInputStream
|
||||
{
|
||||
private final MessageHandlerWrapper msgWrapper;
|
||||
private final MessageHandler.Whole<InputStream> streamHandler;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BinaryStreamMessage(EventDriver driver, MessageHandlerWrapper wrapper)
|
||||
{
|
||||
super(driver);
|
||||
this.msgWrapper = wrapper;
|
||||
this.streamHandler = (Whole<InputStream>)wrapper.getHandler();
|
||||
}
|
||||
}
|
|
@ -1,41 +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.jsr356.messages;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.MessageHandler.Whole;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageReader;
|
||||
|
||||
public class TextStreamMessage extends MessageReader
|
||||
{
|
||||
private final MessageHandlerWrapper msgWrapper;
|
||||
private final MessageHandler.Whole<Reader> streamHandler;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public TextStreamMessage(EventDriver driver, MessageHandlerWrapper wrapper)
|
||||
{
|
||||
super(driver);
|
||||
this.msgWrapper = wrapper;
|
||||
this.streamHandler = (Whole<Reader>)wrapper.getHandler();
|
||||
}
|
||||
}
|
|
@ -65,6 +65,11 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||
}
|
||||
}
|
||||
|
||||
protected void dispatch(Runnable runnable)
|
||||
{
|
||||
session.dispatch(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketPolicy getPolicy()
|
||||
{
|
||||
|
|
|
@ -65,11 +65,6 @@ public class JettyAnnotatedEventDriver extends AbstractEventDriver
|
|||
}
|
||||
}
|
||||
|
||||
private void dispatch(Runnable runnable)
|
||||
{
|
||||
session.dispatch(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue