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:    <!--Configure DSO for 'development' mode;
 016:         See the Terracotta Configuration Guide and Reference for additional information.-->
 017:    <system>
 018:      <configuration-model>development</configuration-model>
 019:    </system>
 020:    <!--Tell DSO where to put the generated client logs
 021:         See the Terracotta Configuration Guide and Reference for additional
 022:         information.-->
 023:    <clients>
 024:      <logs>terracotta/client-logs/pojo/chatter/%D</logs>
 025:    </clients>
 026:    <application>
 027:      <dso>
 028:        <!--The app requires these custom objects/classes to be shared - the following declarations
 029:             tell DSO which ones they are. When the app runs under DSO, instances of these classes
 030:             will broadcast changes in their state.
 031:  
 032:             A best practice (and an MVC pattern) when writing an app that you intend to cluster via Terracotta is to group the 
 033:             classes you want to share under a single package. This makes the list of instrumented classes more concise.-->
 034:        <instrumented-classes>
 035:          <!--The following <include> instruments 'demo.chatter.ChatManager' to be shared, but
 036:               that fields described in the class as 'transient' should still behave as transient fields.
 037:  
 038:               By setting the value of <honor-transient> to 'true', fields declared as transient *are* transient
 039:               and their state and value will not become available across instances of the app. Only local instances of the app
 040:               will be able to create, read, and write to these fields.
 041:  
 042:               In 'demo.chatter.ChatManager' most members (transient and otherwise) are initialized upon creation. 
 043:               However, when DSO finds that an object is already available from the server, additional instances of the app 
 044:               will simply receive a reference to that object, and its constructor will not be called; transient fields 
 045:               will not be initialized at this point, so the <on-load> declaration is used to indicate actions
 046:               that the class needs to take when DSO loads that object from the server (actions that normally
 047:               happens on class instantiation).-->
 048:          <include>
 049:            <class-expression>demo.chatter.ChatManager</class-expression>
 050:            <honor-transient>true</honor-transient>
 051:            <on-load>
 052:              <method>init</method>
 053:            </on-load>
 054:          </include>
 055:          <!--The following <include> sections cause the classes 'demo.chatter.Message' and
 056:              'demo.chatter.User' to be treated as shareable. These objects are used to ferry around the messages
 057:              (and information about the message) sent from chatter clients.-->
 058:          <include>
 059:            <class-expression>demo.chatter.Message</class-expression>
 060:          </include>
 061:          <include>
 062:            <class-expression>demo.chatter.User</class-expression>
 063:            <honor-transient>true</honor-transient>
 064:          </include>
 065:          <include>
 066:            <class-expression>demo.chatter.Main</class-expression>
 067:          </include>
 068:        </instrumented-classes>
 069:        <!--This section makes it so that calls made to this method from any instance of the app
 070:             also happen across all instances of the app at the time of the call.-->
 071:        <distributed-methods>
 072:          <method-expression>void demo.chatter.ChatManager.sendNewMessageEvent(..)</method-expression>
 073:          <method-expression>void demo.chatter.ChatManager.sendNewUserEvent(..)</method-expression>
 074:        </distributed-methods>
 075:        <!--We declare the field 'demo.chatter.Main.message' a root, making it
 076:             available to all instances of our app that run via DSO.-->
 077:        <roots>
 078:          <root>
 079:            <field-name>demo.chatter.Main.chatManager</field-name>
 080:          </root>
 081:        </roots>
 082:        <!-- This section applies autolocking to all methods in the ChatManager class. Autolocking will
 083:             make any syncrhonization in these methods apply accross the cluster. -->
 084:        <locks>
 085:          <autolock>
 086:            <method-expression>* demo.chatter.ChatManager.*(..)</method-expression>
 087:          </autolock>
 088:        </locks>
 089:     <injected-instances>      
 090:         <injected-field> 
 091:            <field-name>demo.chatter.Main.cluster</field-name> 
 092:         </injected-field>
 093:     </injected-instances> 
 094:      </dso>
 095:    </application>
 096:  </tc:tc-config>