001package org.eclipse.aether; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022/** 023 * A container for data that is specific to a repository system session. Both components within the repository system 024 * and clients of the system may use this storage to associate arbitrary data with a session. 025 * <p> 026 * Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be 027 * abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion. 028 * <p> 029 * <strong>Note:</strong> Actual implementations must be thread-safe. 030 * 031 * @see RepositorySystemSession#getData() 032 * @noimplement This interface is not intended to be implemented by clients. 033 * @noextend This interface is not intended to be extended by clients. 034 */ 035public interface SessionData 036{ 037 038 /** 039 * Associates the specified session data with the given key. 040 * 041 * @param key The key under which to store the session data, must not be {@code null}. 042 * @param value The data to associate with the key, may be {@code null} to remove the mapping. 043 */ 044 void set( Object key, Object value ); 045 046 /** 047 * Associates the specified session data with the given key if the key is currently mapped to the given value. This 048 * method provides an atomic compare-and-update of some key's value. 049 * 050 * @param key The key under which to store the session data, must not be {@code null}. 051 * @param oldValue The expected data currently associated with the key, may be {@code null}. 052 * @param newValue The data to associate with the key, may be {@code null} to remove the mapping. 053 * @return {@code true} if the key mapping was successfully updated from the old value to the new value, 054 * {@code false} if the current key mapping didn't match the expected value and was not updated. 055 */ 056 boolean set( Object key, Object oldValue, Object newValue ); 057 058 /** 059 * Gets the session data associated with the specified key. 060 * 061 * @param key The key for which to retrieve the session data, must not be {@code null}. 062 * @return The session data associated with the key or {@code null} if none. 063 */ 064 Object get( Object key ); 065 066}