KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > modules > SessionValueModule


1 /*
2  * Created on Dec 6, 2004
3  */

4 package com.openedit.modules;
5
6 import com.openedit.OpenEditException;
7 import com.openedit.WebPageRequest;
8 import com.openedit.page.PageAction;
9 import com.openedit.page.PageRequestKeys;
10 import com.openedit.util.SessionTool;
11
12 /**
13  * @author Matthew Avery, mavery@einnovation.com
14  */

15 public class SessionValueModule extends BaseModule
16 {
17     public void loadSessionVariable( WebPageRequest inContext ) throws Exception JavaDoc
18     {
19         PageAction inAction = inContext.getCurrentAction();
20         String JavaDoc key = inAction.getConfig().getAttribute("bean");
21         Object JavaDoc bean = inContext.getSessionValue(key);
22         if( bean != null)
23         {
24             return;
25         }
26         String JavaDoc className = inAction.getConfig().getAttribute("class");
27         if ( className != null)
28         {
29             SessionTool classTool = (SessionTool)inContext.getPageValue( PageRequestKeys.CLASSTOOL );
30             inContext.putPageValue( key, classTool.construct( key, className ) );
31             return;
32         }
33         else
34         {
35             bean = getBeanFactory().getBean(key);
36             if ( bean != null)
37             {
38                 inContext.putSessionValue(key,bean);
39                 return;
40             }
41         }
42         throw new OpenEditException("No such bean " + key);
43     }
44 }
45
Popular Tags