[Project] Extended documentation with observer and versioning
This commit is contained in:
parent
7de48c0d43
commit
47d56d6845
|
@ -64,10 +64,11 @@
|
||||||
<li><a href="documentation_queries.html">Strolch Queries</a></li>
|
<li><a href="documentation_queries.html">Strolch Queries</a></li>
|
||||||
<li><a href="documentation_transactions.html">Strolch Transactions</a></li>
|
<li><a href="documentation_transactions.html">Strolch Transactions</a></li>
|
||||||
<li><a href="documentation_policies.html">Strolch Policies</a></li>
|
<li><a href="documentation_policies.html">Strolch Policies</a></li>
|
||||||
<!--
|
|
||||||
<li><a href="documentation_privileges.html">Strolch Privileges</a></li>
|
|
||||||
<li><a href="documentation_observers.html">Strolch Observers</a></li>
|
<li><a href="documentation_observers.html">Strolch Observers</a></li>
|
||||||
<li><a href="documentation_versioning.html">Strolch Versioning</a></li>
|
<li><a href="documentation_versioning.html">Strolch Versioning</a></li>
|
||||||
|
<!--
|
||||||
|
<li><a href="documentation_privileges.html">Strolch Privileges</a></li>
|
||||||
|
<li><a href="documentation_audits.html">Strolch Audits</a></li>
|
||||||
-->
|
-->
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="google-site-verification" content="CPhbjooaiTdROm7Vs4E7kuHZvBfkeLUtonGgcVUbTL8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
<link rel="shortcut icon" href="ico/favicon.ico">
|
||||||
|
|
||||||
|
<title>Strolch: Observers</title>
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Custom styles for this template -->
|
||||||
|
<link href="css/custom.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="index.html">Strolch</a>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="index.html">Overview</a></li>
|
||||||
|
<li><a href="api.html">API</a></li>
|
||||||
|
<li class="active"><a href="documentation.html">Documentation</a></li>
|
||||||
|
<li><a href="downloads.html">Downloads</a></li>
|
||||||
|
<li><a href="development.html">Development</a></li>
|
||||||
|
<li><a href="blog.html">Blog</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="page-header">
|
||||||
|
<h1 class="page-title">Documentation: Observers</h1>
|
||||||
|
|
||||||
|
<p class="lead page-description">This page discusses the Strolch Observers</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
|
||||||
|
<p>All changes done in a Strolch transaction are recorded and then propagated to any registered observers.</p>
|
||||||
|
|
||||||
|
<p>The observer feature is opt-in and is configured for each realm. In the <code>StrolchConfiguration.xml</code>
|
||||||
|
file enable observers by adding the <code>enableObserverUpdates</code> propery per realm:</p>
|
||||||
|
<pre>
|
||||||
|
<StrolchConfiguration>
|
||||||
|
<env id="dev">
|
||||||
|
...
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<depends>PrivilegeHandler</depends>
|
||||||
|
<Properties>
|
||||||
|
<realms>defaultRealm, otherRealm</realms>
|
||||||
|
<enableObserverUpdates>true</enableObserverUpdates>
|
||||||
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
||||||
|
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
||||||
|
<enableObserverUpdates.otherRealm>true</enableObserverUpdates.otherRealm>
|
||||||
|
<dataStoreMode.otherRealm>TRANSIENT</dataStoreMode.otherRealm>
|
||||||
|
<dataStoreFile.otherRealm>StrolchModel.xml</dataStoreFile.otherRealm>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</env>
|
||||||
|
...
|
||||||
|
</StrolchConfiguration></pre>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<p>Registering for updates is done by registering an <code>Observer</code> on the <code>ObserverHandler</code>
|
||||||
|
of the realm itself:</p>
|
||||||
|
<pre>
|
||||||
|
ObserverHandler observerHandler = container.getRealm(StrolchConstants.DEFAULT_REALM).getObserverHandler();
|
||||||
|
observerHandler.registerObserver(Tags.RESOURCE, new Observer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(String key, List<StrolchRootElement> elements) {
|
||||||
|
logger.info(elements.size() + " resources were updated!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(String key, List<StrolchRootElement> elements) {
|
||||||
|
logger.info(elements.size() + " resources were removed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(String key, List<StrolchRootElement> elements) {
|
||||||
|
logger.info(elements.size() + " resources were added!");
|
||||||
|
}
|
||||||
|
});</pre>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<p>Observer updates can be suppressed on the transaction by calling <code>tx.setSuppressUpdates()</code></p>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- content here -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- /.content -->
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<div class="container">
|
||||||
|
<p class="text-muted">© Strolch / <a href="mailto:eitch@eitchnet.ch">Robert von Burg</a> / Hosting by
|
||||||
|
<a href="http://www.eitchnet.ch">eitchnet.ch</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- /.container -->
|
||||||
|
|
||||||
|
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
||||||
|
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||||
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Piwik -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _paq = _paq || [];
|
||||||
|
_paq.push(['trackPageView']);
|
||||||
|
_paq.push(['enableLinkTracking']);
|
||||||
|
(function () {
|
||||||
|
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.eitchnet.ch/";
|
||||||
|
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
||||||
|
_paq.push(['setSiteId', 2]);
|
||||||
|
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||||
|
g.type = 'text/javascript';
|
||||||
|
g.defer = true;
|
||||||
|
g.async = true;
|
||||||
|
g.src = u + 'piwik.js';
|
||||||
|
s.parentNode.insertBefore(g, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript><p><img src="http://piwik.eitchnet.ch/piwik.php?idsite=2" style="border:0;" alt=""/></p></noscript>
|
||||||
|
<!-- End Piwik Code -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,146 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="google-site-verification" content="CPhbjooaiTdROm7Vs4E7kuHZvBfkeLUtonGgcVUbTL8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="">
|
||||||
|
<link rel="shortcut icon" href="ico/favicon.ico">
|
||||||
|
|
||||||
|
<title>Strolch: Versioning</title>
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Custom styles for this template -->
|
||||||
|
<link href="css/custom.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="index.html">Strolch</a>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="index.html">Overview</a></li>
|
||||||
|
<li><a href="api.html">API</a></li>
|
||||||
|
<li class="active"><a href="documentation.html">Documentation</a></li>
|
||||||
|
<li><a href="downloads.html">Downloads</a></li>
|
||||||
|
<li><a href="development.html">Development</a></li>
|
||||||
|
<li><a href="blog.html">Blog</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="page-header">
|
||||||
|
<h1 class="page-title">Documentation: Versioning</h1>
|
||||||
|
|
||||||
|
<p class="lead page-description">This page discusses the Strolch Versioning</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
|
||||||
|
<p>One of Strolch's features that sets it apart from other frameworks, is that versioning is baked into
|
||||||
|
Strolch's fabric. The feature is opt-in, as it is not required in all projects, but it only needs enabling,
|
||||||
|
for all modifications to objects to be versioned, so that rollbacks can be done when needed.</p>
|
||||||
|
|
||||||
|
<p>The feature is enabled for each realm. In the <code>StrolchConfiguration.xml</code> file enable it by adding
|
||||||
|
the <code>enableVersioning</code> propery per realm:</p>
|
||||||
|
<pre>
|
||||||
|
<StrolchConfiguration>
|
||||||
|
<env id="dev">
|
||||||
|
...
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<depends>PrivilegeHandler</depends>
|
||||||
|
<Properties>
|
||||||
|
<realms>defaultRealm, otherRealm</realms>
|
||||||
|
<enableVersioning>true</enableVersioning>
|
||||||
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
||||||
|
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
||||||
|
<enableVersioning.otherRealm>true</enableVersioning.otherRealm>
|
||||||
|
<dataStoreMode.otherRealm>TRANSIENT</dataStoreMode.otherRealm>
|
||||||
|
<dataStoreFile.otherRealm>StrolchModel.xml</dataStoreFile.otherRealm>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</env>
|
||||||
|
...
|
||||||
|
</StrolchConfiguration></pre>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<p>Once versioning is enabled, versioning is handled automatically. The API for versioning is implemented on the
|
||||||
|
ElementMaps.</p>
|
||||||
|
|
||||||
|
<p>Example: Revert to previous version of a Resource:</p>
|
||||||
|
<pre>
|
||||||
|
Resource res = tx.getResourceBy("TestType", "MyTestResource");
|
||||||
|
ResourceMap resourceMap = tx.getResourceMap();
|
||||||
|
Resource previousVersion = resourceMap.revertToVersion(tx, res);
|
||||||
|
// or
|
||||||
|
Resource previousVersion = resourceMap.revertToVersion(tx, "TestType", "MyTestResource", 1);</pre>
|
||||||
|
|
||||||
|
<p>Example: Retrieve all versions of a Resource:</p>
|
||||||
|
<pre>
|
||||||
|
List<Resource> versions = resourceMap.getVersionsFor(tx, "TestType", "MyTestResource");</pre>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<p><b>Note:</b> When reverting to a previous version, it is important to remember, that any references on an
|
||||||
|
element to other elements will also be restored. As long as the relationship is to the same element, then
|
||||||
|
this is not an issue, but should the relationship have changed, then it this must be handled and the user
|
||||||
|
performing a revert be allowed to decided which element to reference in the reverted version.</p>
|
||||||
|
|
||||||
|
<!-- content here -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- /.content -->
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<div class="container">
|
||||||
|
<p class="text-muted">© Strolch / <a href="mailto:eitch@eitchnet.ch">Robert von Burg</a> / Hosting by
|
||||||
|
<a href="http://www.eitchnet.ch">eitchnet.ch</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- /.container -->
|
||||||
|
|
||||||
|
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
||||||
|
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||||
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Piwik -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _paq = _paq || [];
|
||||||
|
_paq.push(['trackPageView']);
|
||||||
|
_paq.push(['enableLinkTracking']);
|
||||||
|
(function () {
|
||||||
|
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.eitchnet.ch/";
|
||||||
|
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
||||||
|
_paq.push(['setSiteId', 2]);
|
||||||
|
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||||
|
g.type = 'text/javascript';
|
||||||
|
g.defer = true;
|
||||||
|
g.async = true;
|
||||||
|
g.src = u + 'piwik.js';
|
||||||
|
s.parentNode.insertBefore(g, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript><p><img src="http://piwik.eitchnet.ch/piwik.php?idsite=2" style="border:0;" alt=""/></p></noscript>
|
||||||
|
<!-- End Piwik Code -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue