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
1
directory. This folder's structure is expected to look like the following:
1 2 3 4 5 6 7 8 9 10 |
|
Directories
The following Martini package directories are standard, each with a specific purpose:
-
code
This directory is used to contain your services' source files, as well as their corresponding byte code files (if any2). 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.You can't create the
web
directory of a started packageYou can only add a
web
directory to loaded (not started) packages. Otherwise, Martini will reject requests to add the directory. You can still create files underneath theweb
directory of started packages.
Some of these directories, however, are not created by default. To create them (and other custom directories if you wish), right click your package, and then select New > Folder.
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-cache-strategy
. There are three possible values for this property:
directory-watcher-cache
which uses the directory watcher to monitor changes in thepackage.xml
file.last-modified-cache
which checks for the last modified time ofpackage.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 onpackage.xml
files. This means your instance will only pick up changes upon instance restart. This is recommended for production instances, as modifyingpackage.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 |
|
-
You can customize Martini's package home path via the
package.home
application property. ↩ -
Groovy (
.groovy
) and Java (.java
) files have.class
file counterparts. ↩