/** * Handles the next request sent by the client using the {@link RequestHandler} that was specified when this class * was created. * * @return the {@link Request} that was handled. * @throws IOException * if an I/O exception of some sort has occurred. * @throws ClassNotFoundException * thrown when an application fails to load in a class. */ @SuppressWarnings("unchecked") public Request<T> handle() throws IOException, ClassNotFoundException { Request<T> request = (Request<T>) receiveObject(); Object response = requestHandler.handle(request); sendObject(response); return request; } }