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
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.util.jar.JarFile;
24 import java.util.zip.ZipEntry;
25 import java.util.zip.ZipFile;
26
27 /***
28 * @author Srinath Perera(hemapani@opensource.lk)
29 */
30 public abstract class AbstractModule implements Module {
31 protected InputStream wscfFile;
32 protected InputStream webddfile;
33 protected InputStream ejbJarfile;
34 protected InputStream wsdlfile;
35 protected InputStream jaxrpcfile;
36 protected ZipFile zip;
37 protected ClassLoader parentCL;
38
39 public AbstractModule(String jarFile, ClassLoader parentCL) throws GenerationFault {
40 try {
41 this.parentCL = parentCL;
42 zip = new JarFile(jarFile);
43 } catch (IOException e) {
44 e.printStackTrace();
45 throw GenerationFault.createGenerationFault(e);
46 }
47 }
48
49 public InputStream getInputStreamForJarEntry(String path)
50 throws GenerationFault {
51 try {
52 ZipEntry zentry = zip.getEntry(path);
53 if (zentry != null) {
54 return zip.getInputStream(zentry);
55 } else {
56 return null;
57 }
58 } catch (IOException e) {
59 e.printStackTrace();
60 throw GenerationFault.createGenerationFault(e);
61 }
62 }
63
64 public InputStream getInputStreamForJarEntry(String jarFile, String path)
65 throws GenerationFault {
66 try {
67 ZipEntry zentry = zip.getEntry(path);
68 if (zentry != null) {
69 return zip.getInputStream(zentry);
70 } else {
71 return null;
72 }
73 } catch (IOException e) {
74 e.printStackTrace();
75 throw GenerationFault.createGenerationFault(e);
76 }
77 }
78
79 public void loadtheClassesInJarFile() throws GenerationFault {
80 }
81
82 /***
83 * @return
84 */
85 public InputStream getEjbJarfile() {
86 return ejbJarfile;
87 }
88
89 /***
90 * @return
91 */
92 public InputStream getWebddfile() {
93 return webddfile;
94 }
95
96 /***
97 * @return
98 */
99 public InputStream getWscfFile() {
100 return wscfFile;
101 }
102
103 /***
104 * @param stream
105 */
106 public void setEjbJarfile(InputStream stream) {
107 ejbJarfile = stream;
108 }
109
110 /***
111 * @param stream
112 */
113 public void setWebddfile(InputStream stream) {
114 webddfile = stream;
115 }
116
117 /***
118 * @param stream
119 */
120 public void setWscfFile(InputStream stream) {
121 wscfFile = stream;
122 }
123
124 public InputStream findFileInModule(String path) throws GenerationFault {
125 return getInputStreamForJarEntry(path);
126 }
127
128 }