Source Code Cross Referenced for GetComponentInfoTask.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » build » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.build.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         * 		Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2008 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.build.ant;
025:
026:        import java.io.File;
027:        import java.util.HashMap;
028:        import java.util.Iterator;
029:        import java.util.List;
030:        import java.util.Vector;
031:
032:        import org.apache.tools.ant.BuildException;
033:        import org.apache.tools.ant.Task;
034:        import org.apache.tools.ant.types.Path;
035:
036:        import com.bostechcorp.cbesb.build.ant.util.JbiXmlFile;
037:
038:        public class GetComponentInfoTask extends Task {
039:
040:            private String workspace;
041:            private String projectName;
042:            private String componentNameProperty;
043:            private String fileListProperty;
044:            private Vector<Path> paths = new Vector<Path>();
045:            private Vector<File> searchPaths = new Vector<File>();
046:
047:            public void setProjectName(String projectName) {
048:                this .projectName = projectName;
049:            }
050:
051:            public void setWorkspace(String workspace) {
052:                this .workspace = workspace;
053:            }
054:
055:            public void setComponentNameProperty(String componentNameProperty) {
056:                this .componentNameProperty = componentNameProperty;
057:            }
058:
059:            public void setFileListProperty(String fileListProperty) {
060:                this .fileListProperty = fileListProperty;
061:            }
062:
063:            public void addPath(Path path) {
064:                paths.add(path);
065:            }
066:
067:            public void execute() throws BuildException {
068:                if (workspace == null) {
069:                    throw new BuildException("Missing workspace attribute.");
070:                }
071:                if (projectName == null) {
072:                    throw new BuildException("Missing projectName attribute.");
073:                }
074:                if (componentNameProperty == null) {
075:                    throw new BuildException(
076:                            "Missing componentNameProperty attribute.");
077:                }
078:                if (fileListProperty == null) {
079:                    throw new BuildException(
080:                            "Missing fileListProperty attribute.");
081:                }
082:                if (paths.size() == 0) {
083:                    throw new BuildException("No search paths specified.");
084:                }
085:
086:                initSearchPaths();
087:
088:                File workspaceFile = new File(workspace);
089:                File jbiXmlFile = new File(workspaceFile, projectName
090:                        + File.separator + "src" + File.separator + "resources"
091:                        + File.separator + "META-INF" + File.separator
092:                        + "jbi.xml");
093:                if (jbiXmlFile.exists()) {
094:                    JbiXmlFile jbi = new JbiXmlFile();
095:                    try {
096:                        jbi.load(jbiXmlFile);
097:                    } catch (Exception e) {
098:                        getProject().log(e.getLocalizedMessage());
099:                        throw new BuildException(
100:                                "Exception loading jbi.xml file:"
101:                                        + jbiXmlFile.getAbsolutePath(), e);
102:                    }
103:
104:                    if (!jbi.isComponent() && !jbi.isSharedLibrary()) {
105:                        throw new BuildException("Project: " + projectName
106:                                + " is not a component or shared library.");
107:                    }
108:
109:                    getProject().setProperty(componentNameProperty,
110:                            jbi.getName());
111:
112:                    HashMap<String, String> resolvedList = new HashMap<String, String>();
113:                    if (jbi.isComponent()) {
114:                        getComponentFileList(resolvedList, jbi
115:                                .getComponentClasspath());
116:                        getComponentFileList(resolvedList, jbi
117:                                .getBootstrapClasspath());
118:
119:                    } else {
120:                        getComponentFileList(resolvedList, jbi
121:                                .getSharedLibraryClasspath());
122:                    }
123:                    StringBuffer sb = new StringBuffer();
124:                    Iterator iter = resolvedList.values().iterator();
125:                    while (iter.hasNext()) {
126:                        String path = (String) iter.next();
127:                        if (sb.length() > 0) {
128:                            sb.append(",");
129:                        }
130:                        sb.append(path);
131:                    }
132:                    getProject().setProperty(fileListProperty, sb.toString());
133:
134:                } else {
135:                    throw new BuildException("jbi.xml file does not exist: "
136:                            + jbiXmlFile.getAbsolutePath());
137:                }
138:
139:            }
140:
141:            private void getComponentFileList(
142:                    HashMap<String, String> resolvedList,
143:                    List<String> classpathList) throws BuildException {
144:                for (int i = 0; i < classpathList.size(); i++) {
145:                    String filename = classpathList.get(i);
146:                    if (!resolvedList.containsKey(filename)) {
147:                        resolvedList.put(filename, resolveFile(filename));
148:                    }
149:
150:                }
151:            }
152:
153:            private String resolveFile(String filename) throws BuildException {
154:                for (int i = 0; i < searchPaths.size(); i++) {
155:                    File dir = searchPaths.get(i);
156:                    File file = new File(dir, filename);
157:                    if (file.exists()) {
158:                        return file.getAbsolutePath();
159:                    }
160:                }
161:                throw new BuildException("Unable to locate required file: "
162:                        + filename);
163:            }
164:
165:            private void initSearchPaths() throws BuildException {
166:                for (Iterator itPaths = paths.iterator(); itPaths.hasNext();) {
167:                    Path path = (Path) itPaths.next();
168:                    String[] includedPaths = path.list();
169:                    for (int i = 0; i < includedPaths.length; i++) {
170:                        File searchDir = new File(includedPaths[i]);
171:                        if (!searchDir.exists()) {
172:                            throw new BuildException(
173:                                    "Specified search path does not exist: "
174:                                            + includedPaths[i]);
175:                        }
176:                        if (!searchDir.isDirectory()) {
177:                            throw new BuildException(
178:                                    "Specified search path is not a directory: "
179:                                            + includedPaths[i]);
180:                        }
181:                        searchPaths.add(searchDir);
182:                    }
183:                }
184:
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.