2012-12-02 20 views
0

我有Datastore Class,我使用這個類來嘗試GCM。我不明白的地方保存數據(註冊ID),但我重新啓動我的IDE(Eclipse中)DatastoreService我不明白它在哪裏保存數據?

感謝網友

private static final DatastoreService datastore = 
    DatastoreServiceFactory.getDatastoreService(); 

private Datastore() { 
    throw new UnsupportedOperationException(); 
} 

/** 
* Registers a device. 
* 
* @param regId device's registration id. 
*/ 

public static void register(String regId) { 
    logger.info("Registering " + regId); 
    Transaction txn = datastore.beginTransaction(); 
    try { 
    Entity entity = findDeviceByRegId(regId); 
    if (entity != null) { 
     logger.fine(regId + " is already registered; ignoring."); 
     return; 
    } 
    entity = new Entity(DEVICE_TYPE); 
    entity.setProperty(DEVICE_REG_ID_PROPERTY, regId); 
    datastore.put(entity); 
    txn.commit(); 
    } finally { 
    if (txn.isActive()) { 
     txn.rollback(); 
    } 
    } 
} 

/** 
* Gets all registered devices. 
*/ 

public static List<String> getDevices() { 
    List<String> devices; 
    Transaction txn = datastore.beginTransaction(); 
    try { 
    Query query = new Query(DEVICE_TYPE); 
    Iterable<Entity> entities = 
     datastore.prepare(query).asIterable(DEFAULT_FETCH_OPTIONS); 
    devices = new ArrayList<String>(); 
    for (Entity entity : entities) { 
     String device = (String) entity.getProperty(DEVICE_REG_ID_PROPERTY); 
     devices.add(device); 
    } 
    txn.commit(); 
    } finally { 
    if (txn.isActive()) { 
     txn.rollback(); 
    } 
    } 
    return devices; 
} 
+2

的數據存儲或者在GAE數據存儲,當你在生產服務器,或者在本地文件中,當你在當地的發展環境。無論如何,您可以從管理控制檯中查看您的應用中存儲了哪些數據。對於開發環境,您可以在http:// localhost:8080/_ah/admin –

+0

http:// localhost:8888/_ah/admin –

回答

0

的數據存儲或者在GAE數據存儲,當你後,我可以retrive這個在生產服務器中,或者在本地開發環境(https://appengine.google.com/ - >應用程序 - >數據存儲索引)中的本地文件中。 在任何情況下,您都可以從管理控制檯中查看應用程序中存儲了哪些數據。對於開發環境,你可以檢查在

本地主機:8888/_ah /管理(從瀏覽器)