View Javadoc
1   // Copyright (c) Microsoft Corporation. All rights reserved.
2   // Licensed under the MIT License.
3   
4   package com.microsoft.azure.servicebus;
5   
6   import java.util.concurrent.CompletableFuture;
7   
8   import com.microsoft.azure.servicebus.primitives.ServiceBusException;
9   
10  /**
11   * Defines a standard way of properly closing and disposing objects.
12   * @since 1.0
13   * 
14   */
15  public interface ICloseable {
16      /**
17       * Closes and disposes any resources associated with this object. An object cannot be used after it is closed. This is an asynchronous method that returns a CompletableFuture immediately.
18       * This object is completely closed when the returned CompletableFuture is completed.
19       * @return a CompletableFuture representing the closing of this object.
20       */
21      CompletableFuture<Void> closeAsync();
22  
23      /**
24       * Synchronously closes and disposes any resources associated with this object. Calling this method is equivalent of calling <code>closeAsync().get()</code>. This method blocks until this object is closed.
25       * @throws ServiceBusException If this object cannot be properly closed.
26       */
27      void close() throws ServiceBusException;
28  }