1 package org.apache.fulcrum.yaafi.framework.tls; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 /** 23 * Provides a service which can temporarily store 24 * thread-local data. This is useful in a multithreaded 25 * environment, such as a servlet or Tapestry application. 26 * ThreadLocalStorage acts like a map around thread local data. 27 * 28 * The code was pasted from the Hivemind container written by 29 * Howard Lewis Ship. 30 * 31 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a> 32 */ 33 34 public interface ThreadLocalStorage 35 { 36 /** 37 * Returns the thread-local object for the given key, or null 38 * if no such object exists. 39 * 40 * @param key the key for the lookup 41 * @return the object 42 */ 43 public Object get(String key); 44 45 /** 46 * Stores the value object at the given key, overwriting 47 * any prior value that may have been stored at that key. 48 * Care should be taken in selecting keys to avoid 49 * naming conflicts; in general, prefixing a key with 50 * a module id is a good idea. 51 * 52 * @param key the key of the object to store 53 * @param value the value of the object to store 54 */ 55 public void put(String key, Object value); 56 57 /** 58 * Checks if the thread-local object for the given key exists 59 * 60 * @param key the key for the lookup 61 * @return true the object exists 62 */ 63 public boolean containsKey(String key); 64 65 /** 66 * Clears all keys. 67 */ 68 public void clear(); 69 }