public synchronized Store open()

in src/main/java/org/apache/servicemix/store/mongo/MongoStoreFactory.java [64:94]


    public synchronized Store open(String collection) throws IOException {
        String key = database + "/" + collection;
        MongoStore store = stores.get(key);
        if (store == null) {
            if (mongo == null) {
                if (host == null || port == null)
                    throw new IOException("MongoDB host and port are required.");
                mongo = new Mongo(host, port);
            }
            if (db == null) {
                if (database == null)
                    throw new IOException("MongoDB database name is required.");
                db = mongo.getDB(database);
            }
            // if credentials are provided
            if (username != null && password != null) {
                boolean authenticated = db.authenticate(username, password.toCharArray());
                if (!authenticated)
                    throw new IOException("MongoDB authentication failed.");
            }
            if (timeout != null)
                store = new MongoStore(db, collection, timeout);
            else store = new MongoStore(db, collection);

             for(StoreListener listener:storeListeners) {
                store.addListener(listener);
            }
            stores.put(key, store);
        }
        return store;
    }