1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.geronimo.ews.ws4j2ee.module;
18
19 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
20 import org.apache.geronimo.ews.ws4j2ee.utils.FileUtils;
21
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.net.MalformedURLException;
26 import java.net.URL;
27 import java.net.URLClassLoader;
28 import java.util.ArrayList;
29
30 /***
31 * @author Srinath Perera(hemapani@opensource.lk)
32 */
33 public class WARModule extends AbstractModule {
34 private ArrayList urls;
35 private ClassLoader cl;
36
37 /***
38 * @param jarFile
39 * @throws GenerationFault
40 */
41 public WARModule(String jarFile, ClassLoader parentCL,File outDir)
42 throws GenerationFault {
43 super(jarFile, parentCL);
44 try {
45 urls = FileUtils.uncompressWar(new File(outDir,"unpacked"), new File(zip.getName()));
46 URL[] aurls = new URL[urls.size()];
47 for (int i = 0; i < aurls.length; i++) {
48 aurls[i] = ((File) urls.get(i)).toURL();
49 System.out.println(aurls[i]);
50 }
51 cl = new URLClassLoader(aurls, Thread.currentThread().getContextClassLoader());
52 wscfFile = getInputStreamForJarEntry(jarFile, "WEB-INF/webservices.xml");
53 if (wscfFile == null) {
54 wscfFile = getInputStreamForJarEntry(jarFile, "webservices.xml");
55 }
56 webddfile = getInputStreamForJarEntry(jarFile, "WEB-INF/web.xml");
57 if (webddfile == null)
58 webddfile = getInputStreamForJarEntry(jarFile, "web.xml");
59 if (wscfFile == null)
60 throw new GenerationFault("wscf file must not be null");
61 } catch (MalformedURLException e) {
62 e.printStackTrace();
63 throw GenerationFault.createGenerationFault(e);
64 } catch (IOException e) {
65 e.printStackTrace();
66 throw GenerationFault.createGenerationFault(e);
67 } catch (GenerationFault e) {
68 e.printStackTrace();
69 throw GenerationFault.createGenerationFault(e);
70 }
71 }
72
73
74
75
76 public ClassLoader getClassLoaderWithPackageLoaded() throws GenerationFault {
77 return cl;
78 }
79
80 public ArrayList getClassPathElements() {
81 return urls;
82 }
83
84 }