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