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


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 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: Message.java 3512 2006-12-08 05:52:03Z yling $
023:         */
024:
025:        package com.bostechcorp.cbesb.ui.util.ucm;
026:
027:        import java.io.File;
028:        import java.lang.reflect.Method;
029:        import java.net.URL;
030:        import java.net.URLClassLoader;
031:        import java.util.ArrayList;
032:        import java.util.Enumeration;
033:        import java.util.List;
034:        import java.util.zip.ZipEntry;
035:        import java.util.zip.ZipException;
036:        import java.util.zip.ZipFile;
037:
038:        import org.eclipse.ui.PlatformUI;
039:
040:        import com.bostechcorp.cbesb.common.i18n.Message;
041:        import com.bostechcorp.cbesb.common.i18n.Messages;
042:        import com.bostechcorp.cbesb.ui.util.MsgUtil;
043:        import com.bostechcorp.cbesb.ui.util.MessageDetailDialog;
044:
045:        public class UcmClassLoader extends URLClassLoader {
046:
047:            private String projectName = "";
048:            private String projectLocation = "";
049:            private List userOperClassList = new ArrayList();
050:            private List scriptClassList = new ArrayList();
051:            private List mapFileterClassList = new ArrayList();
052:            private List trxIDClassList = new ArrayList();
053:            private List upocClassList = new ArrayList();
054:            private List tcpIpClassList = new ArrayList();
055:            private List etlErrorhandlerClassList = new ArrayList();
056:
057:            public UcmClassLoader(URL[] urls, ClassLoader parent,
058:                    String projectName, String projectLocation)
059:                    throws Exception {
060:                super (urls, parent);
061:
062:                this .projectLocation = projectLocation;
063:                //	System.out.println("project location"+projectLocation);
064:                this .projectName = projectName;
065:
066:            }
067:
068:            public static UcmClassLoader getInstance(URL[] urls,
069:                    ClassLoader parent, String projectName,
070:                    String projectLocation) throws Exception {
071:                UcmClassLoader classLoader = new UcmClassLoader(urls, parent,
072:                        projectName, projectLocation);
073:                classLoader.loadUserClassList();
074:                return classLoader;
075:            }
076:
077:            private String getUcmJar() {
078:                String generatePath = projectLocation + "/lib/CBESB_ucm_"
079:                        + projectName + ".jar";
080:                return generatePath;
081:            }
082:
083:            private String getOptionalLib() {
084:                String path = projectLocation + "/src/java";
085:                return path;
086:            }
087:
088:            /**
089:             * upoc class list
090:             * @return
091:             * @throws Exception
092:             */
093:            public List getUpocClassList() throws Exception {
094:
095:                return this .upocClassList;
096:            }
097:
098:            /**
099:             *map filter list
100:             * @return
101:             * @throws Exception
102:             */
103:            public List getMapFilterClassList() throws Exception {
104:
105:                return this .mapFileterClassList;
106:            }
107:
108:            /**
109:             *trxID class list
110:             * @return
111:             * @throws Exception
112:             */
113:            public List getTrxIDClassList() throws Exception {
114:
115:                return this .trxIDClassList;
116:            }
117:
118:            /**
119:             * select uper operation class
120:             * @return
121:             * @throws Exception
122:             */
123:            public List getMapUserOperClassList() throws Exception {
124:                return this .userOperClassList;
125:            }
126:
127:            public List getScriptClassList() throws Exception {
128:
129:                return this .scriptClassList;
130:            }
131:
132:            /**
133:             * select TCPIP handle class
134:             * @return
135:             * @throws Exception
136:             */
137:            public List getTcpIpHandleClassList() throws Exception {
138:                return this .tcpIpClassList;
139:            }
140:
141:            public List getEtlErrorHandlerClassList() throws Exception {
142:                return this .etlErrorhandlerClassList;
143:            }
144:
145:            private void loadUserClassList() throws Exception {
146:                String path = getUcmJar();
147:                File theFile = new File(path);
148:                if (theFile.isFile() && theFile.exists()) {
149:                    loadUserClassList(theFile);
150:                }
151:                File directory = new File(getOptionalLib());
152:                if (directory.exists() && directory.isDirectory()) {
153:                    File[] entries = directory.listFiles();
154:
155:                    for (File entry : entries) {
156:                        if (entry.getName().endsWith("jar")) {
157:                            loadUserClassList(entry);
158:
159:                        }
160:
161:                    }
162:                }
163:
164:            }
165:
166:            private void loadUserClassList(File file) throws Exception {
167:                ZipFile zipFile = new ZipFile(file);
168:                ArrayList<String> errorList = new ArrayList<String>();
169:                for (Enumeration entries = zipFile.entries(); entries
170:                        .hasMoreElements();) {
171:                    ZipEntry entry = (ZipEntry) entries.nextElement();
172:                    if (!entry.isDirectory()) {
173:                        if (entry.getName().endsWith(".class")) {
174:                            // InputStream inputStream = zipFile.getInputStream(entry);
175:                            Class userClass = null;
176:                            String className = UCMClassUtil
177:                                    .handleEntryName(entry.getName());
178:                            try {
179:
180:                                userClass = Class
181:                                        .forName(className, true, this );
182:
183:                                if (userClass != null) {
184:
185:                                    Object object = null;
186:                                    try {
187:                                        object = userClass.newInstance();
188:                                    } catch (java.lang.InstantiationException ex) {
189:                                        //do nothing here
190:                                        continue;
191:                                    }
192:                                    if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.ITransformationOperation)
193:
194:                                        userOperClassList.add(className);
195:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.IScriptObject)
196:                                        scriptClassList.add(className);
197:
198:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.IFilterInterface)
199:                                        mapFileterClassList.add(className);
200:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.ITrxIdInterface)
201:                                        trxIDClassList.add(className);
202:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.IUpocInterface)
203:                                        upocClassList.add(className);
204:
205:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipHandler)
206:                                        tcpIpClassList.add(className);
207:                                    else if (object instanceof  com.bostechcorp.cbesb.runtime.ccsl.lib.IEtlErrorHandler)
208:                                        this .etlErrorhandlerClassList
209:                                                .add(className);
210:
211:                                }
212:
213:                            } catch (Exception ex) {
214:                                try {
215:                                    errorList.add(ex.toString());
216:                                } catch (Exception e) {
217:                                    break;
218:                                }
219:                                continue;
220:
221:                            } catch (Throwable t) {
222:                                // MsgUtil.warningMsg(t.toString());
223:                                try {
224:                                    errorList.add(t.toString());
225:                                } catch (Exception e) {
226:                                    break;
227:                                }
228:                                continue;
229:
230:                            }
231:
232:                        }
233:
234:                    }
235:                }
236:                zipFile.close();
237:                if (errorList.size() > 0) {
238:                    String title = new Message(Messages.CLASS_LOAD_ERROR,
239:                            errorList.size()).getMessage();
240:                    MessageDetailDialog showError = new MessageDetailDialog(
241:                            PlatformUI.getWorkbench()
242:                                    .getActiveWorkbenchWindow().getShell(),
243:                            errorList, title);
244:                    if (!showError.run()) {
245:                        return;
246:                    }
247:                }
248:
249:            }
250:
251:            public List getMethodList(String className) throws Exception {
252:                String entryName = UCMClassUtil.restoreEntryName(className);
253:                List methodList = new ArrayList();
254:
255:                String path = getUcmJar();
256:                File theFile = new File(path);
257:                if (theFile.isFile() && theFile.exists()) {
258:                    methodList.addAll(getMethodList(theFile, className,
259:                            entryName));
260:
261:                }
262:                File directory = new File(getOptionalLib());
263:                if (directory.exists() && directory.isDirectory()) {
264:                    File[] entries = directory.listFiles();
265:
266:                    for (File entry : entries) {
267:                        if (entry.getName().endsWith("jar")) {
268:                            methodList.addAll(getMethodList(entry, className,
269:                                    entryName));
270:                        }
271:
272:                    }
273:                }
274:                return methodList;
275:
276:            }
277:
278:            private List getMethodList(File file, String className,
279:                    String entryName) throws Exception {
280:
281:                List methodList = new ArrayList();
282:
283:                ZipFile zipFile = null;
284:                try {
285:                    zipFile = new ZipFile(file);
286:
287:                    for (Enumeration entries = zipFile.entries(); entries
288:                            .hasMoreElements();) {
289:                        ZipEntry entry = (ZipEntry) entries.nextElement();
290:                        if (!entry.isDirectory()
291:                                && entry.getName().equals(entryName)) {
292:
293:                            //	InputStream inputStream = zipFile
294:                            //			.getInputStream(entry);
295:
296:                            //	Class ucmClass = this.findClass(className,
297:                            //		inputStream);
298:
299:                            Class ucmClass = Class.forName(className, true,
300:                                    this );
301:                            //		inputStream);
302:                            try {
303:                                Method methods[] = ucmClass
304:                                        .getDeclaredMethods();
305:                                for (int i = 0; i < methods.length; i++) {
306:                                    methodList.add(methods[i].getName());
307:                                }
308:                                break;
309:                            } catch (Throwable e) {
310:                                MsgUtil.warningMsg(e.toString());
311:                                continue;
312:                            }
313:
314:                            //		        		               
315:
316:                        }
317:                    }
318:                    zipFile.close();
319:
320:                } catch (ZipException e1) {
321:                    e1.printStackTrace();
322:                    throw e1;
323:                } catch (Exception e1) {
324:                    throw e1;
325:                }
326:
327:                return methodList;
328:
329:            }
330:
331:            public String getClassDescription(String className)
332:                    throws Exception {
333:                Class ucmClass = Class.forName(className, true, this );
334:                Method[] methods = ucmClass.getDeclaredMethods();
335:                for (int i = 0; i < methods.length; i++) {
336:                    if (methods[i].getName().equals("getDescription")) {
337:
338:                        Object descript = methods[i].invoke(ucmClass
339:                                .newInstance(), null);
340:                        return (String) descript;
341:                    }
342:                }
343:
344:                // the fall back is to return the className
345:                return className;
346:            }
347:
348:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.