2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
20 * Copyright (c) 2012 the original author or authors.
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
26 * http://www.apache.org/licenses/LICENSE-2.0
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
35 package org.eclipse.jetty.util;
38 * <p>A callback abstraction that handles completed/failed events of asynchronous operations.</p>
40 * <p>Semantically this is equivalent to an optimise Promise<Void>, but callback is a more meaningful
41 * name than EmptyPromise</p>
43 public interface Callback
46 * <p>Callback invoked when the operation completes.</p>
48 * @see #failed(Throwable)
50 public abstract void succeeded();
53 * <p>Callback invoked when the operation fails.</p>
54 * @param x the reason for the operation failure
56 public void failed(Throwable x);
59 * <p>Empty implementation of {@link Callback}</p>
61 public static class Adapter implements Callback
64 * Instance of Adapter that can be used when the callback methods need an empty
65 * implementation without incurring in the cost of allocating a new Adapter object.
67 public static final Adapter INSTANCE = new Adapter();
70 public void succeeded()
75 public void failed(Throwable x)