View Javadoc
1   /*
2    * #%L
3    * MongoClientClosedException.java - mongodb-async-driver - Allanbank Consulting, Inc.
4    * %%
5    * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.allanbank.mongodb.error;
21  
22  import com.allanbank.mongodb.MongoClient;
23  import com.allanbank.mongodb.MongoDbException;
24  import com.allanbank.mongodb.client.Message;
25  
26  /**
27   * MongoClientClosedException is thrown when there is an attempt to send a
28   * message on a closed {@link MongoClient}.
29   * 
30   * @api.yes This class is part of the driver's API. Public and protected members
31   *          will be deprecated for at least 1 non-bugfix release (version
32   *          numbers are <major>.<minor>.<bugfix>) before being
33   *          removed or modified.
34   * @copyright 2012-2013, Allanbank Consulting, Inc., All Rights Reserved
35   */
36  public class MongoClientClosedException extends MongoDbException {
37  
38      /** Serialization exception for the class. */
39      private static final long serialVersionUID = 1729264905521755667L;
40  
41      /** The message that was being sent. */
42      private transient final Message myMessage;
43  
44      /**
45       * Creates a new CannotConnectException.
46       */
47      public MongoClientClosedException() {
48          super();
49          myMessage = null;
50      }
51  
52      /**
53       * Creates a new CannotConnectException.
54       * 
55       * @param message
56       *            The message that was being sent.
57       */
58      public MongoClientClosedException(final Message message) {
59          super("MongoClient has been closed.");
60          myMessage = message;
61      }
62  
63      /**
64       * Creates a new CannotConnectException.
65       * 
66       * @param message
67       *            Message for the exception.
68       */
69      public MongoClientClosedException(final String message) {
70          super(message);
71          myMessage = null;
72      }
73  
74      /**
75       * Creates a new CannotConnectException.
76       * 
77       * @param message
78       *            Message for the exception.
79       * @param cause
80       *            The cause of the error.
81       */
82      public MongoClientClosedException(final String message,
83              final Throwable cause) {
84          super(message, cause);
85          myMessage = null;
86      }
87  
88      /**
89       * Creates a new CannotConnectException.
90       * 
91       * @param cause
92       *            The cause of the error.
93       */
94      public MongoClientClosedException(final Throwable cause) {
95          super(cause);
96          myMessage = null;
97      }
98  
99      /**
100      * Returns the message that was being sent.
101      * 
102      * @return The message that was being sent.
103      */
104     public Message getSentMessage() {
105         return myMessage;
106     }
107 }