Search in sources :

Example 6 with ServerFeature

use of com.bluenimble.platform.server.ServerFeature in project serverless by bluenimble.

the class FileSystemStoragePlugin method init.

@Override
public void init(final ApiServer server) throws Exception {
    Feature aFeature = Storage.class.getAnnotation(Feature.class);
    if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
        return;
    }
    feature = aFeature.name();
    if (!Lang.isNullOrEmpty(root)) {
        fRoot = new File(root);
    }
    if (!fRoot.exists()) {
        fRoot.mkdirs();
    }
    server.addFeature(new ServerFeature() {

        private static final long serialVersionUID = -9012279234275100528L;

        @Override
        public Class<?> type() {
            return Storage.class;
        }

        @Override
        public Object get(ApiSpace space, String name) {
            String mount = mounts.get(createStorageKey(name, space));
            if (mount == null) {
                return null;
            }
            return new FileSystemStorage(mount, new File(fRoot, mount));
        }

        @Override
        public String provider() {
            return FileSystemStoragePlugin.this.getName();
        }

        @Override
        public Plugin implementor() {
            return FileSystemStoragePlugin.this;
        }
    });
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) FileSystemStorage(com.bluenimble.platform.storage.impls.FileSystemStorage) JsonObject(com.bluenimble.platform.json.JsonObject) Feature(com.bluenimble.platform.Feature) ServerFeature(com.bluenimble.platform.server.ServerFeature) File(java.io.File) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Example 7 with ServerFeature

use of com.bluenimble.platform.server.ServerFeature in project serverless by bluenimble.

the class MemCachedPlugin method init.

@Override
public void init(final ApiServer server) throws Exception {
    Feature aFeature = Cache.class.getAnnotation(Feature.class);
    if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
        return;
    }
    feature = aFeature.name();
    server.addFeature(new ServerFeature() {

        private static final long serialVersionUID = 3585173809402444745L;

        @Override
        public Class<?> type() {
            return Cache.class;
        }

        @Override
        public Object get(ApiSpace space, String name) {
            return new MemCachedCache(((RecyclableCacheClient) (space.getRecyclable(createKey(name)))).client());
        }

        @Override
        public String provider() {
            return MemCachedPlugin.this.getName();
        }

        @Override
        public Plugin implementor() {
            return MemCachedPlugin.this;
        }
    });
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) MemCachedCache(com.bluenimble.platform.cache.impls.memcached.MemCachedCache) JsonObject(com.bluenimble.platform.json.JsonObject) Feature(com.bluenimble.platform.Feature) ServerFeature(com.bluenimble.platform.server.ServerFeature) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Example 8 with ServerFeature

use of com.bluenimble.platform.server.ServerFeature 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)

Example 9 with ServerFeature

use of com.bluenimble.platform.server.ServerFeature in project serverless by bluenimble.

the class OrientDatabasePlugin method init.

@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 OrientDatabase(OrientDatabasePlugin.this.acquire(space, name), tracer());
        }

        @Override
        public Plugin implementor() {
            return OrientDatabasePlugin.this;
        }

        @Override
        public String provider() {
            return OrientDatabasePlugin.this.getName();
        }
    });
    if (Orient.instance() != null) {
        Orient.instance().removeShutdownHook();
    }
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) OrientDatabase(com.bluenimble.platform.plugins.database.orientdb.impls.OrientDatabase) JsonObject(com.bluenimble.platform.json.JsonObject) Feature(com.bluenimble.platform.Feature) ServerFeature(com.bluenimble.platform.server.ServerFeature) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Example 10 with ServerFeature

use of com.bluenimble.platform.server.ServerFeature in project serverless by bluenimble.

the class DataSourcePlugin method init.

@Override
public void init(ApiServer server) throws Exception {
    weight = server.weight();
    Feature aFeature = RemoteDataSource.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 RemoteDataSource.class;
        }

        @Override
        public Object get(ApiSpace space, String name) {
            // get registered factory and create an EntityManager instance
            return entityManager(space, name);
        }

        @Override
        public Plugin implementor() {
            return DataSourcePlugin.this;
        }

        @Override
        public String provider() {
            return DataSourcePlugin.this.getName();
        }
    });
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) ApiSpace(com.bluenimble.platform.api.ApiSpace) 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)12 ServerFeature (com.bluenimble.platform.server.ServerFeature)12 ApiSpace (com.bluenimble.platform.api.ApiSpace)10 JsonObject (com.bluenimble.platform.json.JsonObject)10 Plugin (com.bluenimble.platform.plugins.Plugin)10 AbstractPlugin (com.bluenimble.platform.plugins.impls.AbstractPlugin)9 PackageClassLoader (com.bluenimble.platform.PackageClassLoader)3 FeatureNotFoundException (com.bluenimble.platform.server.FeatureNotFoundException)2 File (java.io.File)2 DescribeOption (com.bluenimble.platform.api.DescribeOption)1 ScriptableApiServiceSpi (com.bluenimble.platform.api.impls.scripting.ScriptableApiServiceSpi)1 ScriptableApiSpi (com.bluenimble.platform.api.impls.scripting.ScriptableApiSpi)1 DefaultScriptingEngine (com.bluenimble.platform.api.scripting.impls.DefaultScriptingEngine)1 MemCachedCache (com.bluenimble.platform.cache.impls.memcached.MemCachedCache)1 ElasticSearchIndexer (com.bluenimble.platform.indexer.impls.ElasticSearchIndexer)1 JsonArray (com.bluenimble.platform.json.JsonArray)1 MongoDatabaseImpl (com.bluenimble.platform.plugins.database.mongodb.impls.MongoDatabaseImpl)1 OrientDatabase (com.bluenimble.platform.plugins.database.orientdb.impls.OrientDatabase)1 Remote (com.bluenimble.platform.remote.Remote)1 HttpRemote (com.bluenimble.platform.remote.impls.http.HttpRemote)1