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