You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/12/22 23:40:32 UTC
[2/4] isis git commit: ISIS-1243: reworking the ugbtb (beyond the
basics) guide a little, breaking out and renaming the techniques chapter
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_i18n.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_i18n.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_i18n.adoc
deleted file mode 100644
index cfbebcf..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_i18n.adoc
+++ /dev/null
@@ -1,409 +0,0 @@
-[[_ugbtb_more-advanced_i18n]]
-= i18n
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-Apache Isis' support for i18n allows every element of the domain model (the class names, property names, action names, parameter names and so forth) to be translated.
-
-It also supports translations of messages raised imperatively, by which we mean as the result of a call to `title()` to obtain an object's title, or messages resulting from any business rule violations (eg xref:rgcms.adoc#_rgcms_methods_prefixes_disable[`disable...()`] or xref:rgcms.adoc#_rgcms_methods_prefixes_validate[`validate...()`], and so on.
-
-Isis does not translate the values of your domain objects, though. So, if you have a domain concept such as `Country` whose name is intended to be localized according to the current user, you will need to model
-
-
-
-== Implementation Approach
-
-Most Java frameworks tackle i18n by using Java's own `ResourceBundle` API. However, there are some serious drawbacks in this approach, such as:
-
-* if a string appears more than once (eg "name" or "description") then it must be translated everywhere it appears in every resource bundle file
-* there is no support for plural forms (see this link:http://stackoverflow.com/questions/14326653/java-internationalization-i18n-with-proper-plurals/14327683#14327683[SO answer])
-* there is no tooling support for translators
-
-Apache Isis therefore takes a different approach, drawing inspiration from GNU's https://www.gnu.org/software/gettext/manual/index.html[gettext] API and specifically its `.pot` and `.po` files. These are intended to be used as follows:
-
-* the `.pot` (portable object template) file holds the message text to be translated
-* this file is translated into multiple `.po` (portable object) files, one per supported locale
-* these `.po` files are renamed according to their locale, and placed into the 'appropriate' location to be picked up by the runtime. The name of each `.po` resolved in a very similar way to resource bundles.
-
-The format of the `.pot` and `.po` files is identical; the only difference is that the `.po` file has translations for each of the message strings. These message strings can also have singular and plural forms.
-
-
-[IMPORTANT]
-====
-Although Apache Isis' implementation is modelled after GNU's API, it does _not_ use any GNU software. This is for two reasons: (a) to simplify the toolchain/developer experience, and (b) because GNU software is usually GPL, which would be incompatible with the Apache license).
-====
-
-This design tackles all the issues of ``ResourceBundle``s:
-
-* the `.po` message format is such that any given message text to translate need only be translated once, even if it appears in multiple places in the application (eg "Name")
-* the `.po` message format includes translations for (optional) plural form as well as singular form
-* there are lots of freely available editors https://www.google.co.uk/search?q=.po+file+editor[to be found], many summarized on this https://www.drupal.org/node/11131[Drupal.org] webpage. +
-+
-In fact, there are also online communities/platforms of translators to assist with translating files. One such is https://crowdin.com/[crowdin] (nb: this link does not imply endorsement).
-
-In Apache Isis' implementation, if the translation is missing from the `.po` file then the original message text from the `.pot` file will be returned. In fact, it isn't even necessary for there to be any `.po` files; `.po` translations can be added piecemeal as the need arises.
-
-
-
-
-== `TranslationService`
-
-The cornerstone of Apache Isis' support for i18n is the `TranslationService` service. This is defined in the applib with the following API:
-
-[source,java]
-----
-public interface TranslationService {
- public String translate( // <1>
- final String context,
- final String text);
- public String translate( // <2>
- final String context,
- final String singularText,
- final String pluralText,
- final int num);
- public enum Mode {
- READ,
- WRITE;
- }
- Mode getMode(); // <3>
-}
-----
-<1> is to translate the singular form of the text
-<2> is to translate the plural form of the text
-<3> indicates whether the translation service is in read or write mode.
-
-The `translate(...)` methods are closely modelled on GNU's gettext API. The first version is used when no translation is required, the second is when both a singular and plural form will be required, with the `num` parameter being used to select which is returned. In both cases the `context` parameter provides some contextual information for the translator; this generally corresponds to the class member.
-
-The mode meanwhile determines the behaviour of the service. More on this below.
-
-
-
-=== `TranslationServicePo`
-
-Isis provides a default implementation of `TranslationService`, namely `TranslationServicePo`.
-
-If the service is running in the normal read mode, then it simply provides translations for the locale of the current user. This means locates the appropriate `.po` file (based on the requesting user's locale), finds the translation and returns it.
-
-If however the service is configured to run in write mode, then it instead records the fact that the message was requested to be translated (a little like a spy/mock in unit testing mock), and returns the original message. The service can then be queried to discover which messages need to be translated. All requested translations are written into the `.pot` file.
-
-To make the service as convenient as possible to use, the service configures itself as follows:
-
-* if running in prototype mode xref:rgcfg.adoc#_rgcfg_deployment-types[deployment type] or during integration tests, then the service runs in *write* mode, in which case it records all translations into the `.pot` file. The `.pot` file is written out when the system is shutdown.
-* if running in server (production) mode xref:rgcfg.adoc#_rgcfg_deployment-types[deployment type], then the service runs in *read* mode. It is also possible to set a configuration setting in `isis.properties` to force read mode even if running in prototype mode (useful to manually test/demo the translations).
-
-When running in write mode the original text is returned to the caller untranslated. If in read mode, then the translated `.po` files are read and translations provided as required.
-
-
-
-
-
-== Imperative messages
-
-The `TranslationService` is used internally by Apache Isis when building up the metamodel; the name and description of every class, property, collection, action and action parameter is automatically translated. Thus the simple act of bootstrapping Apache Isis will cause most of the messages requiring translation (that is: those for the Apache Isis metamodel) to be captured by the `TranslationService`.
-
-However, for an application to be fully internationalized, any validation messages (from either `disableXxx()` or `validateXxx()` supporting methods) and also possibly an object's title (from the `title()` method) will also require translation. Moreover, these messages must be captured in the `.pot` file such that they can be translated.
-
-
-=== `TranslatableString`
-
-The first part of the puzzle is tackled by an extension to Apache Isis' programming model. Whereas previously the `disableXxx()` / `validateXxx()` / `title()` methods could only return a `java.lang.String`, they may now optionally return a `TranslatableString` (defined in Isis applib) instead.
-
-Here's a (silly) example from the xref:ugfun.adoc#_ugfun_getting-started_simpleapp-archetype[SimpleApp archetype]:
-
-[source,java]
-----
-public TranslatableString validateUpdateName(final String name) {
- return name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
-}
-----
-
-This corresponds to the following entry in the `.pot` file:
-
-[source,ini]
-----
-#: dom.simple.SimpleObject#updateName()
-msgid "Exclamation mark is not allowed"
-msgstr ""
-----
-
-The full API of `TranslatableString` is modelled on the design of GNU gettext (in particular the https://code.google.com/p/gettext-commons/wiki/Tutorial[gettext-commons] library):
-
-[source,java]
-----
-public final class TranslatableString {
- public static TranslatableString tr( // <1>
- final String pattern,
- final Object... paramArgs) { ... }
- public static TranslatableString trn( // <2>
- final String singularPattern,
- final String pluralPattern,
- final int number,
- final Object... paramArgs) { ... }
- public String translate( // <3>
- final TranslationService translationService,
- final String context) { ... }
-}
-----
-<1> returns a translatable string with a single pattern for both singular and plural forms.
-<2> returns a translatable string with different patterns for singular and plural forms; the one to use is determined by the 'number' argument
-<3> translates the string using the provided `TranslationService`, using the appropriate singular/regular or plural form, and interpolating any arguments.
-
-The interpolation uses the format `{xxx}`, where the placeholder can occur multiple times.
-
-For example:
-
-[source,java]
-----
-final TranslatableString ts = TranslatableString.tr(
- "My name is {lastName}, {firstName} {lastName}.",
- "lastName", "Bond", "firstName", "James");
-----
-
-would interpolate (for the English locale) as "My name is Bond, James Bond".
-
-For a German user, on the other hand, if the translation in the corresponding `.po` file was:
-
-[source,ini]
-----
-#: xxx.yyy.Whatever#context()
-msgid "My name is {lastName}, {firstName} {lastName}."
-msgstr "Iche heisse {firstName} {lastName}."
-----
-
-then the translation would be: "Ich heisse James Bond".
-
-
-The same class is used in xref:rgsvc.adoc#_rgsvc_api_DomainObjectContainer[`DomainObjectContainer`] so that you can raise translatable info, warning and error messages; each of the relevant methods are overloaded.
-
-For example:
-
-[source,java]
-----
-public interface DomainObjectContainer {
- void informUser(String message);
- void informUser(
- TranslatableMessage message,
- final Class<?> contextClass, final String contextMethod); // <1>
- ...
-}
-----
-<1> are concatenated together to form the context for the `.pot` file.
-
-
-
-=== `TranslatableException`
-
-Another mechanism by which messages can be rendered to the user are as the result of exception messages thrown and recognized by an xref:rgsvc.adoc#_rgsvc_spi_ExceptionRecognizer[`ExceptionRecognizer`].
-
-In this case, if the exception implements `TranslatableException`, then the message will automatically be translated before being rendered. The `TranslatableException` itself takes the form:
-
-[source,java]
-----
-public interface TranslatableException {
- TranslatableString getTranslatableMessage(); // <1>
- String getTranslationContext(); // <2>
-}
-
-----
-<1> the message to translate. If returns `null`, then the `Exception#getMessage()` is used as a fallback
-<2> the context to use when translating the message
-
-
-
-
-
-== Integration Testing
-
-So much for the API; but as noted, it is also necessary to ensure that the required translations are recorded (by the `TranslationService`) into the `.pot` file.
-
-For this, we recommend that you ensure that all such methods are tested through an xref:ugtst.adoc#_ugtst_integ-test-support[integration test] (not unit test).
-
-For example, here's the corresponding integration test for the "Exclamation mark" example from the simpleapp (above):
-
-[source,java]
-----
-@Rule
-public ExpectedException expectedException = ExpectedException.none();
-
-@Inject
-FixtureScripts fixtureScripts;
-
-@Test
-public void failsValidation() throws Exception {
- // given
- RecreateSimpleObjects fs = new RecreateSimpleObjects().setNumber(1);
- fixtureScripts.runFixtureScript(fs, null);
- SimpleObject simpleObjectWrapped = wrap(fs.getSimpleObjects().get(0));
-
- // expect
- expectedExceptions.expect(InvalidException.class);
- expectedExceptions.expectMessage("Exclamation mark is not allowed");
-
- // when
- simpleObjectWrapped.updateName("new name!");
-}
-----
-
-Running this test will result in the framework calling the `validateUpdateName(...)` method, and thus to record that a translation is required in the `.pot` file.
-
-When the integration tests are complete (that is, when Apache Isis is shutdown), the `TranslationServicePo` will write out all captured translations to its log (more on this below). This will include all the translations captured from the Apache Isis metamodel, along with all translations as exercised by the integration tests.
-
-To ensure your app is fully internationalized app, you must therefore:
-
-* use `TranslatableString` rather than `String` for all validation/disable and title methods.
-* ensure that (at a minimum) all validation messages and title methods are integration tested.
-
-[NOTE]
-====
-We make no apologies for this requirement: one of the reasons that we decided to implement Apache Isis' i18n support in this way is because it encourages/requires the app to be properly tested.
-
-Behind the scenes Apache Isis uses a JUnit rule (`ExceptionRecognizerTranslate`) to intercept any exceptions that are thrown. These are simply passed through to the registered xref:rgsvc.adoc#_rgsvc_spi_ExceptionRecognizer[`ExceptionRecognizer`]s so that any messages are recorded as requiring translation.
-====
-
-
-
-
-
-
-== Escaped strings
-
-Translated messages can be escaped if required, eg to include embedded markup.
-
-[source,ini]
-----
-#: com.mycompany.myapp.OrderItem#quantity
-msgid "<i>Quantity</i>"
-msgstr "<i>Quantité</i>"
-----
-
-For this to work, the `namedEscaped()` attribute must be specified using either the
-xref:ugfun.adoc#_ugfun_object-layout_dynamic[dynamic layout] json file, or using an annotation such as
-xref:rgant.adoc#_rgant_PropertyLayout[`@PropertyLayout`] or xref:rgant.adoc#_rgant_ParameterLayout[`@ParameterLayout`].
-
-For example:
-
-[source,java]
-----
-@ParameterLayout(
- named="<i>Quantity</i>", // <1>
- namedEscaped=false
-)
-public Integer getQuantity() { ... }
-----
-<1> required (even though it won't be used when a translation is read; otherwise the escaped flag is ignored)
-
-
-
-
-== Configuration
-
-There are several different aspects of the translation service that can be configured.
-
-=== Logging
-
-To configure the `TranslationServicePo` to write to out the `translations.pot` file, add the following to the _integtests_ `logging.properties` file:
-
-[source,ini]
-----
-log4j.appender.translations-po=org.apache.log4j.FileAppender
-log4j.appender.translations-po.File=./translations.pot
-log4j.appender.translations-po.Append=false
-log4j.appender.translations-po.layout=org.apache.log4j.PatternLayout
-log4j.appender.translations-po.layout.ConversionPattern=%m%n
-
-log4j.logger.org.apache.isis.core.runtime.services.i18n.po.PoWriter=INFO,translations-po
-log4j.additivity.org.apache.isis.core.runtime.services.i18n.po.PotWriter=false
-----
-
-Just to repeat, this is _not_ the `WEB-INF/logging.properties` file, it should instead be added to the `integtests/logging.properties` file.
-
-=== Location of the `.po` files
-
-The default location of the translated `.po` files is in the `WEB-INF` directory. These are named and searched for similarly to regular Java resource bundles.
-
-For example, assuming these translations:
-
-[source,ini]
-----
-/WEB-INF/translations-en-US.po
- /translations-en.po
- /translations-fr-FR.po
- /translations.po
-----
-
-then:
-
-* a user with `en-US` locale will use `translations-en-US.po`
-* a user with `en-GB` locale will use `translations-en.po`
-* a user with `fr-FR` locale will use `translations-fr-FR.po`
-* a user with `fr-CA` locale will use `translations.po`
-
-The basename for translation files is always `translations`; this cannot be altered.
-
-
-=== Externalized translation files
-
-Normally Apache Isis configuration files are read from the `WEB-INF` file. However, Apache Isis can be configured to read config files from an xref:ugbtb.adoc#_ugbtb_deployment_externalized-configuration[external directory]; this is also supported for translations.
-
-Thus, if in `web.xml` the external configuration directory has been set:
-
-[source,xml]
-----
-<context-param>
- <param-name>isis.config.dir</param-name>
- <param-value>location of external config directory</param-value>
-</context-param>
-----
-
-Then this directory will be used as the base for searching for translations (rather than the default 'WEB-INF/' directory).
-
-=== Force read mode
-
-As noted above, if running in prototype mode then `TranslationServicePo` will be in write mode, if in production mode then will be in read mode. To force read mode (ie use translations) even if in prototype mode, add the following configuration property to `isis.properties`:
-
-[source,ini]
-----
-isis.services.translation.po.mode=read
-----
-
-== Supporting services
-
-The `TranslationServicePo` has a number of supporting/related services.
-
-=== `LocaleProvider`
-
-The `LocaleProvider` API is used by the `TranslationServicePo` implementation to obtain the locale of the "current user".
-
-A default implementation is provided by the Wicket viewer.
-
-[NOTE]
-====
-Note that this default implementation does not support requests made through the Restful Objects viewer (there is no Wicket 'application' object available); the upshot is that requests through Restful Objects are never translated. Registering a different implementation of `LocaleProvider` that taps into appropriate REST (RestEasy?) APIs would be the way to address this.
-====
-
-
-=== `TranslationsResolver`
-
-The `TranslationResolver` is used by the `TranslationService` implementation to lookup translations for a specified locale. It is this service that reads from the `WEB-INF/` (or externalized directory).
-
-
-=== `TranslationServicePoMenu`
-
-The `TranslationServicePoMenu` provides a couple of menu actions in the UI (prototype mode only) that interacts with the underlying `TranslationServicePo`:
-
-* the `downloadTranslationsFile()` action - available only in write mode - allows the current `.pot` file to be downloaded. +
-+
-[NOTE]
-====
-While this will contain all the translations from the metamodel, it will not necessarily contain all translations for all imperative methods returning `TranslatableString` instances; which are present and which are missing will depend on which imperative methods have been called (recorded by the service) prior to downloading.
-====
-
-* the `clearTranslationsCache()` action - available only in read mode - will clear the cache so that new translations can be loaded. +
-+
-This allows a translator to edit the appropriate `translations-xx-XX.po` file and check the translation is correct without having to restart the app.
-
-
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_mapping-rdbms-views.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_mapping-rdbms-views.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_mapping-rdbms-views.adoc
deleted file mode 100644
index e4f9049..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_mapping-rdbms-views.adoc
+++ /dev/null
@@ -1,9 +0,0 @@
-[[_ugbtb_more-advanced_mapping-rdbms-views]]
-= Mapping RDBMS Views
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-NOTE: TODO - as used in link:http://github.com/estatio/estatio[Estatio]
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_multi-tenancy.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_multi-tenancy.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_multi-tenancy.adoc
deleted file mode 100644
index 945b157..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_multi-tenancy.adoc
+++ /dev/null
@@ -1,8 +0,0 @@
-[[_ugbtb_more-advanced_multi-tenancy]]
-= Multi-tenancy
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-NOTE: TODO - as supported by (non-ASF) http://github.com/isisaddons/isis-module-security[Isis addons' security] module.
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_overriding-jdo-annotations.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_overriding-jdo-annotations.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_overriding-jdo-annotations.adoc
deleted file mode 100644
index 5601c75..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_overriding-jdo-annotations.adoc
+++ /dev/null
@@ -1,64 +0,0 @@
-[[_ugbtb_more-advanced_overriding-jdo-annotations]]
-= Overriding JDO Annotations
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-
-The JDO Objectstore (or rather, the underlying DataNucleus implementation) builds its own persistence metamodel by reading both annotations on the class and also by searching for metadata in XML files. The metadata in the XML files takes precedence over the annotations, and so can be used to override metadata that is "hard-coded" in annotations.
-
-For example, as of 1.9.0 the various http://www.isisaddons.org[Isis addons] modules (not ASF) use schemas for each entity. For example, the `AuditEntry` entity in the http://github.com/isisaddons/isis-module-audit[audit module] is annotated as:
-
-[source,java]
-----
-@javax.jdo.annotations.PersistenceCapable(
- identityType=IdentityType.DATASTORE,
- schema = "IsisAddonsAudit",
- table="AuditEntry")
-public class AuditEntry {
- ...
-}
-----
-
-This will map the `AuditEntry` class to a table `"IsisAddonsAudit"."AuditEntry"`; that is using a custom schema to own the object.
-
-Suppose though that for whatever reason we didn't want to use a custom schema but would rather use the default. We can override the above annotation using a `package.jdo` file, for example:
-
-[source,xml]
-----
-<?xml version="1.0" encoding="UTF-8" ?>
-<jdo xmlns="http://xmlns.jcp.org/xml/ns/jdo/jdo"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/jdo/jdo
- http://xmlns.jcp.org/xml/ns/jdo/jdo_3_0.xsd" version="3.0">
- <package name="org.isisaddons.module.audit.dom">
- <class name="AuditEntry" schema="PUBLIC" table="IsisAddonsAuditEntry">
- </class>
- </package>
-</jdo>
-----
-
-This file should be placed can be placed in `src/main/java/META-INF` within your application's `dom` module.
-
-[TIP]
-====
-(As of `1.11.0-SNAPSHOT`) you can use a mixin action on xref:rgcms.adoc#_rgcms_classes_mixins_Persistable[`Persistable`] mixin
-to download the JDO class metadata in XML form.
-====
-
-
-[NOTE]
-====
-* The same approach should work for any other JDO metadata, but some experimentation might be required.+
-+
-For example, in writing up the above example we found that writing `schema=""` (in an attempt to say, "use the default schema for this table") actually caused the original annotation value to be used instead.
-
-* Forcing the schema to "PUBLIC" (as in the above example) works, but it isn't ideal because the name "PUBLIC" is not vendor-neutral (it works for HSQLDB, but MS SQL Server uses "dbo" as its default).
-
-* As of 1.9.0 Apache Isis will automatically (attempt) to create the owning schema for a given table if it does not exist. This behaviour can be customized, as described in the section on xref:_ugbtb_more-advanced_decoupling_db-schemas[using modules].
-
-* You may need to override the entire class metadata rather than individual elements; the mixin (`1.11.0-SNAPSHOT`) mentioned above can help here.
-====
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_persisted-title.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_persisted-title.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_persisted-title.adoc
deleted file mode 100644
index 59d3cb4..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_persisted-title.adoc
+++ /dev/null
@@ -1,82 +0,0 @@
-[[_ugbtb_more-advanced_persisted-title]]
-= Persisted Title
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-
-Normally the title of an object is not persisted to the database, rather it is recomputed automatically from underlying properties. On occasion though you might want the title to also be persisted; either to make things easier for the DBA, or for an integration scenario, or some other purpose.
-
-We can implement this feature by leveraging the xref:rgcms.adoc#_rgcms_methods_lifecycle_jdo-api[JDO lifecycle]. In the design we discuss here we make it a responsibility of the entities to persist the title as a property, by implementing a `ObjectWithPersistedTitle` interface:
-
-[source,java]
-----
-public interface ObjectWithPersistedTitle {
- @PropertyLayout(hidden = Where.EVERYWHERE) // <1>
- String getTitle();
- void setTitle(final String title);
-}
-----
-<1> we don't want to expose this in the UI because the title is already prominently displayed.
-
-We can then define a subscribing domain service that leverage this.
-
-[source,java]
-----
-@DomainService(nature = NatureOfService.DOMAIN)
-public class TitlingService extends AbstractSubscriber {
- @Subscribe
- public void on(final ObjectPersistingEvent ev) {
- handle(ev.getSource());
- }
- @Subscribe
- public void on(final ObjectUpdatingEvent ev) {
- handle(ev.getSource());
- }
- private void handle(final Object persistentInstance) {
- if(persistentInstance instanceof ObjectWithPersistedTitle) {
- final ObjectWithPersistedTitle objectWithPersistedTitle =
- (ObjectWithPersistedTitle) persistentInstance;
- objectWithPersistedTitle.setTitle(container.titleOf(objectWithPersistedTitle));
- }
- }
- @Inject
- private DomainObjectContainer container;
-}
-----
-
-Prior to 1.10.0 (when lifecycle events were introduced), this could also be be done by accessing the JDO API directly:
-
-[source,java]
-----
-@RequestScoped
-@DomainService(nature = NatureOfService.DOMAIN)
-public class TitlingService {
- @PostConstruct
- public void init() {
- isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(
- new StoreLifecycleListener() {
- @Override
- public void preStore(final InstanceLifecycleEvent event) {
- final Object persistentInstance = event.getPersistentInstance();
- if(persistentInstance instanceof ObjectWithPersistedTitle) {
- final ObjectWithPersistedTitle objectWithPersistedTitle =
- (ObjectWithPersistedTitle) persistentInstance;
- objectWithPersistedTitle.setTitle(container.titleOf(objectWithPersistedTitle));
- }
- }
- @Override
- public void postStore(final InstanceLifecycleEvent event) {
- }
- }, null);
- }
- @Inject
- private IsisJdoSupport isisJdoSupport;
- @Inject
- private DomainObjectContainer container;
-}
-----
-
-The above is probably the easiest and most straightforward design. One could imagine other designs where the persisted title is stored elsewhere. It could even be stored off into an link:http://lucene.apache.org/[Apache Lucene] (or similar) database to allow for free-text searches.
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_replacing-default-service-implementations.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_replacing-default-service-implementations.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_replacing-default-service-implementations.adoc
deleted file mode 100644
index 5ba01a7..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_replacing-default-service-implementations.adoc
+++ /dev/null
@@ -1,64 +0,0 @@
-[[_ugbtb_more-advanced_replacing-default-service-implementations]]
-= Replacing Service Implns
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-
-The framework provides default implementations for many of the xref:rgsvc.adoc#_rgsvc_api[API Services]. This is convenient, but sometimes you will want to replace the default implementation with your own service implementation.
-
-The trick is to use the xref:rgant.adoc#_rgant-DomainServiceLayout_menuOrder[`@DomainServiceLayout#menuOrder()`] attribute, specifying a low number (typically `"1"`).
-
-For example, suppose you wanted to provide your own implementation of xref:rgsvc.adoc#_rgsvc_api_LocaleProvider[`LocaleProvider`]. Here's how:
-
-[source,java]
-----
-@DomainService(
- nature = NatureOfService.DOMAIN
-)
-@DomainServiceLayout(
- menuOrder = "1" // <1>
-)
-public class MyLocaleProvider implements LocaleProvider {
- @Override
- public Locale getLocale() {
- return ...
- }
-}
-----
-<1> takes precedence over the default implementation.
-
-
-It's also quite common to want to decorate the existing implementation (ie have your own implementation delegate to the default); this is also possible and quite easy if using `1.10.0` or later:
-
-[source,java]
-----
-@DomainService(
- nature = NatureOfService.DOMAIN
-)
-@DomainServiceLayout(
- menuOrder = "1" // <1>
-)
-public class MyLocaleProvider implements LocaleProvider {
- @Override
- public Locale getLocale() {
- return getDelegateLocaleProvider().getLocale(); // <2>
- }
- Optional<LocaleProvider> delegateLocaleProvider; // <3>
- private LocaleProvider getDelegateLocaleProvider() {
- if(delegateLocaleProvider == null) {
- delegateLocaleProvider = Iterables.tryFind(localeProviders, input -> input != this); // <4>
- }
- return delegateLocaleProvider.orNull();
- }
- @Inject
- List<LocaleProvider> localeProviders; // <5>
-}
-----
-<1> takes precedence over the default implementation when injected elsewhere.
-<2> this implementation merely delegates to the default implementation
-<3> lazily populated
-<4> delegate to the first implementation that isn't _this_ implementation (else infinite loop!)
-<5> Injects all implementations, including this implemenation
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_transactions-and-errors.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_transactions-and-errors.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_transactions-and-errors.adoc
deleted file mode 100644
index a3fe75c..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_transactions-and-errors.adoc
+++ /dev/null
@@ -1,33 +0,0 @@
-[[_ugbtb_more-advanced_transactions-and-errors]]
-= Transactions and Errors
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-In Apache Isis, every action invocation (in fact, every interaction) is automatically wrapped in a transaction, and any repository query automatically does a flush.
-
-What that means is that there's no need to explicitly start or commit transactions in Apache Isis; this will be done for you. Indeed, if you do try to manage transactions (eg by reaching into the JDO `PersistenceManager` exposed by the xref:rgsvc.adoc#_rgsvc_api_IsisJdoSupport[IsisJdoSupport] domain service, then you are likely to confuse Isis and get a stack trace for your trouble.
-
-
-
-
-== Aborting Transactions
-
-If you want to abort Apache Isis' transaction, this can be done by throwing `RecoverableException` (or any subclass, eg `ApplicationException`). The transaction will be aborted, and the exception message will be displayed to the user.
-
-If you throw any other exception (ie not a subclass of `RecoverableException`), then the users will see an error page (if Wicket viewer) or a 500 (if Restful Objects viewer).
-
-
-
-
-
-== Raise message/errors to users
-
-NOTE: TODO - xref:rgsvc.adoc#_rgsvc_api_DomainObjectContainer_messages-api[`DomainObjectContainer`]
-
-
-
-== Exception Recognizers
-
-NOTE: TODO - xref:rgsvc.adoc#_rgsvc_spi_ExceptionRecognizer[`ExceptionRecognizer`] service
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models.adoc
deleted file mode 100644
index ad2c5cd..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models.adoc
+++ /dev/null
@@ -1,19 +0,0 @@
-[[_ugbtb_more-advanced_view-models]]
-= View Models
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-View models are a type of domain object (with state, behaviour etc) but where the state is _not_ persisted into the
- JDO/DataNucleus-managed database, but is instead converted to/from a string memento, and held by the calling client.
-This opens up a number of more advanced use cases.
-
-In this topic we'll explore those use cases, and learn the programming model and conventions to use view models in your application.
-
-
-include::_ugbtb_more-advanced_view-models_use-cases.adoc[leveloffset=+1]
-include::_ugbtb_more-advanced_view-models_programming-model.adoc[leveloffset=+1]
-include::_ugbtb_more-advanced_view-models_jaxb.adoc[leveloffset=+1]
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_jaxb.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_jaxb.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_jaxb.adoc
deleted file mode 100644
index 51eef39..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_jaxb.adoc
+++ /dev/null
@@ -1,240 +0,0 @@
-[[_ugbtb_more-advanced_view-models_jaxb]]
-= JAXB-annotated DTOs (`1.11.0-SNAPSHOT`)
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-
-
-This section provides some recommended practices if using JAXB and `@XmlRootElement` to define domain models. The
-examples are taken from the (non-ASF) http://github.com/isisaddons/isis-app-todoapp[Isis addons' todoapp].
-
-
-
-[[_ugbtb_more-advanced_view-models_jaxb_using-packages-to-version]]
-== Use packages to version DTOs
-
-The whole point of using DTOs (in Apache Isis, at least) is to define a formal contact between two interoperating but
-independent applications. Since the only thing we can predicate about the future with any certainty is that it one or
-both of these applications will change, we should version DTOs from the get-go.
-
-With XML every element may be defined as belonging to a particular namespace; in JAXB this translates to Java packages.
-We therefore should place each DTO within its own package, and that package should include a version identifier.
-
-For example, the http://github.com/isisaddons/isis-app-todoapp[Isis addons' todoapp] defines this DTO (as a versioned
-representation of its underlying `ToDoItem` entity):
-
-[source,java]
-----
-@XmlRootElement(name = "toDoItemDto") // <1>
-@XmlType(
- propOrder = { // <2>
- "description",
- "category",
- "subcategory",
- "cost"
- }
-)
-@DomainObjectLayout(
- titleUiEvent = TitleUiEvent.Doop.class // <3>
-)
-public class ToDoItemDto implements Dto {
- @XmlElement(required = true)
- @Getter @Setter // <4>
- protected String description;
-
- @XmlElement(required = true)
- @Getter @Setter
- protected String category;
-
- @Getter @Setter
- protected String subcategory;
-
- @Getter @Setter
- protected BigDecimal cost;
-}
-----
-<1> identifies this class as a view model and defines the root element for JAXB serialization
-<2> all properties in the class must be listed; (they can be ignored using `@XmlTransient`)
-<3> demonstrating use of UI events for a subscriber to provide the DTO's title; see xref:rgant.adoc#_rgant-DomainObjectLayout_titleUiEvent[`@DomainObjectLayout#titleUiEvent()`].
-<4> optional; JAXB metadata can specify such attributes as required/optional
-
-
-For the package in which the DTO class resides, we define a corresponding namespace. This goes in `package-info.java`:
-
-[source,java]
-----
-@javax.xml.bind.annotation.XmlSchema(
- namespace = "http://viewmodels.app.todoapp/todoitem/v1_0/todoitem.xsd", // <1>
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
-)
-package todoapp.app.viewmodels.todoitem.v1_0; // <2>
-----
-<1> the namespace URI, used by the DTO residing in this package. There is no requirement for this to correspond to a physical URL, but it should be unique (this
-usually implies the usage of a company domain name).
-<2> the package in which the DTO resides.
-
-Note how both the XML namespace and package are broadly equivalent to each other; in particular note that they both
-also include a version "v1_0".
-
-
-
-
-[[_ugbtb_more-advanced_view-models_jaxb_semantic-versioning]]
-== Semantic Versioning
-
-Versioning DTOs enables us to make changes without breaking existing consumers of the data. We can distinguish two
-types of changes:
-
-* backwardly compatible changes
-* breaking changes.
-
-Following link:http://semver.org[semantic versioning] approach, we suggest using `v1_0`, `v1_1`, `v1_2` etc as the
-package version for a sequence of backwardly compatible changes, then bump up to `v2_0` for a breaking change.
-
-Backwardly compatible changes can generally (always?) be modelled using class inheritance. Thus, `v1_1.ToDoItemDto`
-is a subclass of `v1_0.ToDoItemDto`. This makes sense too: OO inheritance means "is-substitutable-for", so what is
-true in an OO context is true when processing XML documents.
-
-On the other hand, breaking changes probably (always?) imply that the next version of the DTO does not use inheritance.
-Thus `v2_0.ToDoItemDto` might share many of the same properties as the `v1_1.ToDoItemDto`, but any reuse would be
-copy-n-paste rather than through inheritance.
-
-To see this in practice, here's (the outline of) v1.1 of `ToDoItemDto`:
-
-[source,java]
-----
-package todoapp.app.viewmodels.todoitem.v1_1;
-...
-@XmlRootElement(name = "toDoItemDto")
-@XmlType(
- propOrder = {
- "toDoItem",
- "similarItems"
- }
-)
-public class ToDoItemDto extends todoapp.app.viewmodels.todoitem.v1_0.ToDoItemDto {
- ...
-}
-----
-
-
-The corresponding `package-info.java` is similar to that for `v1_0`, though note how it also defines a namespace prefix
-for `v1_0`:
-
-[source,java]
-----
-@javax.xml.bind.annotation.XmlSchema(
- namespace = "http://viewmodels.app.todoapp/todoitem/v1_1/todoitem.xsd", <!--1-->
- xmlns = {
- @javax.xml.bind.annotation.XmlNs( <!--2-->
- namespaceURI = "http://isis.apache.org/schema/common",
- prefix = "common"
- ),
- @javax.xml.bind.annotation.XmlNs(
- namespaceURI = "http://viewmodels.app.todoapp/todoitem/v1_0/todoitem.xsd",
- prefix = "todoitem-v1_0"
- )
- },
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
-)
-package todoapp.app.viewmodels.todoitem.v1_1;
-----
-<1> namespace URI for DTO in this class.
-<2> aliases for any other namespaces referenced.
-
-
-
-[[_ugbtb_more-advanced_view-models_jaxb_referencing-domain-entities]]
-== Referencing Domain Entities
-
-It's quite common for view models to be "backed by" (be projections of) some underlying domain entity. The
-`ToDoItemDto` we've been using as the example in this section is an example: there is an underlying `ToDoItem` entity.
-
-It wouldn't make sense to serialize out the state of a persistent entity: the point of a DTO is to act as a facade
-on top of the entity so that the implementation details (of the entity's structure) don't leak out to the consumer.
-However, the identity of the underlying entity can be well defined; Apache Isis defines the
-xref:rgcms.adoc#_rgcms_schema-common[Common schema] which defines the `<oid-dto>` element (and corresponding `OidDto` class):
-the object's type and its identifier. This is basically a formal XML equivalent to the `Bookmark` object obtained
-from the xref:rgsvc.adoc#_rgsvc_api_BookmarkService[`BookmarkService`].
-
-There is only one requirement to make this work: every referenced domain entity must be annotated with
-xref:rgant.adoc#_rgant-XmlJavaTypeAdapter[`@XmlJavaTypeAdapter`], specifying the framework-provided
-`PersistentEntityAdapter.class`. This class is similar to the `BookmarkService`: it knows how to create an `OidDto`
-from an object reference.
-
-Thus, in our view model we can legitimately write:
-
-[source,java]
-----
-package todoapp.app.viewmodels.todoitem.v1_1;
-...
-public class ToDoItemDto extends todoapp.app.viewmodels.todoitem.v1_0.ToDoItemDto {
- ...
- @Getter @Setter
- protected ToDoItem toDoItem;
-}
-----
-
-All we need to do is remember to add that `@XmlJavaTypeAdapter` annotation to the referenced entity:
-
-[source,java]
-----
-@XmlJavaTypeAdapter(PersistentEntityAdapter.class)
-public class ToDoItem ... {
- ...
-}
-----
-
-
-
-[[_ugbtb_more-advanced_view-models_jaxb_collections]]
-== Collections
-
-It's also possible for a DTO to hold collections of objects. These can be of any type, either simple properties, or
-references to other objects.
-
-The only bit of boilerplate that is required is the `@XmlElementWrapper` annotation. This instructs JAXB to create
-an XML element (based on the field name) to contain each of the elements. (If this is omitted then the contents of
-the collection are at the same level as the properties; almost certainly not what is required).
-
-For example, the v1.1 of the `ToDoItemDto` could also contain:
-
-[source,java]
-----
-package todoapp.app.viewmodels.todoitem.v1_1;
-...
-public class ToDoItemDto extends todoapp.app.viewmodels.todoitem.v1_0.ToDoItemDto {
- ...
- @XmlElementWrapper
- @XmlElement(name = "todoItem")
- @Getter @Setter
- protected List<ToDoItem> similarItems = Lists.newArrayList();
-}
-----
-
-
-There's nothing to prevent a JAXB DTO from containing rich graphs of data, parent containing children containing
-children. Be aware though that all of this state will become the DTO's memento, ultimately converted into a URL-safe
-form, by way of the xref:rgsvc.adoc#_rgsvc_spi_UrlEncodingService[`UrlEncodingService`].
-
-There are limits to the lengths of URLs, however. Therefore the DTO should not include state that can easily be
-derived from other information. If the URL does exceed limits, then provide a custom implementation of `UrlEncodingService`
-to handle the memento string in some other fashion (eg substituting it with a GUID, with the memento cached somehow
-on the server).
-
-
-
-
-
-== Generating XSDs and DTOs
-
-The xref:cg.adoc#_cg_isis-maven-plugin[Apache Isis maven plugin] provides the xref:cg.adoc#_cg_isis-maven-plugin_xsd[xsd] goal that allows the XSDs to be generated from any JAXB-annotated view models.
-These use the xref:rgsvc.adoc#_rgsvc_api_JaxbService[`JaxbService`] to generate the schemas; using the
-standard `schemagen` command line will not correctly interpret any references to domain entities as OIDs.
-
-The documentation for the `xsd` goal also explains how to generate DTO classes from the generated XSDs. Note that these
-DTOs are not the same as the JAXB view models; they can be used outside of an Isis application, for example in a
-standalone subscriber running on an enterprise service bus such as Apache Camel.
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_programming-model.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_programming-model.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_programming-model.adoc
deleted file mode 100644
index 29cafd8..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_programming-model.adoc
+++ /dev/null
@@ -1,87 +0,0 @@
-[[_ugbtb_more-advanced_view-models_programming-model]]
-= Programming Model
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-
-So much for the theory; how should view models be implemented? Fundamentally all view models' state is serialized into
-a string memento; this memento is then held by the client (browser) in the form of a URL. As you might imagine, this
-URL can become quite long, but Apache Isis offers a mechanism (the xref:rgsvc.adoc#_rgsvc_spi_UrlEncodingService[`UrlEncodingService`]) if it exceeds the maximum length for a URL
-(2083 characters). Also, of course, this string memento must only contain characters that it is valid for use within
-a URL.
-
-While the underlying technique is the same irrespective of use case, the programming model provides various ways of
-defining a view model so that the original intent is not lost. They are:
-
-.View model programming model
-[cols="1a,4a,2a", options="header"]
-|===
-
-| Use case
-| Code
-| Description
-
-
-| External entity
-|[source,java]
-----
-@DomainObject(nature=Nature.EXTERNAL_ENTITY)
-public class CustomerRecordOnSAP { ... }
-----
-|Annotated with xref:rgant.adoc#_rgant-DomainObject_nature[`@DomainObject#nature()`] and a nature of `EXTERNAL_ENTITY`, with memento derived automatically from the properties of the domain object. Collections are ignored, as are any properties annotated as xref:rgant.adoc#_rgant-Property_notPersisted[not persisted].
-
-| In-memory entity
-|[source,java]
-----
-@DomainObject(nature=Nature.INMEMORY_ENTITY)
-public class Log4JAppender { ... }
-----
-|As preceding, but using a nature of `INMEMORY_ENTITY`.
-
-|Application view model
-|[source,java]
-----
-@DomainObject(nature=Nature.VIEW_MODEL)
-public class Dashboard { ... }
-----
-|As preceding, but using a nature of `VIEW_MODEL`.
-
-|Application view model
-|
-[source,java]
-----
-@ViewModel
-public class Dashboard { ... }
-----
-
-|Annotated with xref:rgant.adoc#_rgant-ViewModel[`@ViewModel`] annotation (effectively just an alias)' memento is as preceding: from "persisted" properties, collections ignored
-
-|Application view model
-|
-[source,java]
-----
-public class ExcelUploadManager implements ViewModel {
- public String viewModelMemento() { ... }
- public void viewModelInit(String memento) { ... }
-}
-|Implement xref:rgcms.adoc#_rgcms_classes_super_ViewModel[`ViewModel`] interface. The memento is as defined by the
-interface's methods: the programmer has full control (but also full responsibility) for the string memento.
-
-|DTO (`1.11.0-SNAPSHOT`)
-|
-[source,java]
-----
-@XmlRootElement("customer")
-public class CustomerDto { ... }
-----
-|Annotate using JAXB xref:rgant.adoc#_rgant-XmlRootElement[`@XmlRootElement`] annotation. Memento
-derived automatically by serializing the XML graph as implied by the JAXB annotations. Note that (unlike `@ViewModel`
-et al) this state _can_ include collections.
-|===
-
-JAXB-annotated DTOs are discussed in more detail immediately xref:rg.adoc#_ugbtb_more-advanced_view-models_jaxb[below].
-
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_use-cases.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_use-cases.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_use-cases.adoc
deleted file mode 100644
index 3a10b53..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_more-advanced_view-models_use-cases.adoc
+++ /dev/null
@@ -1,142 +0,0 @@
-[[_ugbtb_more-advanced_view-models_use-cases]]
-= Use Cases
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-:_basedir: ../
-:_imagesdir: images/
-
-
-When developing an Apache Isis application you will most likely start off with the persistent domain entities:
-`Customer`, `Order`, `Product`, and so on. For some applications this may well suffice. However, if the application
-needs to integrate with other systems, or if the application needs to support reasonably complex business processes, then you may need to look beyond just domain entities. This section explores these use cases.
-
-== Externally-managed entities
-
-Sometimes the entities that make up your application are persisted not in the local JDO/DataNucleus database
-but reside in some other system, for example accessible only through a SOAP web service. Logically that data
-might still be considered a domain entity and we might want to associate behaviour with it, however it cannot be
-modelled as a domain entity if only because JDO/DataNucleus doesn't know about the entity nor how to retrieve or
-update it.
-
-There are a couple of ways around this: we could either replicate the data somehow from the external system into the
- Isis-managed database (in which case it is once again just another domain entity), or we could set up a stub/proxy for
- the externally managed entity. This proxy would hold the reference to the externally-managed domain entity (eg an
- external id), as well as the "smarts" to know how to interact with that entity (by making SOAP web service calls etc).
-
-The stub/proxy is a type of view model: a view - if you like - onto the domain entity managed by the external system.
-
-[NOTE]
-====
-DataNucleus does in fact define its own link:http://www.datanucleus.org/documentation/extensions/store_manager.html[Store Manager] extension point, so an alternative architecture would be to implement this interface such that DataNucleus
-could make the calls to the external system; these externally-persisted domain entities would therefore be modelled as regular `@PersistenceCapable` entities after all. For entities not persisted externally the implementation would delegate down to the default RDBMS-specific `StoreManager` provided by DataNucleus itself.
-
-An implementation that supported only reading from an external entity ought to be comparatively straight-forward, but
-implementing one that also supported updating external entities would need to carefully consider error conditions if the
-external system is unavailable; distributed transactions are most likely difficult/impossible to implement (and not
-desirable in any case).
-====
-
-
-== In-memory entities
-
-As a variation on the above, sometimes there are domain objects that are, conceptually at least entities, but whose
-state is not actually persisted anywhere, merely held in-memory (eg in a hash).
-
-A simple example might be read-only configuration data that is read from a config file (eg log4j appender
-definitions) but thereafter is presented in the UI just like any other entity.
-
-
-== Application-layer view models
-
-Domain entities (whether locally persisted using JDO/DataNucleus or managed externally) are the bread-and-butter of Apache Isis applications: the focus after all, should be on the business domain concepts and ensuring that they are
-solid. Generally those domain entities will make sense to the business domain experts: they form the _ubiquitous language_ of the domain. These domain entities are part of the domain layer.
-
-That said, it may not always be practical to expect end-users of the application to interact solely with those domain
-entities. For example, it may be useful to show a dashboard of the most significant data in the system to a user,
-often pulling in and aggregating information from multiple points of the app. Obtaining this information by hand (by
- querying the respective services/repositories) would be tedious and slow; far better to have a dashboard do the job for
- the end user.
-
-A dashboard object is a model of the most relevant state to the end-user, in other words it is (quite literally) a view
- model. It is not a persisted entity, instead it belongs to the application layer.
-
-A view model need not merely aggregate data; it could also provide actions of its own. Most likely these actions will
-be queries and will always ultimately just delegate down to the appropriate domain-layer service/repository. But in
-some cases such view model actions might also modify state of underlying domain entities.
-
-Another common use for view models is to help co-ordinate complex business processes; for example to perform a
-quarterly invoicing run, or to upload annual interest rates from an Excel spreadsheet. In these cases the view model
-might have some state of its own, but in most cases that state does not need to be persisted per se.
-
-.Desire Lines
-****
-One way to think of application view models is as modelling the "desire line": the commonly-trod path
-that end-users must follow to get from point A to point B as quickly as possible.
-
-To explain: there are link:http://ask.metafilter.com/62599/Where-the-sidewalk-ends[documented]
-link:https://sivers.org/walkways[examples]
-link:http://www.softpanorama.org/People/Wall/larry_wall_articles_and_interviews.shtml[that] architects of university
-campus will only add in paths some while after the campus buildings are complete: let the pedestrians figure out the
-routes they want to take. The name we like best for this idea is "desire lines", though it has also been called
-a "desire path", "paving the path" or "paving the sidewalk".
-
-What that means is you should add view models _after_ having built up the domain layer, rather than before. These view
-models pave that commonly-trod path, automating the steps that the end-user would otherwise have to do by hand.
-
-It takes a little practice though, because even when building the domain layer "first", you should still bear in mind
-what the use cases are that those domain entities are trying to support. You certainly _shouldn't_ try to build out a
-domain layer that could support every conceivable use case before starting to think about view models.
-
-Instead, you should iterate. Identify the use case/story/end-user objective that you will deliver value to the
-business. Then build out the minimum domain entities to support that use case (refining the xref:ugfun.adoc#_ugfun_core-concepts_philosophy_domain-driven-design_ubiquitous-language[ubiquitous language] as you
-go). Then, identify if there any view models that could be introduced which would simplify the end-user interactions
-with the system (perhaps automating several related use cases together).
-****
-
-== DTOs (`1.11.0-SNAPSHOT`)
-
-DTOs (data transfer objects) are simple classes that (according to link:https://en.wikipedia.org/wiki/Data_transfer_object[wikipedia]) "carries data between processes".
-
-If those two processes are parts of the same overall application (the same team builds and deploys both server and
-client) then there's generally no need to define a DTO; just access the entities using Apache Isis'
-xref:ugvro.adoc#[RestfulObjects viewer].
-
-On the other hand, if the client consuming the DTO is a different application -- by which we mean developed/deployed by
-a different (possible third-party) team -- then the DTOs act as a formal contract between the provider and the consumer.
-In such cases, exposing domain entities over xref:ugvro.adoc#[RestfulObjects] would be
-"A Bad Thing"(TM) because the consumer would in effect have access to implementation details that could then not be
-easily changed by the producer.
-
-Instead, a view model can be defined to act as a DTO. To put this formal contract onto a solid footing, this view
-model can (as of `1.11.0-SNAPSHOT`) simply be defined as a JAXB-annotated entity; this allows the consumer to obtain
-the DTO in XML format along with a corresponding XSD schema describing the structure of that XML. These XML
-representations can be surfaced by the xref:ugvro.adoc#[RestfulObjects viewer] (by implementing
-the xref:rgsvc.adoc#_rgsvc_spi_ContentMappingService[`ContentMappingService`]); the XSD can be obtained
-using the xref:rgsvc.adoc#_rgsvc_api_JaxbService[`JaxbService`]. Using the formalism of XML also allows
-DTOs to be carefully and properly versioned using XML namespaces.
-
-[TIP]
-====
-If the view model DTO implements the xref:rgcms.adoc#_rgcms_classes_mixins_Dto[`Dto`] marker interface, then the framework
-will also provide the ability to download the XML or its XSD directly from the UI.
-====
-
-In case it's not clear, these DTOs are still usable as "regular" view models; they will render in the xref:ugvw.adoc#[Wicket viewer] just like any other. Indeed (as the xref:ugbtb.adoc#_ugbtb_more-advanced_view-models_programming-model[programming model] section below makes clear), these
-JAXB-annotated view models are in many regards the most powerful of all the view model alternatives.
-
-
-== ESB Subscribers
-
-One important variation of the DTO use case concerns subscribers on an enterprise event bus such as
-link:http://camel.apache.org[Apache Camel(TM)] and similar.
-
-A xref:rgsvc.adoc#_rgsvc_spi_PublishingService[`PublishingService`] implementation (eg that provided by
-(non-ASF) http://github.com/isisaddons/isis-module-publishmq[Isis addons' publishmq] module) can publish XML events
-onto a message queue, typically representing action invocations within the originating Isis application. The ESB
-(Apache Camel) then dispatches this event to all interested subscribers. These subscribers represent external systems
-in the enterprise, managed by other teams, and so act as the third-party consumers of the data.
-
-Rather than try to anticipate their requirements and push the data that these subscribers might need into the original
-XML event (a hopeless task), DTO objects can be defined to allow these consumers to call back to the publishing Isis
-application to obtain the data they need.
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques.adoc
new file mode 100644
index 0000000..d03bf12
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques.adoc
@@ -0,0 +1,22 @@
+[[_ugbtb_other-techniques]]
+= Other Techniques
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+
+
+This chapter pulls together a number of more advanced techniques that we've discovered and developed while building our own Isis applications.
+
+
+include::_ugbtb_other-techniques_overriding-jdo-annotations.adoc[leveloffset=+1]
+include::_ugbtb_other-techniques_mapping-rdbms-views.adoc[leveloffset=+1]
+include::_ugbtb_other-techniques_transactions-and-errors.adoc[leveloffset=+1]
+include::_ugbtb_other-techniques_multi-tenancy.adoc[leveloffset=+1]
+include::_ugbtb_other-techniques_persisted-title.adoc[leveloffset=+1]
+include::_ugbtb_other-techniques_replacing-default-service-implementations.adoc[leveloffset=+1]
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_mapping-rdbms-views.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_mapping-rdbms-views.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_mapping-rdbms-views.adoc
new file mode 100644
index 0000000..7bc2d12
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_mapping-rdbms-views.adoc
@@ -0,0 +1,9 @@
+[[_ugbtb_other-techniques_mapping-rdbms-views]]
+= Mapping RDBMS Views
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+
+NOTE: TODO - as used in link:http://github.com/estatio/estatio[Estatio]
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_multi-tenancy.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_multi-tenancy.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_multi-tenancy.adoc
new file mode 100644
index 0000000..6bc2936
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_multi-tenancy.adoc
@@ -0,0 +1,8 @@
+[[_ugbtb_other-techniques_multi-tenancy]]
+= Multi-tenancy
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+NOTE: TODO - as supported by (non-ASF) http://github.com/isisaddons/isis-module-security[Isis addons' security] module.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_overriding-jdo-annotations.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_overriding-jdo-annotations.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_overriding-jdo-annotations.adoc
new file mode 100644
index 0000000..ffada22
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_overriding-jdo-annotations.adoc
@@ -0,0 +1,64 @@
+[[_ugbtb_other-techniques_overriding-jdo-annotations]]
+= Overriding JDO Annotations
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+
+
+The JDO Objectstore (or rather, the underlying DataNucleus implementation) builds its own persistence metamodel by reading both annotations on the class and also by searching for metadata in XML files. The metadata in the XML files takes precedence over the annotations, and so can be used to override metadata that is "hard-coded" in annotations.
+
+For example, as of 1.9.0 the various http://www.isisaddons.org[Isis addons] modules (not ASF) use schemas for each entity. For example, the `AuditEntry` entity in the http://github.com/isisaddons/isis-module-audit[audit module] is annotated as:
+
+[source,java]
+----
+@javax.jdo.annotations.PersistenceCapable(
+ identityType=IdentityType.DATASTORE,
+ schema = "IsisAddonsAudit",
+ table="AuditEntry")
+public class AuditEntry {
+ ...
+}
+----
+
+This will map the `AuditEntry` class to a table `"IsisAddonsAudit"."AuditEntry"`; that is using a custom schema to own the object.
+
+Suppose though that for whatever reason we didn't want to use a custom schema but would rather use the default. We can override the above annotation using a `package.jdo` file, for example:
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8" ?>
+<jdo xmlns="http://xmlns.jcp.org/xml/ns/jdo/jdo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/jdo/jdo
+ http://xmlns.jcp.org/xml/ns/jdo/jdo_3_0.xsd" version="3.0">
+ <package name="org.isisaddons.module.audit.dom">
+ <class name="AuditEntry" schema="PUBLIC" table="IsisAddonsAuditEntry">
+ </class>
+ </package>
+</jdo>
+----
+
+This file should be placed can be placed in `src/main/java/META-INF` within your application's `dom` module.
+
+[TIP]
+====
+(As of `1.11.0-SNAPSHOT`) you can use a mixin action on xref:rgcms.adoc#_rgcms_classes_mixins_Persistable[`Persistable`] mixin
+to download the JDO class metadata in XML form.
+====
+
+
+[NOTE]
+====
+* The same approach should work for any other JDO metadata, but some experimentation might be required.+
++
+For example, in writing up the above example we found that writing `schema=""` (in an attempt to say, "use the default schema for this table") actually caused the original annotation value to be used instead.
+
+* Forcing the schema to "PUBLIC" (as in the above example) works, but it isn't ideal because the name "PUBLIC" is not vendor-neutral (it works for HSQLDB, but MS SQL Server uses "dbo" as its default).
+
+* As of 1.9.0 Apache Isis will automatically (attempt) to create the owning schema for a given table if it does not exist. This behaviour can be customized, as described in the section on xref:_ugbtb_decoupling_db-schemas[using modules].
+
+* You may need to override the entire class metadata rather than individual elements; the mixin (`1.11.0-SNAPSHOT`) mentioned above can help here.
+====
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_persisted-title.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_persisted-title.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_persisted-title.adoc
new file mode 100644
index 0000000..ea3a88e
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_persisted-title.adoc
@@ -0,0 +1,82 @@
+[[_ugbtb_other-techniques_persisted-title]]
+= Persisted Title
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+
+
+Normally the title of an object is not persisted to the database, rather it is recomputed automatically from underlying properties. On occasion though you might want the title to also be persisted; either to make things easier for the DBA, or for an integration scenario, or some other purpose.
+
+We can implement this feature by leveraging the xref:rgcms.adoc#_rgcms_methods_lifecycle_jdo-api[JDO lifecycle]. In the design we discuss here we make it a responsibility of the entities to persist the title as a property, by implementing a `ObjectWithPersistedTitle` interface:
+
+[source,java]
+----
+public interface ObjectWithPersistedTitle {
+ @PropertyLayout(hidden = Where.EVERYWHERE) // <1>
+ String getTitle();
+ void setTitle(final String title);
+}
+----
+<1> we don't want to expose this in the UI because the title is already prominently displayed.
+
+We can then define a subscribing domain service that leverage this.
+
+[source,java]
+----
+@DomainService(nature = NatureOfService.DOMAIN)
+public class TitlingService extends AbstractSubscriber {
+ @Subscribe
+ public void on(final ObjectPersistingEvent ev) {
+ handle(ev.getSource());
+ }
+ @Subscribe
+ public void on(final ObjectUpdatingEvent ev) {
+ handle(ev.getSource());
+ }
+ private void handle(final Object persistentInstance) {
+ if(persistentInstance instanceof ObjectWithPersistedTitle) {
+ final ObjectWithPersistedTitle objectWithPersistedTitle =
+ (ObjectWithPersistedTitle) persistentInstance;
+ objectWithPersistedTitle.setTitle(container.titleOf(objectWithPersistedTitle));
+ }
+ }
+ @Inject
+ private DomainObjectContainer container;
+}
+----
+
+Prior to 1.10.0 (when lifecycle events were introduced), this could also be be done by accessing the JDO API directly:
+
+[source,java]
+----
+@RequestScoped
+@DomainService(nature = NatureOfService.DOMAIN)
+public class TitlingService {
+ @PostConstruct
+ public void init() {
+ isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(
+ new StoreLifecycleListener() {
+ @Override
+ public void preStore(final InstanceLifecycleEvent event) {
+ final Object persistentInstance = event.getPersistentInstance();
+ if(persistentInstance instanceof ObjectWithPersistedTitle) {
+ final ObjectWithPersistedTitle objectWithPersistedTitle =
+ (ObjectWithPersistedTitle) persistentInstance;
+ objectWithPersistedTitle.setTitle(container.titleOf(objectWithPersistedTitle));
+ }
+ }
+ @Override
+ public void postStore(final InstanceLifecycleEvent event) {
+ }
+ }, null);
+ }
+ @Inject
+ private IsisJdoSupport isisJdoSupport;
+ @Inject
+ private DomainObjectContainer container;
+}
+----
+
+The above is probably the easiest and most straightforward design. One could imagine other designs where the persisted title is stored elsewhere. It could even be stored off into an link:http://lucene.apache.org/[Apache Lucene] (or similar) database to allow for free-text searches.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_replacing-default-service-implementations.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_replacing-default-service-implementations.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_replacing-default-service-implementations.adoc
new file mode 100644
index 0000000..bff0d40
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_replacing-default-service-implementations.adoc
@@ -0,0 +1,64 @@
+[[_ugbtb_other-techniques_replacing-default-service-implementations]]
+= Replacing Service Implns
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+
+
+The framework provides default implementations for many of the xref:rgsvc.adoc#_rgsvc_api[API Services]. This is convenient, but sometimes you will want to replace the default implementation with your own service implementation.
+
+The trick is to use the xref:rgant.adoc#_rgant-DomainServiceLayout_menuOrder[`@DomainServiceLayout#menuOrder()`] attribute, specifying a low number (typically `"1"`).
+
+For example, suppose you wanted to provide your own implementation of xref:rgsvc.adoc#_rgsvc_api_LocaleProvider[`LocaleProvider`]. Here's how:
+
+[source,java]
+----
+@DomainService(
+ nature = NatureOfService.DOMAIN
+)
+@DomainServiceLayout(
+ menuOrder = "1" // <1>
+)
+public class MyLocaleProvider implements LocaleProvider {
+ @Override
+ public Locale getLocale() {
+ return ...
+ }
+}
+----
+<1> takes precedence over the default implementation.
+
+
+It's also quite common to want to decorate the existing implementation (ie have your own implementation delegate to the default); this is also possible and quite easy if using `1.10.0` or later:
+
+[source,java]
+----
+@DomainService(
+ nature = NatureOfService.DOMAIN
+)
+@DomainServiceLayout(
+ menuOrder = "1" // <1>
+)
+public class MyLocaleProvider implements LocaleProvider {
+ @Override
+ public Locale getLocale() {
+ return getDelegateLocaleProvider().getLocale(); // <2>
+ }
+ Optional<LocaleProvider> delegateLocaleProvider; // <3>
+ private LocaleProvider getDelegateLocaleProvider() {
+ if(delegateLocaleProvider == null) {
+ delegateLocaleProvider = Iterables.tryFind(localeProviders, input -> input != this); // <4>
+ }
+ return delegateLocaleProvider.orNull();
+ }
+ @Inject
+ List<LocaleProvider> localeProviders; // <5>
+}
+----
+<1> takes precedence over the default implementation when injected elsewhere.
+<2> this implementation merely delegates to the default implementation
+<3> lazily populated
+<4> delegate to the first implementation that isn't _this_ implementation (else infinite loop!)
+<5> Injects all implementations, including this implemenation
+
http://git-wip-us.apache.org/repos/asf/isis/blob/29452af6/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_transactions-and-errors.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_transactions-and-errors.adoc b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_transactions-and-errors.adoc
new file mode 100644
index 0000000..19eb19e
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_ugbtb_other-techniques_transactions-and-errors.adoc
@@ -0,0 +1,33 @@
+[[_ugbtb_other-techniques_transactions-and-errors]]
+= Transactions and Errors
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+:_basedir: ../
+:_imagesdir: images/
+
+In Apache Isis, every action invocation (in fact, every interaction) is automatically wrapped in a transaction, and any repository query automatically does a flush.
+
+What that means is that there's no need to explicitly start or commit transactions in Apache Isis; this will be done for you. Indeed, if you do try to manage transactions (eg by reaching into the JDO `PersistenceManager` exposed by the xref:rgsvc.adoc#_rgsvc_api_IsisJdoSupport[IsisJdoSupport] domain service, then you are likely to confuse Isis and get a stack trace for your trouble.
+
+
+
+
+== Aborting Transactions
+
+If you want to abort Apache Isis' transaction, this can be done by throwing `RecoverableException` (or any subclass, eg `ApplicationException`). The transaction will be aborted, and the exception message will be displayed to the user.
+
+If you throw any other exception (ie not a subclass of `RecoverableException`), then the users will see an error page (if Wicket viewer) or a 500 (if Restful Objects viewer).
+
+
+
+
+
+== Raise message/errors to users
+
+NOTE: TODO - xref:rgsvc.adoc#_rgsvc_api_DomainObjectContainer_messages-api[`DomainObjectContainer`]
+
+
+
+== Exception Recognizers
+
+NOTE: TODO - xref:rgsvc.adoc#_rgsvc_spi_ExceptionRecognizer[`ExceptionRecognizer`] service
+