use of com.bluenimble.platform.storage.impls.FileSystemStorage 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;
}
});
}
Aggregations