package com.qmth.boot.core.fss.service.impl;

import com.qmth.boot.core.fss.service.FileStoreService;
import com.qmth.boot.core.fss.store.FileStore;

import javax.annotation.PreDestroy;
import javax.validation.constraints.NotNull;

public class SingletonFileStoreService implements FileStoreService {

    private FileStore fileStore;

    public SingletonFileStoreService(@NotNull FileStore fileStore) {
        this.fileStore = fileStore;
    }

    public void close() {
        this.fileStore.close();
    }

    @Override
    public FileStore getFileStore(String name) {
        return this.fileStore;
    }

    @PreDestroy
    public void shutdown() {
        fileStore.close();
    }
}
