Source Code Cross Referenced for JbpmSchemaTask.java in  » Workflow-Engines » jbpm-jpdl-3.2.2 » org » jbpm » ant » 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 » jbpm jpdl 3.2.2 » org.jbpm.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source
003:         * Copyright 2005, JBoss Inc., and individual contributors as indicated
004:         * by the @authors tag. See the copyright.txt in the distribution for a
005:         * full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jbpm.ant;
023:
024:        import java.io.IOException;
025:        import java.io.InputStream;
026:        import java.util.StringTokenizer;
027:
028:        import org.apache.tools.ant.BuildException;
029:        import org.apache.tools.ant.Task;
030:        import org.hibernate.cfg.Configuration;
031:        import org.hibernate.tool.hbm2ddl.SchemaExport;
032:        import org.jbpm.JbpmConfiguration;
033:        import org.jbpm.JbpmContext;
034:        import org.jbpm.db.JbpmSchema;
035:        import org.jbpm.persistence.db.DbPersistenceServiceFactory;
036:        import org.jbpm.svc.Services;
037:
038:        public class JbpmSchemaTask extends Task {
039:
040:            String jbpmCfg = null;
041:            String hibernateCfg = null;
042:            String hibernateProperties = null;
043:
044:            boolean quiet = false;
045:            boolean text = false;
046:            String output = null;
047:            String delimiter = null;
048:
049:            String actions = null;
050:
051:            public void execute() throws BuildException {
052:                if (actions == null) {
053:                    // default action is create
054:                    actions = "create";
055:                }
056:
057:                // we need a configuration
058:                Configuration configuration = null;
059:
060:                // if there is no jbpm nor hibernate configuration specified
061:                if ((jbpmCfg == null) && (hibernateCfg == null)) {
062:                    // search for the default jbpm.cfg.xml
063:                    InputStream defaultJbpmCfgStream = getClass()
064:                            .getClassLoader().getResourceAsStream(
065:                                    "jbpm.cfg.xml");
066:                    if (defaultJbpmCfgStream != null) {
067:                        jbpmCfg = "jbpm.cfg.xml";
068:                        try {
069:                            defaultJbpmCfgStream.close();
070:                        } catch (IOException e) {
071:                            e.printStackTrace();
072:                        }
073:
074:                        // if still not found, search for the default hibernate.cfg.xml
075:                    } else {
076:                        InputStream defaultHibernateCfgStream = getClass()
077:                                .getClassLoader().getResourceAsStream(
078:                                        "hibernate.cfg.xml");
079:                        if (defaultHibernateCfgStream != null) {
080:                            hibernateCfg = "hibernate.cfg.xml";
081:                            try {
082:                                defaultHibernateCfgStream.close();
083:                            } catch (IOException e) {
084:                                e.printStackTrace();
085:                            }
086:                        }
087:                    }
088:                }
089:
090:                // first see if the jbpm cfg is specified cause that implies a hibernate configuration
091:                if (jbpmCfg != null) {
092:                    log("using jbpm configuration " + jbpmCfg);
093:                    JbpmConfiguration jbpmConfiguration = AntHelper
094:                            .getJbpmConfiguration(jbpmCfg);
095:                    JbpmContext jbpmContext = jbpmConfiguration
096:                            .createJbpmContext();
097:                    try {
098:                        DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration
099:                                .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
100:                        configuration = dbPersistenceServiceFactory
101:                                .getConfiguration();
102:                    } finally {
103:                        jbpmContext.close();
104:                    }
105:
106:                    // if there is no jbpm.cfg.xml specified, check if there is a hibernate.cfg.xml specified
107:                } else if (hibernateCfg != null) {
108:                    log("using hibernate configuration " + hibernateCfg);
109:                    configuration = AntHelper.getConfiguration(hibernateCfg,
110:                            hibernateProperties);
111:
112:                    // no hibernate configuration specified
113:                } else {
114:                    throw new BuildException(
115:                            "couldn't create schema.  no jbpm nor hibernate configuration specified.");
116:                }
117:
118:                JbpmSchema jbpmSchema = new JbpmSchema(configuration);
119:
120:                SchemaExport schemaExport = new SchemaExport(configuration);
121:                if (output != null)
122:                    schemaExport.setOutputFile(output);
123:                if (delimiter != null)
124:                    schemaExport.setDelimiter(delimiter);
125:
126:                StringTokenizer tokenizer = new StringTokenizer(actions, ",");
127:                while (tokenizer.hasMoreTokens()) {
128:                    String action = tokenizer.nextToken();
129:
130:                    if ("drop".equalsIgnoreCase(action)) {
131:                        schemaExport.drop(!quiet, !text);
132:
133:                    } else if ("create".equalsIgnoreCase(action)) {
134:                        schemaExport.create(!quiet, !text);
135:
136:                    } else if ("clean".equalsIgnoreCase(action)) {
137:                        jbpmSchema.cleanSchema();
138:                    }
139:                }
140:            }
141:
142:            public void setActions(String actions) {
143:                this .actions = actions;
144:            }
145:
146:            public void setJbpmCfg(String jbpmCfg) {
147:                this .jbpmCfg = jbpmCfg;
148:            }
149:
150:            public void setHibernateCfg(String hibernateCfg) {
151:                this .hibernateCfg = hibernateCfg;
152:            }
153:
154:            public void setHibernateProperties(String hibernateProperties) {
155:                this .hibernateProperties = hibernateProperties;
156:            }
157:
158:            public void setDelimiter(String delimiter) {
159:                this .delimiter = delimiter;
160:            }
161:
162:            public void setOutput(String output) {
163:                this .output = output;
164:            }
165:
166:            public void setQuiet(boolean quiet) {
167:                this .quiet = quiet;
168:            }
169:
170:            public void setText(boolean text) {
171:                this.text = text;
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.