Discussion:
[jira] [Created] (ISIS-1976) Improve the metamodel cache management
Andi Huber (JIRA)
2018-08-31 14:25:00 UTC
Permalink
Andi Huber created ISIS-1976:
--------------------------------

Summary: Improve the metamodel cache management
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Fix For: 2.0.0-M2


The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598911#comment-16598911 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9409b1c759b3a0116d9795e36deb67e30d858ded in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9409b1c ]

ISIS-1976: remove deprecated ObjectSpecification.getCssClass()

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598900#comment-16598900 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3c80e9a5d8f5a61da514308e6c5131631eea1f0e in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3c80e9a ]

ISIS-1976: remove some deprecated features

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598901#comment-16598901 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3c80e9a5d8f5a61da514308e6c5131631eea1f0e in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3c80e9a ]

ISIS-1976: remove some deprecated features

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598903#comment-16598903 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit be08fd82a5928c8590127e89dccdb7d9d992bed3 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=be08fd8 ]

ISIS-1976: don't interfere with garbage collection

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598910#comment-16598910 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9409b1c759b3a0116d9795e36deb67e30d858ded in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9409b1c ]

ISIS-1976: remove deprecated ObjectSpecification.getCssClass()

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598908#comment-16598908 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit e7cfe6d2e6bc72977d1383ce5488f251c3aa9b53 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=e7cfe6d ]

ISIS-1976: remove deprecated
ObjectAssociationContainer.getAssociations(Predicate)

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598913#comment-16598913 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 8619eb60b237a6de87e6b60037cdfd243da47c6a in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8619eb6 ]

ISIS-1976: minor cleanup

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598909#comment-16598909 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit e7cfe6d2e6bc72977d1383ce5488f251c3aa9b53 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=e7cfe6d ]

ISIS-1976: remove deprecated
ObjectAssociationContainer.getAssociations(Predicate)

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598907#comment-16598907 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit fdbc57b780804bbce647866633aebb2f000477b7 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=fdbc57b ]

ISIS-1976: remove deprecated ObjectSpecification.getTitle(ObjectAdapter)

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598912#comment-16598912 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 8619eb60b237a6de87e6b60037cdfd243da47c6a in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8619eb6 ]

ISIS-1976: minor cleanup

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598906#comment-16598906 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit fdbc57b780804bbce647866633aebb2f000477b7 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=fdbc57b ]

ISIS-1976: remove deprecated ObjectSpecification.getTitle(ObjectAdapter)

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598904#comment-16598904 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 5078ac5b48dea8d19d4252befd0a375506381704 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=5078ac5 ]

ISIS-1976: further remove deprecated features

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598902#comment-16598902 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit be08fd82a5928c8590127e89dccdb7d9d992bed3 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=be08fd8 ]

ISIS-1976: don't interfere with garbage collection

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-08-31 15:32:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598905#comment-16598905 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 5078ac5b48dea8d19d4252befd0a375506381704 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=5078ac5 ]

ISIS-1976: further remove deprecated features

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Dan Haywood (JIRA)
2018-08-31 22:05:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Haywood updated ISIS-1976:
------------------------------
Description:
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.

~~~

The main objective is to get rid of these two maps:

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]

and

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]

As their name suggests, these map:

oid -> adapter (look up an adapter from an oid)

pojo -> adapter  (look up an adapter from a pojo)

The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).

 

The "ensureMapsConsistent" method in PersistenceSessionXxx is there to ensure that these are maintained correctly; it's rather paranoid because if these get out of sync, then bad things would happen; eg:

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 

There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]

 

All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.

~~~

At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 

 

This also requires the ability to infer the Oid from the pojo, on the fly.  There are two different ways this is done:

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]

 

To do this for an domain entity (JdoIdHelper) vs for view models (RecreateableObjectFacet).  Ideally the code to recreate/rehydrate the object should be more transparent

could perhaps provide a pluggable service so that can then support other persistence runtime stores ... the idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  

 

 

Ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.

 

 

was:The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
To do this for an domain entity (JdoIdHelper) vs for view models (RecreateableObjectFacet).  Ideally the code to recreate/rehydrate the object should be more transparent
could perhaps provide a pluggable service so that can then support other persistence runtime stores ... the idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
 
Ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Dan Haywood (JIRA)
2018-08-31 22:26:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Haywood updated ISIS-1976:
------------------------------
Description:
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.

~~~

The main objective is to get rid of these two maps:

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]

and

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]

As their name suggests, these map:

oid -> adapter (look up an adapter from an oid)

pojo -> adapter  (look up an adapter from a pojo)

The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).

Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.

The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.

Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  

There's one other subtype of Oid (apart from RootOid), namely ParentedCollectionOid.  That's because the Set or List that holds "child" objects is also managed as an adapter; ie:
{code:java}
public class Order {

@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.

 

The "ensureMapsConsistent" method in PersistenceSessionXxx is there to ensure that these are maintained correctly; it's rather paranoid because if these get out of sync, then bad things would happen; eg:

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 

There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]

 

All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.

~~~

At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 

 

This also requires the ability to infer the Oid from the pojo, on the fly.  There are two different ways this is done:
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]

 

Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  

 

~~~~~~

 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.

 

~~~~~~

 OK, hopefully some the above makes sense!!! 

 

was:
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.

~~~

The main objective is to get rid of these two maps:

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]

and

[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]

As their name suggests, these map:

oid -> adapter (look up an adapter from an oid)

pojo -> adapter  (look up an adapter from a pojo)

The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).

 

The "ensureMapsConsistent" method in PersistenceSessionXxx is there to ensure that these are maintained correctly; it's rather paranoid because if these get out of sync, then bad things would happen; eg:

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 

There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]

 

All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.

~~~

At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 

 

This also requires the ability to infer the Oid from the pojo, on the fly.  There are two different ways this is done:

[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]

 

To do this for an domain entity (JdoIdHelper) vs for view models (RecreateableObjectFacet).  Ideally the code to recreate/rehydrate the object should be more transparent

could perhaps provide a pluggable service so that can then support other persistence runtime stores ... the idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  

 

 

Ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.

 

 
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-01 10:03:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16599598#comment-16599598 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit fee934da2e3b0f95f6e0d30d00db28c55f098ee4 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=fee934d ]

ISIS-1976: add layer of abstraction as first step to deprecate
ObjectAdapter caching

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-01 10:03:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16599599#comment-16599599 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit fee934da2e3b0f95f6e0d30d00db28c55f098ee4 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=fee934d ]

ISIS-1976: add layer of abstraction as first step to deprecate
ObjectAdapter caching

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-02 14:22:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601226#comment-16601226 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 866b09c47d66c5577ef57bc69819471249e60def in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from ***@corax.at
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=866b09c ]

ISIS-1976: experimental refactoring

adapterFor(RootOid)
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-02 16:48:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601249#comment-16601249 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 31c74d680d0e95da805df3b40d643eb40dc538c8 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from ***@corax.at
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=31c74d6 ]

ISIS-1976: make ObjectAdapter's Oid final
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-02 17:09:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601255#comment-16601255 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9cb22ef8f1c62c2f02f0f34bc29fe668dbfa47a9 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from ***@corax.at
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9cb22ef ]

ISIS-1976: minor simplification
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-02 17:14:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601256#comment-16601256 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9016556c53323ee89e0e7b599e520736478977ea in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from andi-huber
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9016556 ]

ISIS-1976: make RootAndCollectionAdapters package private
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-02 17:42:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601264#comment-16601264 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit e9362601a95e2cd4fa3fb0c38673e36c6c4cd3ec in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from andi-huber
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=e936260 ]

ISIS-1976: add some comments
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602024#comment-16602024 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 26c072f157f76a98a2900123454ffe52a2571362 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=26c072f ]

ISIS-1976: decouple PojoAdapter from DN

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602032#comment-16602032 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 96b61219ff6bda6e29995df546e2b7f057fe3c95 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=96b6121 ]

ISIS-1976: rename IsisLifeCycleListener2 -> IsisLifeCycleListener

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602030#comment-16602030 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit d6c4782c6d1e24556714727294f3191e16155103 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=d6c4782 ]

ISIS-1976: rename some methods in AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602027#comment-16602027 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 77dc5ff8c1569fbfe374e0c54e250178e9925645 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=77dc5ff ]

ISIS-1976: remove AdapterManagerBase

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602028#comment-16602028 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 77dc5ff8c1569fbfe374e0c54e250178e9925645 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=77dc5ff ]

ISIS-1976: remove AdapterManagerBase

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602031#comment-16602031 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 96b61219ff6bda6e29995df546e2b7f057fe3c95 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=96b6121 ]

ISIS-1976: rename IsisLifeCycleListener2 -> IsisLifeCycleListener

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602023#comment-16602023 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 26c072f157f76a98a2900123454ffe52a2571362 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=26c072f ]

