org.mapdb
Class EngineWrapper.CloseOnJVMShutdown

java.lang.Object
  extended by org.mapdb.EngineWrapper
      extended by org.mapdb.EngineWrapper.CloseOnJVMShutdown
All Implemented Interfaces:
Engine
Enclosing class:
EngineWrapper

public static class EngineWrapper.CloseOnJVMShutdown
extends EngineWrapper

Closes Engine on JVM shutdown using shutdown hook: Runtime.addShutdownHook(Thread) If engine was closed by user before JVM shutdown, hook is removed to save memory.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.mapdb.EngineWrapper
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper
 
Field Summary
protected  AtomicBoolean shutdownHappened
           
 
Fields inherited from class org.mapdb.EngineWrapper
CLOSED
 
Fields inherited from interface org.mapdb.Engine
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
 
Constructor Summary
EngineWrapper.CloseOnJVMShutdown(Engine engine)
           
 
Method Summary
 void close()
          Close store/cache.
 
Methods inherited from class org.mapdb.EngineWrapper
canRollback, canSnapshot, checkClosed, clearCache, closeListenerRegister, closeListenerUnregister, commit, compact, compareAndSwap, delete, get, getSerializerPojo, getWrappedEngine, isClosed, isReadOnly, preallocate, preallocate, put, rollback, snapshot, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shutdownHappened

protected final AtomicBoolean shutdownHappened
Constructor Detail

EngineWrapper.CloseOnJVMShutdown

public EngineWrapper.CloseOnJVMShutdown(Engine engine)
Method Detail

close

public void close()
Description copied from interface: Engine
Close store/cache. This method must be called before JVM exits to flush all caches and prevent store corruption. Also it releases resources used by MapDB (disk, memory..).

Engine can no longer be used after this method was called. If Engine is used after closing, it may throw any exception including NullPointerException

There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically close Engine when JVM shutdowns.

Specified by:
close in interface Engine
Overrides:
close in class EngineWrapper


Copyright © 2014. All Rights Reserved.