Skip to content
Matt Conway edited this page Sep 19, 2012 · 3 revisions

The application is configured using application.conf and the Spring application-context.xml. It has been tested using Play! 1.2.4 and 1.2.5 under Java 1.7.

application.conf

For the most part, this is a standard Play! application.conf file; the extra parameters are at the end:

  • dashboard.planwindow: the default attempted validity period for graphs; all GTFS feeds which lie within this window from the date of graph build will be built.

  • dashboard.send_requests_automatically - this boolean determines if requests should be automatically sent to Deployer.

  • dashboard.send_deployer_requests_to - this determines what URL to send deployer requests to.

application-context.xml

This is the Spring application context, which is used to define updaters, storers and hooks. First, we can define these terms:

  • updater: a class that fetches data from somewhere and puts it into the database. These implement updater.Updater and return a set of metro areas that they updated. Generally, they fetch GTFS data, but there is also a CityBik.es updater.
  • storer: A class that stores GTFS feeds. Implements updaters.FeedStorer.
  • hook: something that occurs when all updaters have completed. Implement updaters.UpdaterHook

Here's an example application-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springsource.org/dtd/spring-beans-2.0.dtd">
<beans>
  <bean id="updaters" class="updaters.UpdaterFactory">
    <property name="storer">
      <bean class="updaters.S3FeedStorer" >
        <property name="accessKey" value="YOUR S3 ACCESS KEY" />
        <property name="secretKey" value="YOUR S3 SECRET KEY" />
        <property name="bucket" value="S3 BUCKET ID" />
      </bean>
    </property>

    <property name="updaters">
      <list>
        <bean class="updaters.GtfsDataExchangeUpdater" />
        <bean class="updaters.S3WatcherUpdater">
          <property name="accessKey" value="YOUR S3 ACCESS KEY" />
          <property name="secretKey" value="YOUR S3 SECRET KEY" />
          <property name="bucket" value="S3 BUCKET ID" />
          
          <property name="watchedFiles">
            <list>
              <value>manual/file1.zip</value>
              <value>manual/file2.zip</value>
            </list>
          </property>
        </bean>
        <bean class="updaters.CityBikesUpdater" />
      </list>
    </property>

    <property name="hooks">
      <list>
        <bean class="updaters.LoggingUpdaterHook" />
        <bean class="updaters.DeploymentPlanGeneratorHook" />
      </list>
    </property>
  </bean>
</beans>

Let's go through the file step-by-step. It defines only one bean, an UpdaterFactory, which handles updating the database. The first property defines the feed storer; in this example we're using a storer that stores feeds in Amazon S3. There is also a storer that stores feeds in a folder on your local file system; see FileFeedStorer.java.

Next, it defines a list of updaters; each of these has a task that it performs on the database. Here, we are using a GtfsDataExchangeUpdater, which pulls data down from GTFS Data Exchange.

We are also using an S3WatcherUpdater, which watches the given bucket on S3 (the access key and secret key must be the same as your S3FeedStorer, and you must be using an S3FeedStorer). This will watch the named files in your S3 bucket and will update them in the database whenever they change. The first time you upload them, you should edit them with the CRUD interface; changes you make will be propagated forward when they are updated.

Finally, we are using a CityBikes updater, which checks the CityBik.es API for updated bike rental systems.

Below that, we have hooks. There are two hooks defined here: a LoggingUpdaterHook, which just logs what metros have been updated, and a DeploymentPlanGeneratorHook, which will send plans to Deployer if enabled and configured in application.conf (see above).

Clone this wiki locally