Source Code Cross Referenced for CallableManager.java in  » Swing-Library » wings3 » org » wings » plaf » css » dwr » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » wings3 » org.wings.plaf.css.dwr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005 Your Corporation. All Rights Reserved.
003:         */
004:        package org.wings.plaf.css.dwr;
005:
006:        import java.lang.reflect.Method;
007:        import java.util.Iterator;
008:        import java.util.Set;
009:        import org.wings.header.SessionHeaders;
010:        import org.wings.header.JavaScriptHeader;
011:        import org.wings.session.SessionManager;
012:        import org.wings.session.Session;
013:        import org.wings.resource.SessionResource;
014:        import org.directwebremoting.WebContextFactory;
015:        import org.directwebremoting.WebContextFactory.WebContextBuilder;
016:        import org.directwebremoting.impl.DefaultWebContextBuilder;
017:        import org.directwebremoting.impl.DefaultContainer;
018:
019:        import java.util.Collection;
020:        import java.io.Serializable;
021:
022:        /**
023:         * @author hengels
024:         */
025:        public class CallableManager implements  Serializable {
026:
027:            private static final long serialVersionUID = 1L;
028:
029:            private SessionCreatorManager creatorManager = new SessionCreatorManager();
030:            private SessionAccessControl accessControl = new SessionAccessControl();
031:
032:            public static CallableManager getInstance() {
033:                Session session = SessionManager.getSession();
034:                CallableManager callableManager = (CallableManager) session
035:                        .getProperty("CallableManager");
036:                if (callableManager == null) {
037:                    callableManager = new CallableManager();
038:                    session.setProperty("CallableManager", callableManager);
039:                }
040:                return callableManager;
041:            }
042:
043:            /**
044:             * Register callable and expose all public methods.
045:             * @param scriptName
046:             * @param callable
047:             */
048:            public void registerCallable(String scriptName, Object callable) {
049:                Session session = SessionManager.getSession();
050:
051:                WebContextBuilder builder = new DefaultWebContextBuilder();
052:                builder.set(session.getServletRequest(), session
053:                        .getServletResponse(), null, session
054:                        .getServletContext(), new DefaultContainer());
055:
056:                WebContextFactory.setWebContextBuilder(builder);
057:
058:                creatorManager.addCreator(scriptName, new SessionCreator(
059:                        callable));
060:                builder.unset();
061:
062:                JavaScriptHeader header = new JavaScriptHeader(
063:                        new SessionResource("../dwr/interface/" + scriptName
064:                                + ".js"));
065:                SessionHeaders.getInstance().registerHeader(header);
066:            }
067:
068:            /**
069:             * Register callable and only expose a limited number of methods.
070:             * @param scriptName
071:             * @param callable
072:             * @param exportInterface interface that defines the methods to be exposed 
073:             * to the client by DWR
074:             */
075:            public void registerCallable(String scriptName, Object callable,
076:                    Class exportInterface) {
077:                Session session = SessionManager.getSession();
078:
079:                WebContextBuilder builder = new DefaultWebContextBuilder();
080:                builder.set(session.getServletRequest(), session
081:                        .getServletResponse(), null, session
082:                        .getServletContext(), new DefaultContainer());
083:
084:                WebContextFactory.setWebContextBuilder(builder);
085:
086:                Method[] methods = exportInterface.getMethods();
087:
088:                for (int i = 0; i < methods.length; i++) {
089:                    accessControl.addIncludeRule(scriptName, methods[i]
090:                            .getName());
091:                }
092:
093:                creatorManager.addCreator(scriptName, new SessionCreator(
094:                        callable));
095:                builder.unset();
096:
097:                JavaScriptHeader header = new JavaScriptHeader(
098:                        new SessionResource("../dwr/interface/" + scriptName
099:                                + ".js"));
100:                SessionHeaders.getInstance().registerHeader(header);
101:            }
102:
103:            public void unregisterCallable(String scriptName) {
104:                Session session = SessionManager.getSession();
105:
106:                WebContextBuilder builder = new DefaultWebContextBuilder();
107:                builder.set(session.getServletRequest(), session
108:                        .getServletResponse(), null, session
109:                        .getServletContext(), new DefaultContainer());
110:
111:                WebContextFactory.setWebContextBuilder(builder);
112:                creatorManager.removeCreator(scriptName);
113:                builder.unset();
114:
115:                JavaScriptHeader header = new JavaScriptHeader(
116:                        new SessionResource("../dwr/interface/" + scriptName
117:                                + ".js"));
118:                SessionHeaders.getInstance().deregisterHeader(header);
119:            }
120:
121:            public boolean containsCallable(String scriptName) {
122:                Session session = SessionManager.getSession();
123:
124:                WebContextBuilder builder = new DefaultWebContextBuilder();
125:                builder.set(session.getServletRequest(), session
126:                        .getServletResponse(), null, session
127:                        .getServletContext(), new DefaultContainer());
128:
129:                WebContextFactory.setWebContextBuilder(builder);
130:                boolean b = creatorManager.getCreatorNames().contains(
131:                        scriptName);
132:                builder.unset();
133:
134:                return b;
135:            }
136:
137:            public Collection callableNames() {
138:                Session session = SessionManager.getSession();
139:
140:                WebContextBuilder builder = new DefaultWebContextBuilder();
141:                builder.set(session.getServletRequest(), session
142:                        .getServletResponse(), null, session
143:                        .getServletContext(), new DefaultContainer());
144:
145:                WebContextFactory.setWebContextBuilder(builder);
146:                Collection c = creatorManager.getCreatorNames();
147:                builder.unset();
148:
149:                return c;
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.