use of com.bluenimble.platform.plugins.database.mongodb.impls.MongoDatabaseImpl in project serverless by bluenimble.
the class MongoDatabasePlugin method init.
// private int weight;
@Override
public void init(final ApiServer server) throws Exception {
// weight = server.weight ();
Feature aFeature = Database.class.getAnnotation(Feature.class);
if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
return;
}
feature = aFeature.name();
// add features
server.addFeature(new ServerFeature() {
private static final long serialVersionUID = 2626039344401539390L;
@Override
public Class<?> type() {
return Database.class;
}
@Override
public Object get(ApiSpace space, String name) {
return new MongoDatabaseImpl(MongoDatabasePlugin.this.acquire(space, name), tracer());
}
@Override
public Plugin implementor() {
return MongoDatabasePlugin.this;
}
@Override
public String provider() {
return MongoDatabasePlugin.this.getName();
}
});
codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromProviders(PojoCodecProvider.builder().automatic(true).build()));
}
Aggregations