org.yasl.jars
Class DynamicJarLoaderImpl

java.lang.Object
  extended byorg.yasl.jars.DynamicJarLoaderImpl
All Implemented Interfaces:
DynamicJarLoader

public class DynamicJarLoaderImpl
extends Object
implements DynamicJarLoader

Handles loading classes or locating resources from jar files that are not in an application's classpath.

Version:
1.0
Author:
Jeff Chapman

Constructor Summary
DynamicJarLoaderImpl()
           
DynamicJarLoaderImpl(DynamicJarLoaderStatus statusMonitor)
           
 
Method Summary
 void cancelJarLoadingProcess()
           
 List dynamicallyFindJarClasses(String jarFilePath)
          Populates a list with YASLJarResource objects from the class files contained in the jar file or files referenced by the jarFilePath argument.
 List dynamicallyFindJarResources(String jarDirPath)
          Populates a list with YASLJarResource objects from the non-class files contained in the jar file or files referenced by the jarFilePath argument.
 List dynamicallyFindJarResources(String jarDirPath, Set extenders)
          Populates a list with YASLJarResource objects from the non-class files contained in the jar file or files referenced by the jarFilePath argument.
 Map dynamicallyLoadJarClasses(String jarFilePath)
          Loads any class files contained in the jar file or files referenced by the jarFilePath argument.
 void setStatusMonitor(DynamicJarLoaderStatus statusMonitor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicJarLoaderImpl

public DynamicJarLoaderImpl()

DynamicJarLoaderImpl

public DynamicJarLoaderImpl(DynamicJarLoaderStatus statusMonitor)
Method Detail

cancelJarLoadingProcess

public void cancelJarLoadingProcess()
Specified by:
cancelJarLoadingProcess in interface DynamicJarLoader

setStatusMonitor

public void setStatusMonitor(DynamicJarLoaderStatus statusMonitor)
Specified by:
setStatusMonitor in interface DynamicJarLoader

dynamicallyLoadJarClasses

public Map dynamicallyLoadJarClasses(String jarFilePath)
                              throws MalformedURLException,
                                     IOException,
                                     ClassNotFoundException
Loads any class files contained in the jar file or files referenced by the jarFilePath argument. If the jarFilePath is a directory, the directory will be searched for jar files and all the jar files found will be processed for class files.

The classes loaded will be used to populate the classFilesMap with class names mapped to class instances.

Specified by:
dynamicallyLoadJarClasses in interface DynamicJarLoader
Parameters:
jarFilePath - String
Returns:
Map of class names to class instances
Throws:
MalformedURLException
IOException
ClassNotFoundException

dynamicallyFindJarClasses

public List dynamicallyFindJarClasses(String jarFilePath)
                               throws MalformedURLException,
                                      IOException
Populates a list with YASLJarResource objects from the class files contained in the jar file or files referenced by the jarFilePath argument. If the jarFilePath is a directory, the directory will be searched for jar files and all the jar files found will be processed for non-class files.

Specified by:
dynamicallyFindJarClasses in interface DynamicJarLoader
Parameters:
jarFilePath - String
Returns:
List
Throws:
MalformedURLException
IOException

dynamicallyFindJarResources

public List dynamicallyFindJarResources(String jarDirPath)
                                 throws MalformedURLException,
                                        IOException
Populates a list with YASLJarResource objects from the non-class files contained in the jar file or files referenced by the jarFilePath argument. If the jarFilePath is a directory, the directory will be searched for jar files and all the jar files found will be processed for non-class files.

Specified by:
dynamicallyFindJarResources in interface DynamicJarLoader
Parameters:
jarDirPath - String
Returns:
List
Throws:
MalformedURLException
IOException

dynamicallyFindJarResources

public List dynamicallyFindJarResources(String jarDirPath,
                                        Set extenders)
                                 throws MalformedURLException,
                                        IOException
Populates a list with YASLJarResource objects from the non-class files contained in the jar file or files referenced by the jarFilePath argument. If the jarFilePath is a directory, the directory will be searched for jar files and all the jar files found will be processed for non-class files.

Users can limit the types of resources returned by adding their file extenders to the extenders set. For example, to only return a list of xml files, add "xml" to the extenders set.

If users pass in an empty set, all non-class file resources will be returned.

Specified by:
dynamicallyFindJarResources in interface DynamicJarLoader
Parameters:
jarDirPath - String
extenders - Set of file extenders
Returns:
List of YASLJarResource objects
Throws:
MalformedURLException
IOException