当前位置: 首页>>代码示例>>Java>>正文


Java JacksonDBCollection.wrap方法代码示例

本文整理汇总了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;
}
 
开发者ID:eeb,项目名称:dropwizard-mongo,代码行数:18,代码来源:CollectionIdsResource.java

示例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());
    }

}
 
开发者ID:eeb,项目名称:dropwizard-mongo-cms,代码行数:25,代码来源:BasicPageResource.java

示例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;
   }
 
开发者ID:domguinard,项目名称:mongodb-3-drivers-tutorial,代码行数:19,代码来源:DatasourceProviderMongoJack.java

示例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));
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:10,代码来源:MongoDbRuleService.java

示例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));
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:10,代码来源:MongoDbPipelineService.java

示例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());
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:10,代码来源:CollectorConfigurationService.java

示例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());

}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:16,代码来源:CollectorServiceImpl.java

示例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;
}
 
开发者ID:cvtienhoven,项目名称:graylog-plugin-aggregates,代码行数:14,代码来源:RuleServiceImpl.java

示例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);

}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:11,代码来源:LogWriterResource.java

示例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;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:11,代码来源:TruckingManagerBean.java

示例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;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:11,代码来源:TruckingManagerBean.java

示例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;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:12,代码来源:TruckingManagerBean.java

示例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);
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:8,代码来源:PlayerAction.java

示例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);
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:8,代码来源:GameAction.java


注:本文中的org.mongojack.JacksonDBCollection.wrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。