Class HabitatGenerator


  • public class HabitatGenerator
    extends java.lang.Object
    This is a command line (or embedded) utility that will generate habitat files based on @Service annotations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String CLASS_PATH_PROP  
      private static java.lang.String CLASSPATH  
      static java.lang.String DIRECTORY_ARG
      This option gives the name of directory in the target location where the file should be placed
      private java.lang.String directoryOrFileToGenerateFor  
      static java.lang.String FILE_ARG
      The flag for the location of the file
      static java.lang.String HK2_LOCATOR  
      private boolean includeDate  
      static java.lang.String LOCATOR_ARG
      The flag for the name of the locator
      private static java.lang.String LOCATOR_DEFAULT  
      private java.lang.String locatorName  
      private static java.lang.String META_INF  
      static java.lang.String NO_DATE_ARG
      This option gives the name of directory in the target location where the file should be placed
      private boolean noSwap  
      static java.lang.String NOSWAP_ARG
      This option will write files in-place, which is quicker but will remove existing files prior to writing new ones
      static java.lang.String OUTJAR_ARG
      The name of the JAR file to write to (defaults to input file, ignored if input file is directory)
      private java.lang.String outjarName  
      private java.lang.String outputDirectory  
      private java.lang.String searchPath  
      static java.lang.String SEARCHPATH_ARG
      The path-separator delimited list of files to search for contracts and qualifiers (defaults to classpath)
      private boolean verbose  
      static java.lang.String VERBOSE_ARG
      The flag for verbosity
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private HabitatGenerator​(java.lang.String directoryOrFileToGenerateFor, java.lang.String outjarName, java.lang.String locatorName, boolean verbose, java.lang.String searchPath, boolean noSwap, java.lang.String outputDirectory, boolean includeDate)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int embeddedMain​(java.lang.String[] argv)
      A utility to generate inhabitants files.
      private int go()  
      static void main​(java.lang.String[] argv)
      This method will call System.exit() with a 0 on success and non-zero on failure
      private void printThrowable​(java.lang.Throwable th)  
      private static void usage()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CLASSPATH

        private static final java.lang.String CLASSPATH
      • FILE_ARG

        public static final java.lang.String FILE_ARG
        The flag for the location of the file
        See Also:
        Constant Field Values
      • LOCATOR_ARG

        public static final java.lang.String LOCATOR_ARG
        The flag for the name of the locator
        See Also:
        Constant Field Values
      • VERBOSE_ARG

        public static final java.lang.String VERBOSE_ARG
        The flag for verbosity
        See Also:
        Constant Field Values
      • OUTJAR_ARG

        public static final java.lang.String OUTJAR_ARG
        The name of the JAR file to write to (defaults to input file, ignored if input file is directory)
        See Also:
        Constant Field Values
      • SEARCHPATH_ARG

        public static final java.lang.String SEARCHPATH_ARG
        The path-separator delimited list of files to search for contracts and qualifiers (defaults to classpath)
        See Also:
        Constant Field Values
      • NOSWAP_ARG

        public static final java.lang.String NOSWAP_ARG
        This option will write files in-place, which is quicker but will remove existing files prior to writing new ones
        See Also:
        Constant Field Values
      • DIRECTORY_ARG

        public static final java.lang.String DIRECTORY_ARG
        This option gives the name of directory in the target location where the file should be placed
        See Also:
        Constant Field Values
      • NO_DATE_ARG

        public static final java.lang.String NO_DATE_ARG
        This option gives the name of directory in the target location where the file should be placed
        See Also:
        Constant Field Values
      • directoryOrFileToGenerateFor

        private final java.lang.String directoryOrFileToGenerateFor
      • outjarName

        private final java.lang.String outjarName
      • locatorName

        private final java.lang.String locatorName
      • verbose

        private final boolean verbose
      • searchPath

        private final java.lang.String searchPath
      • noSwap

        private final boolean noSwap
      • outputDirectory

        private final java.lang.String outputDirectory
      • includeDate

        private final boolean includeDate
    • Constructor Detail

      • HabitatGenerator

        private HabitatGenerator​(java.lang.String directoryOrFileToGenerateFor,
                                 java.lang.String outjarName,
                                 java.lang.String locatorName,
                                 boolean verbose,
                                 java.lang.String searchPath,
                                 boolean noSwap,
                                 java.lang.String outputDirectory,
                                 boolean includeDate)
    • Method Detail

      • printThrowable

        private void printThrowable​(java.lang.Throwable th)
      • go

        private int go()
      • usage

        private static void usage()
      • embeddedMain

        public static int embeddedMain​(java.lang.String[] argv)
        A utility to generate inhabitants files. By default the first element of the classpath will be analyzed and an inhabitants file will be put into the JAR or directory. The arguments are as follows:

        HabitatGenerator [--file jarFileOrDirectory] [--searchPath path-separator-delimited-classpath] [--outjar jarfile] [--locator locatorName] [--directory targetDirectory] [--verbose]

        If the input file is a directory then the output file will go into META-INF/locatorName in the original directory

        If the input file is a jar file then the output file will go into the JAR file under META-INF/locatorName, overwriting any file that was previously in that location

        --outjar only works if the file being added to is a JAR file, in which case this is the name of the output jar file that should be written. This defaults to the input jar file itself if not specified. If specified and the jarFileOrDirectory parameter is a directory then this parameter is ignored

        Parameters:
        argv - The set of command line arguments
        Returns:
        0 on success, non-zero on failure
      • main

        public static void main​(java.lang.String[] argv)
        This method will call System.exit() with a 0 on success and non-zero on failure
        Parameters:
        argv - The arguments to the command (see embeddedMain)