001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.hivemind.service;
016    
017    /**
018     * Provides a service which can temporarily store
019     * thread-local data. This is useful in a multithreaded
020     * environment, such as a servlet or Tapestry application.
021     * ThreadLocalStorage acts like a map around thread local data.
022     *
023     * @author Howard Lewis Ship
024     */
025    public interface ThreadLocalStorage
026    {
027            /**
028             * Returns the thread-local object for the given key, or null
029             * if no such object exists. 
030             */
031            public Object get(String key);
032            
033            /**
034             * Stores the value object at the given key, overwriting
035             * any prior value that may have been stored at that key.
036             * Care should be taken in selecting keys to avoid
037             * naming conflicts; in general, prefixing a key with
038             * a module id is a good idea.
039             */
040            public void put(String key, Object value);
041            
042            /**
043             * Clears all keys.
044             */
045            public void clear();
046    }