KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > spring > SessionContextSpringProxyableObjectFactory


1 /*
2  * Copyright (c) 2005 Opensymphony. All Rights Reserved.
3  */

4 package com.opensymphony.webwork.spring;
5
6 import com.opensymphony.xwork.ActionContext;
7 import com.opensymphony.xwork.spring.SpringProxyableObjectFactory;
8 import com.opensymphony.webwork.spring.lifecycle.ApplicationContextSessionListener;
9 import org.springframework.context.ApplicationContext;
10
11 import java.util.Map JavaDoc;
12
13 /**
14  * SessionContextSpringProxyableObjectFactory
15  *
16  * @author Jason Carreira <jcarreira@eplus.com>
17  */

18 public class SessionContextSpringProxyableObjectFactory extends SpringProxyableObjectFactory {
19
20     protected ApplicationContext getApplicationContext() {
21         Map JavaDoc session = ActionContext.getContext().getSession();
22         ApplicationContext sessionContext = (ApplicationContext) session.get(ApplicationContextSessionListener.APP_CONTEXT_SESSION_KEY);
23         if (sessionContext == null) {
24             throw new IllegalStateException JavaDoc("There is no application context in the user's session");
25         }
26         return sessionContext;
27     }
28 }
29
Popular Tags