Package org.springframework.data.mongodb.core

Examples of org.springframework.data.mongodb.core.SimpleMongoDbFactory


* @author Oleg Zhurakousky
*/
public class DemoUtils {

  public static MongoDbFactory prepareMongoFactory(String... additionalCollectionToDrop) throws Exception{
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoTemplate template = new MongoTemplate(mongoDbFactory);
    template.dropCollection("messages");
    template.dropCollection("data");
    for (String additionalCollection : additionalCollectionToDrop) {
      template.dropCollection(additionalCollection);
View Full Code Here


public class MongoApp2 {
  private static final Log log = LogFactory.getLog(MongoApp.class);

  public static void main(String[] args) throws Exception {
    MongoOperations mongoOps = new MongoTemplate(new SimpleMongoDbFactory(
        new Mongo(), "database"));
    Person p = new Person("Joe", 34);
    // Insert is used to initially store the object into the database.
    mongoOps.insert(p);
    log.info("Insert: " + p); // Find
View Full Code Here

      return mongo;
    }
   
    @Bean
    public MongoDbFactory mongoDbFactory() {
      return new SimpleMongoDbFactory(mongo, "impromptu-db");
    }
View Full Code Here

    logger.info("MongoDB:");
    createService(VCAP_MONGO_SERVICE, "mongodb", "1.8");
    int tunnelPort = LOCAL_PORT + 2;
    createTunnelServer(VCAP_MONGO_SERVICE, tunnelPort);
    Mongo mongo = new Mongo(LOCAL_HOST, tunnelPort);
    MongoDbFactory mdbf = new SimpleMongoDbFactory(mongo, svc_dbname, new UserCredentials(svc_username, svc_passwd));
    MongoTemplate mongoTemplate = new MongoTemplate(mdbf);
    // Test data
    ObjectMapper objectMapper = new ObjectMapper();
    Map<String,Object> dataMap = null;
    try {
View Full Code Here

@EnableMongoRepositories
public class MongoDbRepositoryConfig {

  @Bean
  public MongoDbFactory mongoDbFactory() throws UnknownHostException {
    return new SimpleMongoDbFactory(new MongoClient("localhost"), "spring-data-rest");
  }
View Full Code Here

@EnableMongoRepositories
public class MongoDbRepositoryConfig {

  @Bean
  public MongoDbFactory mongoDbFactory() throws UnknownHostException {
    return new SimpleMongoDbFactory(new Mongo("localhost"), "spring-data-rest-example");
  }
View Full Code Here

@Configuration
class MongoConfig {

    @Bean
    public MongoDbFactory mongoDbFactory() throws UnknownHostException {
        return new SimpleMongoDbFactory(new Mongo(), "${artifactId}");
    }
View Full Code Here

public class SpringMongoConfig {
  public @Bean
  MongoDbFactory mongoDbFactory() throws Exception {
    //return new SimpleMongoDbFactory(new MongoClient("ds039960.mongolab.com",39960), "degloba");
    return new SimpleMongoDbFactory(new MongoClient("localhost",27017), "test");
  }
View Full Code Here

@Configuration
class MongoConfig {

    @Bean
    public MongoDbFactory mongoDbFactory() throws UnknownHostException {
        return new SimpleMongoDbFactory(new Mongo(), "azad92");
    }
View Full Code Here

    if (jdbcPassword != null) {
      dataSource.setPassword(jdbcPassword);
    }

    try {
      mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(mongoHost + ":" + mongoPort), "xd");
    }
    catch (UnknownHostException unknownHostException) {
      throw new IllegalStateException(unknownHostException.getMessage(), unknownHostException);
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.SimpleMongoDbFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.