![JAR search and dependency download from the Maven repository](/logo.png)
net.ymate.platform.mvc.context.Context Maven / Gradle / Ivy
/*
* Copyright 2007-2107 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.ymate.platform.mvc.context;
import java.util.Map;
/**
*
* Context
*
*
* MVC环境上下文对象封装类;
*
*
* @author 刘镇([email protected])
* @version 0.0.0
*
*
* 版本号 动作 修改人 修改时间
*
*
*
* 0.0.0
* 创建类
* 刘镇
* 2012-12-3下午3:51:42
*
*
*/
public class Context {
protected static ThreadLocal __THREAD_LOCAL_CONTEXT = new ThreadLocal();
private Map __context_map;
/**
* Sets the Context for the current thread.
*
* @param context the Context.
*/
public static void setContext(Context context) {
__THREAD_LOCAL_CONTEXT.set(context);
}
/**
* Returns the Context specific to the current thread.
*
* @return the Context for the current thread, is never null.
*/
public static Context getContext() {
return __THREAD_LOCAL_CONTEXT.get();
}
/**
* 构造器
*
* @param contextMap
*/
public Context(Map contextMap) {
__context_map = contextMap;
}
/**
* Returns a value that is stored in the current Context by doing a lookup using the value's key.
*
* @param key the key used to find the value.
* @return the value that was found using the key or null if the key was not found.
*/
public Object get(String key) {
return __context_map.get(key);
}
/**
* Stores a value in the current Context. The value can be looked up using the key.
*
* @param key the key of the value.
* @param value the value to be stored.
*/
public void put(String key, Object value) {
__context_map.put(key, value);
}
/**
* Sets the context map.
*
* @param contextMap the context map.
*/
public void setContextMap(Map contextMap) {
__context_map = contextMap;
}
/**
* Gets the context map.
*
* @return the context map.
*/
public Map getContextMap() {
return __context_map;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy