Class AppFactory

    • Constructor Detail

      • AppFactory

        public AppFactory​(java.lang.String appID,
                          java.lang.String serverEnvironmentName,
                          IAppLoader loader,
                          AppDefinition definition)
        Load the application from an Jar file or just creates a development instance.
        appID - The application ID.
        serverEnvironmentName - The name of the server environment to use, e.g. "default", "devel" or "prod", null for default.
        loader - The loader.
        file - The Jar file when running in non-development mode.
        definition - The app definition, null for none.
        Throws: - For file errors.
        PropException - For property errors.
    • Method Detail

      • getAppFactory

        public static AppFactory getAppFactory​(GProp<?> anyProp)
        From a property, virtualized or not, get the AppFactory instance.
        anyProp - Any property in the tree.
      • getAppDefinition

        public AppDefinition getAppDefinition()
        Gets the application definition that loaded the app.
        The application definition, or null if not loaded from a definition.
      • getAppFileSystemLocation

        public java.lang.String getAppFileSystemLocation()
        Gets the information of the application Jar file or the Module projects. The returned string is typically used for logging purposes.
        A descriptive string of the application file system location.
      • areProjectsLoaded

        public boolean areProjectsLoaded()
        Returns the projects ready flag.
        false if any project is still not loaded, true if all projects are fully loaded.
      • dispose

        public void dispose()
        Disposes of this factory.
      • isDisposed

        public boolean isDisposed()
        Is this factory disposed?
        true if factory disposed.
      • onApplicationSessionStarted

        public void onApplicationSessionStarted​(AppSessionGyro appGyro)
        Called when an application is instantiated and started by a user session.
        appGyro - The application session.
      • onApplicationSessionStopped

        public void onApplicationSessionStopped​(AppSessionGyro appGyro)
        Called when an application is stopped.
        appGyro - The application session.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Upon finalize, the factory is disposed of if not previously done. An error is logged if it has not been disposed of.
        finalize in class java.lang.Object
        java.lang.Throwable - For potential problems.
      • getServerEnvironmentName

        public java.lang.String getServerEnvironmentName()
        Returns the name of the server environment to use, e.g. "default", "devel" or "prod".
      • getServerConfigEnvProps

        public ServerConfigEnvProps getServerConfigEnvProps()
        Gets the server configuration environment properties for the current environment name. If the properties are not found, a SEVERE event is logged and null is returned.
        The ServerConfigEnvProps, or null if not found.
      • getServerApplicationSetup

        public IServerApplicationSetupPropCnr[] getServerApplicationSetup​(java.lang.String pluginID)
        Gets the configuration setup's for a plug-in with specified ID. Each plug-in may present several configurations, although most commonly a single one. If the configuration environment is not found, a SEVERE event is logged and null is returned.
        pluginID - The plug-in ID.
        The configuration setup, or null if the server environment configuration or plug-in configuration is not found. If the plug-in is found but no configurations, an empty array is returned.
      • initialize

        public void initialize​(IServer server)
        Initializes the factory and application.
        server - The Server instance.
      • getJarFile

        public IJarFile getJarFile()
        Gets the Jar file for the Module. This Jar file can be a Jar-in-Jar file, or null if running in development mode (use getDevelopmentDirectory() instead).
        The Jar file or null when running in development mode.
      • registerVirtualizedReferenceLookupRetriever

        public void registerVirtualizedReferenceLookupRetriever​(java.lang.String type,
                                                                IVirtualizedReferenceLookupRetriever retriever)
        Registers a new virtuals reference look-up retriever for a plug-in.
        type - The reference type, i.e. the string after the Module model, e.g. "panel" for Panels, "vs" for VirtualSpace, and "screen" for Terminal Screens.
        retriever - The virtuals reference look-up retriever instance for the type.
      • getVirtualizedReferenceLookupRetriever

        public IVirtualizedReferenceLookup getVirtualizedReferenceLookupRetriever​(java.lang.String reference)
        Gets the virtuals reference look-up for a reference.
        reference - The reference.
        The reference look-up instance, or null if not found.
      • getCommonClassLoader

        public java.lang.ClassLoader getCommonClassLoader()
        Gets the class loader for the application used to load the user classes for the application.
        Specified by:
        getCommonClassLoader in interface IAppOwner
        A class loader.
      • createPropMgr

        public PropMgr createPropMgr​(ServerShell server)
        Creates the Property Manager with reference resolving to the application static properties. The reference resolving is typically used for images, i.e. a IPropMgrInfoProvider is implemented.
        server - The Server instance.
      • addModuleProject

        public void addModuleProject​(ModuleProjectPropCnr project)
                              throws PropException
        Adds a Module Project to the application.
        project - The loaded project.
        PropException - If the project cannot be added.
      • getModuleProject

        public ModuleProjectPropCnr getModuleProject​(java.lang.String name)
        Gets the Module project property container.
        name - The name of the Module project without alias.
        The container, or null if not found.
      • getModuleProjects

        public ModuleProjectPropCnr[] getModuleProjects()
        Gets all the Module project containers.
        The array of Module project containers.
      • getModuleSettings

        public ModuleProjectSettings getModuleSettings()
        Gets the module project settings for the application.
        The settings, null if not yet loaded.
      • getCustomAppMap

        public java.util.Map<java.lang.String,​java.lang.String> getCustomAppMap()
        Gets the unmodifiable map of custom app properties, a map with keys and values.
        The map, or null if not defined.
      • getExternalAuthenticationProviderMap

        public java.util.Map<AuthenticationProvider,​IServiceCreator<? extends AbstractOAuthService>> getExternalAuthenticationProviderMap()
        Gets the map of defined and initialized external authentication providers for the application.
        An unmodifiable map sorted by Enum.ordinal() with its service creator interface. Note that this map may be empty if no external authentication providers are configured for the application.
      • getPossibleLanguages

        public java.util.List<java.lang.String> getPossibleLanguages()
        Gets the possible languages defined in text files that can be used for the application.
        A cached read-only list of possible languages.
      • prepare

        public int prepare​(java.lang.ClassLoader parentClassLoader,
                           java.util.Set<> resources)
                    throws PropException,
        Prepares the application for use, i.e. load the user classes, resolves references, etc.
        parentClassLoader - The parent class loader, null for default.
        resources - The list of classpath resources (files and directories) that is filled in.
        The resolve failure count.
        PropException - If a property failed to resolve. - For I/O errors.
        java.lang.IllegalStateException - If already prepared once.
      • getAppID

        public java.lang.String getAppID()
        Gets the Application ID.
        Specified by:
        getAppID in interface IAppOwner
        The appID.
      • isUserAuthenticationAlwaysRequired

        public boolean isUserAuthenticationAlwaysRequired()
        Returns if the application requires user authentication every time it's started.
        true for user authentication always required, by password or fingerprint.
      • getAppRoot

        public AppPropCnr getAppRoot()
        Gets the Application Root container that holds all the Module Projects and settings.
        The App root property container.
      • getFileOrResource

        public java.lang.Object getFileOrResource​(java.lang.String target)
        Gets the URL or File resource to a target reference.
        Specified by:
        getFileOrResource in interface IAppOwner
        target - The target reference as a normal Module reference string "module:/path/resource".
        The File or Resource for the resource, null for none.
      • getFontFiles

        public java.util.List<FontFiles> getFontFiles​(java.lang.String fontFamily)
        Gets the mapping of a font name to the FontFiles instance.
        fontFamily - The font family.
        The read-only FontFiles List instance, null if not found.
      • getRuntimePropFromReference

        public GProp<?> getRuntimePropFromReference​(java.lang.String reference,
                                                    boolean fallBackToNonVirtualized)
        Gets a reference for runtime use to get the reference of an item. The reference must be fully qualified such as "*ALIAS:/type/path" or "MODULE:/type/path" and cannot be relative.

        If the flag fallBackToNonVirtualized is false, the search will not fallback to searching for the non-virtualized property in the runtime app. The result will only returned virtualized properties, i.e. for a reference as e.g. "module:/vs/someVS", and depending on where this method is called (the client session), also includes other virtualized properties such as panels as e.g. "module:/panel/somePanel".

        To always fallback to also searching the runtime app, specify fallBackToNonVirtualized to true.

        Specified by:
        getRuntimePropFromReference in interface IRuntimeReferenceLookup
        reference - The reference to look-up.
        fallBackToNonVirtualized - Flag indicating a fallback to non-virtualized properties.
        The property found, or null for reference not found.
      • getEnvironment

        public EnvProps getEnvironment()
        Gets the environment properties to use.
        Specified by:
        getEnvironment in interface IRuntimeReferenceLookup
        The environment for the client session, original session or server in that priority order.
      • getRootFromName

        public PropCnr getRootFromName​(GProp<?> requestor,
                                       java.lang.String module)
        Gets the module root for a name. In the Editor, the module is the project, and that root container is returned. In the Server, the module doesn't matter, so the real root returns itself.

        When running with assertions, this call throws an assertion error by default, showing that the call is directed to a non-root property container.

        Specified by:
        getRootFromName in interface IRuntimeReferenceLookup
        requestor - The requestor property.
        module - The module name (without colon), i.e. the project name in the Designer.
        The root property container, or null if this container is not the root, or if the module name is not found. The default implementation returns null.
      • getHTTPServer

        public java.lang.String getHTTPServer()
        Gets the HTTP Server string prefix including port.
        Specified by:
        getHTTPServer in interface IKStringInfoProvider
        The "" because the client loads from relative path.
      • getImageTarget

        public IImageTarget getImageTarget​(java.lang.String ref)
        Gets the image reference.
        Specified by:
        getImageTarget in interface IKStringInfoProvider
        ref - The image definition reference string.
        The Image target interface, or null if not found.
      • doAddReference

        public boolean doAddReference()
        Gets the flag for adding the reference string in an attribute when editing the KString in a rich text editor.
        Specified by:
        doAddReference in interface IKStringInfoProvider
        Flag to add a special text reference for the rich text editor.
      • shouldResolve

        public boolean shouldResolve()
        Flag indicating the "real" resolved string should be returned. This value is true for the runtime client when in "real run mode".
        Specified by:
        shouldResolve in interface IKStringInfoProvider
        Flag to resolve strings or not.
      • getResourcePrefix

        public java.lang.String getResourcePrefix()
        Gets the base reference name for the resource, typically an image, for the Server or the Designer. This reference is "/$" (the default in this interface) for the Designer, but should be "/$APPID/" for the Server, where APPID is the application being run by the client. The Server must therefore implement this method and return that string instead.
        Specified by:
        getResourcePrefix in interface IKStringInfoProvider
        The resource prefix string: "/$APPID/" for the Server, where APPID is the application being run by the client.
      • getDPR

        public double getDPR()
        Gets the device pixel ratio.
        Specified by:
        getDPR in interface IKStringInfoProvider
        The device pixel ratio, default 1.0.
      • getTargetLanguageCode

        public java.lang.String getTargetLanguageCode()
        Gets the language code to use.
        Specified by:
        getTargetLanguageCode in interface IKStringInfoProvider
        The language code, or null for default.
      • installFont

        public boolean installFont​(java.lang.String fontFamily)
        Installs the font families as specified by the font family.
        Specified by:
        installFont in interface IKStringInfoProvider
        fontFamily - The font family or families.
        true for success, false if the remote part doesn't support installation, e.g. in a preview browser.
      • installFonts

        public boolean installFonts​(java.util.List<FontFiles> fontList)
        Installs the font face as specified by the FontFiles instance for the Client Session. Once installed, the font family can be used.
        Specified by:
        installFonts in interface IKStringInfoProvider
        fontList - The list of font files to install.
        true for success, false if the remote part doesn't support installation, e.g. in a preview browser.
      • cacheSVG

        public int cacheSVG​(java.lang.String svgString)
        Adds the SVG image information as being sent to the client.

        This method is not intended to be called and logs a severe error and returns 1 (one).

        Specified by:
        cacheSVG in interface IPropMgrInfoProvider
        svgString - The SVG string.
        The cached index value for the SVG string. A negative value indicates that it needs sending to the client, whereas a positive means only the index is required to be sent. A return value of zero is an error and means not to send it to client at all.
      • getPreloadClientCacheResources

        public java.util.List<PreloadClientCacheResource> getPreloadClientCacheResources​(ClientSessionGyro clientGyro)
        Gets the resources that are required to be downloaded to the client if not present or outdated.
        clientGyro - The client gyro.
        The list of resources that are relevant for the client in question. The resources relative URLs must be prefixed with Application ID (i.e. getResourcePrefix()).
      • getUserAuthenticationUI

        public IUserAuthenticationUI getUserAuthenticationUI()
        Gets the user authentication UI interface used for the initial login.
        The user authentication interface.
      • getCustomizedAppHTML

        public getCustomizedAppHTML​(ServerShell server,
                                                 java.lang.String lang)
        Gets a customized "iiziApp.html" file for a specific application ID and optional language.
        server - The server instance.
        file - The compressed iiziApp.html file without customization.
        lang - The language requested, or null for default.
        The customized (and cached) file to send instead of the un-customized one, or null for none, i.e. in case of error.