001/* 002 * (C) Copyright 2017 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Kevin Leturc 018 */ 019package org.nuxeo.runtime.mongodb; 020 021import com.mongodb.client.MongoClient; 022import com.mongodb.client.MongoDatabase; 023 024/** 025 * Service used to get a database connection to MongoDB. 026 * 027 * @since 9.1 028 */ 029public interface MongoDBConnectionService { 030 031 /** 032 * Gets the MongoDB client for the given id. 033 * 034 * @param id the connection id 035 * @return the client configured by {@link MongoDBConnectionConfig} for the input id, or the default one if it 036 * doesn't exist 037 * @since 11.1 038 */ 039 MongoClient getClient(String id); 040 041 /** 042 * Gets the MongoDB configuration for the given id. 043 * 044 * @since 11.1 045 */ 046 MongoDBConnectionConfig getConfig(String id); 047 048 /** 049 * Gets the MongoDB database name for the given id. 050 * 051 * @param id the connection id 052 * @return the database name configured by {@link MongoDBConnectionConfig} for the input id, or the default one if 053 * it doesn't exist 054 * @since 11.1 055 */ 056 String getDatabaseName(String id); 057 058 /** 059 * @param id the connection id 060 * @return the database configured by {@link MongoDBConnectionConfig} for the input id, or the default one if it 061 * doesn't exist 062 */ 063 MongoDatabase getDatabase(String id); 064 065 /** 066 * @return all configured databases 067 * @deprecated since 11.1, unused 068 */ 069 @Deprecated 070 Iterable<MongoDatabase> getDatabases(); 071 072}