1 package org.sonatype.aether; 2 3 /******************************************************************************* 4 * Copyright (c) 2010-2011 Sonatype, Inc. 5 * All rights reserved. This program and the accompanying materials 6 * are made available under the terms of the Eclipse Public License v1.0 7 * which accompanies this distribution, and is available at 8 * http://www.eclipse.org/legal/epl-v10.html 9 *******************************************************************************/ 10 11 /** 12 * A container for data that is specific to a repository system session. Both components within the repository system 13 * and clients of the system may use this storage to associate arbitrary data with a session. Unlike a cache, this 14 * session data is not subject to purging. For this same reason, session data should also not be abused as a cache (i.e. 15 * for storing values that can be re-calculated) to avoid memory exhaustion. <strong>Note:</strong> Actual 16 * implementations must be thread-safe. 17 * 18 * @author Benjamin Bentmann 19 * @see RepositorySystemSession#getData() 20 */ 21 public interface SessionData 22 { 23 24 /** 25 * Associates the specified session data with the given key. 26 * 27 * @param key The key under which to store the session data, must not be {@code null}. 28 * @param value The data to associate with the key, may be {@code null} to remove the mapping. 29 */ 30 void set( Object key, Object value ); 31 32 /** 33 * Associates the specified session data with the given key if the key is currently mapped to the given value. This 34 * method provides an atomic compare-and-update of some key's value. 35 * 36 * @param key The key under which to store the session data, must not be {@code null}. 37 * @param oldValue The expected data currently associated with the key, may be {@code null}. 38 * @param newValue The data to associate with the key, may be {@code null} to remove the mapping. 39 * @return {@code true} if the key mapping was updated to the specified value, {@code false} if the current key 40 * mapping didn't match the expected value and was not updated. 41 */ 42 boolean set( Object key, Object oldValue, Object newValue ); 43 44 /** 45 * Gets the session data associated with the specified key. 46 * 47 * @param key The key for which to retrieve the session data, must not be {@code null}. 48 * @return The session data associated with the key or {@code null} if none. 49 */ 50 Object get( Object key ); 51 52 }