tc-config.xml (Client)
 
 001:  <?xml version="1.0" encoding="UTF-8"?>
 002:  <!--
 003:  
 004:  All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
 005:  
 006:  -->
 007:  <tc:tc-config xmlns:tc="http://www.terracotta.org/config"
 008:    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 009:    xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd">
 010:    <!-- Server is colocated with client and DSO is listening on
 011:         default port (9510). -->
 012:    <servers>
 013:      <server host="%i" name="sample"/>
 014:    </servers>
 015:  
 016:    <!-- Tell DSO where to put the generated client logs
 017:         See the Terracotta Configuration Guide and Reference for additional
 018:         information. -->
 019:    <clients>
 020:      <logs>terracotta/client-logs/pojo/sharedqueue/%D</logs>
 021:    </clients>
 022:  
 023:    <application>
 024:      <dso>
 025:        <!-- Our app requires these custom objects/classes to be shared - the following declarations
 026:             tells DSO which ones they are. When the app runs under DSO, instances of these classes
 027:             will broadcast changes in their state.
 028:  
 029:             A good idiom when writing an app thay you intend to cluster via TC DSO, is to group the 
 030:             classes you wish to share under a single package (although if you follow the MVC pattern
 031:             this tends to happen naturally) - this way the list of classes you wish to instrument
 032:             can be concise 
 033:  
 034:             Here, we're basically telling DSO to instrument all of the classes for all packages found -->
 035:        <instrumented-classes>
 036:          <include>
 037:            <class-expression>demo.sharedqueue..*</class-expression>
 038:          </include>
 039:        </instrumented-classes>
 040:  
 041:  
 042:        <!-- These methods (originating from local objects) operates on objects declared as shared. This 
 043:             section tells DSO to assume a lock on those objects for the duration of the call; essentially this
 044:             section declares that all methods found in the 'demo.sharedqueue.Main' class should assume the 
 045:             behavior described -->
 046:        <locks>
 047:          <autolock>
 048:            <method-expression>* demo.sharedqueue.*.*(..)</method-expression>
 049:          </autolock>
 050:        </locks>
 051:  
 052:        <!-- We declare the following fields from the 'demo.sharedqueue.Queue' class
 053:             as roots, making it available for all instances of our app that runs via DSO 
 054:  
 055:             The field 'demo.sharedqueue.Main.lastPortUsed' keeps track of the last port number
 056:             used to launch the web server - subsequent instances of the application will use
 057:             the next port number in the sequence to avoid collision with previous instances -->
 058:        <roots>
 059:          <root>
 060:            <field-name>demo.sharedqueue.Queue.queue</field-name>
 061:          </root>
 062:          <root>
 063:            <field-name>demo.sharedqueue.Queue.workers</field-name>
 064:          </root>
 065:          <root>
 066:            <field-name>demo.sharedqueue.Queue.completedJobs</field-name>
 067:          </root>
 068:          <root>
 069:            <field-name>demo.sharedqueue.Queue.nextJobId</field-name>
 070:          </root>
 071:          <root>
 072:            <field-name>demo.sharedqueue.Main.lastPortUsed</field-name>
 073:          </root>
 074:        </roots>
 075:      </dso>
 076:    </application>
 077:  </tc:tc-config>