ISIS-1976: decouple PojoAdapter from DN

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602026#comment-16602026 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 5d823b6dbe8f87d6d0437dc94f06a522dbd3a485 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=5d823b6 ]

ISIS-1976: decouple ObjectAdapter creation from PersistenceSession

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602025#comment-16602025 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 5d823b6dbe8f87d6d0437dc94f06a522dbd3a485 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=5d823b6 ]

ISIS-1976: decouple ObjectAdapter creation from PersistenceSession

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602029#comment-16602029 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit d6c4782c6d1e24556714727294f3191e16155103 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=d6c4782 ]

ISIS-1976: rename some methods in AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:51:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602034#comment-16602034 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 10189e85d26ae73db1881281b37b149024ffd10f in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=10189e8 ]

ISIS-1976: minor simplifications, also reduce compiler warnings

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:51:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602035#comment-16602035 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit f832562d467616754960dca765231df35b822eb1 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=f832562 ]

ISIS-1976: decouple metamodel's facets from AdapterManager

introduces ObjectAdapterProvider

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:51:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602033#comment-16602033 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 10189e85d26ae73db1881281b37b149024ffd10f in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=10189e8 ]

ISIS-1976: minor simplifications, also reduce compiler warnings

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 10:51:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602036#comment-16602036 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit f832562d467616754960dca765231df35b822eb1 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=f832562 ]

ISIS-1976: decouple metamodel's facets from AdapterManager

introduces ObjectAdapterProvider

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 12:58:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602132#comment-16602132 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9f8681451cdee1384c2e1246ae204b8d8122a304 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9f86814 ]

ISIS-1976: further decouple factets

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 12:58:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602131#comment-16602131 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2cbde12c4eecdad89be4dffbcab320ee4c33a734 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2cbde12 ]

ISIS-1976: add missing license header

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 12:58:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602130#comment-16602130 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2cbde12c4eecdad89be4dffbcab320ee4c33a734 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2cbde12 ]

ISIS-1976: add missing license header

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-03 12:58:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602133#comment-16602133 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9f8681451cdee1384c2e1246ae204b8d8122a304 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9f86814 ]

ISIS-1976: further decouple factets

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602743#comment-16602743 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3a089d1be884361895de7ab196b3ab7d2fc0d900 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3a089d1 ]

ISIS-1976: remove unused spec-loader from some facet constructors

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602746#comment-16602746 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit e54f79bb89650c098eef25f0133884968737366b in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=e54f79b ]

ISIS-1976: further decouple from AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602745#comment-16602745 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit e54f79bb89650c098eef25f0133884968737366b in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=e54f79b ]

ISIS-1976: further decouple from AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602751#comment-16602751 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit c37cde638a7222ac48f6a64c7ad33c607a92af0a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=c37cde6 ]

ISIS-1976: move responsibility for pre-loading service adapters from
PersistenceSession to ObjectAdapterContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602750#comment-16602750 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 507f74db09959fd17b1894a6c67ba720f67b9bda in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=507f74d ]

ISIS-1976: decouple implementations of PersistenceSession and
ObjcetAdapterProvider from each other

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602752#comment-16602752 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit c37cde638a7222ac48f6a64c7ad33c607a92af0a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=c37cde6 ]

ISIS-1976: move responsibility for pre-loading service adapters from
PersistenceSession to ObjectAdapterContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602753#comment-16602753 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit d95d064d376b746dc69d7565e590474b4c5e0e32 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=d95d064 ]

ISIS-1976: PersistentSession: remove virtually unreachable code

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602756#comment-16602756 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 074cecf4cc708006a9f83235415729bf01b3273f in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=074cecf ]

ISIS-1976: moving responsibilities from PersistenceSession to
ObjectAdapterProvider

introduces ObjectAdapterProvider.Delegating
removes AdapterManager
ports changes from DN5-plugin to DN-4 plugin

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602755#comment-16602755 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 074cecf4cc708006a9f83235415729bf01b3273f in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=074cecf ]

ISIS-1976: moving responsibilities from PersistenceSession to
ObjectAdapterProvider

introduces ObjectAdapterProvider.Delegating
removes AdapterManager
ports changes from DN5-plugin to DN-4 plugin

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602748#comment-16602748 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9e5ac834edc31b9bda76789806bc2b31e90fd5bc in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9e5ac83 ]

ISIS-1976: let PersistenceSession no longer implement AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602744#comment-16602744 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3a089d1be884361895de7ab196b3ab7d2fc0d900 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3a089d1 ]

