KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > util > JarClassLoader


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.util;
11
12 /**
13  * A class loader for loading jar files, both local and remote.
14  *
15  * @author Klaus Meffert (adapted from
16  * http://java.sun.com/docs/books/tutorial/deployment/jar/apiindex.html)
17  * @since 3.2
18  */

19 public class JarClassLoader
20     extends MultiClassLoader {
21   /** String containing the CVS revision. Read out via reflection!*/
22   private final static String JavaDoc CVS_REVISION = "$Revision: 1.5 $";
23
24   private JarResources m_jarResources;
25
26   public JarClassLoader(final String JavaDoc a_jarName) {
27     // Create the JarResource and suck in the .jar file.
28
m_jarResources = new JarResources(a_jarName);
29   }
30
31   protected byte[] loadClassBytes(final String JavaDoc a_className) {
32     // Support the MultiClassLoader's class name munging facility.
33
String JavaDoc className = formatClassName(a_className);
34     // Attempt to get the class data from the JarResource.
35
return (m_jarResources.getResource(className));
36   }
37 }
38
Popular Tags