-
Notifications
You must be signed in to change notification settings - Fork 315
Isis 1976 rethink object adapters #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @Override | ||
| public Oid getOid() { | ||
| return oid; | ||
| } | ||
|
|
||
| @Override | ||
| public void replaceOid(Oid persistedOid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
field oid in ObjectAdapter is now final
oid replacement no longer allowed, so we intoduced ObjectAdapter withOid(RootOid newOid) to create a copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 This looks like it's the main significant change in this PR... with the replaceOid stuff now removed.
| protected final ObjectAdapter adapterFor(final RootOid rootOid) { | ||
| return getPersistenceSession().adapterFor(rootOid); | ||
| } | ||
| //TODO[ISIS-1976] not used !? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly changes behavior, need to investigate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractIsisSessionTemplate is public API, so while it might not be used within the framework, it's possible that it's used by application code. However, let's remove it for now, see if we can simplify. If we do need an API like this, it should probably take Bookmark (from the applib) rather than RootOid. Also, should probably return just an Object (the domain object) rather than an ObjectAdapter - ie let's keep ObjectAdapter as an internal implementation detail and not in any of our APIs.
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| public class ObjectAdapterContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class is a product of refactoring, needs refinement later on; but is sane so far
| return mementoSupportMixin; | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from here downward: code is work in progress
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| class ObjectAdapterContext_AdapterManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private mixin for ObjectAdapterContext: responsibility AdapterManager 'legacy' support
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| class ObjectAdapterContext_Consistency { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private mixin for ObjectAdapterContext: responsibility Cache/Map consistency
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| class ObjectAdapterContext_Factories implements ObjectAdapterFactories { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private mixin for ObjectAdapterContext: responsibility provides ObjectAdapter factories
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| class ObjectAdapterContext_MementoSupport implements MementoRecreateObjectSupport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private mixin for ObjectAdapterContext: responsibility provide object recreation to mementos
| * | ||
| * @since 2.0.0-M2 | ||
| */ | ||
| class ObjectAdapterContext_ObjectAdapterProvider implements ObjectAdapterProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private mixin for ObjectAdapterContext: responsibility provides ObjectAdapterProvider implementation
...java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterLegacy.java
Show resolved
Hide resolved
.../java/org/apache/isis/viewer/wicket/viewer/integration/wicket/ConverterForObjectAdapter.java
Show resolved
Hide resolved
| final Oid oid = RootOid.deStringEncoded(value); | ||
| final ObjectAdapter adapter = getPersistenceSession().getAdapterFor(oid); | ||
| return ObjectAdapterMemento.createOrNull(adapter); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method appears not used to me, but not really sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure either.
IConverter is part of Wicket's SPI, to convert strings that are input in forms to underlying objects. So this one seems to convert a string representation of an object (eg "cust.Customer:123", like a Bookmark#toString() would return) into an ObjectAdapterMemento, which is basically the Wicket UI's serializable model for an ObjectAdapter (more or less the same as a RootOid).
So, my guess is that it isn't used, because I can't think of anywhere that we have this abiliity for a user to enter "cust.Customer:123" and have the framework look up the corresponding object reference.
Therefore, let's not worry about it too much. Perhaps add a TODO to see about removing this entire class.
ObjectAdapter caching Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
adapterFor(RootOid)
introduces ObjectAdapterProvider Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
ObjcetAdapterProvider from each other Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
PersistenceSession to ObjectAdapterContext Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
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
ObjectAdapterContext.specificationForViewModel() Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
074cecf to
2c70410
Compare
| final ObjectAdapter element = getAdapterManager().getAdapterFor(element2); | ||
| objectCollection.add(element); | ||
| for (final Object element : array) { | ||
| final ObjectAdapter elementAdapter = getObjectAdapterProvider().adapterFor(element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change in behavior:
BEFORE: only a map lookup, which would not trigger ObjectAdapter creation
AFTER: triggers ObjectAdapter creation if required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok.
I presume that if element == null then this implies that elementAdapter == null ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, pojo is nullable in ObjectAdapterContext_ObjectAdapterProvider ...
public ObjectAdapter adapterFor(Object pojo) {
if(pojo == null) {
return null;
}
...
}| if(isEmpty(array)) { | ||
| return null; | ||
| } | ||
| return array.length > 0 ? getObjectAdapterProvider().adapterFor(array[0]) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change in behavior:
BEFORE: only a map lookup, which would not trigger ObjectAdapter creation
AFTER: triggers ObjectAdapter creation if required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok.
| // or if a copy is sufficient | ||
| return Collections2.transform(collectionOfUnderlying, | ||
| ObjectAdapter.Functions.adapter_ForUsing(getAdapterManager())); | ||
| return Collections2.transform(pojoCollection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no change in behavior, but ...
Is this live-view actually required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably would be fine to be a copy, but is there any need to change the behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to change behavior yet; just a standing question, that prevents removal of guava's class Collections2
| } | ||
| } | ||
|
|
||
| // -- CACHING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we do still have our caches, for the moment at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the point of merging this current state is to reduce the scope of java classes that are involved with coming changes with ISIS-1976
| * FIXME[ISIS-1976] Note: whether or not 'bypassing mapping' should not be exposed by the API. | ||
| * So this further needs refactoring. | ||
| */ | ||
| ObjectAdapter specificationForViewModel(final Object viewModelPojo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method name seems strange, as compared to the "adapterForViewModel" method below, because it returns an ObjectAdapter, not an ObjectSpecification.
My guess of what you're doing here is that the returned ObjectAdapter is ok to call "getSpecification()" on, but is in some sense incomplete because it has bypassed mapping?
Having these "incomplete" ObjectAdapters around seems dangerous though. Your comment does indeed have a FIXME. Is this code used elsewhere? What calls it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code, had me fooled, because it exploited a side-effect. So I had to quick fix this late last night.
2c70410
The interface for ObjectAdapterProvider will definitely change with further refactoring step.
|
I think this PR is fine to merge. To me it seems that mostly this is just moving functionality about ... the OidAdapterMap and PojoAdapterMap are still present, but relocated to ObjectAdapterContext. The most significant change is that ObjectAdapter#rootOid is now final, and so the replacePojo stuff has gone, instead the ObjectAdapter is copied if the rootOid changes. This seems ok to me - or at least will be once we get to the stage where ObjectAdapters are instantiated as required and then discarded immediately afterwards. The ObjectAdapterProvider#specificationForViewModel(...) - which returns an ObjectAdapter - looks a bit odd; I've created a separate comment for that. I suspect this is work in progress so happy to see how it plays out, but this code does look weird at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to merge, though I've added some comments above and elsewhere on the PR.
Main query re: the naming and responsibiliities of ObjectAdapterContext#specificationForViewModel(...)
| this.transactionManager = new IsisTransactionManager(this, /*authenticationSession,*/ servicesInjector); | ||
|
|
||
| this.state = State.NOT_INITIALIZED; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this configuration property get removed? Or was the code just moved elsewhere? I'd prefer to keep it than lose it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regarding property 'concurrencyCheckingGloballyEnabled': code moved here
Key changes so far ...
Interface AdapterManger which allowed read/write access to the ObjectAdapter - cache/map is now gone.
This is replaced by new interface ObjectAdapterProvider, which does not expose the (if any) ObjectAdapter - cache/map.
This affects a lot of facet classes within the metamodel.