1 /*
2 * #%L
3 * MongoImpl.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.client;
21
22 import com.allanbank.mongodb.MongoClient;
23 import com.allanbank.mongodb.MongoClientConfiguration;
24
25 /**
26 * Implements the bootstrap point for interactions with MongoDB.
27 *
28 * @api.no This class is <b>NOT</b> part of the drivers API. This class may be
29 * mutated in incompatible ways between any two releases of the driver.
30 * @deprecated Use the {@link MongoClient} interface instead. This interface
31 * will be removed on or after the 1.3.0 release.
32 * @copyright 2011-2013, Allanbank Consulting, Inc., All Rights Reserved
33 */
34 @Deprecated
35 public class MongoImpl extends MongoClientImpl implements
36 com.allanbank.mongodb.Mongo {
37
38 /**
39 * Create a new MongoClient.
40 *
41 * @param client
42 * The client interface for interacting with the database.
43 */
44 public MongoImpl(final Client client) {
45 super(client);
46 }
47
48 /**
49 * Create a new MongoClient.
50 *
51 * @param config
52 * The configuration for interacting with MongoDB.
53 */
54 public MongoImpl(final com.allanbank.mongodb.MongoDbConfiguration config) {
55 super(config);
56 }
57
58 /**
59 * {@inheritDoc}
60 * <p>
61 * Overridden to create a new Mongo instance around a SerialClientImpl.
62 * </p>
63 *
64 * @deprecated Use the {@link #asSerializedClient()} instead.
65 */
66 @Override
67 @Deprecated
68 public com.allanbank.mongodb.Mongo asSerializedMongo() {
69 if (getClient() instanceof SerialClientImpl) {
70 return this;
71 }
72
73 return new MongoImpl(new SerialClientImpl((ClientImpl) getClient()));
74 }
75
76 /**
77 * {@inheritDoc}
78 * <p>
79 * Overridden to return the clients configuration.
80 * </p>
81 */
82 @Override
83 public com.allanbank.mongodb.MongoDbConfiguration getConfig() {
84 final MongoClientConfiguration config = getClient().getConfig();
85 if (config instanceof com.allanbank.mongodb.MongoDbConfiguration) {
86 return (com.allanbank.mongodb.MongoDbConfiguration) config;
87 }
88 throw new IllegalStateException(
89 "Configuration is not the expected MongoDbConfiguration.");
90 }
91 }