code: public synchronized WriteSession createSession() throws ApplicationContextException {
  		if(this.threadSession.containsKey(Thread.currentThread().getId())) {
  			throw failure("Thread already has an active session");
  		}
  
  		if(this.delegate.isOffline()) {
  			throw failure("The Application Engine is off-line");
  		}
  
  		WriteSession nativeSession=this.delegate.createSession();
  		if(nativeSession==null) {
  			throw failure("Could not create native write session");
  		}
  
  		setUpWriteSessionCleaner();
  
  		return
  			trackSession(
  				new ContextWriteSessionState(
  					nativeSession,
  					new CleanerContextWriteSessionStateListener()));
  	}
docs: Create a {@code WriteSession}. Only one write session can be active per
  thread. Sessions should not be shared among threads.
  
  @return the write session
  @throws ApplicationContextException
  if no write session can be created for whichever reason,
  e.g., the Application Engine is off-line or is not available.