當前位置: 首頁>>代碼示例>>Java>>正文


Java DatastoreManager類代碼示例

本文整理匯總了Java中com.cloudant.sync.datastore.DatastoreManager的典型用法代碼示例。如果您正苦於以下問題:Java DatastoreManager類的具體用法?Java DatastoreManager怎麽用?Java DatastoreManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DatastoreManager類屬於com.cloudant.sync.datastore包,在下文中一共展示了DatastoreManager類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDevelopmentDatabase

import com.cloudant.sync.datastore.DatastoreManager; //導入依賴的package包/類
private static void createDevelopmentDatabase() throws Exception {

        // some temporary code for development purposes :)
        File path = new File(databaseDir);
        DatastoreManager manager = DatastoreManager.getInstance(path.getAbsolutePath());

        // make sure we have a database for development
        Datastore ds = manager.openDatastore("mydb");

//        MutableDocumentRevision rev = new MutableDocumentRevision();
//        Map<String, Object> json = new HashMap<String, Object>();
//        json.put("description", "Buy milk");
//        json.put("completed", false);
//        json.put("type", "com.cloudant.sync.example.task");
//        rev.body = DocumentBodyFactory.create(json);
//        ds.createDocumentFromRevision(rev);
        ds.close();
    }
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:19,代碼來源:Application.java

示例2: onCreate

import com.cloudant.sync.datastore.DatastoreManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // create datastore
    File path = getApplicationContext().getDir("datastores", MODE_PRIVATE);
    DatastoreManager manager = new DatastoreManager(path.getAbsolutePath());

    Datastore ds = manager.openDatastore("mydb");
    ds.close();

    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);
    component.getDefaultHost().attachDefault(HttpListener.class);

    try {
        component.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:snowch,項目名稱:z_sync-android-p2p-example.deprecated,代碼行數:23,代碼來源:MainActivity.java

示例3: HttpListener

import com.cloudant.sync.datastore.DatastoreManager; //導入依賴的package包/類
public HttpListener() {

        databaseDir = 
        		getApplication().getContext().getParameters().getFirstValue("databaseDir");

        port = new Integer(
        			getApplication().getContext().getParameters().getFirstValue("port")
        			);

        manager = DatastoreManager.getInstance(databaseDir);
    }
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:12,代碼來源:HttpListener.java

示例4: createServer

import com.cloudant.sync.datastore.DatastoreManager; //導入依賴的package包/類
void createServer(final int port, final String dbname) throws Exception {

	final String databaseDir = Files.createTempDirectory(null).toAbsolutePath().toString();
	databaseDirs.put(port, databaseDir);

	DatastoreManager manager = DatastoreManager.getInstance(databaseDir);
	Datastore ds = manager.openDatastore(dbname);
	ds.close();

	Runnable r = new Runnable()
	{
		@Override
		public void run()
		{
			final Router router = new Router();
			router.attachDefault(HttpListener.class);

			org.restlet.Application myApp = new org.restlet.Application() {
				@Override
				public org.restlet.Restlet createInboundRoot() {
					Context ctx = getContext();
					ctx.getParameters().add("databaseDir", databaseDir);
					ctx.getParameters().add("port", Integer.toString(port));
					router.setContext(ctx);
					return router;
				};
			};

			Component component = new Component();
			component.getDefaultHost().attach("/", myApp);
			try {
				new Server(Protocol.HTTP, port, component).start();
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
	};
	new Thread(r).start();
}
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:40,代碼來源:P2PAbstractTest.java

示例5: onCreate

import com.cloudant.sync.datastore.DatastoreManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    AndroidLoggingHandler.reset(new AndroidLoggingHandler());
    java.util.logging.Logger.getLogger(HttpListener.class.getCanonicalName()).setLevel(Level.FINEST);

    try {
        // create datastore
        final File databaseDir = getApplicationContext().getDir("datastores", MODE_PRIVATE);
        final DatastoreManager manager = DatastoreManager.getInstance(databaseDir.getAbsolutePath());

        Datastore ds = manager.openDatastore("mydb");
        ds.close();

        // Set up a Restlet service
        final Router router = new Router();
        router.attachDefault(HttpListener.class);

        org.restlet.Application myApp = new org.restlet.Application() {
            @Override
            public org.restlet.Restlet createInboundRoot() {
            	Context ctx = getContext();
				ctx.getParameters().add("databaseDir", databaseDir.getAbsolutePath());
				ctx.getParameters().add("port", Integer.toString(PORT));
				router.setContext(ctx);
                return router;
            };
        };
        Component component = new Component();
        component.getDefaultHost().attach("/", myApp);

        new Server(Protocol.HTTP, PORT, component).start();
        
    } catch (Exception e) {
    	Log.e("snowch.MyActivity", "Error", e);
        throw new RuntimeException(e);
    }
}
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:41,代碼來源:MainActivity.java


注:本文中的com.cloudant.sync.datastore.DatastoreManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。