Source Code Cross Referenced for AntUtil.java in  » Portal » Open-Portal » com » sun » portal » fabric » util » 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 » Portal » Open Portal » com.sun.portal.fabric.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.fabric.util;
002:
003:        import java.util.Vector;
004:        import java.util.logging.Level;
005:        import java.util.logging.Logger;
006:        import java.io.PrintStream;
007:        import java.io.FileOutputStream;
008:        import java.io.File;
009:
010:        import org.apache.tools.ant.BuildEvent;
011:        import org.apache.tools.ant.BuildException;
012:        import org.apache.tools.ant.BuildListener;
013:        import org.apache.tools.ant.DefaultLogger;
014:        import org.apache.tools.ant.Project;
015:        import org.apache.tools.ant.ProjectHelper;
016:
017:        import com.sun.portal.log.common.PortalLogger;
018:
019:        import com.sun.portal.util.Platform;
020:
021:        public class AntUtil implements  BuildListener {
022:
023:            private static String fs = Platform.fs;
024:
025:            private static String logDir;
026:            private static String tmpDir;
027:            protected static Logger logger;
028:
029:            private static String LOG = ".log";
030:
031:            public AntUtil(String psDataDir) {
032:                logger = PortalLogger.getLogger(AntUtil.class);
033:                logDir = psDataDir + fs + "logs" + fs + "config";
034:                tmpDir = psDataDir + fs + "tmp";
035:            }
036:
037:            /*
038:             * Use ant API to configure the sample portals with the <code>buildfile</code>
039:             * and the <code>targets</code>
040:             *
041:             * @param buildfile Ant buildfile
042:             * @param targets   Ant targets
043:             * @param logName   Ant logfile prefix
044:             * @param key       Ant property key
045:             * @param val       Ant property value
046:             */
047:            public void runant(String buildfile, Vector targets,
048:                    String logName, String key, String val) {
049:                String logfile = logDir + fs + logName + LOG;
050:                Project project = new Project();
051:                DefaultLogger antlogger = new DefaultLogger();
052:
053:                try {
054:                    // setup logger
055:                    PrintStream logstream = new PrintStream(
056:                            new FileOutputStream(logfile));
057:                    antlogger.setErrorPrintStream(logstream);
058:                    antlogger.setOutputPrintStream(logstream);
059:                    antlogger.setMessageOutputLevel(Project.MSG_INFO);
060:
061:                    // add build listeners and fire event
062:                    project.addBuildListener(antlogger);
063:                    project.addBuildListener(this );
064:                    project.fireBuildStarted();
065:
066:                    // init project and go
067:                    project.init();
068:                    project.setUserProperty("ant.file", buildfile);
069:                    project.setUserProperty("config.location", tmpDir);
070:
071:                    if (key != null) {
072:                        project.setUserProperty(key, val);
073:                    }
074:
075:                    // debug information
076:                    String[] params = new String[2];
077:                    params[0] = project.getUserProperties().toString();
078:                    if (targets != null) {
079:                        params[1] = targets.toString();
080:                    } else {
081:                        params[1] = project.getDefaultTarget();
082:                    }
083:
084:                    logger.log(Level.INFO, "PSFB_CSPFU0020", params);
085:
086:                    // buildfile integrity check
087:                    ProjectHelper helper = ProjectHelper.getProjectHelper();
088:                    helper.parse(project, new File(buildfile));
089:
090:                    // execute targets
091:                    if (targets != null) {
092:                        project.executeTargets(targets);
093:                    } else {
094:                        project.executeTarget(project.getDefaultTarget());
095:                    }
096:                    project.fireBuildFinished(null);
097:
098:                    // close printstream
099:                    logstream.close();
100:                } catch (Exception e) {
101:                    project.fireBuildFinished(e);
102:                }
103:            }
104:
105:            /*
106:             * Signals that the last target has finished.
107:             */
108:            public void buildFinished(BuildEvent event) {
109:                Throwable error = event.getException();
110:
111:                if (error != null) {
112:                    String[] param = new String[1];
113:
114:                    if (error instanceof  BuildException) {
115:                        param[0] = error.toString();
116:                    } else {
117:                        param[0] = error.getMessage();
118:                    }
119:
120:                    logger.log(Level.SEVERE, "PSFB_CSPFU0019", param);
121:                }
122:            }
123:
124:            /*
125:             * Signals that a build has started.
126:             */
127:            public void buildStarted(BuildEvent event) {
128:            }
129:
130:            /*
131:             * Signals a message logging event.
132:             */
133:            public void messageLogged(BuildEvent event) {
134:            }
135:
136:            /*
137:             * Signals that a target has finished.
138:             */
139:            public void targetFinished(BuildEvent event) {
140:            }
141:
142:            /*
143:             * Signals that a target is starting.
144:             */
145:            public void targetStarted(BuildEvent event) {
146:            }
147:
148:            /*
149:             * Signals that a task has finished.
150:             */
151:            public void taskFinished(BuildEvent event) {
152:            }
153:
154:            /*
155:             * Signals that a task is starting.
156:             */
157:            public void taskStarted(BuildEvent event) {
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.