Search in sources :

Example 1 with MongoDatabaseImpl

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()));
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) MongoDatabaseImpl(com.bluenimble.platform.plugins.database.mongodb.impls.MongoDatabaseImpl) JsonObject(com.bluenimble.platform.json.JsonObject) ServerFeature(com.bluenimble.platform.server.ServerFeature) Feature(com.bluenimble.platform.Feature) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Aggregations

Feature (com.bluenimble.platform.Feature)1 ApiSpace (com.bluenimble.platform.api.ApiSpace)1 JsonObject (com.bluenimble.platform.json.JsonObject)1 Plugin (com.bluenimble.platform.plugins.Plugin)1 MongoDatabaseImpl (com.bluenimble.platform.plugins.database.mongodb.impls.MongoDatabaseImpl)1 AbstractPlugin (com.bluenimble.platform.plugins.impls.AbstractPlugin)1 ServerFeature (com.bluenimble.platform.server.ServerFeature)1