View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.File;
22  import java.net.MalformedURLException;
23  import java.net.URL;
24  import java.net.URLClassLoader;
25  import java.util.ArrayList;
26  
27  /***
28   * @author Srinath Perera(hemapani@opensource.lk)
29   */
30  public class JarModule extends AbstractModule {
31      private ClassLoader cl;
32      private ArrayList list = new ArrayList(1);
33  
34      /***
35       * @param jarFile
36       * @throws GenerationFault
37       */
38      public JarModule(String jarFile, ClassLoader parentCL)
39              throws GenerationFault {
40          super(jarFile, parentCL);
41          try {
42              this.parentCL = parentCL;
43              list.add(new File(jarFile));
44              cl = new URLClassLoader(new URL[]{(new File(jarFile)).toURL()}, parentCL);
45              wscfFile = getInputStreamForJarEntry(jarFile, "META-INF/webservices.xml");
46              if (wscfFile == null) {
47                  wscfFile =
48                          getInputStreamForJarEntry(jarFile, "META-INF/webservice.xml");
49              }
50              if (wscfFile == null) {
51                  wscfFile = getInputStreamForJarEntry(jarFile, "webservice.xml");
52              }
53              webddfile = getInputStreamForJarEntry(jarFile, "META-INF/web.xml");
54              if (wscfFile == null) {
55                  webddfile = getInputStreamForJarEntry(jarFile, "web.xml");
56              }
57              ejbJarfile = getInputStreamForJarEntry(jarFile, "META-INF/ejb-jar.xml");
58              if (wscfFile == null)
59                  throw new GenerationFault("wscf file must not be null");
60          } catch (MalformedURLException e) {
61              e.printStackTrace();
62              throw GenerationFault.createGenerationFault(e);
63          }
64      }
65  
66      /* (non-Javadoc)
67       * @see org.apache.geronimo.ews.ws4j2ee.utils.packager.load.PackageModule#getClassLoaderWithPackageLoaded()
68       */
69      public ClassLoader getClassLoaderWithPackageLoaded() {
70          return cl;
71      }
72  
73      public ArrayList getClassPathElements() {
74          return list;
75      }
76  }