ISIS-1976: remove unused spec-loader from some facet constructors

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602747#comment-16602747 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9e5ac834edc31b9bda76789806bc2b31e90fd5bc in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9e5ac83 ]

ISIS-1976: let PersistenceSession no longer implement AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602749#comment-16602749 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 507f74db09959fd17b1894a6c67ba720f67b9bda in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=507f74d ]

ISIS-1976: decouple implementations of PersistenceSession and
ObjcetAdapterProvider from each other

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-04 08:28:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602754#comment-16602754 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit d95d064d376b746dc69d7565e590474b4c5e0e32 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=d95d064 ]

ISIS-1976: PersistentSession: remove virtually unreachable code

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603986#comment-16603986 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 83f6173a4bd695ace685d3ed26dc7e049e8f8787 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=83f6173 ]

ISIS-1976: remove unused spec-loader from some facet constructors

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603987#comment-16603987 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 83f6173a4bd695ace685d3ed26dc7e049e8f8787 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=83f6173 ]

ISIS-1976: remove unused spec-loader from some facet constructors

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603990#comment-16603990 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9ef889fdbc7909ffc0db48256ebf7c36b3cb28fc in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9ef889f ]

ISIS-1976: let PersistenceSession no longer implement AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603988#comment-16603988 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit ee9ce0f0fb8929e25d7953168cc27fe064d66460 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=ee9ce0f ]

ISIS-1976: further decouple from AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603989#comment-16603989 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit ee9ce0f0fb8929e25d7953168cc27fe064d66460 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=ee9ce0f ]

ISIS-1976: further decouple from AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603992#comment-16603992 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit a7ccf6aa8a94de1dc26741f2027b75fd3c6390ae in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=a7ccf6a ]

ISIS-1976: decouple implementations of PersistenceSession and
ObjcetAdapterProvider from each other

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603993#comment-16603993 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit a7ccf6aa8a94de1dc26741f2027b75fd3c6390ae in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=a7ccf6a ]

ISIS-1976: decouple implementations of PersistenceSession and
ObjcetAdapterProvider from each other

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603991#comment-16603991 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 9ef889fdbc7909ffc0db48256ebf7c36b3cb28fc in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9ef889f ]

ISIS-1976: let PersistenceSession no longer implement AdapterManager

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603995#comment-16603995 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 1cf124b9dee528bb89441843b1f2a5c69a159b52 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=1cf124b ]

ISIS-1976: move responsibility for pre-loading service adapters from
PersistenceSession to ObjectAdapterContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603996#comment-16603996 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 93ac9f22e98e9d10c5767fe37894f10f30cb652e in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=93ac9f2 ]

ISIS-1976: PersistentSession: remove virtually unreachable code

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603994#comment-16603994 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 1cf124b9dee528bb89441843b1f2a5c69a159b52 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=1cf124b ]

ISIS-1976: move responsibility for pre-loading service adapters from
PersistenceSession to ObjectAdapterContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604004#comment-16604004 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3d49fc748a34d410f2549381956dfe837f9377c6 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3d49fc7 ]

Merge pull request #120 from apache/ISIS-1976-rethink-object-adapters

ISIS-1976: merge 'Isis 1976 rethink object adapters'
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603998#comment-16603998 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 77704048cc6a18fa2bc1d238f7b1009485a2ddea in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=7770404 ]

ISIS-1976: moving responsibilities from PersistenceSession to
ObjectAdapterProvider

introduces ObjectAdapterProvider.Delegating
removes AdapterManager
ports changes from DN5-plugin to DN-4 plugin

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604000#comment-16604000 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 69552727226ac65dfec4ab83f47444a08f12783b in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=6955272 ]

ISIS-1976: minor cleanup

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604005#comment-16604005 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3d49fc748a34d410f2549381956dfe837f9377c6 in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3d49fc7 ]

Merge pull request #120 from apache/ISIS-1976-rethink-object-adapters

ISIS-1976: merge 'Isis 1976 rethink object adapters'
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604002#comment-16604002 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2c7041016faf87443befaa80eef9a0457ac1338f in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2c70410 ]

ISIS-1976: fixes StackOverflow with
ObjectAdapterContext.specificationForViewModel()

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604001#comment-16604001 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 69552727226ac65dfec4ab83f47444a08f12783b in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=6955272 ]

ISIS-1976: minor cleanup

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604003#comment-16604003 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2c7041016faf87443befaa80eef9a0457ac1338f in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2c70410 ]

