Skip to content

Home

Development

IDEs

API Explorer

Releases

Release notes

Martini Runtime

Martini Desktop

Martini Online

Feature requests

Bug reports

Martini package directory structure

Martini packages are persisted on the file system. Each package, (except the core package), is assigned a folder named after it under the <martini-home>/packages directory. This folder's structure is expected to look like the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
package
├── code
├── conf
   └── package.xml
   └── properties
       └── package.properties
       └── <prefix>.package.properties
├── lib
├── solr
├── web

Directories

  • code

    This directory is used to contain your services' source files, as well as their corresponding byte code files (if any1). Files and directories under this directory must use a valid Java name and identifier. Specifically, they must follow the JLS 6.2 naming guidelines.

    Naming files and directories under code

    Meaningful names are a must when it comes to writing clean code. A meaningful name should describe the purpose of the unit of code in just one glance. Learn more about how to name and organize model and service files here.

  • conf

    This directory contains your package's configuration files.

  • lib

    Contains any extra .jar files necessary for the package. Classes within these JAR files will be registered to your package's classloader and thus, they will be available for use in your code.

  • solr

    Contains the schema files for embedded Solr cores.

  • web

    This is where optional Java web application resources reside. It can contain web pages which will be used by the embedded Tomcat server to host web applications. If this directory exists, Martini will add the package as a webapp to the underlying Tomcat web manager. This directory can be used to store a WEB-INF/web.xml file as well.

Package configuration XML file

Every package requires a file named package.xml in its conf directory. This file stores package metadata as well as the following information:

  • The Martini endpoints that belong to the package
  • The list of custom Solr cores which can be used in the package to index data
  • The Spring context files that define the Spring beans that need to be instantiated and included in your package's application context
  • The JMS destinations that will be added to the instance's list of broker destinations (if they don't already exist)

Modifying package.xml

It's possible to directly modify the package.xml file in your file system. Whether the changes reflect immediately or not depends on application property package.config.file.caching.strategy. There are three possible values for this property:

  • directory-watcher-cache which uses the directory watcher to monitor changes in the package.xml file.
  • last-modified-cache which checks for the last modified time of package.xml and pushes updates accordingly. This configuration however produces uncessary overhead, therefore it's best to avoid this configuration for production instances.
  • simple-map-cache which does not check for file modifications on package.xml files. This means your instance will only pick up changes upon instance restart. This is recommended for production instances, as modifying package.xml directly on the file system is not advisable.
Example XML document
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<package stateOnStartup="started" documentation-page="https://docs.torocloud.com/martini/v1/quick-start/resources/examples-package/" id="io.toro.examples" version="1.0.0" context-path="/examples">
  <package-dependencies/>
  <startup-services>
    <startup-service>gloop:io.toro.examples.Prepare/io.toro.examples.Prepare</startup-service>
  </startup-services>
  <shutdown-services>
    <shutdown-service>gloop:io.toro.examples.Cleanup/io.toro.examples.Cleanup</shutdown-service>
  </shutdown-services>
  <endpoints>
    <endpoint type="scheduler" name="AnnouncementScheduler" service="gloop:io.toro.examples.SendAnnouncement/io.toro.examples.SendAnnouncement" enabled="true" modifiable="true">
      <properties>
        <property name="schedule">simpleRepeating:1</property>
        <property name="track">true</property>
        <property name="scheduleType">simpleRepeating</property>
        <property name="documentType">Scheduler</property>
        <property name="stateful">false</property>
        <property name="simpleRepeating">1</property>
      </properties>
    </endpoint>
  </endpoints>
</package>

  1. Groovy (.groovy) and Java (.java) files have .class file counterparts.