001 package org.apache.fulcrum.yaafi.framework.tls;
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 * Provides a service which can temporarily store
024 * thread-local data. This is useful in a multithreaded
025 * environment, such as a servlet or Tapestry application.
026 * ThreadLocalStorage acts like a map around thread local data.
027 *
028 * The code was pasted from the Hivemind container written by
029 * Howard Lewis Ship.
030 *
031 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
032 */
033
034 public interface ThreadLocalStorage
035 {
036 /**
037 * Returns the thread-local object for the given key, or null
038 * if no such object exists.
039 *
040 * @param key the key for the lookup
041 * @return the object
042 */
043 public Object get(String key);
044
045 /**
046 * Stores the value object at the given key, overwriting
047 * any prior value that may have been stored at that key.
048 * Care should be taken in selecting keys to avoid
049 * naming conflicts; in general, prefixing a key with
050 * a module id is a good idea.
051 *
052 * @param key the key of the object to store
053 * @param value the value of the object to store
054 */
055 public void put(String key, Object value);
056
057 /**
058 * Checks if the thread-local object for the given key exists
059 *
060 * @param key the key for the lookup
061 * @return true the object exists
062 */
063 public boolean containsKey(String key);
064
065 /**
066 * Clears all keys.
067 */
068 public void clear();
069 }