Java 类javax.websocket.MessageHandler.Whole 实例源码

项目:tomcat7    文件:WsSession.java   
@Override
public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler)
        throws IllegalStateException {
    doAddMessageHandler(clazz, handler);
}
项目:tomcat7    文件:WsSession.java   
@SuppressWarnings("unchecked")
private void doAddMessageHandler(Class<?> target, MessageHandler listener) {
    checkState();

    // Message handlers that require decoders may map to text messages,
    // binary messages, both or neither.

    // The frame processing code expects binary message handlers to
    // accept ByteBuffer

    // Use the POJO message handler wrappers as they are designed to wrap
    // arbitrary objects with MessageHandlers and can wrap MessageHandlers
    // just as easily.

    Set<MessageHandlerResult> mhResults =
            Util.getMessageHandlers(target, listener, endpointConfig, this);

    for (MessageHandlerResult mhResult : mhResults) {
        switch (mhResult.getType()) {
            case TEXT: {
                if (textMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerText"));
                }
                textMessageHandler = mhResult.getHandler();
                break;
            }
            case BINARY: {
                if (binaryMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerBinary"));
                }
                binaryMessageHandler = mhResult.getHandler();
                break;
            }
            case PONG: {
                if (pongMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerPong"));
                }
                MessageHandler handler = mhResult.getHandler();
                if (handler instanceof MessageHandler.Whole<?>) {
                    pongMessageHandler =
                            (MessageHandler.Whole<PongMessage>) handler;
                } else {
                    throw new IllegalStateException(
                            sm.getString("wsSession.invalidHandlerTypePong"));
                }

                break;
            }
            default: {
                throw new IllegalArgumentException(sm.getString(
                        "wsSession.unknownHandlerType", listener,
                        mhResult.getType()));
            }
        }
    }
}
项目:tomcat7    文件:WsSession.java   
protected MessageHandler.Whole<PongMessage> getPongMessageHandler() {
    return pongMessageHandler;
}
项目:apache-tomcat-7.0.73-with-comment    文件:WsSession.java   
@Override
public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler)
        throws IllegalStateException {
    doAddMessageHandler(clazz, handler);
}
项目:apache-tomcat-7.0.73-with-comment    文件:WsSession.java   
@SuppressWarnings("unchecked")
private void doAddMessageHandler(Class<?> target, MessageHandler listener) {
    checkState();

    // Message handlers that require decoders may map to text messages,
    // binary messages, both or neither.

    // The frame processing code expects binary message handlers to
    // accept ByteBuffer

    // Use the POJO message handler wrappers as they are designed to wrap
    // arbitrary objects with MessageHandlers and can wrap MessageHandlers
    // just as easily.

    Set<MessageHandlerResult> mhResults =
            Util.getMessageHandlers(target, listener, endpointConfig, this);

    for (MessageHandlerResult mhResult : mhResults) {
        switch (mhResult.getType()) {
            case TEXT: {
                if (textMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerText"));
                }
                textMessageHandler = mhResult.getHandler();
                break;
            }
            case BINARY: {
                if (binaryMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerBinary"));
                }
                binaryMessageHandler = mhResult.getHandler();
                break;
            }
            case PONG: {
                if (pongMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerPong"));
                }
                MessageHandler handler = mhResult.getHandler();
                if (handler instanceof MessageHandler.Whole<?>) {
                    pongMessageHandler =
                            (MessageHandler.Whole<PongMessage>) handler;
                } else {
                    throw new IllegalStateException(
                            sm.getString("wsSession.invalidHandlerTypePong"));
                }

                break;
            }
            default: {
                throw new IllegalArgumentException(sm.getString(
                        "wsSession.unknownHandlerType", listener,
                        mhResult.getType()));
            }
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:WsSession.java   
protected MessageHandler.Whole<PongMessage> getPongMessageHandler() {
    return pongMessageHandler;
}
项目:lazycat    文件:WsSession.java   
@Override
public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler) throws IllegalStateException {
    doAddMessageHandler(clazz, handler);
}
项目:lazycat    文件:WsSession.java   
@SuppressWarnings("unchecked")
private void doAddMessageHandler(Class<?> target, MessageHandler listener) {
    checkState();

    // Message handlers that require decoders may map to text messages,
    // binary messages, both or neither.

    // The frame processing code expects binary message handlers to
    // accept ByteBuffer

    // Use the POJO message handler wrappers as they are designed to wrap
    // arbitrary objects with MessageHandlers and can wrap MessageHandlers
    // just as easily.

    Set<MessageHandlerResult> mhResults = Util.getMessageHandlers(target, listener, endpointConfig, this);

    for (MessageHandlerResult mhResult : mhResults) {
        switch (mhResult.getType()) {
        case TEXT: {
            if (textMessageHandler != null) {
                throw new IllegalStateException(sm.getString("wsSession.duplicateHandlerText"));
            }
            textMessageHandler = mhResult.getHandler();
            break;
        }
        case BINARY: {
            if (binaryMessageHandler != null) {
                throw new IllegalStateException(sm.getString("wsSession.duplicateHandlerBinary"));
            }
            binaryMessageHandler = mhResult.getHandler();
            break;
        }
        case PONG: {
            if (pongMessageHandler != null) {
                throw new IllegalStateException(sm.getString("wsSession.duplicateHandlerPong"));
            }
            MessageHandler handler = mhResult.getHandler();
            if (handler instanceof MessageHandler.Whole<?>) {
                pongMessageHandler = (MessageHandler.Whole<PongMessage>) handler;
            } else {
                throw new IllegalStateException(sm.getString("wsSession.invalidHandlerTypePong"));
            }

            break;
        }
        default: {
            throw new IllegalArgumentException(
                    sm.getString("wsSession.unknownHandlerType", listener, mhResult.getType()));
        }
        }
    }
}
项目:lazycat    文件:WsSession.java   
protected MessageHandler.Whole<PongMessage> getPongMessageHandler() {
    return pongMessageHandler;
}
项目:WhiteboardProject    文件:MockWebsocketSession.java   
@Override
public <T> void addMessageHandler(Class<T> arg0, Whole<T> arg1) throws IllegalStateException {
    // TODO Auto-generated method stub

}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
@Override
public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler)
        throws IllegalStateException {
    doAddMessageHandler(clazz, handler);
}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
@SuppressWarnings("unchecked")
private void doAddMessageHandler(Class<?> target, MessageHandler listener) {
    checkState();

    // Message handlers that require decoders may map to text messages,
    // binary messages, both or neither.

    // The frame processing code expects binary message handlers to
    // accept ByteBuffer

    // Use the POJO message handler wrappers as they are designed to wrap
    // arbitrary objects with MessageHandlers and can wrap MessageHandlers
    // just as easily.

    Set<MessageHandlerResult> mhResults =
            Util.getMessageHandlers(target, listener, endpointConfig, this);

    for (MessageHandlerResult mhResult : mhResults) {
        switch (mhResult.getType()) {
            case TEXT: {
                if (textMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerText"));
                }
                textMessageHandler = mhResult.getHandler();
                break;
            }
            case BINARY: {
                if (binaryMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerBinary"));
                }
                binaryMessageHandler = mhResult.getHandler();
                break;
            }
            case PONG: {
                if (pongMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerPong"));
                }
                MessageHandler handler = mhResult.getHandler();
                if (handler instanceof MessageHandler.Whole<?>) {
                    pongMessageHandler =
                            (MessageHandler.Whole<PongMessage>) handler;
                } else {
                    throw new IllegalStateException(
                            sm.getString("wsSession.invalidHandlerTypePong"));
                }

                break;
            }
            default: {
                throw new IllegalArgumentException(sm.getString(
                        "wsSession.unknownHandlerType", listener,
                        mhResult.getType()));
            }
        }
    }
}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
protected MessageHandler.Whole<PongMessage> getPongMessageHandler() {
    return pongMessageHandler;
}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
@Override
public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler)
        throws IllegalStateException {
    doAddMessageHandler(clazz, handler);
}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
@SuppressWarnings("unchecked")
private void doAddMessageHandler(Class<?> target, MessageHandler listener) {
    checkState();

    // Message handlers that require decoders may map to text messages,
    // binary messages, both or neither.

    // The frame processing code expects binary message handlers to
    // accept ByteBuffer

    // Use the POJO message handler wrappers as they are designed to wrap
    // arbitrary objects with MessageHandlers and can wrap MessageHandlers
    // just as easily.

    Set<MessageHandlerResult> mhResults =
            Util.getMessageHandlers(target, listener, endpointConfig, this);

    for (MessageHandlerResult mhResult : mhResults) {
        switch (mhResult.getType()) {
            case TEXT: {
                if (textMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerText"));
                }
                textMessageHandler = mhResult.getHandler();
                break;
            }
            case BINARY: {
                if (binaryMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerBinary"));
                }
                binaryMessageHandler = mhResult.getHandler();
                break;
            }
            case PONG: {
                if (pongMessageHandler != null) {
                    throw new IllegalStateException(
                            sm.getString("wsSession.duplicateHandlerPong"));
                }
                MessageHandler handler = mhResult.getHandler();
                if (handler instanceof MessageHandler.Whole<?>) {
                    pongMessageHandler =
                            (MessageHandler.Whole<PongMessage>) handler;
                } else {
                    throw new IllegalStateException(
                            sm.getString("wsSession.invalidHandlerTypePong"));
                }

                break;
            }
            default: {
                throw new IllegalArgumentException(sm.getString(
                        "wsSession.unknownHandlerType", listener,
                        mhResult.getType()));
            }
        }
    }
}
项目:apache-tomcat-7.0.57    文件:WsSession.java   
protected MessageHandler.Whole<PongMessage> getPongMessageHandler() {
    return pongMessageHandler;
}