@Test public void testHandle() throws Exception { Assert.assertEquals("Expected empty dispatch map.", 0, handler.getDispatchMap().size()); NameCallback nameCallback = new NameCallback(">|<"); NameCallbackHandler nameCallbackHandler = new NameCallbackHandler("joe"); handler.register(NameCallback.class, nameCallbackHandler); Assert.assertEquals("Expected a single registered callback handler.", 1, handler.getDispatchMap().size()); handler.handle(new Callback[]{nameCallback}); Assert.assertEquals("Expected a single registered callback handler.", 1, handler.getDispatchMap().size()); Assert.assertEquals("Expecting callback to be populated.", "joe", nameCallback.getName()); }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (dispatchMap != null && dispatchMap.size() > 0) { if (callbacks != null && callbacks.length > 0) { for (Callback callback : callbacks) { if (callback != null) { CallbackHandler handler = dispatchMap.get(callback.getClass()); if (handler != null) { handler.handle(new Callback[]{callback}); } else { throw new UnsupportedCallbackException(callback, "Could not find a handler for callback class " + callback.getClass().getName()); } } else { throw new UnsupportedCallbackException(callback, "A null callback was encountered in the callbacks provided."); } } } } else { throw new UnsupportedCallbackException(null, "No callback handlers are available."); } }
DispatchCallbackHandler implements CallbackHandler { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (dispatchMap != null && dispatchMap.size() > 0) { if (callbacks != null && callbacks.length > 0) { for (Callback callback : callbacks) { if (callback != null) { CallbackHandler handler = dispatchMap.get(callback.getClass()); if (handler != null) { handler.handle(new Callback[]{callback}); } else { throw new UnsupportedCallbackException(callback, "Could not find a handler for callback class " + callback.getClass().getName()); } } else { throw new UnsupportedCallbackException(callback, "A null callback was encountered in the callbacks provided."); } } } } else { throw new UnsupportedCallbackException(null, "No callback handlers are available."); } } }
DispatchCallbackHandler implements CallbackHandler { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (dispatchMap != null && dispatchMap.size() > 0) { if (callbacks != null && callbacks.length > 0) { for (Callback callback : callbacks) { if (callback != null) { CallbackHandler handler = dispatchMap.get(callback.getClass()); if (handler != null) { handler.handle(new Callback[]{callback}); } else { throw new UnsupportedCallbackException(callback, "Could not find a handler for callback class " + callback.getClass().getName()); } } else { throw new UnsupportedCallbackException(callback, "A null callback was encountered in the callbacks provided."); } } } } else { throw new UnsupportedCallbackException(null, "No callback handlers are available."); } }  }
DispatchCallbackHandler implements CallbackHandler { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (dispatchMap != null && dispatchMap.size() > 0) { if (callbacks != null && callbacks.length > 0) { for (Callback callback : callbacks) { if (callback != null) { CallbackHandler handler = dispatchMap.get(callback.getClass()); if (handler != null) { handler.handle(new Callback[]{callback}); } else { throw new UnsupportedCallbackException(callback, "Could not find a handler for callback class " + callback.getClass().getName()); } } else { throw new UnsupportedCallbackException(callback, "A null callback was encountered in the callbacks provided."); } } } } else { throw new UnsupportedCallbackException(null, "No callback handlers are available."); } }  DispatchCallbackHandler register(Class<? extends Callback> callbackClass, CallbackHandler callbackHandler); DispatchCallbackHandler registerAll(TypedCallbackHandlerMap callbackHandlers); CallbackHandler unregister(Class<? extends Callback> callbackClass); @Override void handle(Callback[] callbacks); }
DispatchCallbackHandler implements CallbackHandler { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (dispatchMap != null && dispatchMap.size() > 0) { if (callbacks != null && callbacks.length > 0) { for (Callback callback : callbacks) { if (callback != null) { CallbackHandler handler = dispatchMap.get(callback.getClass()); if (handler != null) { handler.handle(new Callback[]{callback}); } else { throw new UnsupportedCallbackException(callback, "Could not find a handler for callback class " + callback.getClass().getName()); } } else { throw new UnsupportedCallbackException(callback, "A null callback was encountered in the callbacks provided."); } } } } else { throw new UnsupportedCallbackException(null, "No callback handlers are available."); } }  DispatchCallbackHandler register(Class<? extends Callback> callbackClass, CallbackHandler callbackHandler); DispatchCallbackHandler registerAll(TypedCallbackHandlerMap callbackHandlers); CallbackHandler unregister(Class<? extends Callback> callbackClass); @Override void handle(Callback[] callbacks);  }