本文整理汇总了Java中org.mongojack.JacksonDBCollection.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java JacksonDBCollection.wrap方法的具体用法?Java JacksonDBCollection.wrap怎么用?Java JacksonDBCollection.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongojack.JacksonDBCollection
的用法示例。
在下文中一共展示了JacksonDBCollection.wrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetch
import org.mongojack.JacksonDBCollection; //导入方法依赖的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;
}
示例2: put
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public MongoDocument put(@Valid BasicPage newPage) {
try {
final JacksonDBCollection<BasicPage,String> col = JacksonDBCollection.wrap(mongoDb.getCollection("assets"),
BasicPage.class, String.class);
WriteResult<BasicPage, String> res = null;
res = col.insert(newPage);
MongoDocument d = new MongoDocument();
d.setId(((ObjectId)res.getDbObject().get("_id")).toString());
return d;
} catch(Exception e) {
Response.ResponseBuilder response = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
response.entity("{\"message\":\""+e.getMessage()+"\"}");
//TODO: Add logging
throw new WebApplicationException(response.build());
}
}
示例3: loadResources
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public <T> List<T> loadResources(String collection, Class<T> cl) {
// Shell query: db.xxx.find();
List<T> results = new ArrayList<T>();
DBCollection collec = db.getCollection("Fridges");
try {
JacksonDBCollection<T, String> collecMj = JacksonDBCollection.wrap(collec,
cl, String.class);
Iterable<T> all = collecMj.find();
for (T current : all) {
results.add(current);
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex);
}
return results;
}
示例4: MongoDbRuleService
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public MongoDbRuleService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper) {
dbCollection = JacksonDBCollection.wrap(
mongoConnection.getDatabase().getCollection(COLLECTION),
RuleDao.class,
String.class,
mapper.get());
dbCollection.createIndex(DBSort.asc("title"), new BasicDBObject("unique", true));
}
示例5: MongoDbPipelineStreamConnectionsService
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public MongoDbPipelineStreamConnectionsService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper) {
dbCollection = JacksonDBCollection.wrap(
mongoConnection.getDatabase().getCollection(COLLECTION),
PipelineConnections.class,
String.class,
mapper.get());
dbCollection.createIndex(DBSort.asc("stream_id"), new BasicDBObject("unique", true));
}
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:10,代码来源:MongoDbPipelineStreamConnectionsService.java
示例6: MongoDbPipelineService
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public MongoDbPipelineService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper) {
dbCollection = JacksonDBCollection.wrap(
mongoConnection.getDatabase().getCollection(COLLECTION),
PipelineDao.class,
String.class,
mapper.get());
dbCollection.createIndex(DBSort.asc("title"), new BasicDBObject("unique", true));
}
示例7: CollectorConfigurationService
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public CollectorConfigurationService(MongoConnection mongoConnection,
MongoJackObjectMapperProvider mapper) {
dbCollection = JacksonDBCollection.wrap(
mongoConnection.getDatabase().getCollection(COLLECTION_NAME),
CollectorConfiguration.class,
ObjectId.class,
mapper.get());
}
示例8: CollectorServiceImpl
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public CollectorServiceImpl(MongoConnection mongoConnection,
MongoJackObjectMapperProvider mapperProvider,
Validator validator) {
this.validator = validator;
final String collectionName = CollectorImpl.class.getAnnotation(CollectionName.class).value();
final DBCollection dbCollection = mongoConnection.getDatabase().getCollection(collectionName);
this.coll = JacksonDBCollection.wrap(dbCollection, CollectorImpl.class, String.class, mapperProvider.get());
this.coll.createIndex(new BasicDBObject("id", 1), new BasicDBObject("unique", true));
final String actionCollectionName = CollectorActions.class.getAnnotation(CollectionName.class).value();
final DBCollection actionDbCollection = mongoConnection.getDatabase().getCollection(actionCollectionName);
this.collActions = JacksonDBCollection.wrap(actionDbCollection, CollectorActions.class, String.class, mapperProvider.get());
}
示例9: RuleServiceImpl
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Inject
public RuleServiceImpl(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapperProvider,
Validator validator, StreamService streamService, AlertConditionFactory alertConditionFactory,
HistoryItemService historyItemService) {
this.validator = validator;
final String collectionName = RuleImpl.class.getAnnotation(CollectionName.class).value();
final DBCollection dbCollection = mongoConnection.getDatabase().getCollection(collectionName);
this.coll = JacksonDBCollection.wrap(dbCollection, RuleImpl.class, String.class, mapperProvider.get());
this.coll.createIndex(new BasicDBObject("name", 1), new BasicDBObject("unique", true));
this.streamService = streamService;
this.alertConditionFactory = alertConditionFactory;
this.historyItemService = historyItemService;
}
示例10: LogWriterResource
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
public LogWriterResource(String template, String defaultName, DB db) {
this.template = template;
this.defaultName = defaultName;
this.counter = new AtomicLong();
this.mongoDB = db;
mongoDB.getCollection(LOG_COLLECTION).createIndex(new BasicDBObject("timestamp", -1));
entries = JacksonDBCollection.wrap(mongoDB.getCollection(LOG_COLLECTION), Log.class,
String.class);
}
示例11: getHubs
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<Hub> getHubs() {
JacksonDBCollection<Hub, String> col = JacksonDBCollection.wrap(
mongoDB.getCollection("hubs"), Hub.class, String.class);
List<Hub> res = new ArrayList<Hub>();
for (Hub s : col.find()) {
res.add(s);
}
return res;
}
示例12: getSpokes
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<Spoke> getSpokes() {
JacksonDBCollection<Spoke, String> col = JacksonDBCollection.wrap(
mongoDB.getCollection("spokes"), Spoke.class, String.class);
List<Spoke> res = new ArrayList<Spoke>();
for (Spoke s : col.find()) {
res.add(s);
}
return res;
}
示例13: getTruckTypes
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<TruckType> getTruckTypes() {
JacksonDBCollection<TruckType, String> col = JacksonDBCollection.wrap(
mongoDB.getCollection("truckTypes"), TruckType.class,
String.class);
List<TruckType> res = new ArrayList<TruckType>();
for (TruckType s : col.find()) {
res.add(s);
}
return res;
}
示例14: PlayerAction
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
public PlayerAction(DB db) {
super(db);
this.playerCollection = JacksonDBCollection.wrap(db.getCollection(Player.COL_NAME), Player.class, String.class);
this.pbfCollection = JacksonDBCollection.wrap(db.getCollection(PBF.COL_NAME), PBF.class, String.class);
this.gameLogCollection = JacksonDBCollection.wrap(db.getCollection(GameLog.COL_NAME), GameLog.class, String.class);
this.drawAction = new DrawAction(db);
}
示例15: GameAction
import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
public GameAction(DB db) {
super(db);
this.playerCollection = JacksonDBCollection.wrap(db.getCollection(Player.COL_NAME), Player.class, String.class);
this.pbfCollection = JacksonDBCollection.wrap(db.getCollection(PBF.COL_NAME), PBF.class, String.class);
this.chatCollection = JacksonDBCollection.wrap(db.getCollection(Chat.COL_NAME), Chat.class, String.class);
this.gameLogAction = new GameLogAction(db);
}