@Test public void testRegisterProcessor() throws Exception { final WebSocketMessageRouter router = new WebSocketMessageRouter("endpoint-id"); final Processor processor1 = mock(Processor.class); when(processor1.getIdentifier()).thenReturn("processor-1"); final Processor processor2 = mock(Processor.class); when(processor1.getIdentifier()).thenReturn("processor-2"); router.registerProcessor(processor1); try { router.registerProcessor(processor2); fail("Should fail since a processor is already registered."); } catch (WebSocketConfigurationException e) { } assertTrue(router.isProcessorRegistered(processor1)); assertFalse(router.isProcessorRegistered(processor2)); router.deregisterProcessor(processor2); router.deregisterProcessor(processor1); router.deregisterProcessor(processor2); }
public synchronized void registerProcessor(final Processor processor) throws WebSocketConfigurationException { if (this.processor != null) { throw new WebSocketConfigurationException("Processor " + this.processor + " is already assigned to this router."); } this.processor = processor; }
WebSocketMessageRouter { public synchronized void registerProcessor(final Processor processor) throws WebSocketConfigurationException { if (this.processor != null) { throw new WebSocketConfigurationException("Processor " + this.processor + " is already assigned to this router."); } this.processor = processor; } }
WebSocketMessageRouter { public synchronized void registerProcessor(final Processor processor) throws WebSocketConfigurationException { if (this.processor != null) { throw new WebSocketConfigurationException("Processor " + this.processor + " is already assigned to this router."); } this.processor = processor; } WebSocketMessageRouter(final String endpointId); }
WebSocketMessageRouter { public synchronized void registerProcessor(final Processor processor) throws WebSocketConfigurationException { if (this.processor != null) { throw new WebSocketConfigurationException("Processor " + this.processor + " is already assigned to this router."); } this.processor = processor; } WebSocketMessageRouter(final String endpointId); synchronized void registerProcessor(final Processor processor); boolean isProcessorRegistered(final Processor processor); synchronized void deregisterProcessor(final Processor processor); void captureSession(final WebSocketSession session); void onWebSocketClose(final String sessionId, final int statusCode, final String reason); void onWebSocketText(final String sessionId, final String message); void onWebSocketBinary(final String sessionId, final byte[] payload, final int offset, final int length); void sendMessage(final String sessionId, final SendMessage sendMessage); void disconnect(final String sessionId, final String reason); }
WebSocketMessageRouter { public synchronized void registerProcessor(final Processor processor) throws WebSocketConfigurationException { if (this.processor != null) { throw new WebSocketConfigurationException("Processor " + this.processor + " is already assigned to this router."); } this.processor = processor; } WebSocketMessageRouter(final String endpointId); synchronized void registerProcessor(final Processor processor); boolean isProcessorRegistered(final Processor processor); synchronized void deregisterProcessor(final Processor processor); void captureSession(final WebSocketSession session); void onWebSocketClose(final String sessionId, final int statusCode, final String reason); void onWebSocketText(final String sessionId, final String message); void onWebSocketBinary(final String sessionId, final byte[] payload, final int offset, final int length); void sendMessage(final String sessionId, final SendMessage sendMessage); void disconnect(final String sessionId, final String reason);  }