Source Code Cross Referenced for JmsRa.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ant » jonasbase » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.ant.jonasbase 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2004-2006 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JmsRa.java 7937 2006-01-25 17:01:31Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.ant.jonasbase;
025:
026:        import java.io.File;
027:        import java.util.Date;
028:
029:        import org.apache.tools.ant.BuildException;
030:        import org.apache.tools.ant.Task;
031:        import org.apache.tools.ant.taskdefs.Copy;
032:        import org.apache.tools.ant.taskdefs.Java;
033:        import org.apache.tools.ant.taskdefs.Expand;
034:        import org.apache.tools.ant.types.FileSet;
035:        import org.apache.tools.ant.types.selectors.FilenameSelector;
036:
037:        import org.objectweb.jonas.ant.JOnASAntTool;
038:
039:        /**
040:         * Allow to create/adapt the JMS resource adaptor
041:         * @author Benoit Pelletier
042:         */
043:        public class JmsRa extends JTask implements  BaseTaskItf {
044:
045:            /**
046:             * Info for the logger
047:             */
048:            private static final String INFO = "[JmsRa] ";
049:
050:            /**
051:             * Name of the rar
052:             */
053:            private static final String JONAS_JORAMRA = "joram_for_jonas_ra.rar";
054:
055:            /**
056:             * RAConfig classname
057:             */
058:            private static final String RACONFIG_CLASS = "org.objectweb.jonas_rar.raconfig.RAConfig";
059:
060:            /**
061:             * Default port number
062:             */
063:            private static final String DEFAULT_PORT = "16010";
064:
065:            /**
066:             * Port number of the server
067:             */
068:            private String serverPort = DEFAULT_PORT;
069:
070:            /**
071:             * Set the port number
072:             * @param serverPort the port nb
073:             */
074:            public void setServerPort(String serverPort) {
075:                this .serverPort = serverPort;
076:            }
077:
078:            /**
079:             * Execute this task
080:             */
081:            public void execute() {
082:
083:                // Build new temp file for making a resource adaptor
084:                File tmpFile = new File(System.getProperty("java.io.tmpdir"),
085:                        String.valueOf(new Date().getTime()));
086:
087:                // Copy the RAR file from JONAS_ROOT to JONAS_BASE
088:                String srcRarDir = getJonasRoot().getPath() + File.separator
089:                        + "rars" + File.separator + "autoload";
090:                String dstRarDir = getDestDir().getPath() + File.separator
091:                        + "rars" + File.separator + "autoload";
092:                String dstRarFileName = dstRarDir + File.separator
093:                        + JONAS_JORAMRA;
094:
095:                Copy copy = new Copy();
096:                JOnASAntTool.configure(this , copy);
097:                copy.setTodir(new File(dstRarDir));
098:                FilenameSelector fns1 = new FilenameSelector();
099:                fns1.setName(JONAS_JORAMRA);
100:                FileSet fs1 = new FileSet();
101:                fs1.setDir(new File(srcRarDir));
102:                fs1.addFilename(fns1);
103:                copy.addFileset(fs1);
104:                copy.setOverwrite(true);
105:                try {
106:                    copy.execute();
107:                } catch (Exception rae) {
108:                    rae.printStackTrace();
109:                    JOnASAntTool.deleteAllFiles(tmpFile);
110:                    throw new BuildException(INFO + "Cannot copy "
111:                            + JONAS_JORAMRA + " file : ", rae);
112:                }
113:
114:                // Extract the jonas-ra.xml
115:                Expand jarTask = new Expand();
116:                JOnASAntTool.configure(this , (Task) jarTask);
117:                jarTask.setDest(tmpFile);
118:                jarTask.setSrc(new File(dstRarFileName));
119:                try {
120:                    jarTask.execute();
121:                } catch (Exception rae) {
122:                    rae.printStackTrace();
123:                    JOnASAntTool.deleteAllFiles(tmpFile);
124:                    throw new BuildException(
125:                            INFO
126:                                    + "Cannot extract jonas-ra.xml with jar command : ",
127:                            rae);
128:                }
129:
130:                // update the jonas-ra.xml
131:                Replace replaceTask = new Replace();
132:                JOnASAntTool.configure(this , (Task) replaceTask);
133:                replaceTask.setFile(new File(tmpFile.getPath() + File.separator
134:                        + "META-INF/jonas-ra.xml"));
135:
136:                String token = "<jonas-config-property-name>ServerPort</jonas-config-property-name>"
137:                        + "\n"
138:                        + "    <jonas-config-property-value></jonas-config-property-value>";
139:                String value = "<jonas-config-property-name>ServerPort</jonas-config-property-name>"
140:                        + "\n"
141:                        + "    <jonas-config-property-value>"
142:                        + serverPort + "</jonas-config-property-value>";
143:
144:                replaceTask.setToken(token);
145:                replaceTask.setValue(value);
146:                try {
147:                    replaceTask.execute();
148:                } catch (Exception rae) {
149:                    rae.printStackTrace();
150:                    JOnASAntTool.deleteAllFiles(tmpFile);
151:                    throw new BuildException(
152:                            INFO
153:                                    + "Cannot replace port number in the jonas-ra.xml file : ",
154:                            rae);
155:                }
156:
157:                // update the archive
158:                Java raConfigTask = getBootstraptask("");
159:                JOnASAntTool.configure(this , (Task) raConfigTask);
160:                raConfigTask.clearArgs();
161:                raConfigTask.createArg().setValue(RACONFIG_CLASS);
162:                raConfigTask.createArg().setValue("-u");
163:                raConfigTask.createArg().setValue(
164:                        tmpFile.getPath() + File.separator
165:                                + "META-INF/jonas-ra.xml");
166:                raConfigTask.createArg().setValue(dstRarFileName);
167:
168:                try {
169:                    raConfigTask.execute();
170:                } catch (Exception rae) {
171:                    rae.printStackTrace();
172:                    throw new BuildException(INFO
173:                            + "Cannot make a resource adaptor on RAConfig: ",
174:                            rae);
175:                } finally {
176:                    JOnASAntTool.deleteAllFiles(tmpFile);
177:                }
178:
179:                log(INFO + "Setting Port number to :" + serverPort
180:                        + " in the rar '" + dstRarFileName + "'.");
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.