Source Code Cross Referenced for WebLogicConvertor.java in  » EJB-Server-JBoss-4.2.1 » varia » org » jboss » varia » deployment » convertor » 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 » EJB Server JBoss 4.2.1 » varia » org.jboss.varia.deployment.convertor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a 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.jboss.varia.deployment.convertor;
023:
024:        import java.io.File;
025:        import java.util.Properties;
026:        import java.util.jar.JarFile;
027:        import java.net.URL;
028:
029:        import javax.management.JMException;
030:        import javax.management.ObjectName;
031:
032:        import org.jboss.deployment.DeploymentInfo;
033:        import org.jboss.system.ServiceMBeanSupport;
034:
035:        /**
036:         * Converts WebLogic applications.
037:         *
038:         * @author <a href="mailto:aloubyansky@hotmail.com">Alex Loubyansky</a>
039:         * @author <a href="mailto:andreas@jboss.org">Andreas Schaefer</a>
040:         * @version $Revision: 57210 $
041:         *
042:         * <p><b>20020519 Andreas Schaefer:</b>
043:         * <ul>
044:         *    <li>Creation</li>
045:         * </ul>
046:         *
047:         * @jmx.mbean
048:         *    name="jboss.system:service=Convertor,type=WebLogic"
049:         *    extends="org.jboss.system.ServiceMBean"
050:         */
051:        public class WebLogicConvertor extends ServiceMBeanSupport implements 
052:                Convertor, WebLogicConvertorMBean {
053:            // Attributes ---------------------------------------
054:            /** the deployer name this converter is registered with */
055:            private String deployerName;
056:
057:            /** the version of xsl resources to apply */
058:            private String wlVersion;
059:
060:            /** remove-table value */
061:            private String removeTable;
062:
063:            /** datasource name that will be set up for converted bean */
064:            private String datasource;
065:
066:            /** the datasource mapping for the datasource */
067:            private String datasourceMapping;
068:
069:            /** xsl parameters used in transformations */
070:            private Properties xslParams;
071:
072:            // WebLogicConverter implementation -----------------
073:            /**
074:             * @jmx.managed-attribute
075:             */
076:            public String getDeployer() {
077:                return deployerName;
078:            }
079:
080:            /**
081:             * @jmx.managed-attribute
082:             */
083:            public void setDeployer(String name) {
084:                if (deployerName != null && name != null
085:                        && deployerName != name) {
086:                    // Remove deployer
087:                    try {
088:                        server.invoke(new ObjectName(deployerName),
089:                                "removeConvertor", new Object[] { this  },
090:                                new String[] { this .getClass().getName() });
091:                    } catch (JMException jme) {
092:                    }
093:                }
094:                if (name != null)
095:                    deployerName = name;
096:            }
097:
098:            /**
099:             * @jmx.managed-attribute
100:             */
101:            public String getWlVersion() {
102:                return wlVersion;
103:            }
104:
105:            /**
106:             * @jmx.managed-attribute
107:             */
108:            public void setWlVersion(String wlVersion) {
109:                this .wlVersion = wlVersion;
110:            }
111:
112:            /**
113:             * @jmx.managed-attribute
114:             */
115:            public String getRemoveTable() {
116:                return removeTable;
117:            }
118:
119:            /**
120:             * @jmx.managed-attribute
121:             */
122:            public void setRemoveTable(String removeTable) {
123:                this .removeTable = removeTable;
124:            }
125:
126:            /**
127:             * @jmx.managed-attribute
128:             */
129:            public String getDatasource() {
130:                return datasource;
131:            }
132:
133:            /**
134:             * @jmx.managed-attribute
135:             */
136:            public void setDatasource(String datasource) {
137:                this .datasource = datasource;
138:            }
139:
140:            /**
141:             * @jmx.managed-attribute
142:             */
143:            public String getDatasourceMapping() {
144:                return datasourceMapping;
145:            }
146:
147:            /**
148:             * @jmx.managed-attribute
149:             */
150:            public void setDatasourceMapping(String datasourceMapping) {
151:                this .datasourceMapping = datasourceMapping;
152:            }
153:
154:            // ServiceMBeanSupport overridding ------------------
155:            public void startService() {
156:                try {
157:                    // init xsl params first
158:                    initXslParams();
159:
160:                    server.invoke(new ObjectName(deployerName), "addConvertor",
161:                            new Object[] { this  },
162:                            new String[] { Convertor.class.getName() });
163:                } catch (JMException jme) {
164:                    log.error("Caught exception during startService()", jme);
165:                }
166:            }
167:
168:            public void stopService() {
169:                if (deployerName != null) {
170:                    // Remove deployer
171:                    try {
172:                        server.invoke(new ObjectName(deployerName),
173:                                "removeConvertor", new Object[] { this  },
174:                                new String[] { this .getClass().getName() });
175:                    } catch (JMException jme) {
176:                        // Ingore
177:                    }
178:                }
179:            }
180:
181:            // Converter implementation ----------------------------------------
182:            /**
183:             * Checks if the deployment can be converted to a JBoss deployment
184:             * by this converter.
185:             *
186:             * @param url The url of deployment to be converted
187:             * @return true if this converter is able to convert
188:             */
189:            public boolean accepts(URL url) {
190:                String stringUrl = url.toString();
191:                JarFile jarFile = null;
192:                boolean accepted = false;
193:                try {
194:                    jarFile = new JarFile(url.getPath());
195:                    accepted = (jarFile
196:                            .getEntry("META-INF/weblogic-ejb-jar.xml") != null)
197:                            && (stringUrl.endsWith(".wlar") || (stringUrl
198:                                    .endsWith(".wl")))
199:                            || stringUrl.endsWith(".war.wl")
200:                            || stringUrl.endsWith(".ear.wl");
201:                    jarFile.close();
202:                } catch (Exception e) {
203:                    log
204:                            .debug("Couldn't create JarFile for "
205:                                    + url.getPath(), e);
206:                    return false;
207:                }
208:
209:                return accepted;
210:            }
211:
212:            /**
213:             * Converts the necessary files to make the given deployment deployable
214:             * on JBoss
215:             *
216:             * @param di The deployment to be converted
217:             * @param path Path of the extracted deployment
218:             **/
219:            public void convert(DeploymentInfo di, File path) throws Exception {
220:                Properties xslParams = getXslParams();
221:                JarTransformer.transform(path, xslParams);
222:            }
223:
224:            // Public -------------------------------------------
225:            /**
226:             * Returns the XSL parameters
227:             */
228:            public Properties getXslParams() {
229:                if (xslParams == null) {
230:                    log.warn("xmlParams should have been initialized!");
231:                    xslParams = initXslParams();
232:                }
233:
234:                // xsl resources path
235:                xslParams.setProperty("resources_path", "resources/"
236:                        + wlVersion + "/");
237:
238:                // set remove-table
239:                xslParams.setProperty("remove-table", removeTable);
240:
241:                // datasource
242:                xslParams.setProperty("datasource", datasource);
243:
244:                // datasource-mapping
245:                xslParams.setProperty("datasource-mapping", datasourceMapping);
246:
247:                return xslParams;
248:            }
249:
250:            // Private -------------------------------------------------------
251:            /**
252:             * Initializes XSL parameters
253:             */
254:            private Properties initXslParams() {
255:                xslParams = new Properties();
256:
257:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
258:
259:                // path to standardjboss.xml
260:                URL url = cl.getResource("standardjboss.xml");
261:                if (url != null)
262:                    xslParams.setProperty("standardjboss", new File(url
263:                            .getFile()).getAbsolutePath());
264:                else
265:                    log.debug("standardjboss.xml not found.");
266:
267:                // path to standardjbosscmp-jdbc.xml
268:                url = cl.getResource("standardjbosscmp-jdbc.xml");
269:                if (url != null)
270:                    xslParams.setProperty("standardjbosscmp-jdbc", new File(url
271:                            .getFile()).getAbsolutePath());
272:                else
273:                    log.debug("standardjbosscmp-jdbc.xml not found.");
274:
275:                log.debug("initialized xsl parameters: " + xslParams);
276:
277:                return xslParams;
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.