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 2013/06/07 17:10:00 UTC

svn commit: r1490675 - in /isis/site/trunk/content: ./ components/objectstores/jdo/ components/security/shiro/ components/viewers/restfulobjects/ core/services/

Author: danhaywood
Date: Fri Jun  7 15:10:00 2013
New Revision: 1490675

URL: http://svn.apache.org/r1490675
Log:
settings services

Added:
    isis/site/trunk/content/components/objectstores/jdo/settings-services-jdo.md
    isis/site/trunk/content/core/services/settings-services.md
Modified:
    isis/site/trunk/content/components/objectstores/jdo/about.md
    isis/site/trunk/content/components/objectstores/jdo/auditing-service-jdo.md
    isis/site/trunk/content/components/objectstores/jdo/eagerly-registering-entities.md
    isis/site/trunk/content/components/objectstores/jdo/exception-recognizers-jdo.md
    isis/site/trunk/content/components/objectstores/jdo/publishing-service-jdo.md
    isis/site/trunk/content/components/objectstores/jdo/using-jndi-datasource.md
    isis/site/trunk/content/components/objectstores/jdo/workarounds.md
    isis/site/trunk/content/components/security/shiro/using-ldap.md
    isis/site/trunk/content/components/viewers/restfulobjects/about.md
    isis/site/trunk/content/components/viewers/restfulobjects/event-serializer-rospec.md
    isis/site/trunk/content/documentation.md

Modified: isis/site/trunk/content/components/objectstores/jdo/about.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/about.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/about.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/about.md Fri Jun  7 15:10:00 2013
@@ -6,17 +6,18 @@ The DataNucleus objectstore enables the 
 
 - [Maven and Eclipse](maven-and-eclipse.html)
 - [Dates, Blobs and Lazy Loading](dates-blobs-lazy-loading.html)
-- [Using a JNDI Datasource](using-jndi-datasource.html) [1.1.0-SNAPSHOT]
-- [Workarounds (the `IsisJdoSupport` service)](workarounds.html) [1.1.0-SNAPSHOT]
+- [Using a JNDI Datasource](using-jndi-datasource.html)
+- [Workarounds (the `IsisJdoSupport` service)](workarounds.html)
 - [Enabling Logging](enabling-logging.html)
 - [Deploying on the Google App Engine](deploying-on-the-google-app-engine.html)
 
 ### Applib Service Implementations:
 
-- [Eagerly Registering Entities](eagerly-registering-entities.html) [1.1.0-SNAPSHOT]
-- [Publishing Service on JDO](publishing-service-jdo.html) [1.1.0-SNAPSHOT]
-- [Auditing Service on JDO](auditing-service-jdo.html) [1.1.0-SNAPSHOT]
-- [Exception Recognizers](exception-recognizers-jdo.html) [1.1.0-SNAPSHOT]
+- [Eagerly Registering Entities](eagerly-registering-entities.html)
+- [Publishing Service on JDO](publishing-service-jdo.html)
+- [Auditing Service on JDO](auditing-service-jdo.html)
+- [Exception Recognizers](exception-recognizers-jdo.html)
+- [Settings Services](settings-services-jdo.html) [jdo-1.2.0-SNAPSHOT]
 
 ### Releases
 

Modified: isis/site/trunk/content/components/objectstores/jdo/auditing-service-jdo.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/auditing-service-jdo.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/auditing-service-jdo.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/auditing-service-jdo.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Auditing Service using JDO [1.1.0-SNAPSHOT]
+Title: Auditing Service using JDO
 
 The JDO objectstore provides a simple implementation of the applib [AuditingService](../../../core/services/auditing-service.html) that simply persists the event data into a `AuditEntry` entity.
 

Modified: isis/site/trunk/content/components/objectstores/jdo/eagerly-registering-entities.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/eagerly-registering-entities.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/eagerly-registering-entities.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/eagerly-registering-entities.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Eagerly Registering Entity Types [1.1.0-SNAPSHOT]
+Title: Eagerly Registering Entity Types
 
 Both Apache Isis and DataNucleus have their own metamodels of the domain entities.  Isis builds its metamodel by walking the graph of types from the services registered in `isis.properties`.  The JDO objectstore then takes these types and registers them with DataNucleus.
 

Modified: isis/site/trunk/content/components/objectstores/jdo/exception-recognizers-jdo.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/exception-recognizers-jdo.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/exception-recognizers-jdo.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/exception-recognizers-jdo.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Exception Recognizers [1.1.0-SNAPSHOT]
+Title: Exception Recognizers
 
 The JDO objectstore provides a number of implementations of the applib [ExceptionRecognizer](../../../core/services/exception-recognizers.html) API that will recognize SQL constraint exceptions and convert them into user-friendly error messages.  The `ExceptionRecognizerCompositeForJdoObjectStore` wraps these up into a single implementation.
 

Modified: isis/site/trunk/content/components/objectstores/jdo/publishing-service-jdo.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/publishing-service-jdo.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/publishing-service-jdo.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/publishing-service-jdo.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Publishing Service using JDO [1.1.0-SNAPSHOT]
+Title: Publishing Service using JDO
 
 The JDO objectstore provides a simple implementation of the applib [PublishingService](../../../core/services/publishing-service.html) that simply persists the event data into a `PublishedEvent` entity.
 

Added: isis/site/trunk/content/components/objectstores/jdo/settings-services-jdo.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/settings-services-jdo.md?rev=1490675&view=auto
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/settings-services-jdo.md (added)
+++ isis/site/trunk/content/components/objectstores/jdo/settings-services-jdo.md Fri Jun  7 15:10:00 2013
@@ -0,0 +1,34 @@
+Title: Settings Services using JDO [jdo-1.2.0-SNAPSHOT]
+
+The JDO objectstore provides simple implementations of the two applib [SettingsServices](../../../core/services/settings-services.html).
+
+## Application Settings
+
+In the case of `ApplicationSettingsService`, the service is implemented by `ApplicationSettingsServiceJdo`, with the `ApplicationSetting` interface is implemented by a `ApplicationSettingsJdo` entity.
+
+The service also provides the ability to create list all existing settings, create new settings (of whichever datatype), update settings, and to delete settings.
+
+These actions can be hidden using security if need be.  
+
+
+## User Settings
+
+In the case of `UserSettingsService`, the service is implemented by `UserSettingsServiceJdo`, with the `UserSetting` interface is implemented by a `UserSettingsJdo` entity.
+
+As for application settings, the user settings service also provides the ability to create list all existing settings, create new settings (of whichever datatype), update settings, and to delete settings.
+
+These actions can be hidden using security if need be.  
+
+
+### Register the Services
+
+Register the services as any other service, in `isis.properties`:
+
+<pre>
+isis.services=<i>...other services...</i>,\
+              org.apache.isis.objectstore.jdo.applib.service.settings.ApplicationSettingsServiceJdo,\
+org.apache.isis.objectstore.jdo.applib.service.settings.UserSettingsServiceJdo,\
+              ...
+</pre>
+
+Assuming that you've also configured Isis to use the JDO objectstore, you should be good to go...

Modified: isis/site/trunk/content/components/objectstores/jdo/using-jndi-datasource.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/using-jndi-datasource.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/using-jndi-datasource.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/using-jndi-datasource.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Using JNDI Datasource (1.1.0-SNAPSHOT)
+Title: Using JNDI Datasource
 
 Isis' JDO objectstore can be configured either to connect to the database using its own connection pool, or by using a container-managed datasource.
 

Modified: isis/site/trunk/content/components/objectstores/jdo/workarounds.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/workarounds.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/workarounds.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/workarounds.md Fri Jun  7 15:10:00 2013
@@ -1,29 +1,42 @@
-Title: Workarounds [1.1.0-SNAPSHOT]
+Title: Workarounds
 
