* request to see data obtained via the connection.
*
* @return
*/
public Mongo getMongo() {
MongoInstance mongoInstance = MeclipsePlugin.getDefault()
.getMongoInstance(this.getName());
Exception ex;
if (mongoInstance.getMongo() == null) {
Mongo mongo;
try {
mongo = new Mongo(mongoInstance.getHost(),
mongoInstance.getPort());
mongo.getDatabaseNames();
mongoInstance.setMongo(mongo); // add the active Mongo instance
// to the plug-in's state
isDown = false;
return mongo;
/* catch some possible exceptions */
} catch (MongoException e) {
ex = e;
} catch (UnknownHostException e) {
ex = e;
}
if (!isDown) {
this.showMessage(String.format(
getCaption("connection.connectionError"),
this.getName(), mongoInstance.getHost(), ex));
isDown = true;
}
return null;
} else {
return mongoInstance.getMongo();
}
}