The following lines are written to the SAS log:
method m is z folder
method m2 in z folder
In the previous Java code, you could also use .jar files to augment the classpath in the
ClassLoader constructor.
static ClassLoader customLoader = new apiClassLoader("C:\z;C:\tempsome.jar");
In this case, the Java code for the custom class loader is as follows. This code for this
class loader can be added to or modified as needed.
import java.io.*;
import java.util.*;
import java.util.jar.*;
import java.util.zip.*;
public class apiClassLoader extends ClassLoader
{
//class repository where findClass performs its search
private List classRepository;
public apiClassLoader(String loadPath)
{
super(apiClassLoader.class.getClassLoader());
initLoader(loadPath);
}
public apiClassLoader(ClassLoader parent,String loadPath)
{
super(parent);
initLoader(loadPath);
}
/**
* This method will look for the class in the class repository. If
* the method cannot find the class, the method will delegate to its parent
* class loader.
*
* @param className A String specifying the class to be loaded
* @return A Class object loaded by the apiClassLoader
* @throws ClassNotFoundException if the method is unable to load the class
*/
public Class loadClass(String name) throws ClassNotFoundException
{
// Check if the class is already loaded
Class loadedClass = findLoadedClass(name);
// Search for class in local repository before delegating
if (loadedClass == null)
{
loadedClass = myFindClass(name);
}
// If class not found, delegate to parent
if (loadedClass == null)
{
550 Chapter 22 • Using DATA Step Component Objects