ISIS-1976: fixes StackOverflow with
ObjectAdapterContext.specificationForViewModel()

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603997#comment-16603997 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 93ac9f22e98e9d10c5767fe37894f10f30cb652e in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=93ac9f2 ]

ISIS-1976: PersistentSession: remove virtually unreachable code

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 06:48:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603999#comment-16603999 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 77704048cc6a18fa2bc1d238f7b1009485a2ddea in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=7770404 ]

ISIS-1976: moving responsibilities from PersistenceSession to
ObjectAdapterProvider

introduces ObjectAdapterProvider.Delegating
removes AdapterManager
ports changes from DN5-plugin to DN-4 plugin

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 07:22:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604031#comment-16604031 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 85335569a0dc62ced9664f5c0d06467183f79ddb in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8533556 ]

ISIS-1976: fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 07:22:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604032#comment-16604032 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 85335569a0dc62ced9664f5c0d06467183f79ddb in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8533556 ]

ISIS-1976: fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 07:35:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604054#comment-16604054 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 58061be7d0c356fd1a58dd4eea63fd21d23b4c5a in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=58061be ]

ISIS-1976: further fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 07:35:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604055#comment-16604055 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 58061be7d0c356fd1a58dd4eea63fd21d23b4c5a in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=58061be ]

ISIS-1976: further fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 11:42:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604307#comment-16604307 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2fcfc93647a9a32401951b0f01676e9ed11a14dc in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2fcfc93 ]

ISIS-1976: minor polishing

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 11:42:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604306#comment-16604306 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2fcfc93647a9a32401951b0f01676e9ed11a14dc in isis's branch refs/heads/master from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2fcfc93 ]

ISIS-1976: minor polishing

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604551#comment-16604551 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3d49fc748a34d410f2549381956dfe837f9377c6 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3d49fc7 ]

Merge pull request #120 from apache/ISIS-1976-rethink-object-adapters

ISIS-1976: merge 'Isis 1976 rethink object adapters'
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604552#comment-16604552 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 3d49fc748a34d410f2549381956dfe837f9377c6 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=3d49fc7 ]

Merge pull request #120 from apache/ISIS-1976-rethink-object-adapters

ISIS-1976: merge 'Isis 1976 rethink object adapters'
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604560#comment-16604560 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2fcfc93647a9a32401951b0f01676e9ed11a14dc in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2fcfc93 ]

ISIS-1976: minor polishing

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604562#comment-16604562 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 1d8dfcf1f80933c3fcb8bdf159171e8d39c15e57 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=1d8dfcf ]

ISIS-1976: make ObjectAdapter.pojo final

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604554#comment-16604554 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 85335569a0dc62ced9664f5c0d06467183f79ddb in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8533556 ]

ISIS-1976: fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604553#comment-16604553 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 85335569a0dc62ced9664f5c0d06467183f79ddb in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=8533556 ]

ISIS-1976: fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604567#comment-16604567 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit b83de867d4bf9ad4a1bbdc5a3fbff3ec27ce328a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=b83de86 ]

ISIS-1976: let ObjectAdapterContext.replaceRootAdapter(ObjectAdapter,
RootAndCollectionAdapters) no longer use OA's replacePojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604561#comment-16604561 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 1d8dfcf1f80933c3fcb8bdf159171e8d39c15e57 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=1d8dfcf ]

ISIS-1976: make ObjectAdapter.pojo final

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604566#comment-16604566 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2491edc72a088831e1c4bd55d44ab02d26f87e66 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2491edc ]

ISIS-1976: let JavaCollectionFacet no longer change OA's pojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604563#comment-16604563 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2ebc19e35c2878810332059ffaf9cb51c03698b1 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2ebc19e ]

ISIS-1976: removing ObjectAdapter.replacePojo(Object pojo)

also cleaning up

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604564#comment-16604564 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2ebc19e35c2878810332059ffaf9cb51c03698b1 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2ebc19e ]

ISIS-1976: removing ObjectAdapter.replacePojo(Object pojo)

also cleaning up

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604565#comment-16604565 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2491edc72a088831e1c4bd55d44ab02d26f87e66 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2491edc ]

ISIS-1976: let JavaCollectionFacet no longer change OA's pojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604569#comment-16604569 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 67d3c0978067c2375e3263f8dd6d9cf4309a8014 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=67d3c09 ]

ISIS-1976: prepare removal of OA's replacePojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604556#comment-16604556 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 58061be7d0c356fd1a58dd4eea63fd21d23b4c5a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=58061be ]

