KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dwr > CallableManager


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

4 package dwr;
5
6 import org.wings.session.SessionManager;
7 import org.wings.session.Session;
8
9 import uk.ltd.getahead.dwr.ExecutionContext;
10
11 /**
12  * @author hengels
13  * @version $Revision: 1.2 $
14  */

15 public class CallableManager
16 {
17     SessionCreatorManager creatorManager = new SessionCreatorManager();
18
19     public static CallableManager getInstance() {
20         CallableManager callableManager = (CallableManager)SessionManager.getSession().getProperty("CallableManager");
21         if (callableManager == null) {
22             callableManager = new CallableManager();
23             SessionManager.getSession().setProperty("CallableManager", callableManager);
24         }
25         return callableManager;
26     }
27
28     public void registerCallable(String JavaDoc scriptName, Object JavaDoc callable) {
29         Session session = SessionManager.getSession();
30         ExecutionContext.setExecutionContext(session.getServletRequest(), session.getServletResponse(), null);
31         creatorManager.addCreator(scriptName, callable);
32         ExecutionContext.unset();
33     }
34
35     public void unregisterCallable(String JavaDoc scriptName) {
36         Session session = SessionManager.getSession();
37         ExecutionContext.setExecutionContext(session.getServletRequest(), session.getServletResponse(), null);
38         creatorManager.removeCreator(scriptName);
39         ExecutionContext.unset();
40     }
41 }
42
Popular Tags