Source Code Cross Referenced for ResponderFactory.java in  » Testing » StoryTestIQ » fitnesse » responders » 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 » Testing » StoryTestIQ » fitnesse.responders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.responders;
004:
005:        import java.lang.reflect.Constructor;
006:        import java.lang.reflect.InvocationTargetException;
007:        import java.util.HashMap;
008:        import java.util.Map;
009:
010:        import com.sun.rmi.rmid.ExecOptionPermission;
011:
012:        import fitnesse.Responder;
013:        import fitnesse.http.Request;
014:        import fitnesse.responders.editing.CreateStiqPageResponder;
015:        import fitnesse.responders.editing.EditResponder;
016:        import fitnesse.responders.editing.PropertiesResponder;
017:        import fitnesse.responders.editing.SavePropertiesResponder;
018:        import fitnesse.responders.editing.SaveResponder;
019:        import fitnesse.responders.editing.SymbolicLinkResponder;
020:        import fitnesse.responders.editing.TableWizardResponder;
021:        import fitnesse.responders.files.CreateDirectoryResponder;
022:        import fitnesse.responders.files.DeleteConfirmationResponder;
023:        import fitnesse.responders.files.DeleteFileResponder;
024:        import fitnesse.responders.files.RenameFileConfirmationResponder;
025:        import fitnesse.responders.files.RenameFileResponder;
026:        import fitnesse.responders.files.RepoFileResponder;
027:        import fitnesse.responders.files.UploadResponder;
028:        import fitnesse.responders.refactoring.DeletePageResponder;
029:        import fitnesse.responders.refactoring.MovePageResponder;
030:        import fitnesse.responders.refactoring.NewStiqPageResponder;
031:        import fitnesse.responders.refactoring.RefactorPageResponder;
032:        import fitnesse.responders.refactoring.RenamePageResponder;
033:        import fitnesse.responders.run.FitClientResponder;
034:        import fitnesse.responders.run.SocketCatchingResponder;
035:        import fitnesse.responders.run.TestResultFormattingResponder;
036:        import fitnesse.responders.search.SearchFormResponder;
037:        import fitnesse.responders.search.SearchResponder;
038:        import fitnesse.responders.search.WhereUsedResponder;
039:        import fitnesse.responders.versions.RollbackResponder;
040:        import fitnesse.responders.versions.VersionResponder;
041:        import fitnesse.responders.versions.VersionSelectionResponder;
042:        import fitnesse.wiki.WikiPage;
043:        import fitnesse.wikitext.widgets.WikiWordWidget;
044:
045:        public class ResponderFactory {
046:            private String rootPath;
047:
048:            private Map responderMap;
049:
050:            public ResponderFactory(String rootPath) {
051:                this .rootPath = rootPath;
052:                responderMap = new HashMap();
053:                addResponder("edit", EditResponder.class);
054:                addResponder("saveData", SaveResponder.class);
055:                addResponder("tableWizard", TableWizardResponder.class);
056:                addResponder("search", SearchResponder.class);
057:                addResponder("searchForm", SearchFormResponder.class);
058:                //addResponder("test", TestResponder.class);
059:                //addResponder("suite", SuiteResponder.class);
060:                addResponder("proxy", SerializedPageResponder.class);
061:                addResponder("versions", VersionSelectionResponder.class);
062:                addResponder("viewVersion", VersionResponder.class);
063:                addResponder("rollback", RollbackResponder.class);
064:                addResponder("names", NameWikiPageResponder.class);
065:                addResponder("properties", PropertiesResponder.class);
066:                addResponder("saveProperties", SavePropertiesResponder.class);
067:                addResponder("whereUsed", WhereUsedResponder.class);
068:                addResponder("refactor", RefactorPageResponder.class);
069:                addResponder("deletePage", DeletePageResponder.class);
070:                addResponder("renamePage", RenamePageResponder.class);
071:                addResponder("movePage", MovePageResponder.class);
072:                addResponder("pageData", PageDataWikiPageResponder.class);
073:                addResponder("createDir", CreateDirectoryResponder.class);
074:                addResponder("upload", UploadResponder.class);
075:                addResponder("socketCatcher", SocketCatchingResponder.class);
076:                addResponder("fitClient", FitClientResponder.class);
077:                addResponder("deleteFile", DeleteFileResponder.class);
078:                addResponder("renameFile", RenameFileResponder.class);
079:                addResponder("deleteConfirmation",
080:                        DeleteConfirmationResponder.class);
081:                addResponder("renameConfirmation",
082:                        RenameFileConfirmationResponder.class);
083:                addResponder("raw", RawContentResponder.class);
084:                addResponder("rss", RssResponder.class);
085:                addResponder("import", WikiImportingResponder.class);
086:                addResponder("files", ClasspathFileResponder.class);
087:                addResponder("shutdown", ShutdownResponder.class);
088:                addResponder("format", TestResultFormattingResponder.class);
089:                addResponder("symlink", SymbolicLinkResponder.class);
090:
091:                // STIQ
092:                // "Responders" are created using this map when a corresponding Get method parameter name exists
093:                addResponder("storytestiq", ClasspathFileResponder.class);
094:                addResponder("stiq", ClasspathFileResponder.class);
095:                addResponder("startPage", ClasspathFileResponder.class);
096:                addResponder(NewStiqPageResponder.RESPONDER_KEY,
097:                        NewStiqPageResponder.class);
098:                addResponder(CreateStiqPageResponder.RESPONDER_KEY,
099:                        CreateStiqPageResponder.class);
100:                addResponder(ExecuteProcessResponder.RESPONDER_KEY,
101:                        ExecuteProcessResponder.class);
102:            }
103:
104:            public void addResponder(String key, Class responderClass) {
105:                responderMap.put(key, responderClass);
106:            }
107:
108:            public String getResponderKey(Request request) {
109:                if (request.hasInput("responder")) {
110:                    return (String) request.getInput("responder");
111:                } else {
112:                    if (request.getQueryString() != null) {
113:                        int nameValueSplit = request.getQueryString().indexOf(
114:                                '=');
115:                        if (nameValueSplit != -1) {
116:                            return request.getQueryString().substring(0,
117:                                    nameValueSplit);
118:                        }
119:                    }
120:                    return request.getQueryString();
121:                }
122:            }
123:
124:            public Responder makeResponder(Request request, WikiPage root)
125:                    throws Exception {
126:                Responder responder = new DefaultResponder();
127:                String resource = request.getResource();
128:
129:                if ("".equals(resource)) {
130:                    resource = "FrontPage";
131:                }
132:
133:                // The first Get method parameter name (after the ?)
134:                String responderKey = getResponderKey(request);
135:
136:                // Look in responderMap for the Get method parameter name and use its mapped responder
137:                if (usingResponderKey(responderKey)) {
138:                    responder = lookupResponder(responderKey, responder);
139:                } else {
140:                    if (resource.equals("storytestiq/project-extensions.js")) {
141:                        responder = new ProjectExtensionsResponder();
142:                    } else if (resource.startsWith("files")
143:                            || resource.startsWith("storytestiq")
144:                            || resource.startsWith("stiq")) {
145:                        responder = new ClasspathFileResponder();
146:                    } else if (WikiWordWidget.isWikiWord(resource)
147:                            || "root".equals(resource)) {
148:                        responder = new WikiPageResponder();
149:                    } else if (resource.startsWith("SQL")) {
150:                        responder = new SqlResponder();
151:                    } else if (resource
152:                            .startsWith(STIQResultResponder.STIQ_RESULT_URL)) {
153:                        responder = new STIQResultResponder();
154:                    } else if (resource
155:                            .startsWith(RepoFileResponder.RESPONDER_KEY)) {
156:                        responder = RepoFileResponder.makeResponder(request,
157:                                rootPath);
158:                    } else {
159:                        responder = new NotFoundResponder();
160:                    }
161:                }
162:
163:                return responder;
164:            }
165:
166:            private Responder lookupResponder(String responderKey,
167:                    Responder responder) throws NoSuchMethodException,
168:                    InstantiationException, IllegalAccessException,
169:                    InvocationTargetException {
170:                Class responderClass = getResponderClass(responderKey);
171:                if (responderClass != null) {
172:                    try {
173:                        Constructor constructor = responderClass
174:                                .getConstructor(new Class[] { String.class });
175:                        responder = (Responder) constructor
176:                                .newInstance(new Object[] { rootPath });
177:                    } catch (NoSuchMethodException e) {
178:                        Constructor constructor = responderClass
179:                                .getConstructor(new Class[0]);
180:                        responder = (Responder) constructor
181:                                .newInstance(new Object[0]);
182:                    }
183:                }
184:                return responder;
185:            }
186:
187:            public Class getResponderClass(String responderKey) {
188:                return (Class) responderMap.get(responderKey);
189:            }
190:
191:            private boolean usingResponderKey(String responderKey) {
192:                boolean usingKey = false;
193:                if (!("".equals(responderKey) || responderKey == null)) {
194:                    if (responderMap.containsKey(responderKey)) {
195:                        usingKey = true;
196:                    }
197:                }
198:                return usingKey;
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.