ISIS-1976: further fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604570#comment-16604570 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 67d3c0978067c2375e3263f8dd6d9cf4309a8014 in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=67d3c09 ]

ISIS-1976: prepare removal of OA's replacePojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604568#comment-16604568 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit b83de867d4bf9ad4a1bbdc5a3fbff3ec27ce328a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=b83de86 ]

ISIS-1976: let ObjectAdapterContext.replaceRootAdapter(ObjectAdapter,
RootAndCollectionAdapters) no longer use OA's replacePojo

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604555#comment-16604555 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 58061be7d0c356fd1a58dd4eea63fd21d23b4c5a in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=58061be ]

ISIS-1976: further fixing some tests

reason: IsisSessionFactory does no longer live on the ServletContext

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-09-05 15:32:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604559#comment-16604559 ]

ASF subversion and git services commented on ISIS-1976:
-------------------------------------------------------

Commit 2fcfc93647a9a32401951b0f01676e9ed11a14dc in isis's branch refs/heads/ISIS-1976-rethink-object-adapters from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=2fcfc93 ]

ISIS-1976: minor polishing

Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
Post by Andi Huber (JIRA)
Improve the metamodel cache management
--------------------------------------
Key: ISIS-1976
URL: https://issues.apache.org/jira/browse/ISIS-1976
Project: Isis
Issue Type: Improvement
Components: Core
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
The cache management we have with ObjectAdapter, might be simplified such that we just work with java.lang.Object so far as possible. We would have a "disposable" ObjectAdapter that we instantiate around an Object whenever we need it - to access into the metamodel - and then throw it away after. Or perhaps eventually we might not need ObjectAdapter at all, just simply use #getClass() to look up the ObjectSpecification.
~~~
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java]
and
[https://github.com/apache/isis/blob/master/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java]
oid -> adapter (look up an adapter from an oid)
pojo -> adapter  (look up an adapter from a pojo)
The adapter itself has a reference to its oid (getOid()) and to its pojo (getObject()).
Most, though not all, objects have Oids.  Certainly DN persistent objects do, in fact they do even if they are not yet persisted (prior to calling RepositoryService#persist(...).  These will have a RootOid, which will indicate if the object is persistent or still transient.
The same is true of view models, these also have a RootOid.  They also have a RecreatableObjectFacet which is used to actually manufacture the Oid (because the oid for view models is basically a serialization of the state of the domain object).  The RootOid for view models will indicate that they are view models.
Values (ints, strings etc), do NOT have an oid.  This also means that - obviously - they don't get saved in the OidAdapterHashMap; and they probably aren't saved in PojoAdapterHashMap.  Value objects will have a ValueFacet.  
{code:java}
public class Order {
@Getter @Setter
Set<OrderItem> orderItems = Sets.newTreeSet();
...
}{code}
Why is this done?  Because a long time ago (before DN) the framework did its own persistence, so this was for lazy loading etc.
 
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1184] 
There's also some rather horrible "remapRecreatedPojo" methods that hack this stuff
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L1739]
 
All this stuff is a legacy from the original client/server architecture that the framework used to have; it was probably needed then but I really don't think it's needed now.
~~~
At the moment the object adapters are created eagerly, typically using PersistenceSession#adapterFor(...).  For domain services, we eagerly create an adapter around every service before each session, "just in case" it gets interacted with.  This could be removed
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java#L237] 
 
* for DN entities, there is the JdoObjectIdSerlaizer
* for view models, there's RecreatableObjectFacet, already mentioned.
[https://github.com/apache/isis/blob/master/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java]
 
Ideally the code to recreate/rehydrate the object should define a consistent API to the rest of the framework.  My thinking is that it could perhaps be a pluggable service so that we can then support other persistence runtime stores ... The idea is that the framework encounters a pojo and then asks for a service (via an SPI) to see which can extract/infer an Oid from it, using the usual chain-of-responsibility pattern.  Out-of-the-box the framework would provide two default implementations, one for DN entities (JdoIdHelper), the other for view models.  
 
~~~~~~
 Looking forward, ideally, PersistenceSession shouldn't need to use ObjectAdapter at all; the ObjectAdapter really exists only for the viewer(s) etc to obtain the ObjectSpecification to know how to render the object.  Ultimately, we could get rid of ObjectAdapter completely and just uses pojos (=domain objects) everywhere.  ObjectSpecification would remain, though.  I think this is for other tickets, though, not this one.
 
~~~~~~
 OK, hopefully some the above makes sense!!! 
 
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Loading...