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:    <!--Configure DSO for 'development' mode;
 021:         See the Terracotta Configuration Guide and Reference for additional information.-->
 022:    <system>
 023:      <configuration-model>development</configuration-model>
 024:    </system>
 025:    <!--Tell DSO where to put the generated client logs
 026:         See the Terracotta Configuration Guide and Reference for additional
 027:         information.-->
 028:    <clients>
 029:      <logs>terracotta/client-logs/pojo/chatter/%D</logs>
 030:      <statistics>terracotta/client-statistics/pojo/chatter/%D</statistics>
 031:    </clients>
 032:    <application>
 033:      <dso>
 034:        <!--The app requires these custom objects/classes to be shared - the following declarations
 035:             tell DSO which ones they are. When the app runs under DSO, instances of these classes
 036:             will broadcast changes in their state.
 037:  
 038:             A best practice (and an MVC pattern) when writing an app that you intend to cluster via Terracotta is to group the 
 039:             classes you want to share under a single package. This makes the list of instrumented classes more concise.-->
 040:        <instrumented-classes>
 041:          <!--The following <include> instruments 'demo.chatter.ChatManager' to be shared, but
 042:               that fields described in the class as 'transient' should still behave as transient fields.
 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.chatter.ChatManager' 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; transient 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.chatter.ChatManager</class-expression>
 056:            <honor-transient>true</honor-transient>
 057:            <on-load>
 058:              <method>init</method>
 059:            </on-load>
 060:          </include>
 061:          <!--The following <include> sections cause the classes 'demo.chatter.Message' and
 062:              'demo.chatter.User' to be treated as shareable. These objects are used to ferry around the messages
 063:              (and information about the message) sent from chatter clients.-->
 064:          <include>
 065:            <class-expression>demo.chatter.Message</class-expression>
 066:          </include>
 067:          <include>
 068:            <class-expression>demo.chatter.User</class-expression>
 069:            <honor-transient>true</honor-transient>
 070:          </include>
 071:        </instrumented-classes>
 072:        <!--This section makes it so that calls made to this method from any instance of the app
 073:             also happen across all instances of the app at the time of the call.-->
 074:        <distributed-methods>
 075:          <method-expression>void demo.chatter.ChatManager.sendNewMessageEvent(..)</method-expression>
 076:          <method-expression>void demo.chatter.ChatManager.sendNewUserEvent(..)</method-expression>
 077:        </distributed-methods>
 078:        <!--We declare the field 'demo.chatter.Main.message' a root, making it
 079:             available to all instances of our app that run via DSO.-->
 080:        <roots>
 081:          <root>
 082:            <field-name>demo.chatter.Main.chatManager</field-name>
 083:          </root>
 084:        </roots>
 085:        <!-- This section applies autolocking to all methods in the ChatManager class. Autolocking will
 086:             make any syncrhonization in these methods apply accross the cluster. -->
 087:        <locks>
 088:          <autolock>
 089:            <method-expression>* demo.chatter.ChatManager.*(..)</method-expression>
 090:          </autolock>
 091:        </locks>
 092:      </dso>
 093:    </application>
 094:  </tc:tc-config>