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 xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd" xmlns:tc="http://www.terracotta.org/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 008:    <!--Server is colocated with client and DSO is listening on
 009:         default port (9510).-->
 010:    <servers>
 011:      <server host="%i" name="sample"/>
 012:    </servers>
 013:    <!--Configure DSO for 'development' mode;
 014:         See the Terracotta Configuration Guide and Reference for additional information.-->
 015:    <system>
 016:      <configuration-model>development</configuration-model>
 017:    </system>
 018:    <!--Tell DSO where to put the generated client logs
 019:         See the Terracotta Configuration Guide and Reference for additional
 020:         information.-->
 021:    <clients>
 022:      <logs>terracotta/client-logs/pojo/sharededitor/%D</logs>
 023:    </clients>
 024:    <application>
 025:      <dso>
 026:        <!--The app requires these custom objects/classes to be shared - the following declarations
 027:             tell DSO which ones they are. When the app runs under DSO, instances of these classes
 028:             will broadcast changes in their state.
 029:  
 030:             A best practice (and an MVC pattern) when writing an app that you intend to cluster via Terracotta is to group the 
 031:             classes you want to share under a single package. This makes the list of instrumented classes more concise.-->
 032:        <instrumented-classes>
 033:          <!--The following <include> instruments all of the classes found under the 'demo.sharededitor.models'
 034:               package.-->
 035:          <include>
 036:            <class-expression>demo.sharededitor.models.*</class-expression>
 037:            <honor-transient>true</honor-transient>
 038:          </include>
 039:          <!--Although the class 'demo.sharededitor.models.ObjectManager' is already declared as
 040:               instrumented by the preceding declaration, certain parts of it should only
 041:               be available locally (see the <transient-fields/> section), therefore a
 042:               special declaration of it follows.
 043:  
 044:               By setting the value of <honor-transient> to 'true', fields declared as transient *are* transient
 045:               and their state and value will not become available across instances of the app. Only local instances of the app
 046:               will be able to create, read, and write to these fields.
 047:  
 048:               In 'demo.sharededitor.models.ObjectManager', most members (transient and otherwise) are initialized upon creation. 
 049:               However, when DSO finds that an object is already available from the server, additional instances of the app 
 050:               will simply receive a reference to that object, and its constructor will not be called,  Ttransient fields 
 051:               will not be initialized at this point, so the <on-load> declaration is used to indicate actions
 052:               that the class needs to take when DSO loads that object from the server (actions that normally
 053:               happens on class instantiation).-->
 054:          <include>
 055:            <class-expression>demo.sharededitor.models.ObjectManager</class-expression>
 056:            <honor-transient>true</honor-transient>
 057:            <on-load>
 058:              <method>init_transients</method>
 059:            </on-load>
 060:          </include>
 061:          <include>
 062:            <class-expression>demo.sharededitor.controls.Dispatcher</class-expression>
 063:          </include>
 064:          <include>
 065:            <class-expression>javax.swing.event.MouseInputAdapter</class-expression>
 066:          </include>
 067:        </instrumented-classes>
 068:        <!--These methods belong to the root object: demo.sharededitor.controls.Dispatcher.objmgr
 069:             This section makes it so that calls made to this method from any instance of the app
 070:             also happens across all instances of the app at the time of the call.-->
 071:        <distributed-methods>
 072:          <method-expression>void demo.sharededitor.models.ObjectManager.changed(Object, Object)</method-expression>
 073:        </distributed-methods>
 074:        <!--These fields belong to our root object: demo.sharededitor.controls.Dispatcher.objmgr;
 075:             make them transient so the values that they hold are available only locally.-->
 076:        <transient-fields>
 077:          <field-name>demo.sharededitor.models.ObjectManager.listener</field-name>
 078:          <field-name>demo.sharededitor.models.ObjectManager.grabList</field-name>
 079:          <field-name>demo.sharededitor.models.ObjectManager.lastGrabbed</field-name>
 080:        </transient-fields>
 081:        <!--These methods (originating from local objects) operate on objects declared as shared. This 
 082:             section tells DSO to assume a lock on those objects for the duration of the call-->
 083:        <locks>
 084:          <autolock>
 085:            <method-expression>* demo.sharededitor.models.*.*(..)</method-expression>
 086:            <lock-level>write</lock-level>
 087:          </autolock>
 088:        </locks>
 089:        <!--We declare the field 'demo.sharededitor.controls.Dispatcher.objmgr' a root, making it
 090:             available for all instances of our app that run via DSO-->
 091:        <roots>
 092:          <root>
 093:            <field-name>demo.sharededitor.controls.Dispatcher.objmgr</field-name>
 094:          </root>
 095:        </roots>
 096:      </dso>
 097:    </application>
 098:  </tc:tc-config>