`

servlet中得到spring的ApplicationContext

 
阅读更多
private static ApplicationContext ctx = null;
	
	private static Lock lock = new ReentrantLock();

	private ApplicationContext getApplicationContext() {
		if (ctx != null) {
			return ctx;
		}

        lock.lock();
        if (ctx != null) {
            lock.unlock();
            return ctx;
        }

		ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
        lock.unlock();
		return ctx;
	}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics