org.fhcrc.cpl.toolbox.commandline
Class CommandLineModuleDiscoverer

java.lang.Object
  extended by org.fhcrc.cpl.toolbox.commandline.CommandLineModuleDiscoverer
Direct Known Subclasses:
ViewerCommandLineModuleDiscoverer

public class CommandLineModuleDiscoverer
extends java.lang.Object

Utility class for finding all command-line modules. See comments on method discoverAllCommandLineModules() for important details.


Field Summary
protected static org.apache.log4j.Logger _log
           
protected  java.util.Map<java.lang.String,CommandLineModule> allCommandLineModuleMap
           
 java.lang.String[] modulePackageDescriptionsLong
           
 java.lang.String[] modulePackageDescriptionsShort
           
 java.lang.String[] modulePackageIdentifiers
           
 java.lang.String[] modulePackageNames
           
protected static CommandLineModuleDiscoverer singletonInstance
           
 
Constructor Summary
CommandLineModuleDiscoverer()
           
 
Method Summary
protected  java.util.Map<java.lang.String,CommandLineModule> discoverAllCommandLineModules()
          Attempts to discover all the classes in the package org.fhcrc.cpl.viewer.commandline.modules, and other declared packages, that implement the CommandLineModule interface, as determined by the context class loader
 java.util.Map<java.lang.String,CommandLineModule> findAllCommandLineModules()
          Return all known commandline modules, initializing if necessary
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,CommandLineModule>> findAllCommandLineModulesByPackage()
          Broken up by package.
 CommandLineModule getCommandLineModule(java.lang.String command)
          Return the commandline module for the specified command.
 java.lang.String getPackageIdentifier(java.lang.String packageName)
          This could be implemented much more efficiently
 java.lang.String getPackageLongDescription(java.lang.String packageName)
          This could be implemented much more efficiently
 java.lang.String getPackageShortDescription(java.lang.String packageName)
          This could be implemented much more efficiently
static CommandLineModuleDiscoverer getSingletonInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

protected static org.apache.log4j.Logger _log

allCommandLineModuleMap

protected java.util.Map<java.lang.String,CommandLineModule> allCommandLineModuleMap

singletonInstance

protected static CommandLineModuleDiscoverer singletonInstance

modulePackageNames

public java.lang.String[] modulePackageNames

modulePackageIdentifiers

public java.lang.String[] modulePackageIdentifiers

modulePackageDescriptionsShort

public java.lang.String[] modulePackageDescriptionsShort

modulePackageDescriptionsLong

public java.lang.String[] modulePackageDescriptionsLong
Constructor Detail

CommandLineModuleDiscoverer

public CommandLineModuleDiscoverer()
Method Detail

getSingletonInstance

public static CommandLineModuleDiscoverer getSingletonInstance()

findAllCommandLineModules

public java.util.Map<java.lang.String,CommandLineModule> findAllCommandLineModules()
Return all known commandline modules, initializing if necessary

Returns:

findAllCommandLineModulesByPackage

public java.util.Map<java.lang.String,java.util.Map<java.lang.String,CommandLineModule>> findAllCommandLineModulesByPackage()
Broken up by package. Probably it would be better to store this structure rather than the simple map. Would take some reorganization

Returns:

getPackageShortDescription

public java.lang.String getPackageShortDescription(java.lang.String packageName)
This could be implemented much more efficiently

Parameters:
packageName -
Returns:

getPackageIdentifier

public java.lang.String getPackageIdentifier(java.lang.String packageName)
This could be implemented much more efficiently

Parameters:
packageName -
Returns:

getPackageLongDescription

public java.lang.String getPackageLongDescription(java.lang.String packageName)
This could be implemented much more efficiently

Parameters:
packageName -
Returns:

discoverAllCommandLineModules

protected java.util.Map<java.lang.String,CommandLineModule> discoverAllCommandLineModules()
Attempts to discover all the classes in the package org.fhcrc.cpl.viewer.commandline.modules, and other declared packages, that implement the CommandLineModule interface, as determined by the context class loader

Returns:
a map of CommandLineModule-implementing classes that exist within the correct package

getCommandLineModule

public CommandLineModule getCommandLineModule(java.lang.String command)
                                       throws java.io.FileNotFoundException
Return the commandline module for the specified command. If that module doesn't exist, throw a FileNotFoundExcption. That's a bit of a hack, but it's necessary for an exception to be thrown that's not a RunTimeException, to make the calling code handle it explicitly

Parameters:
command -
Returns:
Throws:
java.io.FileNotFoundException - if no module exists for the specified command


Fred Hutchinson Cancer Research Center