Search in sources :

Example 6 with DecoderMetadata

use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.

the class DecoderFactory method getWrapperFor.

public Wrapper getWrapperFor(Class<?> type) {
    synchronized (activeWrappers) {
        Wrapper wrapper = activeWrappers.get(type);
        // Try parent (if needed)
        if ((wrapper == null) && (parentFactory != null)) {
            wrapper = parentFactory.getWrapperFor(type);
        }
        if (wrapper == null) {
            // Attempt to create Wrapper on demand
            DecoderMetadata metadata = metadatas.getMetadataByType(type);
            if (metadata == null) {
                return null;
            }
            wrapper = newWrapper(metadata);
            // track wrapper
            activeWrappers.put(type, wrapper);
        }
        return wrapper;
    }
}
Also used : DecoderMetadata(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata)

Example 7 with DecoderMetadata

use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.

the class JsrSession method removeMessageHandler.

@Override
public void removeMessageHandler(MessageHandler handler) {
    synchronized (wrappers) {
        try {
            for (MessageHandlerMetadata metadata : messageHandlerFactory.getMetadata(handler.getClass())) {
                DecoderMetadata decoder = decoderFactory.getMetadataFor(metadata.getMessageClass());
                MessageType key = decoder.getMessageType();
                wrappers[key.ordinal()] = null;
            }
            updateMessageHandlerSet();
        } catch (IllegalStateException e) {
            LOG.warn("Unable to identify MessageHandler: " + handler.getClass().getName(), e);
        }
    }
}
Also used : MessageHandlerMetadata(org.eclipse.jetty.websocket.jsr356.metadata.MessageHandlerMetadata) DecoderMetadata(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata)

Example 8 with DecoderMetadata

use of org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata in project jetty.project by eclipse.

the class DecoderFactoryTest method assertMetadataFor.

private void assertMetadataFor(Class<?> type, Class<? extends Decoder> expectedDecoderClass, MessageType expectedType) {
    DecoderMetadata metadata = factory.getMetadataFor(type);
    Assert.assertEquals("metadata.coderClass", metadata.getCoderClass(), expectedDecoderClass);
    Assert.assertThat("metadata.messageType", metadata.getMessageType(), is(expectedType));
    Assert.assertEquals("metadata.objectType", metadata.getObjectType(), type);
}
Also used : DecoderMetadata(org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata)

Aggregations

DecoderMetadata (org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata)8 MessageHandlerMetadata (org.eclipse.jetty.websocket.jsr356.metadata.MessageHandlerMetadata)3 Test (org.junit.Test)3 Type (java.lang.reflect.Type)2