Class ApplicationDistributor

java.lang.Object
com.iizix.app.builder.ApplicationDistributor
All Implemented Interfaces:
IAppLoader, Serializable
Direct Known Subclasses:
EclipseApplicationDistributor

public class ApplicationDistributor extends Object implements IAppLoader, Serializable
Class used to produce a distribution of an iiziApp file from module projects. This class is used either from inside Eclipse, or externally from a command line wrapper.
Author:
Christopher Mindus
See Also:
  • Field Details

    • FILENAME

      public static final String FILENAME
      The Application distribution file name located under the Module root.
      See Also:
    • CREATED_BY

      public static final String CREATED_BY
      The Jar "Created-By" version = "a.b.c.buildnr (com.iizigo)".
    • dist

      The distribution property.
    • appCnr

      protected AppPropCnr appCnr
      The Application container.
    • modules

      protected ModuleProjectPropCnr[] modules
      The modules to process.
    • propFactory

      protected final PropFactory propFactory
      The property factory to use when creating the distribution, null for the Designer.
  • Constructor Details

    • ApplicationDistributor

      public ApplicationDistributor(PropFactory propFactory, PropMgr propMgr, PluginLoader pluginLoader, ExecutorService executorService, boolean isVerbose)
      Constructs the application compiler for the target file.
      Parameters:
      propFactory - The Property Factory.
      propMgr - The Property Manager.
      pluginLoader - The plug-in loader.
      executorService - The executor service.
      isVerbose - Verbose output.
  • Method Details

    • initializeLicenseSystem

      public String initializeLicenseSystem()
      Initializes the license system because app registration is requested.
      Returns:
      null for success, otherwise an error message. If an error is returned, it has already been logged as a severe error.
    • initializeLicenseSystem

      public String initializeLicenseSystem(ILicenseCallback licCB)
      Initializes the license system because app registration is requested.
      Parameters:
      licCB - The license callback, null for none. This parameter is used for the Designer.
      Returns:
      null for success, otherwise an error message. If an error is returned, it has already been logged as a severe error.
    • dispose

      public void dispose()
      Disposes of the instance when done.
    • getPropertyManager

      public PropMgr getPropertyManager()
      The property manager to use when creating the distribution.
      Specified by:
      getPropertyManager in interface IAppLoader
    • loadApplicationDefinition

      public void loadApplicationDefinition(File project) throws IOException, PropException, CancelException
      Loads the application definition and all required Modules into memory in Command Line mode.
      Parameters:
      project - The project directory.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
      CancelException - If operation is canceled by user.
    • getDestinationJar

      public File getDestinationJar(File projectDir)
      Gets the destination Jar file.
      Parameters:
      projectDir - The project directory.
      Returns:
      The absolute file, perhaps resolved from the project directory if the name is relative. null is returned if the Jar file name is not specified!
    • resolveReferences

      public void resolveReferences(List<String> warnings, List<String> errors)
      Resolves all references and then checks for property errors.

      The returned list contains the property path in warning/error, a Tab character, then followed by the error message.

      Parameters:
      warnings - Warnings list to fill.
      errors - Errors list to fill.
    • verifyModules

      public String verifyModules()
      Verifies the Modules. This includes verifying the classpath and dependencies to other non-included Modules in the distribution.
      Returns:
      Error message string, or null for OK.
    • createResourceOperations

      public int createResourceOperations(Object monitor) throws IOException, CancelException
      Process all resource operations, i.e. directories and file operations.
      Parameters:
      monitor - The progress monitor.
      Returns:
      The count of resource operations to perform.
      Throws:
      FileNotFoundException - If a file is not found.
      IOException - For file errors.
      CancelException - If operation is canceled by user.
    • getExecutorService

      public ExecutorService getExecutorService()
      Gets the parallel loader ExecutorService.
      Specified by:
      getExecutorService in interface IAppLoader
    • loadFile

      public PropCnr loadFile(String fileName, InputStream inputStream) throws IOException, PropException
      Loads a property file.
      Specified by:
      loadFile in interface IAppLoader
      Parameters:
      fileName - The file name for logging.
      inputStream - The file input stream.
      Returns:
      A Property container.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • loadFile

      public PropCnr loadFile(File file) throws IOException, PropException
      Loads a property file.
      Specified by:
      loadFile in interface IAppLoader
      Parameters:
      file - The file to load.
      Returns:
      A Property container.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • loadPlugins

      public List<IPluginDescriptor<?>> loadPlugins(String names) throws IOException
      Loads required plug-in's.

      Each plug-in must have a class called "name.server.Descriptor" that implement the interface com.iizix.IPluginDescriptor available.

      The plug-in definition should be found at the "name/schema/properties.xml", but the iiziGo modules have the "iizigo" module instead of "iizix". To figure out translation of names, a class called "name.server.Descriptor" is loaded and should implement the interface

      Specified by:
      loadPlugins in interface IAppLoader
      Parameters:
      names - The plug-in name, e.g. "com.iizigo.db,com.iizigo.term,com.iizigo.ws".
      Throws:
      IOException - If a plug-in failed to load.
    • loadFile

      protected <PC extends PropCnr> PC loadFile(IIFile iifile, Class<PC> propClass, Object monitor) throws IOException, PropException
      Loads a property file.
      Parameters:
      iifile - The file to load.
      Returns:
      A Property container.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • addOperation

      public void addOperation(IOperation op)
      Adds a new operation to the target.
      Parameters:
      op - The operation.
    • loadModule

      protected void loadModule(IIDirectory iidir) throws IOException, PropException
      Loads the entire Module application using the "Server code" with parallel thread load of all files.
      Parameters:
      iidir - The directory where the Module project is located.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • createJar

      public File createJar(Object monitor) throws IOException
      Creates the Jar file.
      Parameters:
      monitor - The Eclipse progress monitor, or null for none.
      Returns:
      The temp-file for the Jar.
      Throws:
      IOException - For I/O errors.
    • checkCanceled

      protected void checkCanceled(Object monitor) throws CancelException
      Checks if the monitor is canceled.
      Parameters:
      monitor - The progress monitor, or null for none.
      Throws:
      CancelException - If the operation is canceled.
    • worked

      protected void worked(Object monitor, int work)
      Ticks units of work from progress.
      Parameters:
      monitor - The progress monitor, or null for none.
      work - The work units count.