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