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