本文整理汇总了Java中org.mongojack.DBCursor.close方法的典型用法代码示例。如果您正苦于以下问题:Java DBCursor.close方法的具体用法?Java DBCursor.close怎么用?Java DBCursor.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongojack.DBCursor
的用法示例。
在下文中一共展示了DBCursor.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetch
import org.mongojack.DBCursor; //导入方法依赖的package包/类
@GET
@Path("/list")
public List<Log> fetch(@PathParam("collection") String collection) {
final DBCursor<Log> cursor = entries.find();
final List<Log> l = new ArrayList<Log>();
try {
while (cursor.hasNext()) {
l.add(cursor.next());
}
} finally {
cursor.close();
}
return l;
}
示例2: fetchLatest
import org.mongojack.DBCursor; //导入方法依赖的package包/类
@GET
@Path("/latest")
public List<Log> fetchLatest(@PathParam("collection") String collection) {
final DBCursor<Log> cursor = entries.find().sort(new BasicDBObject("timestamp", -1)).limit(100);
final List<Log> l = new ArrayList<Log>();
try {
while (cursor.hasNext()) {
l.add(cursor.next());
}
} finally {
cursor.close();
}
return l;
}
示例3: fetch
import org.mongojack.DBCursor; //导入方法依赖的package包/类
@GET
public List<MongoDocument> fetch(@PathParam("collection") String collection) {
final JacksonDBCollection<MongoDocument, String> coll = JacksonDBCollection.wrap(mongoDB.getCollection(collection), MongoDocument.class,
String.class);
final DBCursor<MongoDocument> cursor = coll.find();
final List<MongoDocument> l = new ArrayList<>();
try {
while(cursor.hasNext()) {
l.add(cursor.next());
}
}finally {
cursor.close();
}
return l;
}
示例4: get
import org.mongojack.DBCursor; //导入方法依赖的package包/类
/**
* Returns a {@link com.eeb.dropwizardmongo.cms.api.BasicPage} using the slug as a query parameter.
* @param slug
* @return {@code BasicPage} object or a 403 if the object can not be found.
*/
@GET
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public BasicPageView get(@PathParam("slug") String slug) {
JacksonDBCollection<BasicPage,String> col = JacksonDBCollection.wrap(mongoDb.getCollection("assets"),
BasicPage.class, String.class);
//Note: MongoJack does not support the AutoClose interface
DBCursor<BasicPage> cursor = col.find(new BasicDBObject("metadata.slug",slug));
try {
if(!cursor.hasNext()) {
Response.ResponseBuilder response = Response.status(Response.Status.FORBIDDEN);
response.entity("{\"message\":\"Object not found\"}");
throw new WebApplicationException(response.build());
} else {
return new BasicPageView(cursor.next());
}
} finally {
cursor.close();
}
}
示例5: prefillCache
import org.mongojack.DBCursor; //导入方法依赖的package包/类
protected void prefillCache() {
if (LocalCache.PVE_ENABLED) {
final DBCursor<PveEvent> pveevents = db.findPveEvents();
pveevents.batchSize(5000);
for (final PveEvent pveevent : pveevents) {
pveEventCache.put(pveevent.hashCode(), pveevent);
esper.sendEvent(pveevent);
}
pveevents.close();
}
if (LocalCache.WVW_ENABLED) {
final DBCursor<WvwEvent> wvwevents = db.findWvwEvents();
wvwevents.batchSize(5000);
for (final WvwEvent wvwevent : wvwevents) {
wvwEventCache.put(wvwevent.hashCode(), wvwevent);
esper.sendEvent(wvwevent);
}
wvwevents.close();
}
}