com.seeyon.ctp.common
类 AppContext

java.lang.Object
  继承者 com.seeyon.ctp.common.AppContext

public final class AppContext
extends java.lang.Object

Title: T1开发框架

Description: 框架上下文相关操作工具类,包括获取当前登录用户相关信息、线程变量和Session操作方法、 配置文件夹操作等

Copyright: Copyright (c) 2012

Company: seeyon.com

从以下版本开始:
CTP2.0

构造方法摘要
AppContext()
           
 
方法摘要
static void clearThreadContext()
          清除所有线程变量
static long currentAccountId()
          当前登陆单位ID
static java.lang.String currentAccountName()
          当前登陆单位名称
static long currentUserId()
          当前登录用户ID
static java.lang.String currentUserLoginName()
          当前用户登录名。
static java.lang.String currentUserName()
          当前登录用户姓名
static java.lang.Object getBean(java.lang.String beanName)
          根据Spring管理的Bean名称获取Bean实例(带bean缓存以优化性能),非singleton的bean不适用
static
<T> java.util.Map<java.lang.String,T>
getBeansOfType(java.lang.Class<T> type)
          根据Spring管理的Bean类型获取Bean实例Map,key为bean id或name,value为Bean实例
static java.lang.Object getBeanWithoutCache(java.lang.String beanName)
          根据Spring管理的Bean名称获取Bean实例,不走性能优化缓存,适用于非singleton的bean获取
static java.lang.Object getCache(java.lang.String key)
           
static java.io.File getCfgHome()
          获取配置文件存放根目录
static User getCurrentUser()
          取得当前登录用户。
static java.util.Locale getLocale()
           
static javax.servlet.http.HttpServletRequest getRawRequest()
          获取原始HttpServletRequest对象,不建议应用直接使用
static javax.servlet.http.HttpServletResponse getRawResponse()
          获取原始HttpServletResponse对象,不建议应用直接使用
static javax.servlet.http.HttpSession getRawSession()
          获取原始HttpSession对象,不建议应用直接使用
static java.lang.String getRemoteAddr()
           
static java.lang.Object getRequestContext(java.lang.String ctxKey)
          获取request级上下文参数
static java.lang.Object getSessionContext(java.lang.String ctxKey)
          获取session级上下文参数
static java.lang.String getSystemProperty(java.lang.String key)
          根据key获取系统配置参数
static java.lang.Object getThreadContext(java.lang.String ctxKey)
          获取线程上下文参数
static boolean hasPlugin(java.lang.String id)
          判断当前系统是否启用了指定插件ID的模块
static boolean hasResourceCode(java.lang.String resourceCode)
          判断当前登陆用户是否具备指定资源Code的权限
static void init(org.springframework.context.ApplicationContext wac, java.io.File hapHome)
          初始化Spring应用上下文和系统配置目录
static void initSystemEnvironmentContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          初始化系统环境上下文,在请求入口调用,比如Ajax、controller、servlet等,否则会引起应用 功能异常
static void initSystemEnvironmentContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean session)
          初始化系统环境上下文,在请求入口调用,比如Ajax、controller、servlet等,否则会引起应用 功能异常
static boolean isAdministrator()
           
static boolean isAuditAdmin()
           
static boolean isRunningModeDevelop()
          获取当前运行模式是否为develop开发态
static boolean isRunningModeProduction()
          获取当前运行模式是否为production生产运行态
static boolean isRunningModeTest()
          获取当前运行模式是否为test测试态
static boolean isSystemAdmin()
           
static void putCache(java.lang.String key, java.lang.Object value)
           
static void putRequestContext(java.lang.String ctxKey, java.lang.Object ctxValue)
          设置request级上下文参数
static void putSessionContext(java.lang.String ctxKey, java.lang.Object ctxValue)
          设置session级上下文参数
static void putThreadContext(java.lang.String ctxKey, java.lang.Object ctxValue)
          设置线程上下文参数
static void removeSessionArrribute(java.lang.String key)
          移除session级上下文参数
static void removeThreadContext(java.lang.String ctxKey)
          删除线程上下文参数
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

AppContext

public AppContext()
方法详细信息

init

public static void init(org.springframework.context.ApplicationContext wac,
                        java.io.File hapHome)
初始化Spring应用上下文和系统配置目录

参数:
wac - Spring应用上下文
hapHome - 系统配置目录

getCurrentUser

public static User getCurrentUser()
取得当前登录用户。

返回:

currentUserId

public static long currentUserId()
当前登录用户ID

返回:
用户ID

currentUserLoginName

public static java.lang.String currentUserLoginName()
当前用户登录名。

返回:
用户登录名

currentUserName

public static java.lang.String currentUserName()
当前登录用户姓名

返回:
用户姓名

currentAccountId

public static long currentAccountId()
当前登陆单位ID

返回:
单位ID

currentAccountName

public static java.lang.String currentAccountName()
当前登陆单位名称

返回:
单位名称

isAdministrator

public static boolean isAdministrator()

isAuditAdmin

public static boolean isAuditAdmin()

