Source Code Cross Referenced for AppServerFactory.java in  » Net » Terracotta » com » tc » test » server » appserver » 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 » Net » Terracotta » com.tc.test.server.appserver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.test.server.appserver;
006:
007:        import com.tc.config.Directories;
008:        import com.tc.exception.ImplementMe;
009:        import com.tc.test.TempDirectoryHelper;
010:        import com.tc.test.TestConfigObject;
011:        import com.tc.test.server.appserver.glassfishv1.GlassfishV1AppServerFactory;
012:        import com.tc.test.server.appserver.jboss3x.JBoss3xAppServerFactory;
013:        import com.tc.test.server.appserver.jboss4x.JBoss4xAppServerFactory;
014:        import com.tc.test.server.appserver.jetty6x.Jetty6xAppServerFactory;
015:        import com.tc.test.server.appserver.tomcat5x.Tomcat5xAppServerFactory;
016:        import com.tc.test.server.appserver.was6x.Was6xAppServerFactory;
017:        import com.tc.test.server.appserver.wasce1x.Wasce1xAppServerFactory;
018:        import com.tc.test.server.appserver.weblogic8x.Weblogic8xAppServerFactory;
019:        import com.tc.test.server.appserver.weblogic9x.Weblogic9xAppServerFactory;
020:        import com.tc.util.Assert;
021:        import com.tc.util.io.TCFileUtils;
022:
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.util.Properties;
026:
027:        /**
028:         * This factory is meant to be used by the general public. The properties file supplied in obtaining an instance may be
029:         * blank, which will fall on the default appserver implementations. This class should be the only point for reference in
030:         * creating a working appserver. Never instantiate specific appserver classes explicitly.
031:         */
032:        public abstract class AppServerFactory {
033:
034:            public static final int WEBLOGIC = 0;
035:            public static final int JBOSS = 1;
036:            public static final int TOMCAT = 2;
037:            public static final int WASCE = 3;
038:            public static final int GLASSFISH = 4;
039:            public static final int JETTY = 5;
040:            public static final int WEBSPHERE = 6;
041:
042:            protected final TestConfigObject config;
043:            private boolean licenseIsSet;
044:
045:            protected AppServerFactory(ProtectedKey protectedKey,
046:                    TestConfigObject config) {
047:                Assert.assertNotNull(protectedKey);
048:                Assert.assertNotNull(config);
049:                copyLicenseIfAvailable();
050:                this .config = config;
051:            }
052:
053:            public abstract AppServerParameters createParameters(
054:                    String instanceName, Properties props);
055:
056:            public AppServerParameters createParameters(String instanceName) {
057:                return createParameters(instanceName, new Properties());
058:            }
059:
060:            public abstract AppServer createAppServer(
061:                    AppServerInstallation installation);
062:
063:            public abstract AppServerInstallation createInstallation(File home,
064:                    File workingDir) throws Exception;
065:
066:            public static final AppServerFactory createFactoryFromProperties(
067:                    TestConfigObject config) {
068:                Assert.assertNotNull(config);
069:                String factoryName = config.appserverFactoryName();
070:                String majorVersion = config.appserverMajorVersion();
071:                int appId = getAppServerId(factoryName);
072:                switch (appId) {
073:                case TOMCAT:
074:                    if ("5".equals(majorVersion) || "6".equals(majorVersion))
075:                        return new Tomcat5xAppServerFactory(new ProtectedKey(),
076:                                config);
077:                case WEBLOGIC:
078:                    if ("8".equals(majorVersion))
079:                        return new Weblogic8xAppServerFactory(
080:                                new ProtectedKey(), config);
081:                    if ("9".equals(majorVersion))
082:                        return new Weblogic9xAppServerFactory(
083:                                new ProtectedKey(), config);
084:                case WASCE:
085:                    if ("1".equals(majorVersion))
086:                        return new Wasce1xAppServerFactory(new ProtectedKey(),
087:                                config);
088:                case JBOSS:
089:                    if ("3".equals(majorVersion))
090:                        return new JBoss3xAppServerFactory(new ProtectedKey(),
091:                                config);
092:                    if ("4".equals(majorVersion))
093:                        return new JBoss4xAppServerFactory(new ProtectedKey(),
094:                                config);
095:                case GLASSFISH:
096:                    if ("v1".equals(majorVersion))
097:                        return new GlassfishV1AppServerFactory(
098:                                new ProtectedKey(), config);
099:                case JETTY:
100:                    if ("6".equals(majorVersion))
101:                        return new Jetty6xAppServerFactory(new ProtectedKey(),
102:                                config);
103:                case WEBSPHERE:
104:                    if ("6".equals(majorVersion))
105:                        return new Was6xAppServerFactory(new ProtectedKey(),
106:                                config);
107:                }
108:
109:                throw new ImplementMe("App server named '" + factoryName
110:                        + "' with major version " + majorVersion
111:                        + " is not yet supported.");
112:            }
113:
114:            private final synchronized void copyLicenseIfAvailable() {
115:                if (this .licenseIsSet)
116:                    return;
117:
118:                try {
119:                    File licenseFile = new File(Directories
120:                            .getLicenseLocation(), "license.lic");
121:
122:                    if (!licenseFile.exists()) {
123:                        this .licenseIsSet = true;
124:                        return;
125:                    }
126:
127:                    TempDirectoryHelper helper = new TempDirectoryHelper(
128:                            getClass());
129:                    File toDir = helper.getDirectory();
130:                    File toFile = new File(toDir, licenseFile.getName());
131:                    TCFileUtils.copyFile(licenseFile, toFile);
132:                    this .licenseIsSet = true;
133:                } catch (IOException ioe) {
134:                    throw new RuntimeException("Can't set up license file", ioe);
135:                }
136:            }
137:
138:            protected static class ProtectedKey {
139:                // ensure that only this class may invoke it's children
140:            }
141:
142:            public static int getAppServerId(String appserverName) {
143:                if (appserverName.equals("weblogic")) {
144:                    return WEBLOGIC;
145:                } else if (appserverName.equals("jboss")) {
146:                    return JBOSS;
147:                } else if (appserverName.equals("tomcat")) {
148:                    return TOMCAT;
149:                } else if (appserverName.equals("wasce")) {
150:                    return WASCE;
151:                } else if (appserverName.equals("glassfish")) {
152:                    return GLASSFISH;
153:                } else if (appserverName.equals("jetty")) {
154:                    return JETTY;
155:                } else if (appserverName.equals("websphere")) {
156:                    return WEBSPHERE;
157:                } else {
158:                    throw new RuntimeException("App server [" + appserverName
159:                            + "] is not yet defined!");
160:                }
161:            }
162:
163:            public static int getCurrentAppServerId() {
164:                return getAppServerId(TestConfigObject.getInstance()
165:                        .appserverFactoryName());
166:            }
167:
168:            public static String getCurrentAppServerMajorVersion() {
169:                return TestConfigObject.getInstance().appserverMajorVersion();
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.