Source Code Cross Referenced for GenericWeblogicFileProjectLifecycle.java in  » Workflow-Engines » JFolder » org » jfolder » project » lifecycle » 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 » Workflow Engines » JFolder » org.jfolder.project.lifecycle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


        /*
         * JFolder, Copyright 2001-2006 Gary Steinmetz
         *
         * Distributable under LGPL license.
         * See terms of license at gnu.org.
         */

        package org.jfolder.project.lifecycle;

        //base classes
        import java.io.File;
        import java.io.FileOutputStream;
        import java.io.IOException;

        //project specific classes
        import org.jfolder.common.UnexpectedSystemException;
        import org.jfolder.common.utils.misc.MiscHelper;
        import org.jfolder.services.config.ConfigServiceCaller;
        import org.jfolder.services.config.ConfigServiceCallerFactory;

        //other classes

        /*public class GenericWeblogicFileProjectApplicationLifecycle
         implements ProjectApplicationLifecycle {
        
         private final static String INIT_JSP =
         "<%\n"
         + "    org.jfolder.workflow.web.client.SimpleWebClient client =\n"
         + "        (org.jfolder.workflow.web.client.SimpleWebClient)"
         + "request.getAttribute(\"client\");\n"
         + "    client.setPageContext(pageContext);\n"
         + "    String goTo = \"/\" + client.getDestination() + \".jsp\";\n"
         //+ "        MiscHelper.println(\"Ab cd = \"
         //+ client.getDestination());"
         //+ "        MiscHelper.println(\"About to dispatch to \" + goTo);"
         + "%>\n"
         + "<jsp:include page=\"<%= goTo%>\"/>\n";
         //+ "<%\n"
         //+ "        MiscHelper.println(\"About to dispatch to \" + goTo);"
         //+ "%>\n";
         //private final static String INIT_JSP =
         //    "<%\n"
         //    + "    SimpleWebClient client =\n"
         //    + "        SimpleWebClient.newSimpleWebClient(pageContext);\n"
         //    + "    request.setAttribute(\"client\", client);\n"
         //    + "%>\n"
         //    + "<jsp:include page=\"%= (\"/WEB-INF/jsps/apps/\""
         //        + " + inRequest.getServletPath() + \".jsp\")%\"/>"
         //    + "<%\n"
         //    + "    client.saveChanges();\n"
         //    + "%>\n";
        
         public void undeployApplication(String inContext) {
         ConfigManager cm = ConfigManagerFactory.getConfigManager();
        
         String deployLocation = cm.getMandatoryPropertyAttribute(
         ConfigManagerPaths.XPATH_BASE_LOCATIONS, "deploy");
         File finalDeployDir = new File(deployLocation);
        
         File earFile = new File(finalDeployDir, inContext + ".ear");
        
         earFile.delete();
        
         cm.close();
         }
        
         public void deployApplication(ProjectApplication inApplication,
         String inContextPath) {
        
         ConfigManager cm = ConfigManagerFactory.getConfigManager();
        
         String deployLocation = cm.getMandatoryPropertyAttribute(
         ConfigManagerPaths.XPATH_BASE_LOCATIONS, "deploy");
         File finalDeployDir = new File(deployLocation);
        
         File pfDir = getJFolderDirectory(cm);
         //MiscHelper.println("pfDir: " + pfDir.getAbsolutePath());
        
         File assembleDir = new File(pfDir, "assemble");
         //make assembly directory, but make sure it is empty
         if (!assembleDir.exists()) {
         assembleDir.mkdirs();
         }
         MiscHelper.deleteFileOrDirectory(assembleDir);
         if (!assembleDir.exists()) {
         assembleDir.mkdirs();
         }
        
         //create WEB-INF directory
         File webInfDir = new File(assembleDir, "WEB-INF");
         if (!webInfDir.exists()) {
         webInfDir.mkdirs();
         }
        
         //create jsps directory
         File jspsDir = new File(webInfDir, "jsps");
         if (!jspsDir.exists()) {
         jspsDir.mkdirs();
         }
        
         //create apps jsps directory
         File appsJspsDir = new File(jspsDir, "apps");
         if (!appsJspsDir.exists()) {
         appsJspsDir.mkdirs();
         }
        
         //create core jsps directory
         File coreJspsDir = new File(jspsDir, "core");
         if (!coreJspsDir.exists()) {
         coreJspsDir.mkdirs();
         }
        
         //create parent.jsp file
         //File parentJspDir = new File(coreJspsDir,"parent.jsp");
         File parentJspDir = new File(assembleDir,"parent.jsp");
         MiscHelper.writeTextFile(parentJspDir, INIT_JSP);
        
         //copy jsp pages
         for (int i = 0; i < inApplication.getWebPageCount(); i++) {
         ProjectWebPage wwp = inApplication.getWebPage(i);
         String content = wwp.getContent();
         //File wwpFile = new File(appsJspsDir, wwp.getName() + ".jsp");
         File wwpFile = new File(assembleDir, wwp.getName() + ".jsp");
         //MiscHelper.println("pfDir: " + wwpFile.getAbsolutePath());
         MiscHelper.writeTextFile(wwpFile, content);
         }
        
         //copy web content
         for (int i = 0; i < inApplication.getWebFileCount(); i++) {
         ProjectWebFile wwf = inApplication.getWebFile(i);
         byte content[] = wwf.getContent();
         File wwfFile = new File(assembleDir, wwf.getName());
         MiscHelper.writeBinaryFile(wwfFile, content);
         }
        
         String descriptor = getDeploymentDescriptor(inApplication);
         File webFile = new File(webInfDir, "web.xml");
         MiscHelper.writeTextFile(webFile, descriptor);
        
         String weblogicWebDescriptor = getWeblogicDeploymentDescriptor();
         File weblogicWebFile = new File(webInfDir, "weblogic.xml");
         MiscHelper.writeTextFile(weblogicWebFile, weblogicWebDescriptor);
        
         //copy lib file
         //create lib directory
         File libDir = new File(webInfDir, "lib");
         if (!libDir.exists()) {
         libDir.mkdirs();
         }
         File destJfolderJarFile = new File(libDir, "jfolder.jar");
         File sourceLibDir = new File(pfDir, "lib");
         if (!sourceLibDir.exists()) {
         sourceLibDir.mkdirs();
         }
         File sourceJfolderJarFile =
         new File(sourceLibDir, "jfolder.jar");
         MiscHelper.writeBinaryFile(destJfolderJarFile,
         MiscHelper.readBinaryFile(sourceJfolderJarFile));
        
         //assemble war file
         File deployDir = new File(pfDir, "deploy");
         //make assembly directory, but make sure it is empty
         if (!deployDir.exists()) {
         deployDir.mkdirs();
         }
         MiscHelper.deleteFileOrDirectory(deployDir);
         if (!deployDir.exists()) {
         deployDir.mkdirs();
         }
         File warFile = new File(deployDir, "deploy.war");
         createWarFile(assembleDir, warFile);
        
         //create META-INF directory
         File metaInfDir = new File(deployDir, "META-INF");
         if (!metaInfDir.exists()) {
         metaInfDir.mkdirs();
         }
        
         String earDescriptor = getAppDeploymentDescriptor(inContextPath);
         File earFile = new File(metaInfDir, "application.xml");
         MiscHelper.writeTextFile(earFile, earDescriptor);
         File finalEarFile = new File(finalDeployDir, inContextPath + ".ear");
         createWarFile(deployDir, finalEarFile);
        
         cm.close();
        
         }
        
         private final static void createWarFile(File inSource, File inDest) {
         try {
         FileOutputStream fos = new FileOutputStream(inDest);
         MiscHelper.zipDirectory(inSource, fos);
         fos.flush();
         fos.close();
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
         }
        
         private final static String getDeploymentDescriptor(
         ProjectApplication inApplication) {
        
         final String START = "<!DOCTYPE web-app\n"
         + "    PUBLIC \"-//Sun Microsystems, Inc."
         + "//DTD Web Application 2.3//EN\"\n"
         + "    \"http://java.sun.com/dtd/web-app_2_3.dtd\">\n"
         + "\n"
         + "<web-app>\n";
         final String END = "    <ejb-ref>\n"
         + "        <ejb-ref-name>ejb/jfolder/WorkflowLifecycle"
         + "</ejb-ref-name>\n"
         + "        <ejb-ref-type>Session</ejb-ref-type>\n"
         + "        <home>org.jfolder.workflow.lifecycle."
         + "WorkflowLifecycleHome</home>\n"
         + "        <remote>org.jfolder.workflow.lifecycle."
         + "WorkflowLifecycleRemote</remote>\n"
         + "    </ejb-ref>\n"
         + "    <ejb-ref>\n"
         + "        <ejb-ref-name>ejb/jfolder/ConfigManager"
         + "</ejb-ref-name>\n"
         + "        <ejb-ref-type>Entity</ejb-ref-type>\n"
         + "        <home>org.jfolder.workflow.config."
         + "ConfigManagerHome</home>\n"
         + "        <remote>org.jfolder.workflow.config."
         + "ConfigManagerRemote</remote>\n"
         + "    </ejb-ref>\n"
         + "</web-app>\n";
        
         StringBuffer outValue = new StringBuffer();
        
         outValue.append(START);
        
         outValue.append("    <servlet>\n");
         outValue.append("        <servlet-name>\n");
         outValue.append("            BaseClientServlet\n");
         outValue.append("        </servlet-name>\n");
         //outValue.append("        <jsp-file>\n");
         //outValue.append("            /WEB-INF/jsps/core/parent.jsp\n");
         //outValue.append("        </jsp-file>\n");
         outValue.append("        <servlet-class>\n");
         outValue.append(
         "            org.jfolder.workflow.web.client.BaseClientServlet\n");
         outValue.append("        </servlet-class>\n");
         outValue.append("    </servlet>\n");
         outValue.append("    <servlet-mapping>\n");
         outValue.append("        <servlet-name>\n");
         outValue.append("            BaseClientServlet\n");
         outValue.append("        </servlet-name>\n");
         outValue.append("        <url-pattern>/</url-pattern>\n");
         outValue.append("    </servlet-mapping>\n");
        
         //previous mappings
         //for (int i = 0; i < inApplication.getWebPageCount(); i++) {
         //    WorkflowWebPage wwp = inApplication.getWebPage(i);
         //    String webPageName = wwp.getName();
         //    outValue.append("    <servlet>\n");
         //    outValue.append("        <servlet-name>\n");
         //    outValue.append("            " + webPageName + "\n");
         //    outValue.append("        </servlet-name>\n");
         //    outValue.append("        <jsp-file>\n");
         //    outValue.append("            /WEB-INF/jsps/"
         //        + (webPageName + ".jsp") + "\n");
         //    outValue.append("        </jsp-file>\n");
         //    outValue.append("    </servlet>\n");
         //}
         //for (int i = 0; i < inApplication.getWebPageCount(); i++) {
         //    WorkflowWebPage wwp = inApplication.getWebPage(i);
         //    String webPageName = wwp.getName();
         //    outValue.append("    <servlet-mapping>\n");
         //    outValue.append("        <servlet-name>\n");
         //    outValue.append("            " + webPageName + "\n");
         //    outValue.append("        </servlet-name>\n");
         //    outValue.append("        <url-pattern>\n");
         //    outValue.append("            /" + webPageName + "\n");
         //    outValue.append("        </url-pattern>\n");
         //    outValue.append("    </servlet-mapping>\n");
         //}
        
         outValue.append(END);
        
         return outValue.toString();
         }
        
         private final static String getWeblogicDeploymentDescriptor() {
         return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
         + "<!DOCTYPE weblogic-web-app\n"
         + "    PUBLIC \"-//BEA Systems, Inc.//DTD Web Application 7.0//EN\"\n"
         + "    \"http://www.bea.com/servers/wls700/dtd/weblogic700-web-jar.dtd\">\n"
         + "\n"
         + "<weblogic-web-app>\n"
         + "<reference-descriptor>\n"
         + "<ejb-reference-description>\n"
         + " <ejb-ref-name>ejb/jfolder/WorkflowLifecycle</ejb-ref-name>\n"
         + " <jndi-name>jfolder/WorkflowLifecycle</jndi-name>\n"
         + "</ejb-reference-description>\n"
         + "\n"
         + "<ejb-reference-description>\n"
         + "<ejb-ref-name>ejb/jfolder/ConfigManager</ejb-ref-name>\n"
         + "<jndi-name>jfolder/ConfigManager</jndi-name>\n"
         + "</ejb-reference-description>\n"
         + "</reference-descriptor>\n"
         + "</weblogic-web-app>\n";
        
         }
        
         private final static String getAppDeploymentDescriptor(
         String inContextPath) {
        
         StringBuffer outValue = new StringBuffer();
        
         outValue.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
         outValue.append("<!DOCTYPE application\n");
         outValue.append("    PUBLIC '-//Sun Microsystems, Inc."
         + "//DTD J2EE Application 1.3//EN' \n");
         outValue.append("    'http://java.sun.com/dtd/application_1_3.dtd'>\n");
         outValue.append("\n");
         outValue.append("<application>\n");
         outValue.append("    <display-name>" + inContextPath
         + "</display-name>\n");
         outValue.append("    <description>" + inContextPath
         + "</description>\n");
         outValue.append("\n");
         outValue.append("    <module>\n");
         outValue.append("        <web>\n");
         outValue.append("            <web-uri>deploy.war</web-uri>\n");
         outValue.append("            <context-root>" + inContextPath
         + "</context-root>\n");
         outValue.append("        </web>\n");
         outValue.append("    </module>\n");
         outValue.append("</application>\n");
        
         return outValue.toString();
         }
        
         //TO DO: this is duplicated in GenericFileWorkflowApplicationSet
         protected final static File getJFolderDirectory(ConfigManager inCm) {
        
         File outValue = null;
        
         //ConfigManager cm = ConfigManagerFactory.getConfigManager();
        
         String baseDirName = inCm.getMandatoryPropertyAttribute(
         ConfigManagerPaths.XPATH_BASE_LOCATIONS, "base");
         String pfDirName = inCm.getMandatoryPropertyAttribute(
         ConfigManagerPaths.XPATH_BASE_LOCATIONS, "pf");
         File baseDir = new File(baseDirName);
         outValue = new File(baseDir, pfDirName);
         if (!outValue.exists()) {
         outValue.mkdirs();
         }
        
         //cm.close();
        
         return outValue;
         }
         }*/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.