本文整理汇总了Java中org.mongodb.morphia.converters.TypeConverter类的典型用法代码示例。如果您正苦于以下问题:Java TypeConverter类的具体用法?Java TypeConverter怎么用?Java TypeConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeConverter类属于org.mongodb.morphia.converters包,在下文中一共展示了TypeConverter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addConverters
import org.mongodb.morphia.converters.TypeConverter; //导入依赖的package包/类
private void addConverters(final MappedClass mc) {
final List<Annotation> convertersList = mc.getAnnotations(Converters.class);
if (convertersList != null) {
for (Annotation a : convertersList) {
final Converters c = (Converters) a;
if (c != null) {
for (final Class<? extends TypeConverter> clazz : c.value()) {
if (!getConverters().isRegistered(clazz)) {
getConverters().addConverter(clazz);
}
}
}
}
}
}
开发者ID:mongodb,项目名称:morphia,代码行数:17,代码来源:Mapper.java
示例2: configure
import org.mongodb.morphia.converters.TypeConverter; //导入依赖的package包/类
@Override
protected void configure() {
Multibinder<TypeConverter> mb = Multibinder
.newSetBinder(binder(), TypeConverter.class);
bind(new TypeLiteral<GeometryConverter<BSONObject>>() {
}).to(GeoBSON.class);
mb.addBinding().to(DateTimeConverter.class);
mb.addBinding().to(DurationConverter.class);
mb.addBinding().to(FileConverter.class);
mb.addBinding().to(JTSConverter.class);
mb.addBinding().to(URLConverter.class);
mb.addBinding().to(DimensionedNumberConverter.class);
mb.addBinding().to(TrackSummariesConverter.class);
}
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:15,代码来源:MongoConverterModule.java
示例3: MongoDB
import org.mongodb.morphia.converters.TypeConverter; //导入依赖的package包/类
@Inject
public MongoDB(Injector injector,
Set<TypeConverter> converters,
@Named(MAPPED_CLASSES) Set<Class<?>> mappedClasses,
@Named(HOST_PROPERTY) String host,
@Named(PORT_PROPERTY) int port,
@Named(DATABASE_PROPERTY) String database,
@Nullable @Named(USER_PROPERTY) String username,
@Nullable @Named(PASS_PROPERTY) char[] password) {
try {
MorphiaLoggerFactory.registerLogger(SLF4JLoggerImplFactory.class);
if (username == null) {
mongo = new MongoClient(new ServerAddress(host, port));
}
else {
mongo = new MongoClient(new ServerAddress(host, port), Collections.singletonList(
MongoCredential.createMongoCRCredential(username, database, password)));
}
morphia = new Morphia();
morphia.getMapper().getOptions().setObjectFactory(new CustomGuiceObjectFactory(new DefaultCreator(), injector));
addConverters(converters);
addMappedClasses(mappedClasses);
datastore = morphia
.createDatastore(mongo, database);
datastore.ensureIndexes();
ensureIndexes();
datastore.ensureCaps();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:34,代码来源:MongoDB.java
示例4: addConverters
import org.mongodb.morphia.converters.TypeConverter; //导入依赖的package包/类
private void addConverters(Set<TypeConverter> converters) {
converters.forEach(getMapper().getConverters()::addConverter);
}
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:4,代码来源:MongoDB.java
示例5: configure
import org.mongodb.morphia.converters.TypeConverter; //导入依赖的package包/类
@Override
protected void configure() {
bind(DataService.class).to(DataServiceImpl.class);
bind(AccessRights.class).to(NonRestrictiveRights.class);
bind(DataService.class).to(DataServiceImpl.class);
bind(UserService.class).to(UserServiceImpl.class);
bind(FriendService.class).to(FriendServiceImpl.class);
bind(GroupService.class).to(GroupServiceImpl.class);
bind(StatisticsService.class).to(StatisticsServiceImpl.class);
bind(PasswordEncoder.class).to(BCryptPasswordEncoder.class);
bind(UserStatisticService.class).to(UserStatisticServiceImpl.class);
bind(GeometryOperations.class).to(GeodesicGeometryOperations.class);
Multibinder.newSetBinder(binder(), TypeConverter.class);
bind(new TypeLiteral<GeometryConverter<BSONObject>>() {
}).to(GeoBSON.class);
bind(new TypeLiteral<JSONEntityDecoder<Measurement>>() {
}).to(MeasurementDecoder.class);
bind(new TypeLiteral<JSONEntityDecoder<Geometry>>() {
}).to(GeoJSONDecoder.class);
install(new FactoryModuleBuilder()
.implement(User.class, MongoUser.class)
.implement(Group.class, MongoGroup.class)
.implement(Track.class, MongoTrack.class)
.implement(UserStatistic.class, MongoUserStatistic.class)
.implement(Measurement.class, MongoMeasurement.class)
.implement(MeasurementValue.class, MongoMeasurementValue.class)
.implement(Phenomenon.class, MongoPhenomenon.class)
.implement(Sensor.class, MongoSensor.class)
.implement(Fueling.class, MongoFueling.class)
.build(EntityFactory.class));
install(new FactoryModuleBuilder()
.implement(Activity.class, MongoActivity.class)
.implement(GroupActivity.class, MongoGroupActivity.class)
.implement(TrackActivity.class, MongoTrackActivity.class)
.implement(UserActivity.class, MongoUserActivity.class)
.build(ActivityFactory.class));
bind(UserDao.class).to(MongoUserDao.class);
bind(GroupDao.class).to(MongoGroupDao.class);
bind(TrackDao.class).to(MongoTrackDao.class);
bind(UserStatisticDao.class).to(MongoUserStatisticDao.class);
bind(MeasurementDao.class).to(MongoMeasurementDao.class);
bind(SensorDao.class).to(MongoSensorDao.class);
bind(StatisticsDao.class).to(MongoStatisticsDao.class);
bind(PhenomenonDao.class).to(MongoPhenomenonDao.class);
bind(ActivityDao.class).to(MongoActivityDao.class);
bind(TermsOfUseDao.class).to(MongoTermsOfUseDao.class);
bind(AnnouncementsDao.class).to(MongoAnnouncementsDao.class);
bind(BadgesDao.class).to(MongoBadgesDao.class);
bind(PasswordResetDAO.class).to(MongoPasswordResetDAO.class);
bind(FuelingDao.class).to(MongoFuelingDao.class);
bind(CarSimilarityService.class).to(CarSimilarityServiceImpl.class);
}
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:53,代码来源:EncodingTestModule.java
注:本文中的org.mongodb.morphia.converters.TypeConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论