Source Code Cross Referenced for ComponentFactory.java in  » Testing » StoryTestIQ » fitnesse » 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 
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;
004:
005:        import fitnesse.wiki.*;
006:        import fitnesse.html.HtmlPageFactory;
007:        import fitnesse.responders.ResponderFactory;
008:        import fitnesse.authentication.*;
009:        import fitnesse.wikitext.WidgetBuilder;
010:        import java.util.*;
011:        import java.io.*;
012:        import java.lang.reflect.*;
013:
014:        public class ComponentFactory {
015:            private final String endl = System.getProperty("line.separator");
016:
017:            public static final String PROPERTIES_FILE = "plugins.properties";
018:
019:            public static final String WIKI_PAGE_CLASS = "WikiPage";
020:
021:            public static final String HTML_PAGE_FACTORY = "HtmlPageFactory";
022:
023:            public static final String RESPONDERS = "Responders";
024:
025:            public static final String WIKI_WIDGETS = "WikiWidgets";
026:
027:            public static final String AUTHENTICATOR = "Authenticator";
028:
029:            private Properties loadedProperties;
030:
031:            private String propertiesLocation;
032:
033:            public ComponentFactory(String propertiesLocation) {
034:                this (propertiesLocation, new Properties());
035:            }
036:
037:            public ComponentFactory(String propertiesLocation,
038:                    Properties properties) {
039:                this .propertiesLocation = propertiesLocation;
040:                this .loadedProperties = properties;
041:                loadProperties();
042:            }
043:
044:            public void loadProperties() {
045:                try {
046:                    loadedProperties.load(new FileInputStream(
047:                            propertiesLocation + "/" + PROPERTIES_FILE));
048:                } catch (IOException e) {
049:                    // No properties files means all defaults are loaded
050:                }
051:            }
052:
053:            private Object createComponent(String componentType)
054:                    throws Exception {
055:                String componentClassName = loadedProperties
056:                        .getProperty(componentType);
057:                if (componentClassName != null) {
058:                    Class componentClass = Class.forName(componentClassName);
059:                    Constructor constructor = componentClass
060:                            .getConstructor(new Class[] { Properties.class });
061:                    return constructor
062:                            .newInstance(new Object[] { loadedProperties });
063:                }
064:                return null;
065:            }
066:
067:            public WikiPage getRootPage(WikiPage defaultPage) throws Exception {
068:                String rootPageClassName = loadedProperties
069:                        .getProperty(WIKI_PAGE_CLASS);
070:                if (rootPageClassName != null) {
071:                    Class rootPageClass = Class.forName(rootPageClassName);
072:                    Method constructorMethod = rootPageClass.getMethod(
073:                            "makeRoot", new Class[] { Properties.class });
074:                    return (WikiPage) constructorMethod.invoke(rootPageClass,
075:                            new Object[] { loadedProperties });
076:                } else
077:                    return defaultPage;
078:            }
079:
080:            public HtmlPageFactory getHtmlPageFactory(
081:                    HtmlPageFactory defaultPageFactory) throws Exception {
082:                HtmlPageFactory htmlPageFactory = (HtmlPageFactory) createComponent(HTML_PAGE_FACTORY);
083:                return htmlPageFactory == null ? defaultPageFactory
084:                        : htmlPageFactory;
085:            }
086:
087:            public String loadResponderPlugins(ResponderFactory responderFactory)
088:                    throws Exception {
089:                StringBuffer buffer = new StringBuffer();
090:                String responderList = loadedProperties.getProperty(RESPONDERS);
091:                if (responderList != null) {
092:                    buffer.append("\tCustom responders loaded:").append(endl);
093:                    String[] responderPairs = responderList.split(",");
094:                    for (int i = 0; i < responderPairs.length; i++) {
095:                        String pair = responderPairs[i].trim();
096:                        String[] values = pair.split(":");
097:                        String responderKey = values[0];
098:                        Class responderClass = Class.forName(values[1]);
099:                        responderFactory.addResponder(responderKey,
100:                                responderClass);
101:                        buffer.append(
102:                                "\t\t" + responderKey + ":"
103:                                        + responderClass.getName())
104:                                .append(endl);
105:                    }
106:                }
107:                return buffer.toString();
108:            }
109:
110:            public Authenticator getAuthenticator(
111:                    Authenticator defaultAuthenticator) throws Exception {
112:                Authenticator authenticator = (Authenticator) createComponent(AUTHENTICATOR);
113:                return authenticator == null ? defaultAuthenticator
114:                        : authenticator;
115:            }
116:
117:            public String loadWikiWidgetPlugins() throws Exception {
118:                StringBuffer buffer = new StringBuffer();
119:                String widgetList = loadedProperties.getProperty(WIKI_WIDGETS);
120:                if (widgetList != null) {
121:                    List widgetClasses = new ArrayList(Arrays
122:                            .asList(WidgetBuilder.htmlWidgetClasses));
123:                    buffer.append("\tCustom wiki widgets loaded:").append(endl);
124:                    String[] widgetNames = widgetList.split(",");
125:                    for (int i = 0; i < widgetNames.length; i++) {
126:                        String widgetName = widgetNames[i].trim();
127:                        Class widgetClass = Class.forName(widgetName);
128:                        widgetClasses.add(widgetClass);
129:                        buffer.append("\t\t" + widgetClass.getName()).append(
130:                                endl);
131:                    }
132:                    Class[] widgetClassesArray = (Class[]) widgetClasses
133:                            .toArray(new Class[] {});
134:                    WidgetBuilder.htmlWidgetBuilder = new WidgetBuilder(
135:                            widgetClassesArray);
136:                }
137:                return buffer.toString();
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.