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 2014/01/19 16:14:40 UTC

svn commit: r1559504 - in /isis/site/trunk/content: ./ applib-guide/how-tos/

Author: danhaywood
Date: Sun Jan 19 15:14:40 2014
New Revision: 1559504

URL: http://svn.apache.org/r1559504
Log:
isis docs

Added:
    isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.md
      - copied, changed from r1557348, isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.md
Removed:
    isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.md
    isis/site/trunk/content/applib-guide/how-tos/how-to-01-020-How-to-have-a-domain-service-be-a-POJO.md
Modified:
    isis/site/trunk/content/applib-guide/how-tos/about.md
    isis/site/trunk/content/applib-guide/how-tos/how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.md
    isis/site/trunk/content/documentation.md

Modified: isis/site/trunk/content/applib-guide/how-tos/about.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/applib-guide/how-tos/about.md?rev=1559504&r1=1559503&r2=1559504&view=diff
==============================================================================
--- isis/site/trunk/content/applib-guide/how-tos/about.md (original)
+++ isis/site/trunk/content/applib-guide/how-tos/about.md Sun Jan 19 15:14:40 2014
@@ -13,9 +13,7 @@ as factories and repositories. Domain en
 properties and collections; domain services do not. Both domain entities
 and services have behaviour, in the form of actions.
 
-* [How to have a domain entity be a POJO](./how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.html)
-
-* [How to have a domain service be a POJO](./how-to-01-020-How-to-have-a-domain-service-be-a-POJO.html)
+* [How to have a domain entity/service be a POJO](./how-to-01-010-How-to-have-a-domain-object-be-a-POJO.html)
 
 * [How to add a property to a domain entity](./how-to-01-030-How-to-add-a-property-to-a-domain-entity.html)
 

Copied: isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.md (from r1557348, isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.md)
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.md?p2=isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.md&p1=isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.md&r1=1557348&r2=1559504&rev=1559504&view=diff
==============================================================================
--- isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.md (original)
+++ isis/site/trunk/content/applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.md Sun Jan 19 15:14:40 2014
@@ -1,17 +1,35 @@
-How to have a domain entity be a POJO (not inherit from framework superclasses)
+Pojos vs framework superclasses
 -------------------------------------------------------------------------------
 
-It isn't mandatory for domain entities to inherit from any framework
-superclass; they can be plain old java objects (pojos) if required.
+It isn't mandatory for either domain entities or domain services to inherit from any framework superclass; they can be plain old java objects (pojos) if required.
+
 However, they do at a minimum need to have a
-`org.apache.isis.applib.DomainObjectContainer` injected into them (an
-interface), from which other framework services can be accessed.
+[`org.apache.isis.applib.DomainObjectContainer`](../reference/DomainObjectContainer.html) injected into them, from which other framework services can be accessed.
+
+    public void setContainer(DomainObjectContainer container) {
+        this.container = container;
+    }
+
+Other syntaxes supported for dependency injection are described [here](../how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.html).
 
 If you don't have a requirement to inherit from any other superclass,
-then it usually makes sense to inherit from mention
-`org.apache.isis.applib.AbstractDomainObject`, which already supports the
+then it usually makes sense to inherit from one of the abstract classes providede in the applib.
+
+### Domain entities
+
+In the case of entities, you can inherit from 
+`org.apache.isis.applib.AbstractDomainObject`.  This already supports the injection of
 `DomainObjectContainer` and has a number of convenience helper methods.
 
-<!--
-There is further coverage of DomainObjectContainer in ? and also in ?.
--->
+### Domain services
+
+In the case of services, you can inherit either from `org.apache.isis.applib.AbstractService` or from
+`org.apache.isis.applib.AbstractRepositoryAndFactory`.  Again, these support the injection of `DomainObjectContainer` and have a number of convenience
+helper methods.
+
+The diagram below shows the relationship between these types
+and the `DomainObjectContainer`.
+
+![](images/AbstractContainedObject-hierarchy.png)
+
+**For DDD'ers**: note that what this implies is that *Apache Isis* treats factories and repositories as just another type of domain service.

Modified: isis/site/trunk/content/applib-guide/how-tos/how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/applib-guide/how-tos/how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.md?rev=1559504&r1=1559503&r2=1559504&view=diff
==============================================================================
--- isis/site/trunk/content/applib-guide/how-tos/how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.md (original)
+++ isis/site/trunk/content/applib-guide/how-tos/how-to-01-150-How-to-inject-services-into-a-domain-entity-or-other-service.md Sun Jan 19 15:14:40 2014
@@ -1,8 +1,11 @@
 How to inject services into a domain entity or other service
 ------------------------------------------------------------
 
-All that is required to inject a service into an entity (or indeed into
-another service) is to provide an appropriately typed setter. The name
+Apache Isis autowires (automatically injects) domain services into each entity, as well as into the domain services themselves, using either method injection or field injection.  The applib `DomainObjectContainer` is also a service, so can be injected in exactly the same manner.
+
+### Method Injection
+
+All that is required to inject a service into a entity/service is to provide an appropriate method or field.  The name
 of the method does not matter, only that it is prefixed either "set" or "inject", is
 public, and has a single parameter of the correct type.
 
@@ -28,5 +31,19 @@ or alternatively, using 'inject' as the 
 
 Note that the method name can be anything; it doesn't need to be related to the type being injected.
 
-Note that we consider `DomainObjectContainer` to be a service too; hence
-it can be injected in exactly the same manner.
+### Field Injection
+
+Field injection is also supported, using the `javax.inject.Inject annotation`.  For example:
+
+    public class Customer {
+        @javax.inject.Inject
+        private OrderRepository orderRepository;
+        ...
+    }
+
+Although this has the least boilerplate, do note that the `private` visibility of the field makes it harder to inject mocks within unit tests.  There are two options here: either use some reflection code to inject the mock (not typesafe/refactoring friendly), or change the visibility to default (package level) visibility and ensure that the unit tests are in the same package as the code under test.
+
+### Constructor injection
+
+Simply to note that constructor injection is *not* supported by Isis (and is unlikely to be, because the JDO specification for entities requires a no-arg constructor).
+

Modified: isis/site/trunk/content/documentation.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/documentation.md?rev=1559504&r1=1559503&r2=1559504&view=diff
==============================================================================
--- isis/site/trunk/content/documentation.md (original)
+++ isis/site/trunk/content/documentation.md Sun Jan 19 15:14:40 2014
@@ -68,8 +68,7 @@ Title: Documentation
 
 ###Pojos
 
-* [Pojo as domain entity](./applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-entity-be-a-POJO.html)
-* [Pojo as domain service](./applib-guide/how-tos/how-to-01-020-How-to-have-a-domain-service-be-a-POJO.html)
+* [Pojo vs framework abstract classe](./applib-guide/how-tos/how-to-01-010-How-to-have-a-domain-object-be-a-POJO.html)
 * [Registering a domain service](./applib-guide/domain-services/how-to-09-010-How-to-register-domain-services,-repositories-and-factories.html)
 * [Entity property](./applib-guide/how-tos/how-to-01-030-How-to-add-a-property-to-a-domain-entity.html)
 * [Built-in Value Types](./applib-guide/value-types/010-Built-in-Value-Types.html)