Source Code Cross Referenced for Ejbc.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » ejb » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional.ejb;
019:
020:        import java.io.File;
021:        import org.apache.tools.ant.BuildException;
022:        import org.apache.tools.ant.DirectoryScanner;
023:        import org.apache.tools.ant.taskdefs.Java;
024:        import org.apache.tools.ant.taskdefs.MatchingTask;
025:        import org.apache.tools.ant.types.Commandline;
026:        import org.apache.tools.ant.types.Path;
027:        import org.apache.tools.ant.util.FileUtils;
028:
029:        /**
030:         * Builds EJB support classes using WebLogic's ejbc tool from a directory containing
031:         * a set of deployment descriptors.
032:         *
033:         *
034:         */
035:        public class Ejbc extends MatchingTask {
036:            /**
037:             * The root directory of the tree containing the serialised deployment desciptors. The actual
038:             * deployment descriptor files are selected using include and exclude constructs
039:             * on the ejbc task provided by the MatchingTask superclass.
040:             */
041:            private File descriptorDirectory;
042:
043:            /**
044:             * The directory where generated files are placed.
045:             */
046:            private File generatedFilesDirectory;
047:
048:            /**
049:             * The name of the manifest file generated for the EJB jar.
050:             */
051:            private File generatedManifestFile;
052:
053:            /**
054:             * The classpath to be used in the weblogic ejbc calls. It must contain the weblogic
055:             * classes <b>and</b> the implementation classes of the home and remote interfaces.
056:             */
057:            private String classpath;
058:
059:            /**
060:             * The source directory for the home and remote interfaces. This is used to determine if
061:             * the generated deployment classes are out of date.
062:             */
063:            private File sourceDirectory;
064:
065:            // CheckStyle:VisibilityModifier OFF - bc
066:            /** Whether to keep the generated files */
067:            public boolean keepgenerated;
068:
069:            // CheckStyle:VisibilityModifier ON
070:
071:            /**
072:             * Do the work.
073:             *
074:             * The work is actually done by creating a separate JVM to run a helper task.
075:             * This approach allows the classpath of the helper task to be set. Since the
076:             * weblogic tools require the class files of the project's home and remote
077:             * interfaces to be available in the classpath, this also avoids having to
078:             * start ant with the class path of the project it is building.
079:             *
080:             * @exception BuildException if someting goes wrong with the build
081:             */
082:            public void execute() throws BuildException {
083:                if (descriptorDirectory == null
084:                        || !descriptorDirectory.isDirectory()) {
085:                    throw new BuildException("descriptors directory "
086:                            + descriptorDirectory.getPath() + " is not valid");
087:                }
088:                if (generatedFilesDirectory == null
089:                        || !generatedFilesDirectory.isDirectory()) {
090:                    throw new BuildException("dest directory "
091:                            + generatedFilesDirectory.getPath()
092:                            + " is not valid");
093:                }
094:
095:                if (sourceDirectory == null || !sourceDirectory.isDirectory()) {
096:                    throw new BuildException("src directory "
097:                            + sourceDirectory.getPath() + " is not valid");
098:                }
099:
100:                String systemClassPath = System.getProperty("java.class.path");
101:                String execClassPath = FileUtils.translatePath(systemClassPath
102:                        + ":" + classpath + ":" + generatedFilesDirectory);
103:                // get all the files in the descriptor directory
104:                DirectoryScanner ds = super 
105:                        .getDirectoryScanner(descriptorDirectory);
106:
107:                String[] files = ds.getIncludedFiles();
108:
109:                Java helperTask = new Java(this );
110:                helperTask.setFork(true);
111:                helperTask
112:                        .setClassname("org.apache.tools.ant.taskdefs.optional.ejb.EjbcHelper");
113:                String args = "";
114:                args += " " + descriptorDirectory;
115:                args += " " + generatedFilesDirectory;
116:                args += " " + sourceDirectory;
117:                args += " " + generatedManifestFile;
118:                args += " " + keepgenerated;
119:
120:                for (int i = 0; i < files.length; ++i) {
121:                    args += " " + files[i];
122:                }
123:
124:                Commandline.Argument arguments = helperTask.createArg();
125:                arguments.setLine(args);
126:                helperTask.setClasspath(new Path(getProject(), execClassPath));
127:                if (helperTask.executeJava() != 0) {
128:                    throw new BuildException("Execution of ejbc helper failed");
129:                }
130:            }
131:
132:            /**
133:             * get the keep generated attribute.
134:             * @return the attribute.
135:             */
136:            public boolean getKeepgenerated() {
137:                return keepgenerated;
138:            }
139:
140:            /**
141:             * Set the directory from where the serialized deployment descriptors are
142:             * to be read.
143:             *
144:             * @param dirName the name of the directory containing the serialised deployment descriptors.
145:             */
146:            public void setDescriptors(String dirName) {
147:                descriptorDirectory = new File(dirName);
148:            }
149:
150:            /**
151:             * Set the directory into which the support classes, RMI stubs, etc are to be written.
152:             *
153:             * @param dirName the name of the directory into which code is generated
154:             */
155:            public void setDest(String dirName) {
156:                generatedFilesDirectory = new File(dirName);
157:            }
158:
159:            /**
160:             * If true, ejbc will keep the
161:             * intermediate Java files used to build the class files.
162:             * This can be useful when debugging.
163:             * @param newKeepgenerated a boolean as a string.
164:             */
165:            public void setKeepgenerated(String newKeepgenerated) {
166:                keepgenerated = Boolean.valueOf(newKeepgenerated.trim())
167:                        .booleanValue();
168:
169:            }
170:
171:            /**
172:             * Set the name of the generated manifest file.
173:             *
174:             * For each EJB that is processed an entry is created in this file. This can then be used
175:             * to create a jar file for dploying the beans.
176:             *
177:             * @param manifestFilename the name of the manifest file to be generated.
178:             */
179:            public void setManifest(String manifestFilename) {
180:                generatedManifestFile = new File(manifestFilename);
181:            }
182:
183:            /**
184:             * Set the classpath to be used for this compilation.
185:             * @param s the classpath (as a string) to use.
186:             */
187:            public void setClasspath(String s) {
188:                this .classpath = FileUtils.translatePath(s);
189:            }
190:
191:            /**
192:             * Set the directory containing the source code for the home interface, remote interface
193:             * and public key class definitions.
194:             *
195:             * @param dirName the directory containg the source tree for the EJB's interface classes.
196:             */
197:            public void setSrc(String dirName) {
198:                sourceDirectory = new File(dirName);
199:            }
200:        }
www__.___ja___va__2__s.c__o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.