2012-12-02 2 views
0

데이터 저장소 클래스가 있으며이 클래스를 사용하여 GCM을 시도합니다. 나는 데이터를 저장 (등록 ID)를 이해하지 않습니다하지만 난 내 IDE (이클립스) 당신이 데이터는 하나 GAE 데이터 저장소에 저장됩니다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

덕분에 친구를 다시 시작한 후 나는이 문제를 가져 오지 수 프로덕션 서버 또는 로컬 개발 환경 (https://appengine.google.com/ -> 응용 프로그램 -> 데이터 스토어 색인)에있을 때 로컬 파일에 저장됩니다. 어쨌든 관리 콘솔에서 앱에 저장된 데이터를 확인할 수 있습니다. 개발 환경의 경우,

로컬 호스트에서 확인할 수 있습니다 (브라우저에서) 8888/_ah/관리자

관련 문제