private synchronized final UsageAwareDatastoreConnection<E> getDatastoreConnection() {
		if (_datastoreConnection != null) {
			return _datastoreConnection;
		}

		UsageAwareDatastoreConnection<E> datastoreConnection;
		if (_datastoreConnectionRef != null) {
			datastoreConnection = _datastoreConnectionRef.get();
			if (datastoreConnection != null && datastoreConnection.requestUsage()) {
				// reuse existing data context provider
				logger.debug("Reusing existing DatastoreConnection: {}", datastoreConnection);
				return datastoreConnection;
			}
		}

		datastoreConnection = createDatastoreConnection();
		if (datastoreConnection == null) {
			throw new IllegalStateException("createDatastoreConnection() returned null");
		}
		_datastoreConnectionRef = new WeakReference<UsageAwareDatastoreConnection<E>>(datastoreConnection);

		return datastoreConnection;
	}
private synchronized final UsageAwareDatastoreConnection < E > getDatastoreConnection ( ) { if ( _datastoreConnection != null ) { return _datastoreConnection ; } UsageAwareDatastoreConnection < E > datastoreConnection ; if ( _datastoreConnectionRef != null ) { datastoreConnection = _datastoreConnectionRef . get ( ) ; if ( datastoreConnection != null && datastoreConnection . requestUsage ( ) ) { logger . debug ( "Reusing existing DatastoreConnection: {}" , datastoreConnection ) ; return datastoreConnection ; } } datastoreConnection = createDatastoreConnection ( ) ; if ( datastoreConnection == null ) { throw new IllegalStateException ( "createDatastoreConnection() returned null" ) ; } _datastoreConnectionRef = new WeakReference < UsageAwareDatastoreConnection < E > > ( datastoreConnection ) ; return datastoreConnection ; }
{@inheritDoc}