public final PersistenceServiceUnit getPersistenceServiceUnit ( ) throws Exception { lock . readLock ( ) . lock ( ) ; try { if ( destroyed ) throw new IllegalStateException ( ) ; if ( persistenceServiceUnit == null ) { // Switch to write lock for lazy initialization lock . readLock ( ) . unlock ( ) ; lock . writeLock ( ) . lock ( ) ; try { if ( destroyed ) throw new IllegalStateException ( ) ; if ( persistenceServiceUnit == null ) persistenceServiceUnit = dbStore . createPersistenceServiceUnit ( priv . getClassLoader ( Task . class ) , Partition . class . getName ( ) , Property . class . getName ( ) , Task . class . getName ( ) ) ; } finally { // Downgrade to read lock for rest of method lock . readLock ( ) . lock ( ) ; lock . writeLock ( ) . unlock ( ) ; } } return persistenceServiceUnit ; } finally { lock . readLock ( ) . unlock ( ) ; } }
Returns the persistence service unit lazily initializing if necessary .