JMRI is...

Scripting

Information on writing scripts to control JMRI in more detail:

General Tools

The general objects available to control your layout.

JMRI Layout Automation

JMRI applications provide a large number of ways of automating your layout, ranging from simple fill-in forms to full-fledged scripting and programming capabilities. These include:
Signal logic
JMRI provides built-in signaling logic which can be used to drive your signal heads in many applications.
Routes
A simple form of automation is to define Routes, which allow you to simplify the control of your turnouts.
Logix
Using JMRI Logix, you can specify actions to happen when various conditions occur on the layout.
Scripting
JMRI provides a very powerful scripting tool. Based on a real programming language, it gives you access to all the JMRI capabilities.
Writing your own code in Java
The JMRI libraries greatly simplify writing a program to make your layout do exactly what you want.