Packaging class

The Packaging class offers SDK openings for deploying your solutions with more flexibility.

How it works :

In an XML file, you define calls to Java extensions. The extension's call can be launched :

  • at startup of VDoc server, see <startup> element.
  • when you install a new instance of VDoc (first startup), see <install> element.
  • for a migration (from version A to version B), see <migration> element.

Packaging definition

XML definition file

The XML packaging definition file must be deployed on the custom/packaging folder. Its name must be unique on the VDoc server. This XML definition file provides all the necessary information to launch the extension.

The packaging element

The packaging element can contain the following children elements :

Element Description
name the name of the application, ex: VDoc.
version the current version of the application.
startup it's used to launch the extension at every startup of VDoc.
install it's used to launch the extension for a new installation.
migration it's used to launch the extension during a migration.

XML example

Error during retrieving content skip as ignoreDownloadError activated.

The extension element

It's a child element for the startup, install and migration elements. It defines the developed extension that will be executed.

The extension element contains the following attributes:

Attribute Description
name the class name.
runOnce used with startup element, it launches the extension once.
critical if a critical error occurs, the startup is stopped.

XML example

Error during retrieving content skip as ignoreDownloadError activated.

The param element

The param element is a child of the extension element. It's used to pass parameters to the developed extension.

The param element contains the following attributes:

Attribute Description
name the name of the parameter.
value the value of the parameter.

XML example

Error during retrieving content skip as ignoreDownloadError activated.

Runtime class

A runtime class is a Java class that will be called by the framework at the startup of VDoc. A runtime class must extend the com.axemble.vdoc.sdk.packaging.extensions.BaseTaskExtension class.

By creating a packaging runtime class you need to implement the execute() method:

  • execute(): The execute method receives one parameter of type java.util.Map<key,value>.

A runtime class is declared as follow:

public class LaunchCmdTaskExtension extends BaseTaskExtension
{
        /**
          * @see com.axemble.vdoc.sdk.packaging.extensions.BaseTaskExtension#execute(java.util.Map)
          */
        @Override
        protected void execute(Map<String, String> parameters) throws Exception
        {
          String command = parameters.get("Name of the parameter");
          ...
        }
}

Example

The following example shows how to mount a network drive at startup of VDoc.

XML definition file

Error during retrieving content skip as ignoreDownloadError activated.

Runtime class definition

public class LaunchCmdTaskExtension extends BaseTaskExtension
{
        /** the default class logger */
        private static final com.axemble.vdoc.sdk.utils.Logger LOG = com.axemble.vdoc.sdk.utils.Logger.getLogger(LaunchCmdTaskExtension.class);
        
        /**
          * @see com.axemble.vdoc.sdk.packaging.extensions.BaseTaskExtension#execute(java.util.Map)
          */
        @Override
        protected void execute(Map<String, String> parameters) throws Exception
        {
          String command = parameters.get("command");
          Runtime.getRuntime().exec(command);
        }

}

Running the task by programming

It's possible to run the LaunchCmdTaskExtension task by programming using the executeTask() method.

        Map<String,String> parameters= new HashMap<>();
        parameters.put("command", "val1");
        
        portalModule.executeTask( LaunchCmdTaskExtension.class, parameters );