// Path: src/main/java/com/papercut/dust/model/TransactionalMap.java
// public interface TransactionalMap<T> extends Map<Long, T> {
// 
//     void commit();
// 
//     void rollback();
// }
// 
// Path: src/main/java/com/papercut/dust/model/TransactionalMapProducer.java
// public interface TransactionalMapProducer {
// 
//     <T> TransactionalMap<T> createStore(final String name);
// 
// }


import com.papercut.dust.model.TransactionalMap;
import com.papercut.dust.model.TransactionalMapProducer;
import org.mapdb.DB;
import org.mapdb.DBMaker;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
/*
 * Copyright (c) 2017 PaperCut Software International Pty. Ltd.
 *
 * https://www.papercut.com
 *
 * Use of this source code is governed by an MIT license.
 * See the project's LICENSE file for more information.
 */
package com.papercut.dust.mapdb;



@ApplicationScoped
public class MapDbProducer implements TransactionalMapProducer {

    private DB db;

    @PostConstruct
    public void init() {
        db = DBMaker
                .fileDB("data/persistence/device-mgmt.db")
                .fileMmapEnable()
                .make();
    }

// Path: src/main/java/com/papercut/dust/model/TransactionalMap.java
// public interface TransactionalMap<T> extends Map<Long, T> {
// 
//     void commit();
// 
//     void rollback();
// }
// 
// Path: src/main/java/com/papercut/dust/model/TransactionalMapProducer.java
// public interface TransactionalMapProducer {
// 
//     <T> TransactionalMap<T> createStore(final String name);
// 
// }


// Path: src/main/java/com/papercut/dust/mapdb/MapDbProducer.java
import com.papercut.dust.model.TransactionalMap;
import com.papercut.dust.model.TransactionalMapProducer;
import org.mapdb.DB;
import org.mapdb.DBMaker;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;

/*
 * Copyright (c) 2017 PaperCut Software International Pty. Ltd.
 *
 * https://www.papercut.com
 *
 * Use of this source code is governed by an MIT license.
 * See the project's LICENSE file for more information.
 */
package com.papercut.dust.mapdb;



@ApplicationScoped
public class MapDbProducer implements TransactionalMapProducer {

    private DB db;

    @PostConstruct
    public void init() {
        db = DBMaker
                .fileDB("data/persistence/device-mgmt.db")
                .fileMmapEnable()
                .make();
    }

    @PreDestroy