[isis] 03/03: ISIS-1943: Internal API: introduces _Functions
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git commit a8646c4e18a5e01e96934be96f802bda0168c6cd Author: Andi HuberAuthorDate: Fri May 4 17:19:16 2018 +0200 ISIS-1943: Internal API: introduces _Functions Task-Url: https://issues.apache.org/jira/browse/ISIS-1943 --- .../isis/applib/internal/functions/_Functions.java | 53 ++ .../_Functions_IndexAwareFunctionAdapter.java | 44 ++ .../applib/internal/functions/package-info.java| 28 .../components/tree/IsisToWicketTreeAdapter.java | 15 +++--- 4 files changed, 134 insertions(+), 6 deletions(-) diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions.java b/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions.java new file mode 100644 index 000..9a33621 --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.applib.internal.functions; + +import java.util.function.Function; + +/** + * - internal use only - + * + * Common Function idioms. + * + * + * WARNING: Do NOT use any of the classes provided by this package! + * These may be changed or removed without notice! + * + * + * @since 2.0.0 + */ +public class _Functions { + + @FunctionalInterface + public interface IndexAwareFunction { + public R apply(int index, T t); + } + + /** +* Converts an IndexAwareFunction into a Function, having its index start at 0, +* and incremented after each function call. +* @param indexAwareFunction +* @return +*/ + public static Function indexAwareFunctionToFunction(IndexAwareFunction indexAwareFunction){ + return new _Functions_IndexAwareFunctionAdapter (indexAwareFunction); + } + + +} diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions_IndexAwareFunctionAdapter.java b/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions_IndexAwareFunctionAdapter.java new file mode 100644 index 000..883abe0 --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions_IndexAwareFunctionAdapter.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.applib.internal.functions; + +import java.util.function.Function; + +import org.apache.isis.applib.internal.functions._Functions.IndexAwareFunction; + +/** + * Package private mixin for _Functions. + * Extending a Function to keep track of an index, incremented with each function call. + */ +class _Functions_IndexAwareFunctionAdapter implements Function { + + + private int index=0; + private final IndexAwareFunction indexAwareFunction; + + _Functions_IndexAwareFunctionAdapter(IndexAwareFunction indexAwareFunction) { + this.indexAwareFunction = indexAwareFunction; + } + + @Override + public R apply(T t) { + return indexAwareFunction.apply(index++, t); + } + +} diff
[isis] 01/03: ISIS-1943: extending the tree API: introduces TreePath
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git commit f485b1b06f0b99405b3712ea8bd5463d071e1e9f Author: Andi HuberAuthorDate: Fri May 4 15:43:23 2018 +0200 ISIS-1943: extending the tree API: introduces TreePath Task-Url: https://issues.apache.org/jira/browse/ISIS-1943 --- .../org/apache/isis/applib/tree/LazyTreeNode.java | 35 +++ .../java/org/apache/isis/applib/tree/TreeNode.java | 4 ++ .../java/org/apache/isis/applib/tree/TreePath.java | 50 ++ .../apache/isis/applib/tree/TreePath_Default.java | 47 .../components/tree/IsisToWicketTreeAdapter.java | 3 +- 5 files changed, 138 insertions(+), 1 deletion(-) diff --git a/core/applib/src/main/java/org/apache/isis/applib/tree/LazyTreeNode.java b/core/applib/src/main/java/org/apache/isis/applib/tree/LazyTreeNode.java index 1d75d33..98ce49f 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/tree/LazyTreeNode.java +++ b/core/applib/src/main/java/org/apache/isis/applib/tree/LazyTreeNode.java @@ -19,10 +19,12 @@ package org.apache.isis.applib.tree; import java.util.Objects; +import java.util.concurrent.atomic.LongAdder; import java.util.stream.Stream; import org.apache.isis.applib.annotation.Value; import org.apache.isis.applib.internal.base._Lazy; +import org.apache.isis.applib.internal.exceptions._Exceptions; @Value(semanticsProviderName="org.apache.isis.core.metamodel.facets.value.treenode.TreeNodeValueSemanticsProvider") public class LazyTreeNode implements TreeNode { @@ -30,6 +32,7 @@ public class LazyTreeNode implements TreeNode { private final T value; private final Class> treeAdapterClass; private final _Lazy treeAdapter = _Lazy.of(this::newTreeAdapter); + private final _Lazy treePath = _Lazy.of(this::resolveTreePath); public static TreeNode of(T value, Class> treeAdapterClass) { return new LazyTreeNode(value, treeAdapterClass); @@ -73,6 +76,11 @@ public class LazyTreeNode implements TreeNode { return treeAdapterClass; } + @Override + public TreePath getPositionAsPath() { + return treePath.get(); + } + // -- HELPER private TreeAdapter newTreeAdapter() { @@ -92,5 +100,32 @@ public class LazyTreeNode implements TreeNode { return of(value, getTreeAdapterClass()); } + private TreePath resolveTreePath() { + final TreeNode parent = getParentIfAny(); + if(parent==null) { + return TreePath.root(); + } + return parent.getPositionAsPath().append(indexWithinSiblings(parent)); + } + + /* +* @return zero based index +*/ + private int indexWithinSiblings(TreeNode parent) { + final LongAdder indexOneBased = new LongAdder(); + + boolean found = parent.streamChildren() + .peek(__->indexOneBased.increment()) + .anyMatch(sibling->this.equals(sibling)) + ; + + if(!found) { + throw _Exceptions.unexpectedCodeReach(); + } + + return indexOneBased.intValue()-1; + } + + } diff --git a/core/applib/src/main/java/org/apache/isis/applib/tree/TreeNode.java b/core/applib/src/main/java/org/apache/isis/applib/tree/TreeNode.java index e387c0c..7ebb3ee 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/tree/TreeNode.java +++ b/core/applib/src/main/java/org/apache/isis/applib/tree/TreeNode.java @@ -51,6 +51,10 @@ public interface TreeNode { public default boolean isLeaf() { return getChildCount() == 0; } + + // -- PATH INFO + + public TreePath getPositionAsPath(); // -- CONSTRUCTION diff --git a/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java new file mode 100644 index 000..0e8c349 --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software
[isis] 02/03: ISIS-1943: introduces TreeModel that extends EntityModel
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git commit 9aa747ead77790658bcd591b697cc20fb170ad8d Author: Andi HuberAuthorDate: Fri May 4 16:38:24 2018 +0200 ISIS-1943: introduces TreeModel that extends EntityModel Task-Url: https://issues.apache.org/jira/browse/ISIS-1943 --- .../java/org/apache/isis/applib/tree/TreePath.java | 10 ++ .../apache/isis/applib/tree/TreePath_Default.java | 32 +- .../components/tree/IsisToWicketTreeAdapter.java | 125 + 3 files changed, 119 insertions(+), 48 deletions(-) diff --git a/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java index 0e8c349..0ecda6c 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java +++ b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath.java @@ -20,6 +20,8 @@ package org.apache.isis.applib.tree; import java.io.Serializable; +import javax.annotation.Nullable; + /** * Provides an unambiguous way to address nodes by position within a tree-structure. Examples: * @@ -37,6 +39,14 @@ public interface TreePath extends Serializable { */ public TreePath append(int indexWithinSiblings); + /** +* +* @return a new TreePath instance that represents the parent path of this +*/ + public @Nullable TreePath getParentIfAny(); + + public boolean isRoot(); + // -- CONSTRUCTION public static TreePath of(final int ... canonicalPath) { diff --git a/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath_Default.java b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath_Default.java index ce30341..4851572 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath_Default.java +++ b/core/applib/src/main/java/org/apache/isis/applib/tree/TreePath_Default.java @@ -18,6 +18,7 @@ */ package org.apache.isis.applib.tree; +import java.util.Arrays; import java.util.Objects; /** @@ -38,10 +39,39 @@ class TreePath_Default implements TreePath { @Override public TreePath append(int indexWithinSiblings) { - int[] newCanonicalPath = new int[canonicalPath.length+1]; + final int[] newCanonicalPath = new int[canonicalPath.length+1]; System.arraycopy(canonicalPath, 0, newCanonicalPath, 0, canonicalPath.length); newCanonicalPath[canonicalPath.length] = indexWithinSiblings; return new TreePath_Default(newCanonicalPath); } + @Override + public boolean equals(Object obj) { + if(obj instanceof TreePath_Default) { + final TreePath_Default other = (TreePath_Default) obj; + return Arrays.equals(canonicalPath, other.canonicalPath); + } + return false; + } + + @Override + public int hashCode() { + return canonicalPath.hashCode(); + } + + @Override + public TreePath getParentIfAny() { + if(isRoot()) { + return null; + } + final int[] newCanonicalPath = new int[canonicalPath.length-1]; + System.arraycopy(canonicalPath, 0, newCanonicalPath, 0, canonicalPath.length-1); + return new TreePath_Default(newCanonicalPath); + } + + @Override + public boolean isRoot() { + return canonicalPath.length==1; + } + } diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java index 102a12a..164481d 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; +import java.util.concurrent.atomic.LongAdder; import java.util.stream.Stream; import javax.resource.spi.IllegalStateException; @@ -12,6 +13,7 @@ import javax.resource.spi.IllegalStateException; import org.apache.isis.applib.internal.collections._Lists; import org.apache.isis.applib.tree.TreeAdapter; import org.apache.isis.applib.tree.TreeNode; +import org.apache.isis.applib.tree.TreePath; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.adapter.oid.RootOid; import org.apache.isis.core.runtime.system.context.IsisContext; @@
[isis] branch master updated (f4c9cdd -> a8646c4)
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/isis.git. from f4c9cdd ISIS-898: cleanup debug code, also suppress unchecked+rawtypes warnings new f485b1b ISIS-1943: extending the tree API: introduces TreePath new 9aa747e ISIS-1943: introduces TreeModel that extends EntityModel new a8646c4 ISIS-1943: Internal API: introduces _Functions The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../{_Constants.java => functions/_Functions.java} | 36 +++--- .../_Functions_IndexAwareFunctionAdapter.java} | 34 +++--- .../internal/{base => functions}/package-info.java | 2 +- .../org/apache/isis/applib/tree/LazyTreeNode.java | 35 ++ .../java/org/apache/isis/applib/tree/TreeNode.java | 4 + .../_Comparators.java => tree/TreePath.java} | 49 .../apache/isis/applib/tree/TreePath_Default.java | 77 .../components/tree/IsisToWicketTreeAdapter.java | 131 + 8 files changed, 260 insertions(+), 108 deletions(-) copy core/applib/src/main/java/org/apache/isis/applib/internal/{_Constants.java => functions/_Functions.java} (64%) copy core/{applib-legacy/src/main/java/org/apache/isis/applib/layout/component/FieldSet_legacy.java => applib/src/main/java/org/apache/isis/applib/internal/functions/_Functions_IndexAwareFunctionAdapter.java} (57%) copy core/applib/src/main/java/org/apache/isis/applib/internal/{base => functions}/package-info.java (95%) copy core/applib/src/main/java/org/apache/isis/applib/{internal/compare/_Comparators.java => tree/TreePath.java} (50%) create mode 100644 core/applib/src/main/java/org/apache/isis/applib/tree/TreePath_Default.java -- To stop receiving notification emails like this one, please contact ahu...@apache.org.
[isis] branch master updated: ISIS-898: cleanup debug code, also suppress unchecked+rawtypes warnings
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git The following commit(s) were added to refs/heads/master by this push: new f4c9cdd ISIS-898: cleanup debug code, also suppress unchecked+rawtypes warnings f4c9cdd is described below commit f4c9cdd5cec5705631fe7cc74ada8acf9916b99b Author: Andi HuberAuthorDate: Fri May 4 14:29:16 2018 +0200 ISIS-898: cleanup debug code, also suppress unchecked+rawtypes warnings Task-Url: https://issues.apache.org/jira/browse/ISIS-898 --- .../viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java index 222623e..766fd68 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java @@ -91,9 +91,7 @@ class IsisToWicketTreeAdapter { @Override public void onClick(AjaxRequestTarget target) { - System.out.println("!!! before toggle"); toggleExpandCollapse.run(); - System.out.println("!!! after toggle"); } @Override @@ -120,7 +118,8 @@ class IsisToWicketTreeAdapter { } // -- HELPER - + + @SuppressWarnings({"rawtypes", "unchecked"}) private static class EntityModelTreeAdapter implements TreeAdapter, Serializable { private static final long serialVersionUID = 1L; @@ -229,6 +228,7 @@ class IsisToWicketTreeAdapter { * @param model * @return Wicket's ITreeProvider */ + @SuppressWarnings({ "rawtypes", "unchecked" }) private static ITreeProvider toITreeProvider(ModelAbstract model) { final TreeNode tree = (TreeNode) model.getObject().getObject(); -- To stop receiving notification emails like this one, please contact ahu...@apache.org.
[isis] 01/03: ISIS-898: hardcode AjaxFallbackLink to be enabled in hierarchy
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git commit dfe84e10c740cfadb19fe6bb68f6b15248227d43 Author: Andi HuberAuthorDate: Fri May 4 11:56:18 2018 +0200 ISIS-898: hardcode AjaxFallbackLink to be enabled in hierarchy Task-Url: https://issues.apache.org/jira/browse/ISIS-898 --- .../components/tree/IsisToWicketTreeAdapter.java | 70 -- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java index 021d447..020d4ef 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/IsisToWicketTreeAdapter.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.stream.Stream; import org.apache.isis.applib.internal.collections._Lists; +import org.apache.isis.applib.internal.exceptions._Exceptions; import org.apache.isis.applib.tree.TreeAdapter; import org.apache.isis.applib.tree.TreeNode; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; @@ -19,8 +20,12 @@ import org.apache.isis.viewer.wicket.model.models.ScalarModel; import org.apache.isis.viewer.wicket.model.models.ValueModel; import org.apache.isis.viewer.wicket.ui.components.entity.icontitle.EntityIconAndTitlePanel; import org.apache.wicket.Component; +import org.apache.wicket.MarkupContainer; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider; import org.apache.wicket.extensions.markup.html.repeater.tree.NestedTree; +import org.apache.wicket.extensions.markup.html.repeater.tree.Node; import org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme; import org.apache.wicket.model.IModel; import org.apache.wicket.model.LoadableDetachableModel; @@ -37,6 +42,9 @@ class IsisToWicketTreeAdapter { // -- RENDERING + /** +* Wicket's Tree Component implemented for Isis +*/ private static class EntityTree extends NestedTree { private static final long serialVersionUID = 1L; @@ -44,6 +52,9 @@ class IsisToWicketTreeAdapter { public EntityTree(String id, ITreeProvider provider) { super(id, provider); add(new WindowsTheme()); // TODO not required if Isis provides it's own css styles for tree-nodes + + super.setEnabled(true); + super.setVisible(true); } /** @@ -52,7 +63,50 @@ class IsisToWicketTreeAdapter { @Override protected Component newContentComponent(String id, IModel node) { final EntityModel entityModel = node.getObject(); - return new EntityIconAndTitlePanel(id, entityModel); + final Component entityIconAndTitle = new EntityIconAndTitlePanel(id, entityModel); + return entityIconAndTitle; + } + + /** +* To hardcode Node's AjaxFallbackLink.isEnabledInHierarchy()->true we override this method. +*/ + @Override + public Component newNodeComponent(String id, IModel model) { + return new Node(id, this, model) + { + private static final long serialVersionUID = 1L; + + @Override + protected Component createContent(String id, IModel model) { + return EntityTree.this.newContentComponent(id, model); + } + + @Override + protected MarkupContainer createJunctionComponent(String id) { + + final Node self = this; + + return new AjaxFallbackLink(id) { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + toggle(); +
[isis] 02/03: ISIS-1841: IsisContext: adds shortcuts for convenience
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git commit 5b92468d60dbdfe6c9c3a837b10f50484642d75f Author: Andi HuberAuthorDate: Fri May 4 12:34:51 2018 +0200 ISIS-1841: IsisContext: adds shortcuts for convenience also removes deprecated testReset() --- .../core/integtestsupport/IsisSystemForTest.java | 2 +- .../runtime/headless/IsisSystemBootstrapper.java | 2 +- .../core/runtime/system/context/IsisContext.java | 45 ++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java index 1149542..c2fef4d 100644 --- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java +++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java @@ -327,7 +327,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic // for subsequent tests; the attempt to bootstrap the framework will leave // the IsisContext singleton as set. -IsisContext.testReset(); +IsisContext.clear(); final Set validationErrors = ex.getValidationErrors(); final StringBuilder buf = new StringBuilder(); diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystemBootstrapper.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystemBootstrapper.java index b167b51..e587ec5 100644 --- a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystemBootstrapper.java +++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystemBootstrapper.java @@ -187,7 +187,7 @@ public class IsisSystemBootstrapper { isisSessionFactory.destroyServicesAndShutdown(); pmf.close(); -IsisContext.testReset(); +IsisContext.clear(); } public void tearDownAllModules() { diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java index 9763ff5..3e4bf99 100644 --- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java +++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java @@ -19,8 +19,15 @@ package org.apache.isis.core.runtime.system.context; +import java.util.Optional; + import org.apache.isis.applib.internal.context._Context; +import org.apache.isis.core.commons.config.IsisConfiguration; +import org.apache.isis.core.metamodel.services.ServicesInjector; +import org.apache.isis.core.metamodel.specloader.SpecificationLoader; import org.apache.isis.core.metamodel.specloader.validator.MetaModelInvalidException; +import org.apache.isis.core.runtime.system.persistence.PersistenceSession; +import org.apache.isis.core.runtime.system.session.IsisSession; import org.apache.isis.core.runtime.system.session.IsisSessionFactory; /** @@ -40,6 +47,7 @@ public interface IsisContext { /** * * @return Isis's session factory +* @throws IllegalStateException if IsisSessionFactory not initialized */ // Implementation Note: Populated only by {@link IsisSessionFactoryBuilder}. public static IsisSessionFactory getSessionFactory() { @@ -68,16 +76,39 @@ public interface IsisContext { resetLogging(); } -// -- DEPRECATIONS +// -- CONVENIENT SHORTCUTS /** - * Resets - * @deprecated replaced by {@link #clear()} - * + * @return framework's current PersistenceSession (if any) + * @throws IllegalStateException if IsisSessionFactory not initialized + */ +public static Optional getPersistenceSession() { +return Optional.ofNullable(getSessionFactory().getCurrentSession()) + .map(IsisSession::getPersistenceSession); +} + +/** + * @return framework's IsisConfiguration + * @throws IllegalStateException if IsisSessionFactory not initialized + */ +public static IsisConfiguration getConfiguration() { +return getSessionFactory().getConfiguration(); +} + +/** + * @return framework's SpecificationLoader + * @throws IllegalStateException if IsisSessionFactory not initialized + */ +public static SpecificationLoader getSpecificationLoader() { +return getSessionFactory().getSpecificationLoader(); +} + +/** + * @return framework's ServicesInjector + * @throws IllegalStateException if IsisSessionFactory not initialized */ -@Deprecated -
[isis] branch master updated (9a51b98 -> 318c156)
This is an automated email from the ASF dual-hosted git repository. ahuber pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/isis.git. from 9a51b98 ISIS-1940 let the SortedSet-of-list adapter return a comparator=null new dfe84e1 ISIS-898: hardcode AjaxFallbackLink to be enabled in hierarchy new 5b92468 ISIS-1841: IsisContext: adds shortcuts for convenience new 318c156 ISIS-898: completes proof of concept The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../core/integtestsupport/IsisSystemForTest.java | 2 +- .../runtime/headless/IsisSystemBootstrapper.java | 2 +- .../core/runtime/system/context/IsisContext.java | 45 ++-- .../components/tree/IsisToWicketTreeAdapter.java | 123 ++--- 4 files changed, 146 insertions(+), 26 deletions(-) -- To stop receiving notification emails like this one, please contact ahu...@apache.org.