Package com.iizix.app.builder
Class ApplicationDistributor
- java.lang.Object
- com.iizix.app.builder.ApplicationDistributor
- All Implemented Interfaces:
IAppLoader
,java.io.Serializable
- Direct Known Subclasses:
EclipseApplicationDistributor
public class ApplicationDistributor extends java.lang.Object implements IAppLoader, java.io.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:
- Serialized Form
Field Summary
Fields Modifier and Type Field Description protected AppPropCnr
appCnr
The Application container.static java.lang.String
CREATED_BY
The Jar "Created-By" version = "a.b.c.buildnr (com.iizigo)".protected ServerAppDistributionProps
dist
The distribution property.static java.lang.String
FILENAME
The Application distribution file name located under the Module root.protected ModuleProjectPropCnr[]
modules
The modules to process.protected PropFactory
propFactory
The property factory to use when creating the distribution, null for the Designer.
Constructor Summary
Constructors Constructor Description ApplicationDistributor(PropFactory propFactory, PropMgr propMgr, PluginLoader pluginLoader, java.util.concurrent.ExecutorService executorService, boolean isVerbose)
Constructs the application compiler for the target file.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOperation(IOperation op)
Adds a new operation to the target.protected void
checkCanceled(java.lang.Object monitor)
Checks if the monitor is canceled.java.io.File
createJar(java.lang.Object monitor)
Creates the Jar file.int
createResourceOperations(java.lang.Object monitor)
Process all resource operations, i.e.void
dispose()
Disposes of the instance when done.java.io.File
getDestinationJar(java.io.File projectDir)
Gets the destination Jar file.java.util.concurrent.ExecutorService
getExecutorService()
Gets the parallel loader ExecutorService.PropMgr
getPropertyManager()
The property manager to use when creating the distribution.java.lang.String
initializeLicenseSystem()
Initializes the license system because app registration is requested.java.lang.String
initializeLicenseSystem(ILicenseCallback licCB)
Initializes the license system because app registration is requested.void
loadApplicationDefinition(java.io.File project)
Loads the application definition and all required Modules into memory in Command Line mode.protected <PC extends PropCnr>
PCloadFile(IIFile iifile, java.lang.Class<PC> propClass, java.lang.Object monitor)
Loads a property file.PropCnr
loadFile(java.io.File file)
Loads a property file.PropCnr
loadFile(java.lang.String fileName, java.io.InputStream inputStream)
Loads a property file.protected void
loadModule(IIDirectory iidir)
Loads the entire Module application using the "Server code" with parallel thread load of all files.java.util.List<IPluginDescriptor<?>>
loadPlugins(java.lang.String names)
Loads required plug-in's.void
resolveReferences(java.util.List<java.lang.String> warnings, java.util.List<java.lang.String> errors)
Resolves all references and then checks for property errors.java.lang.String
verifyModules()
Verifies the Modules.protected void
worked(java.lang.Object monitor, int work)
Ticks units of work from progress.
Field Detail
FILENAME
public static final java.lang.String FILENAME
The Application distribution file name located under the Module root.- See Also:
- Constant Field Values
CREATED_BY
public static final java.lang.String CREATED_BY
The Jar "Created-By" version = "a.b.c.buildnr (com.iizigo)".
dist
protected ServerAppDistributionProps 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 Detail
ApplicationDistributor
public ApplicationDistributor(PropFactory propFactory, PropMgr propMgr, PluginLoader pluginLoader, java.util.concurrent.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 Detail
initializeLicenseSystem
public java.lang.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 java.lang.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 interfaceIAppLoader
loadApplicationDefinition
public void loadApplicationDefinition(java.io.File project) throws java.io.IOException, PropException, CancelException
Loads the application definition and all required Modules into memory in Command Line mode.- Parameters:
project
- The project directory.- Throws:
java.io.IOException
- For file errors.PropException
- For property errors.CancelException
- If operation is canceled by user.
getDestinationJar
public java.io.File getDestinationJar(java.io.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(java.util.List<java.lang.String> warnings, java.util.List<java.lang.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 java.lang.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(java.lang.Object monitor) throws java.io.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:
java.io.FileNotFoundException
- If a file is not found.java.io.IOException
- For file errors.CancelException
- If operation is canceled by user.
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
Gets the parallel loader ExecutorService.- Specified by:
getExecutorService
in interfaceIAppLoader
loadFile
public PropCnr loadFile(java.lang.String fileName, java.io.InputStream inputStream) throws java.io.IOException, PropException
Loads a property file.- Specified by:
loadFile
in interfaceIAppLoader
- Parameters:
fileName
- The file name for logging.inputStream
- The file input stream.- Returns:
- A Property container.
- Throws:
java.io.IOException
- For file errors.PropException
- For property errors.
loadFile
public PropCnr loadFile(java.io.File file) throws java.io.IOException, PropException
Loads a property file.- Specified by:
loadFile
in interfaceIAppLoader
- Parameters:
file
- The file to load.- Returns:
- A Property container.
- Throws:
java.io.IOException
- For file errors.PropException
- For property errors.
loadPlugins
public java.util.List<IPluginDescriptor<?>> loadPlugins(java.lang.String names) throws java.io.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 interfaceIAppLoader
- Parameters:
names
- The plug-in name, e.g. "com.iizigo.db,com.iizigo.term,com.iizigo.ws".- Throws:
java.io.IOException
- If a plug-in failed to load.
loadFile
protected <PC extends PropCnr> PC loadFile(IIFile iifile, java.lang.Class<PC> propClass, java.lang.Object monitor) throws java.io.IOException, PropException
Loads a property file.- Parameters:
iifile
- The file to load.- Returns:
- A Property container.
- Throws:
java.io.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 java.io.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:
java.io.IOException
- For file errors.PropException
- For property errors.
createJar
public java.io.File createJar(java.lang.Object monitor) throws java.io.IOException
Creates the Jar file.- Parameters:
monitor
- The Eclipse progress monitor, or null for none.- Returns:
- The temp-file for the Jar.
- Throws:
java.io.IOException
- For I/O errors.
checkCanceled
protected void checkCanceled(java.lang.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(java.lang.Object monitor, int work)
Ticks units of work from progress.- Parameters:
monitor
- The progress monitor, or null for none.work
- The work units count.