-There are a number of limitations in DataNucleus' implementation of JDO, specifically with regard to 1:m bidirectional relationships.  
+The `IsisJdoSupport` service  provides a number of methods to fill in the gaps either of the Isis framework or of DataNucleus.
 
-* loading the children from the parent does not fire the `jdoPostLoad` callback (either on the entity via `javax.jdo.listener.LoadCallback` nor `javax.jdo.listener.LoadLifecycleListener`)
-
-  More precisely, this doesn't occur if the child being loaded has subclasses, and the subclasses has fields/properties that are part of the default fetch group.
-
-* persisting a child entity does not cause the parent's collection to be updated.
+## Reloading entities
+
+A [known limitation](http://www.datanucleus.org/products/datanucleus/jdo/orm/relationships.html) of DataNucleus' implementation of JDO is that persisting a child entity (in a 1:n bidirectional relationship) does not cause the parent's collection to be updated.
 
-  Note that this is documented behaviour; see this [DataNucleus page](http://www.datanucleus.org/products/datanucleus/jdo/orm/relationships.html).
+The `IsisJdoSupport#refresh(T domainObject)` method can be used to reload the parent object (or indeed any object).
+
+For example:
+
+    public Order newOrder(final Customer customer) {
+        Order order = newTransientInstance(Order.class);
+        order.setCustomer(customer);
+        persist(customer);
+        getContainer().flush(); // to database
+        isisJdoSupport.refresh(customer); // reload parent from database
+        return order;
+    }
 
-The `IsisJdoSupport` service provides a number of methods to enable workarounds for these cases.
 
-*This page will be updated if we determine that such workarounds are not (or are no longer) required.*
+## Accessing the JDO `PersistenceManager` [jdo-1.2.0-SNAPSHOT]
 
-## `IsisJdoSupport`
+Isis currently only supports JDO named queries.  If you require more flexibility than this, eg for dynamically constructed queries, then the `IsisJdoSupport` interface can be used to obtain access to the underlying JDO `PersistenceManager`.
 
-The `IsisJdoSupport` is defined in the JDO applib. It is defined as:
+For example:
 
-    package org.apache.isis.objectstore.jdo.applib.service.support;
-public interface IsisJdoSupport {
-        <T> T injected(T domainObject);
-        <T> T refresh(T domainObject);
+    public List<Order> findOrders(...) {
+        javax.jdo.PersistenceManager pm = isisJdoSupport.getPersistenceManager();
+        
+        // knock yourself out...
+        
+        return someListOfOrders;
     }
 
+    
+## Registering the Service
+
 The implementation is `IsisJdoSupportImpl`.  It is registered in `isis.properties` as per usual:
 
     isis.services = ...\
@@ -40,96 +53,4 @@ In the domain entity or service, add:
     // }}
 
 The service will then be automatically injected as normal.
-                    
-## Workaround for Lazy Loading
-
-In a bidir 1:m, we have found that in certain circumstances the post-load callback for the children is not fired.  Specifically, if the child has subclasses, and the subclass has fields/properties that are in the [default fetch group](http://db.apache.org/jdo/fetchgroups.html).
-
-A test case illustrating the problem (*though whether with the spec or the DN implementation, we are not yet sure*) can be found [here on github](https://github.com/danhaywood/test-jdo).
-
-The consequence of this is that any domain services used by the child object (including `DomainObjectContainer`) are not injected into the child.
-
-The workaround is to have the parent inject the services when returning the children.
-
-For example, suppose we have a `Customer` <->* `Order` bidir relationship, and where `Order` my have subclasses, eg `RushedOrder`.  In `Customer`, we would add a new method `getOrdersWorkaround()`:
-
-    // {{ Orders (Collection)
-    private SortedSet<Order> orders = new TreeSet<Order>();
-
-    @Persistent(mappedBy = "customer")
-    public SortedSet<Order> getOrders() {
-        return this.orders;
-    }
-
-    public void setOrders(final SortedSet<Order> orders) {
-        this.orders = orders;
-    }
-
-    public SortedSet<Order> getOrdersWorkaround() {
-        
-        if (this.orders == null) {
-            // this can happen, it would seem, by JDO/DN when it is 
-            // setting up the object with its own set impl for lazy loading.
-            return null;
-        } else {
-            // inject each element before returning it
-            return Sets.newTreeSet(
-                Iterables.transform(
-                    this.getOrders(), 
-                    new Function<Order, Order>(){
-                        public Order apply(Order order) {
-                            return isisJdoSupport.injected(order);                        
-                        }
-                    }));
-        }
-    }
-
-Alternatively, you can reload each child object.  Change:
-
-                    new Function<Order, Order>(){
-                        public Order apply(Order order) {
-                            return isisJdoSupport.injected(order);                        
-                        }
-                    }));
-
-to:
-
-                    new Function<Order, Order>(){
-                        public Order apply(Order order) {
-                            return isisJdoSupport.refresh(order);
-                        }
-                    }));
-
-Use [logging](enabling-logging.html) to determine if this makes more calls to the database than using the `injected()` method.
-
-## Handling Unmanaged Parent Relationship
-
-(Also in a bidir 1:m), we have found that the parent collection is not added to if a new child entity is persisted.
-
-There are two choices here.  The first is to ensure that there is code that manually updates each side of the relationship.  The second is to flush the changes and then to manually reload the parent entity from the database.
-
-For example, suppose we have a Customer <->* Order bidir relationship, with an action that persists an Order.  
-
-To update both sides of the relationship, use:
-
-    public Order newOrder(final Customer customer) {
-        Order order = newTransientInstance(Order.class);
-        order.setCustomer(customer);
-        customer.getOrders().add(order); // update parent's collection
-        persist(customer);
-        return order;
-    }
-
-
-Alternatively, to reload the parent, use the `IsisJdoSupport` service:
-
-    public Order newOrder(final Customer customer) {
-        Order order = newTransientInstance(Order.class);
-        order.setCustomer(customer);
-        persist(customer);
-        getContainer().flush(); // to database
-        isisJdoSupport.refresh(customer); // reload parent from database
-        return order;
-    }
-
-
+                    
\ No newline at end of file

Modified: isis/site/trunk/content/components/security/shiro/using-ldap.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/security/shiro/using-ldap.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/security/shiro/using-ldap.md (original)
+++ isis/site/trunk/content/components/security/shiro/using-ldap.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Using Shiro with an LDAP Server (1.1.0-SNAPSHOT)
+Title: Using Shiro with an LDAP Server
 
 Isis ships with an implementation of [Apache Shiro](http://shiro.apache.org)'s `Realm` class that allows user authentication and authorization to be performed against an LDAP server.
 

Modified: isis/site/trunk/content/components/viewers/restfulobjects/about.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/viewers/restfulobjects/about.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/viewers/restfulobjects/about.md (original)
+++ isis/site/trunk/content/components/viewers/restfulobjects/about.md Fri Jun  7 15:10:00 2013
@@ -8,7 +8,7 @@ The viewer is an implementation of the [
 
 ### Applib Service Implementations
 
-- [Event Serializer per RO Spec](event-serializer-rospec.html) [1.1.0-SNAPSHOT]
+- [Event Serializer per RO Spec](event-serializer-rospec.html)
 
 
 

Modified: isis/site/trunk/content/components/viewers/restfulobjects/event-serializer-rospec.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/viewers/restfulobjects/event-serializer-rospec.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/components/viewers/restfulobjects/event-serializer-rospec.md (original)
+++ isis/site/trunk/content/components/viewers/restfulobjects/event-serializer-rospec.md Fri Jun  7 15:10:00 2013
@@ -1,4 +1,4 @@
-Title: Event Serializer for the RO Spec [1.1.0-SNAPSHOT]
+Title: Event Serializer for the RO Spec
 
 The [Publishing Service](../../../core/services/publishing-service.html) enables Isis to publish action invocations and also changes of domain objects to third party systems.
 

Added: isis/site/trunk/content/core/services/settings-services.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/core/services/settings-services.md?rev=1490675&view=auto
==============================================================================
--- isis/site/trunk/content/core/services/settings-services.md (added)
+++ isis/site/trunk/content/core/services/settings-services.md Fri Jun  7 15:10:00 2013
@@ -0,0 +1,65 @@
+Title: Settings Services
+
+The `ApplicationSettingsService` and the `UserSettingsService` are two similar services that provide the ability to store either configuration settings.  With `ApplicationSettingsService` these settings have global scope; for the `UserSettingsService` the settings are stored per user.
+
+The core applib defines only interfaces and some convenience abstract classes.  The JDO objectstore provides an [implementation](../../components/objectstores/jdo/, alternatively you could write your own implementation.
+
+
+## ApplicationSettingsService
+
+The API defined by `ApplicationSettingsService` is:
+
+    public interface ApplicationSettingsService {
+        ApplicationSetting find(@Named("Key") String key);
+    }
+
+where `ApplicationSetting` in turn is defined as:
+
+    public interface ApplicationSetting {
+    
+        String getKey();
+    
+        SettingType getType();
+        String getDescription();
+    
+        String getValueRaw();
+    
+        String valueAsString();
+        LocalDate valueAsLocalDate();
+        Integer valueAsInt();
+        Long valueAsLong();
+        Boolean valueAsBoolean();
+    }
+
+The intention is for implementations to store only the value of each setting as a raw string (`getValueRaw()`), however for callers the API has typesafe methods `valueAsXxx()`; calling the wrong method will throw an exception.  The `getType()` property indicates the datatype of each setting. 
+
+## UserSettingsService
+
+The API defined by `UserSettingsService` is:
+
+    public interface UserSettingsService {
+        UserSetting find(
+            @Named("User") String user, 
+            @Named("Key") String key);
+    }
+
+where `UserSetting` in turn is defined as:
+
+    public interface ApplicationSetting {
+    
+        String getUser();
+        String getKey();
+    
+        SettingType getType();
+        String getDescription();
+    
+        String getValueRaw();
+    
+        String valueAsString();
+        LocalDate valueAsLocalDate();
+        Integer valueAsInt();
+        Long valueAsLong();
+        Boolean valueAsBoolean();
+    }
+
+This is typesafe following the same pattern as `ApplicationSetting`, discussed above.
\ No newline at end of file

Modified: isis/site/trunk/content/documentation.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/documentation.md?rev=1490675&r1=1490674&r2=1490675&view=diff
==============================================================================
--- isis/site/trunk/content/documentation.md (original)
+++ isis/site/trunk/content/documentation.md Fri Jun  7 15:10:00 2013
@@ -75,6 +75,7 @@ Guidance for committers is at the bottom
 - [Bookmark Service](core/services/bookmark-service.html)
 - [Exception Recognizers](core/services/exception-recognizers.html)
 - [Publishing Service](core/services/publishing-service.html)
+- [Settings Services](core/services/settings-services.html) [1.3.0-SNAPSHOT]
 
 }
 
@@ -206,6 +207,7 @@ Note: this viewer is third-party open so
 - [Publishing Service on JDO](components/objectstores/jdo/publishing-service-jdo.html) 
 - [Auditing Service on JDO](components/objectstores/jdo/auditing-service-jdo.html)
 - [Exception Recognizers](components/objectstores/jdo/exception-recognizers-jdo.html)
+- [Settings Services on JDO](components/objectstores/jdo/settings-services-jdo.html) [jdo-1.2.0-SNAPSHOT]
 
 }