Example usage for com.mongodb MongoURI MongoURI

List of usage examples for com.mongodb MongoURI MongoURI

Introduction

In this page you can find the example usage for com.mongodb MongoURI MongoURI.

Prototype

@SuppressWarnings("deprecation")
@Deprecated
public MongoURI(final MongoClientURI proxied) 

Source Link

Document

Create a new MongoURI from a MongoClientURI.

Usage

From source file:flipkart.mongo.replicator.core.model.Node.java

License:Apache License

public MongoURI getMongoURI() {
    return new MongoURI("mongodb://" + host + ":" + port);
}

From source file:fr.xebia.cocktail.CocktailRepository.java

License:Apache License

@Inject
public CocktailRepository(@Value("${mongodb_uri}") String mongoUri, @Value("${solr_url}") String solrUri)
        throws UnknownHostException, MalformedURLException {
    MongoURI databaseUri = new MongoURI(mongoUri);
    mongo = new Mongo(databaseUri);

    db = mongo.getDB(databaseUri.getDatabase());
    if (!Strings.isNullOrEmpty(databaseUri.getUsername())) {
        db.authenticate(databaseUri.getUsername(), databaseUri.getPassword());
    }/*from www .  j a  v a  2  s .c om*/
    cocktails = db.getCollection("cocktails");

    solrServer = new CommonsHttpSolrServer(solrUri);

}

From source file:gov.llnl.iscr.iris.MongoInstance.java

License:Open Source License

/**
 * employs a singleton approach that creates a Mongo described by a URI;
 * returns a mongo object/*from  ww w.  j a v a  2  s .  c om*/
 * @param host server to connect to
 * @return 
 */
private static Mongo getMongo(String host) {
    if (mongo == null) {
        try {
            MongoURI mongoURI = new MongoURI(host);
            mongo = holder.connect(mongoURI);
        } catch (UnknownHostException e) {
            System.err.println("Database host cannot be resolved: " + e);
        } catch (MongoException e) {
            System.err.println("A problem occured connecting to server: " + e);
        }
    }
    return mongo;
}

From source file:jmockmongo.MockMongo.java

License:Open Source License

MockMongo(int port) {
    this.port = port;
    this.uri = new MongoURI("mongodb://0.0.0.0:" + port);
}

From source file:org.ardverk.gibson.appender.MongoAppender.java

License:Apache License

public void setUri(String uri) {
    this.uri = new MongoURI(uri);
}

From source file:org.ardverk.gibson.dashboard.MongoModule.java

License:Apache License

private static MongoURI parseURI(String uri, MongoURI defaultValue) {
    if (uri != null) {
        return new MongoURI(uri);
    }/*from  ww  w. j  a  v  a  2s .  c  om*/

    return defaultValue;
}

From source file:org.bndtools.rt.packager.mongodb.client.MongoCommands.java

License:Open Source License

@Reference(target = "(uri=mongodb:*)")
public void bindEndpoint(Endpoint ep, Map<String, String> props) throws Exception {
    boundUri = new MongoURI(props.get(Endpoint.URI));
}

From source file:org.eclipse.birt.data.oda.mongodb.impl.MongoDBDriver.java

License:Open Source License

private static MongoURI getMongoURI(Properties connProps) {
    // check if explicitly indicated not to use URI, even if URI value exists
    Boolean ignoreURI = getBooleanPropValue(connProps, IGNORE_URI_PROP);
    if (ignoreURI != null && ignoreURI)
        return null;

    String uri = getStringPropValue(connProps, MONGO_URI_PROP);
    if (uri == null || uri.isEmpty())
        return null;

    try {/*from   w  w  w .jav a  2 s  . co m*/
        return new MongoURI(uri);
    } catch (Exception ex) {
        // log and ignore
        getLogger().log(Level.INFO, Messages.bind("Invalid Mongo Database URI: {0}", uri), ex); //$NON-NLS-1$
    }
    return null;
}

From source file:org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStoreFactory.java

License:Open Source License

public IStore createStore(String repositoryName, Map<String, String> repositoryProperties,
        Element storeConfig) {//from w w w. java  2  s  .  c  o m
    Map<String, String> properties = RepositoryConfigurator.getProperties(storeConfig, 1);
    String uri = properties.get("uri");
    if (StringUtil.isEmpty(uri)) {
        throw new IllegalArgumentException("Property 'uri' missing");
    }

    MongoURI mongoURI = new MongoURI(uri);
    String dbName = properties.get("db");
    if (StringUtil.isEmpty(dbName)) {
        dbName = repositoryName;
    }

    String drop = properties.get("drop");
    if (Boolean.toString(true).equals(drop)) {
        dropDatabase(mongoURI, dbName);
    }

    return CDOMongoDBUtil.createStore(uri, dbName);
}

From source file:org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil.java

License:Open Source License

public static IMongoDBStore createStore(String uri, String dbName) {
    MongoURI mongoURI = new MongoURI(uri);
    MongoDBStore store = new MongoDBStore();
    store.setMongoURI(mongoURI);//from   w  w w  .j  av  a  2  s  .co  m
    store.setDBName(dbName);
    return store;
}