<!doctype html><htmllang=enclass="js csstransforms3d"><head><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><metaname=generatorcontent="Hugo 0.80.0"><metaname=descriptioncontent="Strolch is a parameterized framework for use on servers and IoT"><metaname=authorcontent="Strolch"><linkrel=iconhref=/favicon.icotype=image/ico><title>Realms - Strolch</title><linkhref=/css/nucleus.css?1631087427rel=stylesheet><linkhref=/css/fontawesome-all.min.css?1631087427rel=stylesheet><linkhref=/css/hybrid.css?1631087427rel=stylesheet><linkhref=/css/featherlight.min.css?1631087427rel=stylesheet><linkhref=/css/perfect-scrollbar.min.css?1631087427rel=stylesheet><linkhref=/css/auto-complete.css?1631087427rel=stylesheet><linkhref=/css/atom-one-dark-reasonable.css?1631087427rel=stylesheet><linkhref=/css/theme.css?1631087427rel=stylesheet><linkhref=/css/hugo-theme.css?1631087427rel=stylesheet><linkhref=/css/theme-green.css?1631087427rel=stylesheet><scriptsrc=/js/jquery-3.3.1.min.js?1631087427></script><style>:root#header+#content>#left>#rlblock_left{display:none!important}</style></head><bodydata-url=/documentation/realms/><navid=sidebar><divid=header-wrapper><divid=header><aid=logohref=/><imgsrc=/logo.png></a></div><divclass=searchbox><labelfor=search-by><iclass="fas fa-search"></i></label><inputdata-search-inputid=search-bytype=searchplaceholder=Search...>
parent"><ahref=/documentation/>Documentation</a><ul><lidata-nav-id=/documentation/architecture/title=Architectureclass=dd-item><ahref=/documentation/architecture/>Architecture</a></li><lidata-nav-id=/documentation/model/title=Modelclass=dd-item><ahref=/documentation/model/>Model</a></li><lidata-nav-id=/documentation/do-and-donts/title="Do and Don't"class=dd-item><ahref=/documentation/do-and-donts/>Do and Don't</a></li><lidata-nav-id=/documentation/runtime-configuration/title="Runtime Configuration"class=dd-item><ahref=/documentation/runtime-configuration/>Runtime Configuration</a></li><lidata-nav-id=/documentation/realms/title=Realmsclass="dd-item active"><ahref=/documentation/realms/>Realms</a></li><lidata-nav-id=/documentation/components/title=Componentsclass=dd-item><ahref=/documentation/components/>Components</a></li><lidata-nav-id=/documentation/services-and-commands/title="Services and Commands"class=dd-item><ahref=/documentation/services-and-commands/>Services and Commands</a></li><lidata-nav-id=/documentation/searches/title=Searchesclass=dd-item><ahref=/documentation/searches/>Searches</a></li><lidata-nav-id=/documentation/queries/title=Queriesclass=dd-item><ahref=/documentation/queries/>Queries</a></li><lidata-nav-id=/documentation/transactions/title=Transactionsclass=dd-item><ahref=/documentation/transactions/>Transactions</a></li><lidata-nav-id=/documentation/policies/title=Policiesclass=dd-item><ahref=/documentation/policies/>Policies</a></li><lidata-nav-id=/documentation/observers/title=Observersclass=dd-item><ahref=/documentation/observers/>Observers</a></li><lidata-nav-id=/documentation/versioning/title=Versioningclass=dd-item><ahref=/documentation/versioning/>Versioning</a></li><lidata-nav-id=/documentation/reports/title=Reportsclass=dd-item><ahref=/documentation/reports/>Reports</a></li><lidata-nav-id=/documentation/priviles/title=Privilegesclass=dd-item><ahref=/documentation/priviles/>Privileges</a></li></ul></li><lidata-nav-id=/plc/title=PLCclass=dd-item><ahref=/plc/>PLC</a><ul><lidata-nav-id=/plc/architecture/title=Architectureclass=dd-item><ahref=/plc/architecture/>Architecture</a></li><lidata-nav-id=/plc/example-set-up/title="Example Set-Up"class=dd-item><ahref=/plc/example-set-up/>Example Set-Up</a></li></ul></li><lidata-nav-id=/tutorial/title=Tutorialclass=dd-item><ahref=/tutorial/>Tutorial</a><ul><lidata-nav-id=/tutorial/configuration/title=Configurationclass=dd-item><ahref=/tutorial/configuration/>Configuration</a></li><lidata-nav-id=/tutorial/model/title=Modelclass=dd-item><ahref=/tutorial/model/>Model</a></li><lidata-nav-id=/tutorial/crud-book/title="CRUD Book"class=dd-item><ahref=/tutorial/crud-book/>CRUD Book</a></li></ul></li><lidata-nav-id=/download/title=Downloadclass=dd-item><ahref=/download/>Download</a></li><lidata-nav-id=/development/title=Developmentclass=dd-item><ahref=/development/>Development</a></li><lidata-nav-id=/blog/title=Blogclass=dd-item><ahref=/blog/>Blog</a><ul><lidata-nav-id=/blog/post-00016/title="Strolch PLC now also on Maven Central"class=dd-item><ahref=/blog/post-00016/>Strolch PLC now also on Maven Central</a></li><lidata-nav-id=/blog/post-00015/title="Release of Strolch 1.6.100"class=dd-item><ahref=/blog/post-00015/>Release of Strolch 1.6.100</a></li><lidata-nav-id=/blog/post-00014/title="Strolch Reports"class=dd-item><ahref=/blog/post-00014/>Strolch Reports</a></li><lidata-nav-id=/blog/post-00013/title="Strolch Searches"class=dd-item><ahref=/blog/post-00013/>Strolch Searches</a></li><lidata-nav-id=/blog/post-00012/title="Wow, the many changes!"class=dd-item><ahref=/blog/post-00012/>Wow, the many changes!</a></li><lidata-nav-id=/blog/post-00011/title="Strolch now on Maven Central"class=dd-item><ahref=/blog/post-00011/>Strolch now on Maven Central</a></li><lidata-nav-id=/blog/post-00010/title="Versioning of objects"class=dd-item><ahref=/blog/post-00010/>Versioning of objects</a></li><lidata-nav-id=/blog/post-00009/title="Release 1.2.0"
arbitrary number of realms configured and each realm has its own persistence
configuration, allowing to separate mandates completely.</p><p>A realm can run in one of the following modes:</p><ul><li>EMPTY
This is a transient data store mode, where no model changes are
persisted - they are only kept in memory. When the Strolch agent is
started, this realm is empty as no data is loaded.</li><li>TRANSIENT
This is the same as EMPTY, but with the difference that when the Strolch
agent is started, a model file is parsed and the in-memory realm is
populated with the elements parsed from the model file.</li><li>CACHED
In this mode, all data is stored in-memory, and any changes made are
written back to the persistence layer. This allows for fast in-memory
qeuries, but makes sure no data is lost when the agent is restarted.</li></ul><p>Realms are mostly hidden from a developer as a <code>StrolchTransaction</code> exposes
all important operations needed to access Strolch objects. A developer will
however need to configure the realms for their specific project. If the
project only requires one realm, then the <code>defaultRealm</code> can be used, where the
developer only is required to configure the mode and any relevant model file.</p><p>If the mode is <code>CACHED</code>, then the <code>PersistenceHandler</code> component is required to
be configured, so that the DAOs know how to access the underlying database.</p><p>The configuration in the <code>StrolchConfiguration.xml</code> file is as follows:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-xmldata-lang=xml><spanstyle=color:#f92672><StrolchConfiguration></span>
</code></pre></div><h2id=multi-realm>Multi-Realm</h2><p>A multi-realm configuration would be as follows.</p><divclass="notices tip"><p>Note how the defaultRealm is still enabled, and has its configuration as
before. Further the PostgreSQL PersistenceHandler is configured to show how the
realms are connected to the persistence handler:</p></div><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-xmldata-lang=xml><spanstyle=color:#f92672><StrolchConfiguration></span>
</code></pre></div><h2id=access-realm>Access realm</h2><p>Accessing a realm is done in multiple ways. Important is to note, that a user
should use the <code>StrolchTransaction</code> object, instead of accessing the Realm directly.</p><p>Opening a transaction is done from a <code>Service</code> by calling one of the
<code>openTx()</code>-methods. Nevertheless, the realm can be accessed as follows:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java><spanstyle=color:#66d9ef>public</span><spanstyle=color:#66d9ef>class</span><spanstyle=color:#a6e22e>Example</span><spanstyle=color:#f92672>{</span>