package jp.troter.servlet.httpsession.example.mongo.spi.impl;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import jp.troter.servlet.httpsession.spi.MongoDBInitializer;

import com.mongodb.DB;
import com.mongodb.Mongo;

public class MongoDBInitializerImpl extends MongoDBInitializer {

    Mongo m = null;

    @Override
    public DB getDB() {
        if (m == null) {
            try {
                m = new Mongo("localhost", 27017);
            } catch (IOException e) {
                return null;
            }
        }
        return m.getDB("httpsession");
    }

    @Override
    public int getSessionTimeout() {
        return Long.valueOf(TimeUnit.HOURS.toSeconds(1L)).intValue();
    }
}

@@ -233,16 +233,45 @@
 b.Mongo;
+%0Aimport com.mongodb.MongoURI;
 %0A%0Apublic
@@ -452,40 +452,99 @@
     
-m = new Mongo(%22localhost%22, 27017
+MongoURI uri = new MongoURI(%22mongodb://127.0.0.1:27017%22);%0A                m = new Mongo(uri
 );%0A 

use MongoURI