isSystemAdmin

public static boolean isSystemAdmin()

getRemoteAddr

public static java.lang.String getRemoteAddr()

getBean

public static java.lang.Object getBean(java.lang.String beanName)
根据Spring管理的Bean名称获取Bean实例(带bean缓存以优化性能),非singleton的bean不适用

参数:
beanName - Spring管理的Bean名称
返回:
Bean实例

getBeanWithoutCache

public static java.lang.Object getBeanWithoutCache(java.lang.String beanName)
根据Spring管理的Bean名称获取Bean实例,不走性能优化缓存,适用于非singleton的bean获取

参数:
beanName - Spring管理的Bean名称
返回:
Bean实例

getBeansOfType

public static <T> java.util.Map<java.lang.String,T> getBeansOfType(java.lang.Class<T> type)
根据Spring管理的Bean类型获取Bean实例Map,key为bean id或name,value为Bean实例

参数:
type - 要获取Spring管理的Bean的类型,比如接口、抽象类
返回:
Spring容器中指定类型的Bean实例Map,key为bean id或name,value为Bean实例

getCfgHome

public static java.io.File getCfgHome()
获取配置文件存放根目录

返回:
配置文件存放根目录

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key)
根据key获取系统配置参数

参数:
key - 系统配置key
返回:
系统配置值

putThreadContext

public static void putThreadContext(java.lang.String ctxKey,
                                    java.lang.Object ctxValue)
设置线程上下文参数

参数:
ctxKey - 上下文键
ctxValue - 上下文值

getThreadContext

public static java.lang.Object getThreadContext(java.lang.String ctxKey)
获取线程上下文参数

参数:
ctxKey - 上下文键
返回:
上下文值

removeThreadContext

public static void removeThreadContext(java.lang.String ctxKey)
删除线程上下文参数

参数:
ctxKey - 上下文键

clearThreadContext

public static void clearThreadContext()
清除所有线程变量


putCache

public static void putCache(java.lang.String key,
                            java.lang.Object value)

getCache

public static java.lang.Object getCache(java.lang.String key)

putSessionContext

public static void putSessionContext(java.lang.String ctxKey,
                                     java.lang.Object ctxValue)
设置session级上下文参数

参数:
ctxKey - 上下文键
ctxValue - 上下文值

removeSessionArrribute

public static void removeSessionArrribute(java.lang.String key)
移除session级上下文参数

参数:
key - 上下文键

getSessionContext

public static java.lang.Object getSessionContext(java.lang.String ctxKey)
获取session级上下文参数

参数:
ctxKey - 上下文键
返回:
上下文值

getRawSession

public static javax.servlet.http.HttpSession getRawSession()
获取原始HttpSession对象,不建议应用直接使用

返回:
HttpSession实例

putRequestContext

public static void putRequestContext(java.lang.String ctxKey,
                                     java.lang.Object ctxValue)
设置request级上下文参数

参数:
ctxKey - 上下文键
ctxValue - 上下文值

getRequestContext

public static java.lang.Object getRequestContext(java.lang.String ctxKey)
获取request级上下文参数

参数:
ctxKey - 上下文键
返回:
上下文值

getRawRequest

public static javax.servlet.http.HttpServletRequest getRawRequest()
获取原始HttpServletRequest对象,不建议应用直接使用

返回:
HttpServletRequest实例

getRawResponse

public static javax.servlet.http.HttpServletResponse getRawResponse()
获取原始HttpServletResponse对象,不建议应用直接使用

返回:
HttpServletResponse实例

hasPlugin

public static boolean hasPlugin(java.lang.String id)
判断当前系统是否启用了指定插件ID的模块

参数:
id - 插件ID
返回:
如果指定插件启用则返回true,否则返回false

hasResourceCode

public static boolean hasResourceCode(java.lang.String resourceCode)
判断当前登陆用户是否具备指定资源Code的权限

参数:
resourceCode - 资源Code
返回:
如果当前登陆用户具有指定资源Code权限则返回true,否则返回false

getLocale

public static java.util.Locale getLocale()

isRunningModeDevelop

public static boolean isRunningModeDevelop()
获取当前运行模式是否为develop开发态

返回:
true为开发态

isRunningModeTest

public static boolean isRunningModeTest()
获取当前运行模式是否为test测试态

返回:
true为测试态

isRunningModeProduction

public static boolean isRunningModeProduction()
获取当前运行模式是否为production生产运行态

返回:
true为生产运行态

initSystemEnvironmentContext

public static void initSystemEnvironmentContext(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)
初始化系统环境上下文,在请求入口调用,比如Ajax、controller、servlet等,否则会引起应用 功能异常

参数:
request - Servlet请求对象
response - Servlet应答对象

initSystemEnvironmentContext

public static void initSystemEnvironmentContext(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                boolean session)
初始化系统环境上下文,在请求入口调用,比如Ajax、controller、servlet等,否则会引起应用 功能异常

参数:
request - Servlet请求对象
response - Servlet应答对象
session - 是否session不存在则创建,request.getSession(true or false)