You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/04/22 11:47:36 UTC
[01/14] isis git commit: ISIS-1387: ensure that the geneated bs3
layout XML files have suitable namespace prefix 'bs3:' and 'cpt:'
Repository: isis
Updated Branches:
refs/heads/ISIS-1291 43e919eb9 -> 10693b1a4
ISIS-1387: ensure that the geneated bs3 layout XML files have suitable namespace prefix 'bs3:' and 'cpt:'
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/4846c96d
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/4846c96d
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/4846c96d
Branch: refs/heads/ISIS-1291
Commit: 4846c96dadceedf9c76df7058d9e0ac62e2c33b4
Parents: 6bff3d3
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 13:17:19 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 13:33:52 2016 +0100
----------------------------------------------------------------------
.../org/apache/isis/applib/layout/component/package-info.java | 7 +++++--
.../isis/applib/layout/grid/bootstrap3/package-info.java | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/4846c96d/core/applib/src/main/java/org/apache/isis/applib/layout/component/package-info.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/component/package-info.java b/core/applib/src/main/java/org/apache/isis/applib/layout/component/package-info.java
index 3b17836..49bcff5 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/layout/component/package-info.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/layout/component/package-info.java
@@ -29,8 +29,11 @@
*/
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://isis.apache.org/applib/layout/component",
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
- // specifying the location seems to cause JaxbService#toXsd() to not generate the schema; not sure why...
+ elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+ xmlns = {
+ @javax.xml.bind.annotation.XmlNs(
+ namespaceURI = "http://isis.apache.org/applib/layout/component", prefix = "cpt")
+ } // specifying the location seems to cause JaxbService#toXsd() to not generate the schema; not sure why...
//, location = ..."http://isis.apache.org/schema/metamodel/layout/common/common.xsd"
)
package org.apache.isis.applib.layout.component;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/4846c96d/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/package-info.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/package-info.java b/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/package-info.java
index 3658ae9..6fcc0e7 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/package-info.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/package-info.java
@@ -29,6 +29,9 @@
*/
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://isis.apache.org/applib/layout/grid/bootstrap3",
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
-)
+ elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+ xmlns = {
+ @javax.xml.bind.annotation.XmlNs(
+ namespaceURI = "http://isis.apache.org/applib/layout/grid/bootstrap3", prefix = "bs3")
+ })
package org.apache.isis.applib.layout.grid.bootstrap3;
\ No newline at end of file
[11/14] isis git commit: ISIS-1374: ditto.
Posted by da...@apache.org.
ISIS-1374: ditto.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7c379667
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7c379667
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7c379667
Branch: refs/heads/ISIS-1291
Commit: 7c3796674bba8859c8c16d5819706b8c5558aae4
Parents: d605797
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 16:25:39 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 16:25:39 2016 +0100
----------------------------------------------------------------------
.../ActionInvocationFacetForDomainEventAbstract.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7c379667/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 8981bfc..4d1485f 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -431,16 +431,19 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
LOG.debug(" action result " + result);
}
if (result == null) {
-
+
if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
// if this was a void method on cloneable view model, then (to save boilerplate in the domain)
// automatically do the clone and return the clone instead.
final ViewModelFacet facet = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
final Object clone = facet.clone(targetAdapter.getObject());
final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
- return InvocationResult.forActionThatReturned(clonedAdapter);
+
+ resultAdapter = clonedAdapter;
+
+ } else {
+ resultAdapter = null;
}
- resultAdapter = null;
} else {
[04/14] isis git commit: ISIS-1374: now correctly persisting the
mixinFqClassName into the cmd memento for mixin actions.
Posted by da...@apache.org.
ISIS-1374: now correctly persisting the mixinFqClassName into the cmd memento for mixin actions.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/af4e3ca2
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/af4e3ca2
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/af4e3ca2
Branch: refs/heads/ISIS-1291
Commit: af4e3ca200b1530c7c7ae9ae0bff94b31d4632ae
Parents: 0a33532
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 13:30:03 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 13:34:58 2016 +0100
----------------------------------------------------------------------
...onInvocationFacetForDomainEventAbstract.java | 5 +--
.../specimpl/ObjectActionMixedIn.java | 44 ++++++++++++++++++++
.../command/CommandMementoServiceDefault.java | 7 +++-
3 files changed, 52 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/af4e3ca2/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 6199504..fc85208 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -42,11 +42,9 @@ import org.apache.isis.applib.services.background.ActionInvocationMemento;
import org.apache.isis.applib.services.bookmark.Bookmark;
import org.apache.isis.applib.services.command.Command;
import org.apache.isis.applib.services.command.CommandContext;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.applib.services.command.spi.CommandService;
import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.applib.services.jaxb.JaxbService;
import org.apache.isis.applib.services.queryresultscache.QueryResultsCache;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
@@ -71,6 +69,7 @@ import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFa
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.specloader.ReflectiveActionException;
@@ -338,7 +337,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
}
if(command.getMemento() == null) {
- // similarly, guard here to deal with subsequent contributed/mixin actions.
+ // similarly, guard here to deal with subsequent or prior contributed/mixin actions.
final CommandMementoService commandMementoService = getCommandMementoService();
http://git-wip-us.apache.org/repos/asf/isis/blob/af4e3ca2/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
index 483d140..9bdb98e 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
@@ -45,9 +45,12 @@ import org.apache.isis.core.metamodel.facets.all.named.NamedFacetInferred;
import org.apache.isis.core.metamodel.interactions.InteractionUtils;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
import org.apache.isis.core.metamodel.interactions.VisibilityContext;
+import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
+import org.apache.isis.schema.cmd.v1.CommandMementoDto;
+import org.apache.isis.schema.utils.CommandMementoDtoUtils;
public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInMember2 {
@@ -231,7 +234,31 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
final Bookmark targetBookmark = CommandUtil.bookmarkFor(mixedInAdapter);
command.setTarget(targetBookmark);
+
+ }
+
+ if(command.getMemento() == null) {
+ // similarly, guard here to deal with subsequent or prior contributed/mixin actions.
+
+ final CommandMementoService commandMementoService = getCommandMementoService();
+
+ final CommandMementoDto dto = commandMementoService.asCommandMemento(
+ Collections.singletonList(mixedInAdapter),
+ this, arguments);
+
+ if(dto != null) {
+ // the default implementation will always return a dto. The guard is to allow
+ // for the default implementation to be replaced with a version that returns null
+ // allowing a fallback to the original API (using ActionInvocationMemento rather than
+ // CommandMementoDto).
+ final String mementoXml = CommandMementoDtoUtils.toXml(dto);
+ command.setMemento(mementoXml);
+ } else {
+ // no fallback to old behaviour is required; mixin actions were simply not correctly supported.
+ }
}
+
+
}
return mixinAction.execute(mixinAdapterFor(mixinType, mixedInAdapter), arguments, interactionInitiatedBy);
@@ -250,6 +277,10 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
return mixinAdapterFor(mixinType, mixedInAdapter);
}
+ private static Object unwrap(final ObjectAdapter adapter) {
+ return adapter == null ? null : adapter.getObject();
+ }
+
/* (non-Javadoc)
* @see org.apache.isis.core.metamodel.specloader.specimpl.ObjectMemberAbstract#getIdentifier()
*/
@@ -263,4 +294,17 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
return getSpecificationLoader().loadSpecification(mixinType);
}
+
+
+
+ // //////////////////////////////////////
+
+ private CommandMementoService getCommandMementoService() {
+ return lookupService(CommandMementoService.class);
+ }
+
+ private <T> T lookupService(final Class<T> serviceClass) {
+ return getServicesInjector().lookupService(serviceClass);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/af4e3ca2/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
index 1f09abb..9ec9094 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
@@ -42,6 +42,7 @@ import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionMixedIn;
import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
import org.apache.isis.core.runtime.services.memento.MementoServiceDefault;
import org.apache.isis.core.runtime.system.context.IsisContext;
@@ -169,7 +170,11 @@ public class CommandMementoServiceDefault implements CommandMementoService {
final Object arg = argAdapter != null? argAdapter.getObject(): null;
CommandMementoDtoUtils.addParamArg(actionDto.getParameters(), parameterName, paramType, arg, bookmarkService);
}
- actionDto.setMixinFqClassName(null);
+ if(objectAction instanceof ObjectActionMixedIn) {
+ final ObjectActionMixedIn actionMixedIn = (ObjectActionMixedIn) objectAction;
+ final String mixinTypeName = actionMixedIn.getMixinType().getCorrespondingClass().getName();
+ actionDto.setMixinFqClassName(mixinTypeName);
+ }
dto.setTransactionId(UUID.randomUUID().toString());
return dto;
[07/14] isis git commit: ISIS-1344: deleting some unused exception
classes and deprecated adapter classes, part of runtime/system/transaction
Posted by da...@apache.org.
ISIS-1344: deleting some unused exception classes and deprecated adapter classes, part of runtime/system/transaction
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7fcb167e
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7fcb167e
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7fcb167e
Branch: refs/heads/ISIS-1291
Commit: 7fcb167e99298e9346cafaabae8c0ac3b669e5ce
Parents: 624292a
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 16:09:21 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 16:09:21 2016 +0100
----------------------------------------------------------------------
.../IsisTransactionManagerCommitException.java | 43 --------------------
...sTransactionManagerDomCallbackException.java | 43 --------------------
...ansactionManagerResourceCommitException.java | 43 --------------------
.../TransactionalClosureAbstract.java | 30 --------------
.../TransactionalClosureWithReturnAbstract.java | 30 --------------
5 files changed, 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7fcb167e/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerCommitException.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerCommitException.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerCommitException.java
deleted file mode 100644
index 2d88353..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerCommitException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class IsisTransactionManagerCommitException extends IsisException {
-
- private static final long serialVersionUID = 1L;
-
- public IsisTransactionManagerCommitException() {
- }
-
- public IsisTransactionManagerCommitException(final String message) {
- super(message);
- }
-
- public IsisTransactionManagerCommitException(final Throwable cause) {
- super(cause);
- }
-
- public IsisTransactionManagerCommitException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7fcb167e/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerDomCallbackException.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerDomCallbackException.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerDomCallbackException.java
deleted file mode 100644
index 8201b0f..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerDomCallbackException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class IsisTransactionManagerDomCallbackException extends IsisException {
-
- private static final long serialVersionUID = 1L;
-
- public IsisTransactionManagerDomCallbackException() {
- }
-
- public IsisTransactionManagerDomCallbackException(final String message) {
- super(message);
- }
-
- public IsisTransactionManagerDomCallbackException(final Throwable cause) {
- super(cause);
- }
-
- public IsisTransactionManagerDomCallbackException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7fcb167e/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerResourceCommitException.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerResourceCommitException.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerResourceCommitException.java
deleted file mode 100644
index da13e54..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManagerResourceCommitException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class IsisTransactionManagerResourceCommitException extends IsisException {
-
- private static final long serialVersionUID = 1L;
-
- public IsisTransactionManagerResourceCommitException() {
- }
-
- public IsisTransactionManagerResourceCommitException(final String message) {
- super(message);
- }
-
- public IsisTransactionManagerResourceCommitException(final Throwable cause) {
- super(cause);
- }
-
- public IsisTransactionManagerResourceCommitException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7fcb167e/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
deleted file mode 100644
index cace0c3..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-/**
- * Not used by the framework, but provided for backward compatibility.
- *
- * @deprecated - implement {@link TransactionalClosure} instead
- */
-@Deprecated
-public abstract class TransactionalClosureAbstract implements TransactionalClosure {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7fcb167e/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
deleted file mode 100644
index 78849b8..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-/**
- * Not used by the framework, but provided for backward compatibility.
- *
- * @deprecated - implement {@link TransactionalClosureWithReturn} instead
- */
-@Deprecated
-public abstract class TransactionalClosureWithReturnAbstract<T> implements TransactionalClosureWithReturn<T> {
-
-}
[13/14] isis git commit: ISIS-1374: moved setupXxx functionality out
of ActionInvocationFacet,
and into ObjectActionDefault. Removed duplication with ObjectActionMixedIn and
ObjectActionContributee.
Posted by da...@apache.org.
ISIS-1374: moved setupXxx functionality out of ActionInvocationFacet, and into ObjectActionDefault. Removed duplication with ObjectActionMixedIn and ObjectActionContributee.
Also:
- removed unnecessary guards for CommandContext or Command being null (they never will)
- removed (after all) the idea of CommandMento
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/46089a20
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/46089a20
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/46089a20
Branch: refs/heads/ISIS-1291
Commit: 46089a2037e829f1b387a78b17f2e3a1d73cc923
Parents: 6da1e31
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Apr 22 09:34:20 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Apr 22 09:34:20 2016 +0100
----------------------------------------------------------------------
...onInvocationFacetForDomainEventAbstract.java | 525 +++++++++----------
.../PropertySetterFacetViaModifyMethod.java | 36 +-
.../services/command/CommandMementoService.java | 4 +-
.../metamodel/spec/feature/ObjectAction.java | 18 +-
.../specimpl/ObjectActionContributee.java | 55 +-
.../specimpl/ObjectActionDefault.java | 190 ++++++-
.../specimpl/ObjectActionMixedIn.java | 109 +---
.../background/BackgroundServiceDefault.java | 18 +-
8 files changed, 504 insertions(+), 451 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 99f0ca4..bac5458 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -34,18 +34,18 @@ import org.slf4j.LoggerFactory;
import org.apache.isis.applib.NonRecoverableException;
import org.apache.isis.applib.RecoverableException;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.InvokedOn;
import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
-import org.apache.isis.applib.services.background.ActionInvocationMemento;
import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
import org.apache.isis.applib.services.command.Command;
import org.apache.isis.applib.services.command.CommandContext;
import org.apache.isis.applib.services.command.spi.CommandService;
import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.applib.services.metamodel.MetaModelService2;
import org.apache.isis.applib.services.queryresultscache.QueryResultsCache;
+import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.applib.services.xactn.TransactionService;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
import org.apache.isis.core.commons.config.IsisConfiguration;
@@ -62,21 +62,16 @@ import org.apache.isis.core.metamodel.facets.DomainEventHelper;
import org.apache.isis.core.metamodel.facets.ImperativeFacet;
import org.apache.isis.core.metamodel.facets.actcoll.typeof.ElementSpecificationProviderFromTypeOfFacet;
import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
-import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.specloader.ReflectiveActionException;
import org.apache.isis.core.metamodel.transactions.TransactionState;
import org.apache.isis.core.metamodel.transactions.TransactionStateProvider;
-import org.apache.isis.schema.cmd.v1.CommandMementoDto;
-import org.apache.isis.schema.utils.CommandMementoDtoUtils;
public abstract class ActionInvocationFacetForDomainEventAbstract
extends ActionInvocationFacetAbstract
@@ -196,7 +191,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
final InteractionInitiatedBy interactionInitiatedBy) {
final CommandContext commandContext = getCommandContext();
- final Command command = commandContext != null ? commandContext.getCommand() : null;
+ final Command command = commandContext.getCommand();
// ... post the executing event
final ActionDomainEvent<?> event =
@@ -207,214 +202,55 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
command,
null);
- // ... invoke the action
- InvocationResult result1;
-
- try {
-
- final Object[] executionParameters = new Object[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- executionParameters[i] = unwrap(arguments[i]);
- }
-
- final Object targetPojo = unwrap(targetAdapter);
-
- final BulkFacet bulkFacet = getFacetHolder().getFacet(BulkFacet.class);
- if (bulkFacet != null) {
- final ActionInvocationContext actionInvocationContext = getActionInvocationContext();
- if (actionInvocationContext != null &&
- actionInvocationContext.getInvokedOn() == null) {
-
- actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
- actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
- }
-
- final Bulk.InteractionContext bulkInteractionContext = getBulkInteractionContext();
-
- if (bulkInteractionContext != null &&
- bulkInteractionContext.getInvokedAs() == null) {
-
- bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
- actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
- }
- }
-
- if(command != null && command.getExecutor() == Command.Executor.USER && owningAction != null) {
-
- if(command.getTarget() != null) {
- // already set up by a ObjectActionContributee or edit form;
- // don't overwrite
- } else {
- command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
- command.setTargetAction(CommandUtil.targetActionNameFor(owningAction));
- command.setArguments(CommandUtil.argDescriptionFor(owningAction, arguments));
-
- final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
- command.setTarget(targetBookmark);
- }
-
- if(Command.ACTION_IDENTIFIER_FOR_EDIT.equals(command.getMemberIdentifier())) {
- // special case for edit properties
- } else {
-
- if(command.getMemberIdentifier() == null) {
- // any contributed/mixin actions will fire after the main action
- // the guard here prevents them from trashing the command's memberIdentifier
- command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));
- }
-
- if(command.getMemento() == null) {
- // similarly, guard here to deal with subsequent or prior contributed/mixin actions.
-
- final CommandMementoService commandMementoService = getCommandMementoService();
-
- final Object targetObject = unwrap(targetAdapter);
- final Object[] args = CommandUtil.objectsFor(arguments);
-
- final CommandMementoDto dto = commandMementoService.asCommandMemento(
- Collections.singletonList(targetAdapter),
- owningAction, arguments);
-
- if(dto != null) {
- // the default implementation will always return a dto. The guard is to allow
- // for the default implementation to be replaced with a version that returns null
- // allowing a fallback to the original API (using ActionInvocationMemento rather than
- // CommandMementoDto).
- final String mementoXml = CommandMementoDtoUtils.toXml(dto);
- command.setMemento(mementoXml);
- } else {
-
- // fallback to old behaviour
- ActionInvocationMemento aim = commandMementoService
- .asActionInvocationMemento(method, targetObject, args);
- if(aim != null) {
- command.setMemento(aim.asMementoString());
-
- } else {
- String actionIdentifier = owningAction.getIdentifier().toClassAndNameIdentityString();
- throw new IsisException(
- "Unable to build memento for action " + actionIdentifier);
- }
- }
- }
- }
-
- // copy over the command execution 'context' (if available)
- final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
- if(commandFacet != null && !commandFacet.isDisabled()) {
- command.setExecuteIn(commandFacet.executeIn());
- command.setPersistence(commandFacet.persistence());
- } else {
- // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
- command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
- command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
- }
- }
+ final InvocationResult invocationResult = invoke(owningAction, targetAdapter, arguments);
+ final ObjectAdapter invocationResultAdapter = invocationResult.getAdapter();
- ObjectAdapter resultAdapter;
+ // ... post the executed event
+ if (invocationResult.getWhetherInvoked()) {
+ // perhaps the Action was not properly invoked (i.e. an exception was raised).
+ // If invoked ok, then post to the event bus
+ domainEventHelper.postEventForAction(
+ AbstractDomainEvent.Phase.EXECUTED,
+ eventType, verify(event),
+ owningAction, targetAdapter, arguments,
+ command,
+ invocationResultAdapter);
+ }
- if( command != null &&
- command.getExecutor() == Command.Executor.USER &&
- command.getExecuteIn() == org.apache.isis.applib.annotation.Command.ExecuteIn.BACKGROUND) {
+ if (invocationResultAdapter == null) {
+ return null;
+ }
- // deal with background commands
+ return filteredIfRequired(invocationResultAdapter, interactionInitiatedBy);
- // persist command so can be this command can be in the 'background'
- final CommandService commandService = getCommandService();
- if (!commandService.persistIfPossible(command)) {
- throw new IsisException(
- "Unable to schedule action '"
- + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
- + "CommandService does not support persistent commands " );
- }
- resultAdapter = getAdapterManager().adapterFor(command);
+ }
- } else {
+ protected InvocationResult invoke(
+ final ObjectAction owningAction,
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments) {
- // otherwise, go ahead and execute action in the 'foreground'
- if(command != null) {
- command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
- }
+ final CommandContext commandContext = getCommandContext();
+ final Command command = commandContext.getCommand();
- final ActionSemanticsFacet semanticsFacet = getFacetHolder().getFacet(ActionSemanticsFacet.class);
- final boolean cacheable = semanticsFacet != null && semanticsFacet.value().isSafeAndRequestCacheable();
-
- Object result11;
- if(cacheable) {
- final QueryResultsCache queryResultsCache = getQueryResultsCache();
- final Object[] targetPojoPlusExecutionParameters = ArrayExtensions.appendT(executionParameters, targetPojo);
- result11 = queryResultsCache.execute(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- return method.invoke(targetPojo, executionParameters);
- }
- }, targetPojo.getClass(), method.getName(), targetPojoPlusExecutionParameters);
- } else {
- result11 = method.invoke(targetPojo, executionParameters);
- }
+ try {
+ setupActionInvocationContext(owningAction, targetAdapter);
- if (LOG.isDebugEnabled()) {
- LOG.debug(" action result " + result11);
- }
- if (result11 == null) {
-
- if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
- // if this was a void method on cloneable view model, then (to save boilerplate in the domain)
- // automatically do the clone and return the clone instead.
- final ViewModelFacet facet1 = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
- final Object clone = facet1.clone(targetAdapter.getObject());
- final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
-
- resultAdapter = clonedAdapter;
-
- } else {
- resultAdapter = null;
- }
-
- } else {
-
- resultAdapter = getAdapterManager().adapterFor(result11);
-
- if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
- // if the object returned is cloneable, then
- // (to save boilerplate in the domain) automatically do the clone.
- final ViewModelFacet facet1 = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
- result11 = facet1.clone(result11);
- resultAdapter = getAdapterManager().adapterFor(result11);
- }
-
-
- // copy over TypeOfFacet if required
- final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
- resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
-
- if(command != null) {
- if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
- final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
- command.setResult(bookmark);
- }
- }
-
- if(currentInvocation.get() == null) {
- final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
- if(publishedActionFacet != null) {
- currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(),
- arguments, resultAdapter, command));
- }
- }
- }
+ owningAction.setupCommand(targetAdapter, arguments);
- }
+ ObjectAdapter resultAdapter = invokeThruCommand(owningAction, targetAdapter, arguments, command);
- result1 = InvocationResult.forActionThatReturned(resultAdapter);
+ return InvocationResult.forActionThatReturned(resultAdapter);
} catch (final IllegalArgumentException e) {
throw e;
} catch (final InvocationTargetException e) {
final Throwable targetException = e.getTargetException();
if (targetException instanceof IllegalStateException) {
- throw new ReflectiveActionException("IllegalStateException thrown while executing " + method + " " + targetException.getMessage(), targetException);
+ throw new ReflectiveActionException( String.format(
+ "IllegalStateException thrown while executing %s %s",
+ method, targetException.getMessage()), targetException);
}
if(targetException instanceof RecoverableException) {
if (!getTransactionState().canCommit()) {
@@ -424,13 +260,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
Throwable nonRecoverableCause = targetExceptionCause != null? targetExceptionCause: targetException;
// trim to first 300 chars
- String message = nonRecoverableCause.getMessage();
- if(!Strings.isNullOrEmpty(message)) {
- message = message.substring(0, Math.min(message.length(), 300));
- if(message.length() == 300) {
- message += " ...";
- }
- }
+ final String message = trim(nonRecoverableCause.getMessage(), 300);
throw new NonRecoverableException(message, nonRecoverableCause);
}
@@ -439,63 +269,236 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
ThrowableExtensions.throwWithinIsisException(e, "Exception executing " + method);
// Action was not invoked (an Exception was thrown)
- result1 = InvocationResult.forActionNotInvoked();
+ return InvocationResult.forActionNotInvoked();
+
} catch (final IllegalAccessException e) {
throw new ReflectiveActionException("Illegal access of " + method, e);
}
- final InvocationResult invocationResult = result1;
- final ObjectAdapter invocationResultAdapter = invocationResult.getAdapter();
+ }
- // ... post the executed event
- if (invocationResult.getWhetherInvoked()) {
- // perhaps the Action was not properly invoked (i.e. an exception was raised).
- // If invoked ok, then post to the event bus
- domainEventHelper.postEventForAction(
- AbstractDomainEvent.Phase.EXECUTED,
- eventType, verify(event),
- owningAction, targetAdapter, arguments,
- command,
- invocationResultAdapter);
+ private static String trim(String message, final int maxLen) {
+ if(!Strings.isNullOrEmpty(message)) {
+ message = message.substring(0, Math.min(message.length(), maxLen));
+ if(message.length() == maxLen) {
+ message += " ...";
+ }
}
+ return message;
+ }
- if (invocationResultAdapter == null) {
- return null;
+ protected void setupActionInvocationContext(
+ final ObjectAction owningAction,
+ final ObjectAdapter targetAdapter) {
+
+ owningAction.setupActionInvocationContext(targetAdapter);
+ }
+
+ protected ObjectAdapter invokeThruCommand(
+ final ObjectAction owningAction,
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments, final Command command)
+ throws IllegalAccessException, InvocationTargetException {
+ final ObjectAdapter resultAdapter;
+ if( command.getExecutor() == Command.Executor.USER &&
+ command.getExecuteIn() == org.apache.isis.applib.annotation.Command.ExecuteIn.BACKGROUND) {
+
+ // deal with background commands
+
+ // persist command so can be this command can be in the 'background'
+ final CommandService commandService = getCommandService();
+ if (!commandService.persistIfPossible(command)) {
+ throw new IsisException(
+ "Unable to schedule action '"
+ + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
+ + "CommandService does not support persistent commands " );
+ }
+ resultAdapter = getAdapterManager().adapterFor(command);
+
+ } else {
+
+ // otherwise, go ahead and execute action in the 'foreground'
+ command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
+
+ final Object resultPojo = invokeMethodElseFromCache(targetAdapter, arguments);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" action result " + resultPojo);
+ }
+
+ resultAdapter = cloneIfViewModelCloneable(resultPojo, targetAdapter);
+
+ setCommandResultIfEntity(command, resultAdapter);
+ captureCurrentInvocationForPublishing(owningAction, targetAdapter, arguments, command, resultAdapter);
}
+ return resultAdapter;
+ }
- boolean filterForVisibility = getConfiguration().getBoolean("isis.reflector.facet.filterVisibility", true);
- if(filterForVisibility) {
- final Object result = invocationResultAdapter.getObject();
- if(result instanceof Collection || result.getClass().isArray()) {
- final CollectionFacet facet = CollectionFacet.Utils.getCollectionFacetFromSpec(invocationResultAdapter);
-
- final Iterable<ObjectAdapter> adapterList = facet.iterable(invocationResultAdapter);
- final List<ObjectAdapter> visibleAdapters =
- ObjectAdapter.Util.visibleAdapters(
- adapterList,
- interactionInitiatedBy);
- final Object visibleObjects =
- CollectionUtils.copyOf(
- Lists.transform(visibleAdapters, ObjectAdapter.Functions.getObject()),
- method.getReturnType());
- if (visibleObjects != null) {
- return getAdapterManager().adapterFor(visibleObjects);
- }
- // would be null if unable to take a copy (unrecognized return type)
- // fallback to returning the original adapter, without filtering for visibility
-
- } else {
- boolean visible =
- ObjectAdapter.Util.isVisible(
- invocationResultAdapter,
- interactionInitiatedBy);
- if(!visible) {
- return null;
+
+ protected Object invokeMethodElseFromCache(
+ final ObjectAdapter targetAdapter, final ObjectAdapter[] arguments)
+ throws IllegalAccessException, InvocationTargetException {
+
+ final Object[] executionParameters = new Object[arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ executionParameters[i] = unwrap(arguments[i]);
+ }
+
+ final Object targetPojo = unwrap(targetAdapter);
+
+ final ActionSemanticsFacet semanticsFacet = getFacetHolder().getFacet(ActionSemanticsFacet.class);
+ final boolean cacheable = semanticsFacet != null && semanticsFacet.value().isSafeAndRequestCacheable();
+ if(cacheable) {
+ final QueryResultsCache queryResultsCache = getQueryResultsCache();
+ final Object[] targetPojoPlusExecutionParameters = ArrayExtensions.appendT(executionParameters, targetPojo);
+ return queryResultsCache.execute(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ return method.invoke(targetPojo, executionParameters);
}
+ }, targetPojo.getClass(), method.getName(), targetPojoPlusExecutionParameters);
+
+ } else {
+ return method.invoke(targetPojo, executionParameters);
+ }
+ }
+
+ protected ObjectAdapter cloneIfViewModelCloneable(
+ final Object resultPojo,
+ final ObjectAdapter targetAdapter) {
+
+ // to remove boilerplate from the domain, we automatically clone the returned object if it is a view model.
+
+ if (resultPojo != null) {
+ final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(resultPojo);
+ return cloneIfViewModelElse(resultAdapter, resultAdapter);
+ } else {
+ // if void or null, attempt to clone the original target, else return null.
+ return cloneIfViewModelElse(targetAdapter, null);
+ }
+ }
+
+ private ObjectAdapter cloneIfViewModelElse(final ObjectAdapter adapter, final ObjectAdapter dfltAdapter) {
+
+ if (!adapter.getSpecification().isViewModelCloneable(adapter)) {
+ return dfltAdapter;
+ }
+
+ final ViewModelFacet viewModelFacet = adapter.getSpecification().getFacet(ViewModelFacet.class);
+ final Object clone = viewModelFacet.clone(adapter.getObject());
+
+ final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
+
+ // copy over TypeOfFacet if required
+ final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
+ clonedAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
+
+ return clonedAdapter;
+ }
+
+
+ protected void setCommandResultIfEntity(final Command command, final ObjectAdapter resultAdapter) {
+ if(command.getResult() != null) {
+ // don't trample over any existing result, eg subsequent mixins.
+ return;
+ }
+ if (resultAdapter == null) {
+ return;
+ }
+
+ final Class<?> domainType = resultAdapter.getSpecification().getCorrespondingClass();
+ final MetaModelService2.Sort sort = getMetaModelService().sortOf(domainType);
+ switch (sort) {
+ case JDO_ENTITY:
+ final Object domainObject = resultAdapter.getObject();
+ // ensure that any still-to-be-persisted adapters get persisted to DB.
+ if(!getRepositoryService().isPersistent(domainObject)) {
+ getTransactionService().flushTransaction();
}
+ if(getRepositoryService().isPersistent(domainObject)) {
+ BookmarkService bookmarkService = getBookmarkService();
+ Bookmark bookmark = bookmarkService.bookmarkFor(domainObject);
+ command.setResult(bookmark);
+ }
+ break;
+ default:
+ // ignore all other sorts of objects
+ break;
+ }
+ }
+
+ private MetaModelService2 getMetaModelService() {
+ return lookupService(MetaModelService2.class);
+ }
+
+ private TransactionService getTransactionService() {
+ return lookupService(TransactionService.class);
+ }
+
+ private BookmarkService getBookmarkService() {
+ return lookupService(BookmarkService.class);
+ }
+
+ private RepositoryService getRepositoryService() {
+ return lookupService(RepositoryService.class);
+ }
+
+ protected void captureCurrentInvocationForPublishing(
+ final ObjectAction owningAction,
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments,
+ final Command command,
+ final ObjectAdapter resultAdapter) {
+
+ // TODO: should instead be using the top-level ActionInvocationMemento associated with command.
+
+ final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
+ if (publishedActionFacet != null && currentInvocation.get() == null) {
+ final CurrentInvocation currentInvocation = new CurrentInvocation(
+ targetAdapter, owningAction, getIdentified(),
+ arguments, resultAdapter, command);
+ ActionInvocationFacet.currentInvocation.set(currentInvocation);
+ }
+ }
+
+ protected ObjectAdapter filteredIfRequired(
+ final ObjectAdapter resultAdapter,
+ final InteractionInitiatedBy interactionInitiatedBy) {
+
+ final boolean filterForVisibility = getConfiguration().getBoolean("isis.reflector.facet.filterVisibility", true);
+ if (!filterForVisibility) {
+ return resultAdapter;
+ }
+
+ final Object result = resultAdapter.getObject();
+
+ if(result instanceof Collection || result.getClass().isArray()) {
+ final CollectionFacet facet = CollectionFacet.Utils.getCollectionFacetFromSpec(resultAdapter);
+
+ final Iterable<ObjectAdapter> adapterList = facet.iterable(resultAdapter);
+ final List<ObjectAdapter> visibleAdapters =
+ ObjectAdapter.Util.visibleAdapters(
+ adapterList,
+ interactionInitiatedBy);
+ final Object visibleObjects =
+ CollectionUtils.copyOf(
+ Lists.transform(visibleAdapters, ObjectAdapter.Functions.getObject()),
+ method.getReturnType());
+ if (visibleObjects != null) {
+ return getAdapterManager().adapterFor(visibleObjects);
+ }
+
+ // would be null if unable to take a copy (unrecognized return type)
+ // fallback to returning the original adapter, without filtering for visibility
+
+ return resultAdapter;
+
+ } else {
+ boolean visible = ObjectAdapter.Util.isVisible(resultAdapter, interactionInitiatedBy);
+ return visible ? resultAdapter : null;
}
- return invocationResultAdapter;
}
+
/**
* Optional hook to allow the facet implementation for the deprecated {@link org.apache.isis.applib.annotation.PostsActionInvokedEvent} annotation
* to discard the event if the domain event is of a different type (specifically if was installed by virtue of a no
@@ -528,7 +531,11 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
// /////////////////////////////////////////////////////////
private CommandContext getCommandContext() {
- return lookupService(CommandContext.class);
+ CommandContext commandContext = lookupService(CommandContext.class);
+ if (commandContext == null) {
+ throw new IllegalStateException("The CommandContext service is not registered!");
+ }
+ return commandContext;
}
private QueryResultsCache getQueryResultsCache() {
@@ -539,18 +546,6 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
return lookupService(CommandService.class);
}
- private CommandMementoService getCommandMementoService() {
- return lookupService(CommandMementoService.class);
- }
-
- private Bulk.InteractionContext getBulkInteractionContext() {
- return lookupService(Bulk.InteractionContext.class);
- }
-
- private ActionInvocationContext getActionInvocationContext() {
- return lookupService(ActionInvocationContext.class);
- }
-
private <T> T lookupService(final Class<T> serviceClass) {
return getServicesInjector().lookupService(serviceClass);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/modify/PropertySetterFacetViaModifyMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/modify/PropertySetterFacetViaModifyMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/modify/PropertySetterFacetViaModifyMethod.java
index 9339274..32865c5 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/modify/PropertySetterFacetViaModifyMethod.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/modify/PropertySetterFacetViaModifyMethod.java
@@ -64,24 +64,20 @@ public class PropertySetterFacetViaModifyMethod extends PropertySetterFacetAbstr
final InteractionInitiatedBy interactionInitiatedBy) {
final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
- final Command command;
+ final Command command = commandContext.getCommand();
- if (commandContext != null) {
- command = commandContext.getCommand();
+ // cf similar code in ActionInvocationFacetForDomainEventFacet
+ command.setExecutor(Command.Executor.USER);
- // cf similar code in ActionInvocationFacetForDomainEventFacet
- command.setExecutor(Command.Executor.USER);
+ command.setTarget(CommandUtil.bookmarkFor(targetAdapter));
+ command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
+ command.setTargetAction(Command.ACTION_IDENTIFIER_FOR_EDIT);
+ command.setMemberIdentifier(Command.ACTION_IDENTIFIER_FOR_EDIT);
- command.setTarget(CommandUtil.bookmarkFor(targetAdapter));
- command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
- command.setTargetAction(Command.ACTION_IDENTIFIER_FOR_EDIT);
- command.setMemberIdentifier(Command.ACTION_IDENTIFIER_FOR_EDIT);
+ command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
+ command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
- command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
- command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
-
- command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
- }
+ command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
ObjectAdapter.InvokeUtils.invoke(method, targetAdapter, valueAdapter);
}
@@ -96,4 +92,16 @@ public class PropertySetterFacetViaModifyMethod extends PropertySetterFacetAbstr
return servicesInjector;
}
+ private <T> T lookupService(final Class<T> serviceClass) {
+ return getServicesInjector().lookupService(serviceClass);
+ }
+
+ protected CommandContext getCommandContext() {
+ CommandContext commandContext = lookupService(CommandContext.class);
+ if (commandContext == null) {
+ throw new IllegalStateException("The CommandContext service is not registered!");
+ }
+ return commandContext;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/command/CommandMementoService.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/command/CommandMementoService.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/command/CommandMementoService.java
index acbec29..713d2de 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/command/CommandMementoService.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/command/CommandMementoService.java
@@ -41,8 +41,8 @@ public interface CommandMementoService {
ActionInvocationMemento asActionInvocationMemento(Method m, Object domainObject, Object[] args);
/**
- * The default implementation returns a non-null value. If a custom implementation returns <tt>null</tt>, then
- * the framework will fall back to using the deprecated {@link #asActionInvocationMemento(Method, Object, Object[])}.
+ * Returns a JAXB DTO (hence convertible to XML) that represents the intention to invoke an action on an action
+ * (or possible many, for bulk actions). The action can be a mixin action or a contributed action.
*/
@Programmatic
CommandMementoDto asCommandMemento(
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
index 659c5dc..cf50c4b 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAction.java
@@ -17,7 +17,6 @@
package org.apache.isis.core.metamodel.spec.feature;
-import java.lang.reflect.Method;
import java.util.List;
import com.google.common.base.Predicate;
@@ -52,7 +51,8 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
public interface ObjectAction extends ObjectMember {
- // //////////////////////////////////////////////////////
+
+ // //////////////////////////////////////////////////////
// semantics, realTarget, getOnType
// //////////////////////////////////////////////////////
@@ -186,6 +186,20 @@ public interface ObjectAction extends ObjectMember {
final InteractionInitiatedBy interactionInitiatedBy);
+
+ /**
+ * internal API
+ */
+ void setupActionInvocationContext(
+ final ObjectAdapter targetAdapter);
+
+ /**
+ * internal API
+ */
+ void setupCommand(
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments);
+
// //////////////////////////////////////////////////////
// Utils
// //////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionContributee.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionContributee.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionContributee.java
index 4d9d782..59a0048 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionContributee.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionContributee.java
@@ -17,21 +17,13 @@
package org.apache.isis.core.metamodel.specloader.specimpl;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.InvokedOn;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command.Executor;
-import org.apache.isis.applib.services.command.CommandContext;
import org.apache.isis.core.commons.lang.ObjectExtensions;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.consent.Consent;
@@ -41,8 +33,6 @@ import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facetapi.FacetHolderImpl;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
import org.apache.isis.core.metamodel.facetapi.MultiTypedFacet;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
-import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
import org.apache.isis.core.metamodel.interactions.InteractionUtils;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
import org.apache.isis.core.metamodel.interactions.VisibilityContext;
@@ -199,53 +189,14 @@ public class ObjectActionContributee extends ObjectActionDefault implements Cont
final ObjectAdapter[] arguments,
final InteractionInitiatedBy interactionInitiatedBy) {
- // this code also exists in ActionInvocationFacetViaMethod
- // we need to repeat it here because the target adapter should be the contributee, not the contributing service.
+ setupActionInvocationContext(contributee);
+ setupCommandTarget(contributee, arguments);
- final BulkFacet bulkFacet = getFacet(BulkFacet.class);
- if (bulkFacet != null) {
-
- final ActionInvocationContext actionInvocationContext = getServicesInjector().lookupService(ActionInvocationContext.class);
- if (actionInvocationContext != null &&
- actionInvocationContext.getInvokedOn() == null) {
-
- actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
- actionInvocationContext.setDomainObjects(Collections.singletonList(contributee.getObject()));
- }
-
- final Bulk.InteractionContext bulkInteractionContext = getServicesInjector().lookupService(Bulk.InteractionContext.class);
- if (bulkInteractionContext != null &&
- bulkInteractionContext.getInvokedAs() == null) {
-
- bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
- bulkInteractionContext.setDomainObjects(Collections.singletonList(contributee.getObject()));
- }
-
-
- }
-
- final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
- final Command command = commandContext != null ? commandContext.getCommand() : null;
-
- if(command != null && command.getExecutor() == Executor.USER) {
-
- if (command.getTarget() != null) {
- // already set up by a edit form
- // don't overwrite
- } else {
- command.setTargetClass(CommandUtil.targetClassNameFor(contributee));
- command.setTargetAction(CommandUtil.targetActionNameFor(this));
- command.setArguments(CommandUtil.argDescriptionFor(this, arguments));
-
- final Bookmark targetBookmark = CommandUtil.bookmarkFor(contributee);
- command.setTarget(targetBookmark);
- }
- }
-
return serviceAction.execute(getServiceAdapter(), argsPlusContributee(contributee, arguments),
interactionInitiatedBy);
}
+
private ObjectAdapter[] argsPlusContributee(final ObjectAdapter contributee, final ObjectAdapter[] arguments) {
return addElementToArray(arguments, contributeeParam, contributee, new ObjectAdapter[]{});
}
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionDefault.java
index 7060cf1..bcc0f03 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionDefault.java
@@ -19,6 +19,7 @@
package org.apache.isis.core.metamodel.specloader.specimpl;
+import java.util.Collections;
import java.util.List;
import com.google.common.base.Objects;
@@ -29,8 +30,13 @@ import org.slf4j.LoggerFactory;
import org.apache.isis.applib.RecoverableException;
import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.Bulk;
+import org.apache.isis.applib.annotation.InvokedOn;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.command.CommandContext;
import org.apache.isis.core.commons.debug.DebugString;
import org.apache.isis.core.commons.exceptions.UnknownTypeException;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -44,6 +50,9 @@ import org.apache.isis.core.metamodel.facets.FacetedMethod;
import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
import org.apache.isis.core.metamodel.facets.TypedHolder;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
+import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
+import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
import org.apache.isis.core.metamodel.facets.actions.debug.DebugFacet;
import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
import org.apache.isis.core.metamodel.facets.actions.exploration.ExplorationFacet;
@@ -59,12 +68,15 @@ import org.apache.isis.core.metamodel.interactions.InteractionUtils;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
import org.apache.isis.core.metamodel.interactions.ValidityContext;
import org.apache.isis.core.metamodel.interactions.VisibilityContext;
+import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ActionType;
import org.apache.isis.core.metamodel.spec.DomainModelException;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
+import org.apache.isis.schema.cmd.v1.CommandMementoDto;
+import org.apache.isis.schema.utils.CommandMementoDtoUtils;
public class ObjectActionDefault extends ObjectMemberAbstract implements ObjectAction {
@@ -353,15 +365,15 @@ public class ObjectActionDefault extends ObjectMemberAbstract implements ObjectA
@Override
public ObjectAdapter execute(
- final ObjectAdapter target,
+ final ObjectAdapter targetAdapter,
final ObjectAdapter[] arguments,
final InteractionInitiatedBy interactionInitiatedBy) {
if(LOG.isDebugEnabled()) {
- LOG.debug("execute action " + target + "." + getId());
+ LOG.debug("execute action " + targetAdapter + "." + getId());
}
final ActionInvocationFacet facet = getFacet(ActionInvocationFacet.class);
- return facet.invoke(this, target, arguments,
- interactionInitiatedBy);
+
+ return facet.invoke(this, targetAdapter, arguments, interactionInitiatedBy);
}
protected ActionInvocationFacet getActionInvocationFacet() {
@@ -412,10 +424,8 @@ public class ObjectActionDefault extends ObjectMemberAbstract implements ObjectA
}
final ObjectAdapter[] parameterDefaultAdapters = new ObjectAdapter[parameterCount];
- if (parameterDefaultPojos != null) {
- for (int i = 0; i < parameterCount; i++) {
- parameterDefaultAdapters[i] = adapterFor(parameterDefaultPojos[i]);
- }
+ for (int i = 0; i < parameterCount; i++) {
+ parameterDefaultAdapters[i] = adapterFor(parameterDefaultPojos[i]);
}
return parameterDefaultAdapters;
@@ -494,6 +504,141 @@ public class ObjectActionDefault extends ObjectMemberAbstract implements ObjectA
return parameterChoicesAdapters;
}
+
+ /**
+ * Internal API
+ */
+ @Override
+ public void setupActionInvocationContext(final ObjectAdapter targetAdapter) {
+
+ final Object targetPojo = unwrap(targetAdapter);
+
+ final BulkFacet bulkFacet = getFacetHolder().getFacet(BulkFacet.class);
+ if (bulkFacet != null) {
+ final org.apache.isis.applib.services.actinvoc.ActionInvocationContext actionInvocationContext = getActionInvocationContext();
+ if (actionInvocationContext != null && actionInvocationContext.getInvokedOn() == null) {
+
+ actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
+ actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
+ }
+
+ final Bulk.InteractionContext bulkInteractionContext = getBulkInteractionContext();
+
+ if (bulkInteractionContext != null && bulkInteractionContext.getInvokedAs() == null) {
+
+ bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
+ bulkInteractionContext.setDomainObjects(Collections.singletonList(targetPojo));
+ }
+ }
+ }
+
+ /**
+ * Internal API
+ */
+ @Override
+ public void setupCommand(
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments) {
+
+ setupCommandTarget(targetAdapter, arguments);
+ setupCommandMemberIdentifier();
+ setupCommandMementoAndExecutionContext(targetAdapter, arguments);
+ }
+
+
+ protected void setupCommandTarget(
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments) {
+
+ final CommandContext commandContext = getCommandContext();
+ final Command command = commandContext.getCommand();
+
+ if (command.getExecutor() != Command.Executor.USER) {
+ return;
+ }
+
+ if(command.getTarget() != null) {
+ // already set up by a ObjectActionContributee or edit form;
+ // don't overwrite
+ return;
+ }
+
+ command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
+ command.setTargetAction(CommandUtil.targetActionNameFor(this));
+ command.setArguments(CommandUtil.argDescriptionFor(this, arguments));
+
+ final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
+ command.setTarget(targetBookmark);
+ }
+
+ protected void setupCommandMemberIdentifier() {
+
+ final CommandContext commandContext = getCommandContext();
+ final Command command = commandContext.getCommand();
+
+ if (command.getExecutor() != Command.Executor.USER) {
+ return;
+ }
+
+ if(Command.ACTION_IDENTIFIER_FOR_EDIT.equals(command.getMemberIdentifier())) {
+ // special case for edit properties, don't overwrite
+ return;
+ }
+
+ if (command.getMemberIdentifier() != null) {
+ // any contributed/mixin actions will fire after the main action
+ // the guard here prevents them from trashing the command's memberIdentifier
+ return;
+ }
+
+ command.setMemberIdentifier(CommandUtil.actionIdentifierFor(this));
+ }
+
+ protected void setupCommandMementoAndExecutionContext(
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] arguments) {
+
+ final CommandContext commandContext = getCommandContext();
+ final Command command = commandContext.getCommand();
+
+
+ if (command.getExecutor() != Command.Executor.USER) {
+ return;
+ }
+
+ if(Command.ACTION_IDENTIFIER_FOR_EDIT.equals(command.getMemberIdentifier())) {
+ // special case for edit properties, don't overwrite
+ return;
+ }
+
+ if (command.getMemento() != null) {
+ // guard here to prevent subsequent contributed/mixin actions from
+ // trampling over the command's memento and execution context
+ return;
+ }
+
+ // memento
+ final CommandMementoService commandMementoService = getCommandMementoService();
+ final CommandMementoDto dto = commandMementoService.asCommandMemento(
+ Collections.singletonList(targetAdapter),
+ this, arguments);
+
+ final String mementoXml = CommandMementoDtoUtils.toXml(dto);
+ command.setMemento(mementoXml);
+
+ // copy over the command execution 'context' (if available)
+ final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
+ if(commandFacet != null && !commandFacet.isDisabled()) {
+ command.setExecuteIn(commandFacet.executeIn());
+ command.setPersistence(commandFacet.persistence());
+ } else {
+ // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
+ command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
+ command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
+ }
+
+ }
+
//endregion
//region > debug, toString
@@ -528,4 +673,33 @@ public class ObjectActionDefault extends ObjectMemberAbstract implements ObjectA
//endregion
+ private static Object unwrap(final ObjectAdapter adapter) {
+ return adapter == null ? null : adapter.getObject();
+ }
+
+ private <T> T lookupService(final Class<T> serviceClass) {
+ return getServicesInjector().lookupService(serviceClass);
+ }
+
+ protected CommandContext getCommandContext() {
+ CommandContext commandContext = lookupService(CommandContext.class);
+ if (commandContext == null) {
+ throw new IllegalStateException("The CommandContext service is not registered!");
+ }
+ return commandContext;
+ }
+
+ protected CommandMementoService getCommandMementoService() {
+ return lookupService(CommandMementoService.class);
+ }
+
+ protected Bulk.InteractionContext getBulkInteractionContext() {
+ return lookupService(Bulk.InteractionContext.class);
+ }
+
+ protected org.apache.isis.applib.services.actinvoc.ActionInvocationContext getActionInvocationContext() {
+ return lookupService(org.apache.isis.applib.services.actinvoc.ActionInvocationContext.class);
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
index 9bdb98e..3490efd 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
@@ -16,7 +16,6 @@
*/
package org.apache.isis.core.metamodel.specloader.specimpl;
-import java.util.Collections;
import java.util.List;
import com.google.common.base.Objects;
@@ -24,13 +23,8 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.InvokedOn;
import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
-import org.apache.isis.applib.services.bookmark.Bookmark;
import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command.Executor;
import org.apache.isis.applib.services.command.CommandContext;
import org.apache.isis.core.commons.lang.ObjectExtensions;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -39,18 +33,13 @@ import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facetapi.FacetHolderImpl;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
-import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacetInferred;
import org.apache.isis.core.metamodel.interactions.InteractionUtils;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
import org.apache.isis.core.metamodel.interactions.VisibilityContext;
-import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
-import org.apache.isis.schema.cmd.v1.CommandMementoDto;
-import org.apache.isis.schema.utils.CommandMementoDtoUtils;
public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInMember2 {
@@ -154,7 +143,7 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
final Where where) {
final VisibilityContext<?> ic =
mixinAction.createVisibleInteractionContext(
- mixinAdapterFor(mixinType, mixedInAdapter), interactionInitiatedBy, where);
+ mixinAdapterFor(mixedInAdapter), interactionInitiatedBy, where);
ic.putContributee(0, mixedInAdapter);
return InteractionUtils.isVisibleResult(this, ic).createConsent();
}
@@ -165,28 +154,32 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
final InteractionInitiatedBy interactionInitiatedBy, final Where where) {
final UsabilityContext<?> ic =
mixinAction.createUsableInteractionContext(
- mixinAdapterFor(mixinType, mixedInAdapter), interactionInitiatedBy, where);
+ mixinAdapterFor(mixedInAdapter), interactionInitiatedBy, where);
ic.putContributee(0, mixedInAdapter);
return InteractionUtils.isUsableResult(this, ic).createConsent();
}
@Override
public ObjectAdapter[] getDefaults(final ObjectAdapter mixedInAdapter) {
- return mixinAction.getDefaults(mixinAdapterFor(mixinType, mixedInAdapter));
+ return mixinAction.getDefaults(mixinAdapterFor(mixedInAdapter));
}
@Override
public ObjectAdapter[][] getChoices(
final ObjectAdapter mixedInAdapter,
final InteractionInitiatedBy interactionInitiatedBy) {
- return mixinAction.getChoices(mixinAdapterFor(mixinType, mixedInAdapter), interactionInitiatedBy);
+ return mixinAction.getChoices(mixinAdapterFor(mixedInAdapter), interactionInitiatedBy);
+ }
+
+ protected ObjectAdapter mixinAdapterFor(final ObjectAdapter mixedInAdapter) {
+ return mixinAdapterFor(mixinType, mixedInAdapter);
}
public Consent isProposedArgumentSetValid(
final ObjectAdapter mixedInAdapter,
final ObjectAdapter[] proposedArguments,
final InteractionInitiatedBy interactionInitiatedBy) {
- return mixinAction.isProposedArgumentSetValid(mixinAdapterFor(mixinType, mixedInAdapter), proposedArguments, interactionInitiatedBy);
+ return mixinAction.isProposedArgumentSetValid(mixinAdapterFor(mixedInAdapter), proposedArguments, interactionInitiatedBy);
}
@Override
@@ -198,73 +191,17 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
// this code also exists in ActionInvocationFacetViaMethod
// we need to repeat it here because the target adapter should be the mixedInAdapter, not the mixin
- final BulkFacet bulkFacet = getFacet(BulkFacet.class);
- if (bulkFacet != null) {
-
- final ActionInvocationContext actionInvocationContext =
- getServicesInjector().lookupService(ActionInvocationContext.class);
- if (actionInvocationContext != null &&
- actionInvocationContext.getInvokedOn() == null) {
+ setupActionInvocationContext(mixedInAdapter);
- actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
- actionInvocationContext.setDomainObjects(Collections.singletonList(mixedInAdapter.getObject()));
- }
-
- final Bulk.InteractionContext bulkInteractionContext = getServicesInjector().lookupService(Bulk.InteractionContext.class);
- if (bulkInteractionContext != null &&
- bulkInteractionContext.getInvokedAs() == null) {
+ final CommandContext commandContext = getCommandContext();
+ final Command command = commandContext.getCommand();
- bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
- actionInvocationContext.setDomainObjects(Collections.singletonList(mixedInAdapter.getObject()));
- }
- }
+ setupCommandTarget(mixedInAdapter, arguments);
+ setupCommandMementoAndExecutionContext(mixedInAdapter, arguments);
- final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
- final Command command = commandContext != null ? commandContext.getCommand() : null;
-
- if(command != null && command.getExecutor() == Executor.USER) {
-
- if (command.getTarget() != null) {
- // already set up by a edit form
- // don't overwrite
- } else {
- command.setTargetClass(CommandUtil.targetClassNameFor(mixedInAdapter));
- command.setTargetAction(CommandUtil.targetActionNameFor(this));
- command.setArguments(CommandUtil.argDescriptionFor(this, arguments));
-
- final Bookmark targetBookmark = CommandUtil.bookmarkFor(mixedInAdapter);
- command.setTarget(targetBookmark);
-
- }
-
- if(command.getMemento() == null) {
- // similarly, guard here to deal with subsequent or prior contributed/mixin actions.
-
- final CommandMementoService commandMementoService = getCommandMementoService();
-
- final CommandMementoDto dto = commandMementoService.asCommandMemento(
- Collections.singletonList(mixedInAdapter),
- this, arguments);
-
- if(dto != null) {
- // the default implementation will always return a dto. The guard is to allow
- // for the default implementation to be replaced with a version that returns null
- // allowing a fallback to the original API (using ActionInvocationMemento rather than
- // CommandMementoDto).
- final String mementoXml = CommandMementoDtoUtils.toXml(dto);
- command.setMemento(mementoXml);
- } else {
- // no fallback to old behaviour is required; mixin actions were simply not correctly supported.
- }
- }
-
-
- }
-
- return mixinAction.execute(mixinAdapterFor(mixinType, mixedInAdapter), arguments, interactionInitiatedBy);
+ return mixinAction.execute(mixinAdapterFor(mixedInAdapter), arguments, interactionInitiatedBy);
}
-
//region > facetHolder
@Override
protected FacetHolder getFacetHolder() {
@@ -272,15 +209,6 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
}
//endregion
-
- ObjectAdapter mixinAdapterFor(final ObjectAdapter mixedInAdapter) {
- return mixinAdapterFor(mixinType, mixedInAdapter);
- }
-
- private static Object unwrap(final ObjectAdapter adapter) {
- return adapter == null ? null : adapter.getObject();
- }
-
/* (non-Javadoc)
* @see org.apache.isis.core.metamodel.specloader.specimpl.ObjectMemberAbstract#getIdentifier()
*/
@@ -299,12 +227,5 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
// //////////////////////////////////////
- private CommandMementoService getCommandMementoService() {
- return lookupService(CommandMementoService.class);
- }
-
- private <T> T lookupService(final Class<T> serviceClass) {
- return getServicesInjector().lookupService(serviceClass);
- }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/46089a20/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index 845d7ff..b758e65 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -129,9 +129,7 @@ public class BackgroundServiceDefault implements BackgroundService {
proxyObject.setHandler(methodHandler);
return newInstance;
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
+ } catch (final InstantiationException | IllegalAccessException e) {
throw new IsisException(e);
}
}
@@ -170,20 +168,13 @@ public class BackgroundServiceDefault implements BackgroundService {
final Command command = commandContext.getCommand();
if(backgroundCommandService instanceof BackgroundCommandService2) {
- final BackgroundCommandService2 backgroundCommandService2 =
- (BackgroundCommandService2) backgroundCommandService;
+ final BackgroundCommandService2 bcs2 = (BackgroundCommandService2) backgroundCommandService;
final CommandMementoDto dto = commandMementoService
.asCommandMemento(Collections.singletonList(targetAdapter), action, argAdapters);
- if(dto != null) {
- // the default implementation returns a non-null value. This guard is to allow a different
- // implementation to be configured that returns null, thereby falling through to the
- // original behaviour (of using ActionInvocationMemento instead of CommandMementoDto).
- backgroundCommandService2.schedule(dto, command, targetClassName, targetActionName, targetArgs);
-
- return null;
- }
+ bcs2.schedule(dto, command, targetClassName, targetActionName, targetArgs);
+ return null;
}
// fallback
@@ -191,7 +182,6 @@ public class BackgroundServiceDefault implements BackgroundService {
.asActionInvocationMemento(proxyMethod, domainObject, args);
backgroundCommandService.schedule(aim, command, targetClassName, targetActionName, targetArgs);
-
return null;
}
[14/14] isis git commit: ISIS-1374: new BackgroundService2 API to be
able to schedule explicitly mixin actions. Necessary changes to
BackgroundCommandExcecution (not as many as expected, actually;
has simplified).
Posted by da...@apache.org.
ISIS-1374: new BackgroundService2 API to be able to schedule explicitly mixin actions. Necessary changes to BackgroundCommandExcecution (not as many as expected, actually; has simplified).
Also, able to remove mixinFqClassName from cmd-1.0.xsd.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/10693b1a
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/10693b1a
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/10693b1a
Branch: refs/heads/ISIS-1291
Commit: 10693b1a4ac302e6bd40a71bd307a0427e3702a6
Parents: 46089a2
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 15:33:19 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Apr 22 10:47:01 2016 +0100
----------------------------------------------------------------------
.../guides/_rgsvc_api_BackgroundService.adoc | 44 ++++---
.../services/background/BackgroundService.java | 6 +-
.../services/background/BackgroundService2.java | 33 +++++
.../specimpl/ObjectActionMixedIn.java | 5 +
.../background/BackgroundCommandExecution.java | 17 +--
.../background/BackgroundServiceDefault.java | 128 +++++++++++++++----
.../command/CommandMementoServiceDefault.java | 5 -
.../org/apache/isis/schema/cmd/cmd-1.0.xsd | 10 +-
8 files changed, 179 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_api_BackgroundService.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_api_BackgroundService.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_api_BackgroundService.adoc
index 3f2ad64..1c074f6 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_api_BackgroundService.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_api_BackgroundService.adoc
@@ -1,32 +1,46 @@
[[_rgsvc_api_BackgroundService]]
-= `BackgroundService`
+= `BackgroundService2`
:Notice: 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.
:_basedir: ../
:_imagesdir: images/
-The `BackgroundService`, and the companion xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService[`BackgroundCommandService`] SPI service (used by Apache Isis itself), enable action invocations to be persisted such that they may be invoked in the background.
+The `BackgroundService2` domain service, and also the companion
+xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService[`BackgroundCommandService2`] SPI service, enable commands
+to be persisted such that they may be invoked in the background. (The `BackgroundService2` and
+`BackgroundCommandService2` extensions to these services introduced in `1.13.0-SNAPSHOT`).
-The `BackgroundService` is responsible for capturing a memento representing the action invocation in a typesafe way, and persisting it rather than executing it directly.
+The `BackgroundService2` is responsible for capturing a memento representing the command in a typesafe way,
+and persisting it rather than executing it directly.
-The default `BackgroundServiceDefault` implementation (provided by isis-core) works by using a proxy wrapper around the target so that it can capture the action to invoke and its arguments using (a private copy of) xref:rgsvc.adoc#_rgsvc_api_MementoService[`MementoService`]. The persistence delegates the persistence of the memento to an appropriate implementation of the companion `BackgroundCommandService`. One such implementation of `BackgroundCommandService` is provided by (non-ASF) http://github.com/isisaddons/isis-module-command[Isis addons' command] module.
+The default `BackgroundServiceDefault` implementation works by using a proxy wrapper around the target so that it can
+capture the action to invoke and its arguments. (As of `1.13.0-SNAPSHOT`), this is done using xref:rgsvc.adoc#_rgsvc_spi_CommandMementoService[`CommandMementoService`] (in previous releases it used (a private copy of) xref:rgsvc.adoc#_rgsvc_api_MementoService[`MementoService`]).
-The persisting of commands is only half the story; there needs to be a separate process to read the commands and execute them. The `BackgroundCommandExecution` abstract class (discussed xref:rgsvc.adoc#_rgsvc_api_BackgroundService_BackgroundCommandExecution[below]) provides infrastructure to do this; the concrete
-implementation of this class depends on the configured `BackgroundCommandService` (in order to query for the persisted (background) ``Command``s.
+The persistence delegates the persistence of the memento to an appropriate implementation of the companion
+`BackgroundCommandService2`. One such implementation of `BackgroundCommandService` is provided by (non-ASF)
+http://github.com/isisaddons/isis-module-command[Isis addons' command] module.
+
+The persisting of commands is only half the story; there needs to be a separate process to read the commands and
+execute them. The `BackgroundCommandExecution` abstract class (discussed
+xref:rgsvc.adoc#_rgsvc_api_BackgroundService_BackgroundCommandExecution[below]) provides infrastructure to do this;
+the concrete implementation of this class depends on the configured `BackgroundCommandService` (in order to query for
+the persisted (background) ``Command``s.
== API & Implementation
-Returns a proxy around the object which is then used to obtain the signature of the action to be invoked in the background.
+The API is:
[source,java]
----
-public interface BackgroundService {
- @Programmatic
- <T> T execute(final T object);
+public interface BackgroundService2 {
+ <T> T execute(final T object); // <1>
+ <T> T executeMixin(Class<T> mixinClass, Object mixedIn); // <2>
}
----
+<1> returns a proxy around the domain object; any methods executed against this proxy will result in a command (to invoke the corresponding action) being persisted by xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService2[`BackgroundCommandService2`]
+<2> (`1.13.0-SNAPSHOT`) returns a proxy around the mixin; any methods executed against this proxy will result in a command (to invoke the corresponding mixin action) being persisted by xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService2[`BackgroundCommandService2`].
The default implementation is provided by core (`o.a.i.core.runtime.services.background.BackgroundServiceDefault`).
@@ -44,7 +58,7 @@ public void submitCustomerInvoices() {
for(Customer customer: customerRepository.findCustomersToInvoice()) {
backgroundService.execute(customer).submitInvoice();
}
- container.informUser("Calculating...");
+ messageService.informUser("Calculating...");
}
----
@@ -112,12 +126,10 @@ The `CommandContext` service is responsible for providing a parent `Command` wit
The implementations of `CommandService` and `BackgroundCommandService` go together; typically both parent `Command`s and child background `Command`s will be persisted in the same way. The (non-ASF) http://github.com/isisaddons/isis-module-command[Isis addons' command] module provides implementations of both (see xref:rgsvc.adoc#_rgsvc_spi_CommandService[`CommandService`] and xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService[`BackgroundCommandService`]).
+The xref:rgsvc.adoc#_rgsvc_spi_CommandMementoService[`CommandMementoService`] (`1.13.0-SNAPSHOT`) is used to obtain
+a memento of the command such that it can be persisted. (In earlier versions, xref:rgsvc.adoc#_rgsvc_api_MementoService[`MementoService`] was used for this purpose).
+
include::_rgsvc_api_BackgroundService_BackgroundCommandExecution.adoc[leveloffset=+1]
include::_rgsvc_api_BackgroundService_Quartz.adoc[leveloffset=+1]
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
index 18d2356..23b8f28 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
@@ -39,8 +39,12 @@ import org.apache.isis.applib.annotation.Programmatic;
public interface BackgroundService {
/**
- * Returns a proxy around the object which is then used to obtain the
+ * Returns a proxy around the object (entity or view model) which is then used to obtain the
* signature of the action to be invoked in the background.
+ *
+ * <p>
+ * To obtain a proxy for a mixin, use {@link BackgroundService2#executeMixin(Class, Object)}.
+ * </p>
*/
@Programmatic
<T> T execute(final T object);
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
new file mode 100644
index 0000000..529aa85
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
@@ -0,0 +1,33 @@
+/**
+ * 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.services.background;
+
+import org.apache.isis.applib.annotation.Programmatic;
+
+/**
+ * Submit actions to be invoked in the background.
+ */
+public interface BackgroundService2 extends BackgroundService {
+
+ /**
+ * Returns a proxy around the mixin object which is then used to obtain the
+ * signature of the action to be invoked in the background.
+ */
+ @Programmatic
+ <T> T executeMixin(Class<T> mixinClass, Object mixedIn);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
index 3490efd..8fabba0 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
@@ -38,6 +38,7 @@ import org.apache.isis.core.metamodel.interactions.InteractionUtils;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
import org.apache.isis.core.metamodel.interactions.VisibilityContext;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
@@ -108,6 +109,10 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
return super.getId();
}
+ public boolean hasMixinAction(final ObjectAction mixinAction) {
+ return this.mixinAction == mixinAction;
+ }
+
@Override
public ObjectSpecification getOnType() {
return mixedInType;
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index 82ec4ab..fbed501 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -144,10 +144,9 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
final Object targetObject = bookmarkService.lookup(bookmark);
final ObjectAdapter targetAdapter = adapterFor(targetObject);
- final String mixinFqClassName = actionDto.getMixinFqClassName();
final ObjectAction objectAction =
- findObjectAction(mixinFqClassName, targetAdapter, actionId);
+ findObjectAction(targetAdapter, actionId);
final ObjectAdapter[] argAdapters = argAdaptersFor(dto);
final ObjectAdapter resultAdapter = objectAction.execute(
@@ -176,20 +175,14 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
}
private ObjectAction findObjectAction(
- final String mixinFqClassName,
final ObjectAdapter targetAdapter,
final String actionId) throws Exception {
final ObjectAction objectAction;
- if(mixinFqClassName != null) {
- final ObjectSpecification mixinSpec = getSpecificationLoader()
- .loadSpecification(mixinFqClassName);
- objectAction = mixinSpec.getObjectAction(actionId);
- } else {
- final ObjectSpecification specification = targetAdapter.getSpecification();
-
- objectAction = findAction(specification, actionId);
- }
+
+ final ObjectSpecification specification = targetAdapter.getSpecification();
+
+ objectAction = findAction(specification, actionId);
if(objectAction == null) {
throw new Exception("Unknown action '" + actionId + "'");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index b758e65..74ee8e6 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -16,8 +16,11 @@
*/
package org.apache.isis.core.runtime.services.background;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
@@ -29,10 +32,10 @@ import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.services.background.ActionInvocationMemento;
import org.apache.isis.applib.services.background.BackgroundCommandService;
import org.apache.isis.applib.services.background.BackgroundCommandService2;
-import org.apache.isis.applib.services.background.BackgroundService;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.background.BackgroundService2;
import org.apache.isis.applib.services.command.Command;
import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.factory.FactoryService;
import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.isis.core.commons.lang.ArrayExtensions;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -41,9 +44,11 @@ import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUt
import org.apache.isis.core.metamodel.services.command.CommandMementoService;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
import org.apache.isis.core.metamodel.specloader.classsubstitutor.JavassistEnhanced;
+import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionMixedIn;
import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.schema.cmd.v1.CommandMementoDto;
@@ -60,8 +65,7 @@ import javassist.util.proxy.ProxyObject;
@DomainService(
nature = NatureOfService.DOMAIN
)
-public class BackgroundServiceDefault implements BackgroundService {
-
+public class BackgroundServiceDefault implements BackgroundService2 {
@Programmatic
@@ -103,13 +107,23 @@ public class BackgroundServiceDefault implements BackgroundService {
@Override
public <T> T execute(final T domainObject) {
final Class<? extends Object> cls = domainObject.getClass();
- final MethodHandler methodHandler = newMethodHandler(domainObject);
- return newProxy(cls, methodHandler);
+ final MethodHandler methodHandler = newMethodHandler(domainObject, null);
+ return newProxy(cls, null, methodHandler);
}
+ @Override
+ public <T> T executeMixin(Class<T> mixinClass, Object mixedIn) {
+ final T mixin = factoryService.mixin(mixinClass, mixedIn);
+ final MethodHandler methodHandler = newMethodHandler(mixin, mixedIn);
+ return newProxy(mixinClass, mixedIn, methodHandler);
+ }
@SuppressWarnings("unchecked")
- private <T> T newProxy(Class<? extends Object> cls, MethodHandler methodHandler) {
+ private <T> T newProxy(
+ final Class<? extends Object> cls,
+ final Object mixedInIfAny,
+ final MethodHandler methodHandler) {
+
final ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setSuperclass(cls);
proxyFactory.setInterfaces(ArrayExtensions.combine(cls.getInterfaces(), new Class<?>[] { JavassistEnhanced.class }));
@@ -124,32 +138,62 @@ public class BackgroundServiceDefault implements BackgroundService {
final Class<T> proxySubclass = proxyFactory.createClass();
try {
- final T newInstance = proxySubclass.newInstance();
+ final T newInstance;
+ if(mixedInIfAny == null) {
+ newInstance = proxySubclass.newInstance();
+ } else {
+ Constructor constructor = findConstructor(proxySubclass, mixedInIfAny);
+ newInstance = (T) constructor.newInstance(mixedInIfAny);
+ }
final ProxyObject proxyObject = (ProxyObject) newInstance;
proxyObject.setHandler(methodHandler);
return newInstance;
- } catch (final InstantiationException | IllegalAccessException e) {
+ } catch (final InstantiationException |
+ IllegalAccessException |
+ InvocationTargetException e) {
throw new IsisException(e);
}
}
- private <T> MethodHandler newMethodHandler(final T domainObject) {
+ private <T> Constructor<?> findConstructor(final Class<T> proxySubclass, final Object mixedInIfAny) {
+ final Constructor<?>[] constructors = proxySubclass.getConstructors();
+ for (Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length == 1 && parameterTypes[0].isAssignableFrom(mixedInIfAny.getClass())) {
+ return constructor;
+ }
+ }
+ throw new IllegalArgumentException( String.format(
+ "Could not locate 1-arg constructor for mixin type of '%s' accepting an instance of '%s'",
+ proxySubclass, mixedInIfAny.getClass().getName()));
+ }
+
+ /**
+ *
+ * @param target - the object that is proxied, either a domain object or a mixin around a domain object
+ * @param mixedInIfAny - if target is a mixin, then this is the domain object that is mixed-in to.
+ */
+ private <T> MethodHandler newMethodHandler(
+ final T target, final Object mixedInIfAny) {
return new MethodHandler() {
@Override
- public Object invoke(final Object proxied, final Method proxyMethod, final Method proxiedMethod, final Object[] args) throws Throwable {
+ public Object invoke(
+ final Object proxied,
+ final Method proxyMethod,
+ final Method proxiedMethod,
+ final Object[] args) throws Throwable {
final boolean inheritedFromObject = proxyMethod.getDeclaringClass().equals(Object.class);
if(inheritedFromObject) {
- return proxyMethod.invoke(domainObject, args);
+ return proxyMethod.invoke(target, args);
}
- final ObjectAdapter targetAdapter = getAdapterManager().adapterFor(domainObject);
final ObjectSpecificationDefault targetObjSpec = getJavaSpecificationOfOwningClass(proxyMethod);
final ObjectMember member = targetObjSpec.getMember(proxyMethod);
if(member == null) {
- return proxyMethod.invoke(domainObject, args);
+ return proxyMethod.invoke(target, args);
}
if(!(member instanceof ObjectAction)) {
@@ -158,10 +202,22 @@ public class BackgroundServiceDefault implements BackgroundService {
+ "(method " + proxiedMethod.getName() + " represents a " + member.getFeatureType().name() + "')");
}
- final ObjectAction action = (ObjectAction) member;
+ ObjectAction action = (ObjectAction) member;
+
+ final Object domainObject;
+ if (mixedInIfAny == null) {
+ domainObject = target;
+ } else {
+ domainObject = mixedInIfAny;
+ // replace action with the mixedIn action of the domain object itself
+ action = findMixedInAction(action, mixedInIfAny);
+ }
+
+ final ObjectAdapter domainObjectAdapter = getAdapterManager().adapterFor(domainObject);
+ final String domainObjectClassName = CommandUtil.targetClassNameFor(domainObjectAdapter);
- final String targetClassName = CommandUtil.targetClassNameFor(targetAdapter);
final String targetActionName = CommandUtil.targetActionNameFor(action);
+
final ObjectAdapter[] argAdapters = adaptersFor(args);
final String targetArgs = CommandUtil.argDescriptionFor(action, argAdapters);
@@ -170,21 +226,39 @@ public class BackgroundServiceDefault implements BackgroundService {
if(backgroundCommandService instanceof BackgroundCommandService2) {
final BackgroundCommandService2 bcs2 = (BackgroundCommandService2) backgroundCommandService;
- final CommandMementoDto dto = commandMementoService
- .asCommandMemento(Collections.singletonList(targetAdapter), action, argAdapters);
+ final List<ObjectAdapter> targetList = Collections.singletonList(domainObjectAdapter);
+ final CommandMementoDto dto =
+ commandMementoService.asCommandMemento(targetList, action, argAdapters);
- bcs2.schedule(dto, command, targetClassName, targetActionName, targetArgs);
- return null;
- }
+ bcs2.schedule(dto, command, domainObjectClassName, targetActionName, targetArgs);
+ } else {
+ // fallback
+ final ActionInvocationMemento aim =
+ commandMementoService.asActionInvocationMemento(proxyMethod, target, args);
- // fallback
- final ActionInvocationMemento aim = commandMementoService
- .asActionInvocationMemento(proxyMethod, domainObject, args);
+ backgroundCommandService.schedule(aim, command, domainObjectClassName, targetActionName, targetArgs);
+ }
- backgroundCommandService.schedule(aim, command, targetClassName, targetActionName, targetArgs);
return null;
}
+ private ObjectAction findMixedInAction(final ObjectAction action, final Object domainObject) {
+ final String actionId = action.getId();
+ final ObjectSpecification domainSpec = getAdapterManager().adapterFor(domainObject).getSpecification();
+ List<ObjectAction> objectActions = domainSpec.getObjectActions(Contributed.INCLUDED);
+ for (ObjectAction objectAction : objectActions) {
+ if(objectAction instanceof ObjectActionMixedIn) {
+ ObjectActionMixedIn objectActionMixedIn = (ObjectActionMixedIn) objectAction;
+ if(objectActionMixedIn.hasMixinAction(action)) {
+ return objectActionMixedIn;
+ }
+ }
+ }
+
+ throw new IllegalArgumentException(String.format(
+ "Unable to find mixin action '%s' for %s", actionId, domainSpec.getFullIdentifier()));
+ }
+
ObjectAdapter[] adaptersFor(final Object[] args) {
final AdapterManager adapterManager = getAdapterManager();
return CommandUtil.adaptersFor(args, adapterManager);
@@ -211,10 +285,10 @@ public class BackgroundServiceDefault implements BackgroundService {
private CommandMementoService commandMementoService;
@javax.inject.Inject
- private BookmarkService bookmarkService;
+ private CommandContext commandContext;
@javax.inject.Inject
- private CommandContext commandContext;
+ private FactoryService factoryService;
// //////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
index 9ec9094..3b3be55 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
@@ -170,11 +170,6 @@ public class CommandMementoServiceDefault implements CommandMementoService {
final Object arg = argAdapter != null? argAdapter.getObject(): null;
CommandMementoDtoUtils.addParamArg(actionDto.getParameters(), parameterName, paramType, arg, bookmarkService);
}
- if(objectAction instanceof ObjectActionMixedIn) {
- final ObjectActionMixedIn actionMixedIn = (ObjectActionMixedIn) objectAction;
- final String mixinTypeName = actionMixedIn.getMixinType().getCorrespondingClass().getName();
- actionDto.setMixinFqClassName(mixinTypeName);
- }
dto.setTransactionId(UUID.randomUUID().toString());
return dto;
http://git-wip-us.apache.org/repos/asf/isis/blob/10693b1a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
----------------------------------------------------------------------
diff --git a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
index 85ed6f1..408c31d 100644
--- a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
+++ b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0.xsd
@@ -52,7 +52,7 @@
</xs:element>
<xs:element name="targets" type="common:oidDto" minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
- <xs:documentation>For regular actions, represents the entity/entities or view model(s) upon which the action is to be invoked. For mixin actions, is the object(s) being mixed-into (the constructor arg to the mixin). For contributed actions, is the domain service (the contributee object will be one of the action arguments within the payload). Note that this means that bulk contributed actions cannot be reified as a memento (for this use case, implement as a mixin action instead). Mixin actions can be determined by the presence of the 'mixinFqClassName' element.
+ <xs:documentation>For regular actions, represents the entity/entities or view model(s) upon which the action is to be invoked. For mixin actions, is the object(s) being mixed-into (the constructor arg to the mixin). For contributed actions, is the domain service (the contributee object will be one of the action arguments within the payload). Note that this means that bulk contributed actions cannot be reified as a memento (for this use case, implement as a mixin action instead).
</xs:documentation>
</xs:annotation>
</xs:element>
@@ -74,16 +74,10 @@
<xs:complexType name="actionDto">
<xs:annotation>
- <xs:documentation>Captures the information required to be able to invoke an action on the target(s). In particular, identifies the action to be invoked, whether that action is a mixin, and also the arguments for the parameters of said action. Note that the targets are not part of this structure so that it can be reused between cmd and aim schemas (the former of which can relate to multiple targets, the latter always to a single target).
+ <xs:documentation>Captures the information required to be able to invoke an action on the target(s). In particular, identifies the action to be invoked, and also the arguments for the parameters of said action. Note that the targets are not part of this structure so that it can be reused between cmd and aim schemas (the former of which can relate to multiple targets, the latter always to a single target). It also _isn't_ necessary to capture whether the action is actually a mixin; this detail is encapsulated within the Apache Isis metamodel.
</xs:documentation>
</xs:annotation>
<xs:sequence>
- <xs:element name="mixinFqClassName" type="xs:string" minOccurs="0" maxOccurs="1">
- <xs:annotation>
- <xs:documentation>Populated only for mixin actions, is the fully qualified class name of the mixin type.
- </xs:documentation>
- </xs:annotation>
- </xs:element>
<xs:element name="actionIdentifier" type="xs:string">
<xs:annotation>
<xs:documentation>Formal identifier of the action being invoked.
[12/14] isis git commit: ISIS-1374: inlined internalInvoke
Posted by da...@apache.org.
ISIS-1374: inlined internalInvoke
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/6da1e317
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/6da1e317
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/6da1e317
Branch: refs/heads/ISIS-1291
Commit: 6da1e317ba44f8c836e71bb87bf64ed3f8784c37
Parents: 7c37966
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 17:11:56 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 17:14:00 2016 +0100
----------------------------------------------------------------------
...onInvocationFacetForDomainEventAbstract.java | 171 +++++++++----------
1 file changed, 83 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/6da1e317/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 4d1485f..99f0ca4 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -208,80 +208,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
null);
// ... invoke the action
- final InvocationResult invocationResult = internalInvoke(command, owningAction, targetAdapter, arguments);
- final ObjectAdapter invocationResultAdapter = invocationResult.getAdapter();
-
- // ... post the executed event
- if (invocationResult.getWhetherInvoked()) {
- // perhaps the Action was not properly invoked (i.e. an exception was raised).
- // If invoked ok, then post to the event bus
- domainEventHelper.postEventForAction(
- AbstractDomainEvent.Phase.EXECUTED,
- eventType, verify(event),
- owningAction, targetAdapter, arguments,
- command,
- invocationResultAdapter);
- }
-
- if (invocationResultAdapter == null) {
- return null;
- }
-
- boolean filterForVisibility = getConfiguration().getBoolean("isis.reflector.facet.filterVisibility", true);
- if(filterForVisibility) {
- final Object result = invocationResultAdapter.getObject();
- if(result instanceof Collection || result.getClass().isArray()) {
- final CollectionFacet facet = CollectionFacet.Utils.getCollectionFacetFromSpec(invocationResultAdapter);
-
- final Iterable<ObjectAdapter> adapterList = facet.iterable(invocationResultAdapter);
- final List<ObjectAdapter> visibleAdapters =
- ObjectAdapter.Util.visibleAdapters(
- adapterList,
- interactionInitiatedBy);
- final Object visibleObjects =
- CollectionUtils.copyOf(
- Lists.transform(visibleAdapters, ObjectAdapter.Functions.getObject()),
- method.getReturnType());
- if (visibleObjects != null) {
- return getAdapterManager().adapterFor(visibleObjects);
- }
- // would be null if unable to take a copy (unrecognized return type)
- // fallback to returning the original adapter, without filtering for visibility
-
- } else {
- boolean visible =
- ObjectAdapter.Util.isVisible(
- invocationResultAdapter,
- interactionInitiatedBy);
- if(!visible) {
- return null;
- }
- }
- }
- return invocationResultAdapter;
- }
-
- /**
- * Optional hook to allow the facet implementation for the deprecated {@link org.apache.isis.applib.annotation.PostsActionInvokedEvent} annotation
- * to discard the event if the domain event is of a different type (specifically if was installed by virtue of a no
- * @{@link org.apache.isis.applib.annotation.Action} or @{@link org.apache.isis.applib.annotation.ActionInteraction} annotations.
- */
- protected ActionDomainEvent<?> verify(final ActionDomainEvent<?> event) {
- return event;
- }
-
- /**
- * For testing only.
- */
- public Class<? extends ActionDomainEvent<?>> getEventType() {
- return eventType;
- }
-
- protected InvocationResult internalInvoke(
- final Command command,
- final ObjectAction owningAction,
- final ObjectAdapter targetAdapter,
- final ObjectAdapter[] arguments) {
+ InvocationResult result1;
try {
@@ -413,30 +340,30 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
final ActionSemanticsFacet semanticsFacet = getFacetHolder().getFacet(ActionSemanticsFacet.class);
final boolean cacheable = semanticsFacet != null && semanticsFacet.value().isSafeAndRequestCacheable();
- Object result;
+ Object result11;
if(cacheable) {
final QueryResultsCache queryResultsCache = getQueryResultsCache();
final Object[] targetPojoPlusExecutionParameters = ArrayExtensions.appendT(executionParameters, targetPojo);
- result = queryResultsCache.execute(new Callable<Object>() {
+ result11 = queryResultsCache.execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
return method.invoke(targetPojo, executionParameters);
}
}, targetPojo.getClass(), method.getName(), targetPojoPlusExecutionParameters);
} else {
- result = method.invoke(targetPojo, executionParameters);
+ result11 = method.invoke(targetPojo, executionParameters);
}
if (LOG.isDebugEnabled()) {
- LOG.debug(" action result " + result);
+ LOG.debug(" action result " + result11);
}
- if (result == null) {
+ if (result11 == null) {
if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
// if this was a void method on cloneable view model, then (to save boilerplate in the domain)
// automatically do the clone and return the clone instead.
- final ViewModelFacet facet = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
- final Object clone = facet.clone(targetAdapter.getObject());
+ final ViewModelFacet facet1 = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
+ final Object clone = facet1.clone(targetAdapter.getObject());
final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
resultAdapter = clonedAdapter;
@@ -447,14 +374,14 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
} else {
- resultAdapter = getAdapterManager().adapterFor(result);
+ resultAdapter = getAdapterManager().adapterFor(result11);
if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
// if the object returned is cloneable, then
// (to save boilerplate in the domain) automatically do the clone.
- final ViewModelFacet facet = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
- result = facet.clone(result);
- resultAdapter = getAdapterManager().adapterFor(result);
+ final ViewModelFacet facet1 = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
+ result11 = facet1.clone(result11);
+ resultAdapter = getAdapterManager().adapterFor(result11);
}
@@ -472,14 +399,15 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
if(currentInvocation.get() == null) {
final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
if(publishedActionFacet != null) {
- currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(), arguments, resultAdapter, command));
+ currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(),
+ arguments, resultAdapter, command));
}
}
}
}
- return InvocationResult.forActionThatReturned(resultAdapter);
+ result1 = InvocationResult.forActionThatReturned(resultAdapter);
} catch (final IllegalArgumentException e) {
throw e;
@@ -511,10 +439,77 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
ThrowableExtensions.throwWithinIsisException(e, "Exception executing " + method);
// Action was not invoked (an Exception was thrown)
- return InvocationResult.forActionNotInvoked();
+ result1 = InvocationResult.forActionNotInvoked();
} catch (final IllegalAccessException e) {
throw new ReflectiveActionException("Illegal access of " + method, e);
}
+ final InvocationResult invocationResult = result1;
+ final ObjectAdapter invocationResultAdapter = invocationResult.getAdapter();
+
+ // ... post the executed event
+ if (invocationResult.getWhetherInvoked()) {
+ // perhaps the Action was not properly invoked (i.e. an exception was raised).
+ // If invoked ok, then post to the event bus
+ domainEventHelper.postEventForAction(
+ AbstractDomainEvent.Phase.EXECUTED,
+ eventType, verify(event),
+ owningAction, targetAdapter, arguments,
+ command,
+ invocationResultAdapter);
+ }
+
+ if (invocationResultAdapter == null) {
+ return null;
+ }
+
+ boolean filterForVisibility = getConfiguration().getBoolean("isis.reflector.facet.filterVisibility", true);
+ if(filterForVisibility) {
+ final Object result = invocationResultAdapter.getObject();
+ if(result instanceof Collection || result.getClass().isArray()) {
+ final CollectionFacet facet = CollectionFacet.Utils.getCollectionFacetFromSpec(invocationResultAdapter);
+
+ final Iterable<ObjectAdapter> adapterList = facet.iterable(invocationResultAdapter);
+ final List<ObjectAdapter> visibleAdapters =
+ ObjectAdapter.Util.visibleAdapters(
+ adapterList,
+ interactionInitiatedBy);
+ final Object visibleObjects =
+ CollectionUtils.copyOf(
+ Lists.transform(visibleAdapters, ObjectAdapter.Functions.getObject()),
+ method.getReturnType());
+ if (visibleObjects != null) {
+ return getAdapterManager().adapterFor(visibleObjects);
+ }
+ // would be null if unable to take a copy (unrecognized return type)
+ // fallback to returning the original adapter, without filtering for visibility
+
+ } else {
+ boolean visible =
+ ObjectAdapter.Util.isVisible(
+ invocationResultAdapter,
+ interactionInitiatedBy);
+ if(!visible) {
+ return null;
+ }
+ }
+ }
+ return invocationResultAdapter;
+ }
+
+ /**
+ * Optional hook to allow the facet implementation for the deprecated {@link org.apache.isis.applib.annotation.PostsActionInvokedEvent} annotation
+ * to discard the event if the domain event is of a different type (specifically if was installed by virtue of a no
+ * @{@link org.apache.isis.applib.annotation.Action} or @{@link org.apache.isis.applib.annotation.ActionInteraction} annotations.
+ */
+ protected ActionDomainEvent<?> verify(final ActionDomainEvent<?> event) {
+ return event;
+ }
+
+ /**
+ * For testing only.
+ */
+ public Class<? extends ActionDomainEvent<?>> getEventType() {
+ return eventType;
}
private static Object unwrap(final ObjectAdapter adapter) {
[09/14] isis git commit: ISIS-1344: removing some further evidence of
FacetDecorator API
Posted by da...@apache.org.
ISIS-1344: removing some further evidence of FacetDecorator API
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7faee573
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7faee573
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7faee573
Branch: refs/heads/ISIS-1291
Commit: 7faee5738dfb892a6cd5d4be5d3e0ded4e2f1670
Parents: 52f80c0
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 16:22:27 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 16:22:27 2016 +0100
----------------------------------------------------------------------
.../isis/core/metamodel/specloader/ReflectorConstants.java | 5 -----
1 file changed, 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7faee573/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ReflectorConstants.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ReflectorConstants.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ReflectorConstants.java
index a71af17..87f1eb4 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ReflectorConstants.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ReflectorConstants.java
@@ -21,7 +21,6 @@ package org.apache.isis.core.metamodel.specloader;
import org.apache.isis.core.commons.config.ConfigurationConstants;
import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
import org.apache.isis.core.metamodel.facets.FacetFactory;
import org.apache.isis.core.metamodel.layoutmetadata.json.LayoutMetadataReaderFromJson;
import org.apache.isis.core.metamodel.metamodelvalidator.dflt.MetaModelValidatorDefault;
@@ -69,10 +68,6 @@ public final class ReflectorConstants {
*/
public static final String FACET_FACTORY_EXCLUDE_CLASS_NAME_LIST = ProgrammingModel.FACET_FACTORY_EXCLUDE_CLASS_NAME_LIST;
- /**
- * Key used to lookup comma-separated list of {@link FacetDecorator}s.
- */
- public static final String FACET_DECORATOR_CLASS_NAMES = ConfigurationConstants.ROOT + "reflector.facet-decorators";
/**
* Key used to lookup comma-separated list of {@link org.apache.isis.core.metamodel.layoutmetadata.LayoutMetadataReader}s.
[06/14] isis git commit: ISIS-1344: removing the WrapTransaction
facets,
and from that also the entire FacetDecorator infrastructure since is no longer
required.
Posted by da...@apache.org.
ISIS-1344: removing the WrapTransaction facets, and from that also the entire FacetDecorator infrastructure since is no longer required.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/624292a0
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/624292a0
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/624292a0
Branch: refs/heads/ISIS-1291
Commit: 624292a08bfc892f2db67ca7abf5afc13c846452
Parents: af4e3ca
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 15:58:52 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 15:58:52 2016 +0100
----------------------------------------------------------------------
.../facetdecorator/FacetDecorator.java | 43 ----
.../facetdecorator/FacetDecoratorAbstract.java | 39 ----
.../facetdecorator/FacetDecoratorSet.java | 171 ----------------
.../facetdecorator/help/HelpFacetDecorator.java | 26 ---
.../HelpFacetDecoratorUsingHelpManager.java | 67 -------
.../help/HelpFacetLookedUpViaHelpManager.java | 34 ----
.../facetdecorator/help/HelpManager.java | 34 ----
.../help/HelpManagerAbstract.java | 45 -----
.../HelpFacetDecoratorUsingFilesInstaller.java | 47 -----
.../file/internal/HelpManagerUsingFiles.java | 147 --------------
.../facetdecorator/help/package-info.java | 28 ---
...8nDecoratorUsingResourceBundleInstaller.java | 48 -----
.../specloader/FacetDecoratorInstaller.java | 32 ---
.../specloader/ObjectReflectorDefault.java | 19 --
.../specloader/ObjectReflectorInstaller.java | 2 -
.../progmodels/dflt/JavaReflectorHelper.java | 6 +-
.../progmodels/dflt/JavaReflectorInstaller.java | 23 +++
.../JavaReflectorInstallerNoDecorators.java | 41 +---
.../file/internal/SimpleHelpManagerTest.java | 200 -------------------
.../ObjectReflectorDefaultTestAbstract.java | 5 -
.../progmodels/JavaReflectorInstaller.java | 102 ----------
.../system/transaction/TransactionUtils.java | 50 -----
.../IsisComponentProviderDefault2.java | 8 +-
.../IsisComponentProviderUsingInstallers.java | 9 -
.../TransactionFacetDecorator.java | 26 ---
.../TransactionFacetDecoratorAbstract.java | 48 -----
.../facetdecorator/package-info.java | 27 ---
.../StandardTransactionFacetDecorator.java | 93 ---------
.../TransactionFacetDecoratorInstaller.java | 45 -----
.../ActionInvocationFacetWrapTransaction.java | 98 ---------
.../CollectionAddToFacetWrapTransaction.java | 82 --------
.../CollectionClearFacetWrapTransaction.java | 78 --------
...ollectionRemoveFromFacetWrapTransaction.java | 82 --------
.../PropertyClearFacetWrapTransaction.java | 79 --------
.../PropertySetterFacetWrapTransaction.java | 82 --------
.../core/runtime/installer-registry.properties | 2 +-
36 files changed, 32 insertions(+), 1936 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecorator.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecorator.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecorator.java
deleted file mode 100644
index 47052be..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecorator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-public interface FacetDecorator {
-
- /**
- * If applicable, replace the provided {@link Facet} with a decorating
- * {@link Facet} that should be held by the provided {@link FacetHolder
- * required holder}.
- *
- * <p>
- *
- * @return the decorating {@link Facet}, or <tt>null</tt> if this decoration
- * does not apply to this Facet.
- */
- Facet decorate(Facet facet, FacetHolder requiredHolder);
-
- Class<? extends Facet>[] getFacetTypes();
-
- String getFacetTypeNames();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorAbstract.java
deleted file mode 100644
index a6cd316..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorAbstract.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-
-public abstract class FacetDecoratorAbstract implements FacetDecorator {
-
- @Override
- public String getFacetTypeNames() {
- final Class<? extends Facet>[] decoratorFacetTypes = getFacetTypes();
- final StringBuilder buf = new StringBuilder();
- for (int i = 0; i < decoratorFacetTypes.length; i++) {
- if (i > 0) {
- buf.append(", ");
- }
- buf.append(decoratorFacetTypes[i].getName());
- }
- return buf.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorSet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorSet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorSet.java
deleted file mode 100644
index 38eb045..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/FacetDecoratorSet.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.exceptions.MetaModelException;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-
-public class FacetDecoratorSet implements ApplicationScopedComponent {
-
- private final Map<Class<? extends Facet>, List<FacetDecorator>> facetDecoratorByFacetType = new HashMap<>();
- private final Set<FacetDecorator> facetDecoratorSet = new LinkedHashSet<FacetDecorator>();
-
- // ////////////////////////////////////////////////////////////
- // init, shutdown
- // ////////////////////////////////////////////////////////////
-
- public void init() {
- }
-
- public void shutdown() {
- }
-
- // ////////////////////////////////////////////////////////////
- // add, get, isEmpty
- // ////////////////////////////////////////////////////////////
-
- public void add(final FacetDecorator decorator) {
- final Class<? extends Facet>[] decoratedFacetTypes = decorator.getFacetTypes();
- for (final Class<? extends Facet> decoratedFacetType : decoratedFacetTypes) {
- getFacetDecoratorList(decoratedFacetType).add(decorator);
- facetDecoratorSet.add(decorator);
- }
- }
-
- private List<FacetDecorator> getFacetDecoratorList(final Class<? extends Facet> decoratedFacetType) {
- List<FacetDecorator> facetDecoratorList = facetDecoratorByFacetType.get(decoratedFacetType);
- if (facetDecoratorList == null) {
- facetDecoratorList = new ArrayList<>();
- facetDecoratorByFacetType.put(decoratedFacetType, facetDecoratorList);
- }
- return facetDecoratorList;
- }
-
- public void add(final List<FacetDecorator> decorators) {
- for (final FacetDecorator decorator : decorators) {
- add(decorator);
- }
- }
-
- public boolean isEmpty() {
- return facetDecoratorByFacetType.isEmpty();
- }
-
- // ////////////////////////////////////////////////////////////
- // decorate
- // ////////////////////////////////////////////////////////////
-
- /**
- * @param holder
- */
- public void decorate(final ObjectSpecification holder) {
- decorateAllFacets(holder);
- for (final ObjectAssociation objectAssociation : holder.getAssociations(Contributed.EXCLUDED)) {
- this.decorateAllFacets(objectAssociation);
- }
- for (final ObjectAction objectAction : holder.getObjectActions(Contributed.EXCLUDED)) {
- decorateAllFacets(objectAction);
- final List<ObjectActionParameter> parameters = objectAction.getParameters();
- for (final ObjectActionParameter parameter : parameters) {
- this.decorateAllFacets(parameter);
- }
- }
- }
-
- private void decorateAllFacets(final FacetHolder holder) {
- if (isEmpty()) {
- return;
- }
- final Set<Class<? extends Facet>> facetTypes = facetDecoratorByFacetType.keySet();
- for (final Class<? extends Facet> facetType : facetTypes) {
- final Facet facet = holder.getFacet(facetType);
- if(facet != null) {
- decorateFacet(facet, holder);
- }
- }
- }
-
- /**
- * REVIEW: the design is a little clumsy here. We want to decorate the
- * provided {@link Facet}, but its owning {@link FacetHolder holder} turns
- * out to be a runtime peer (eg <tt>JavaAction</tt>) rather than the
- * metamodel (eg {@link ObjectAction}). Since we want to decorate the
- * {@link ObjectAction}, we have to pass it through.
- */
- private void decorateFacet(final Facet facet, final FacetHolder requiredHolder) {
- final Class<? extends Facet> facetType = facet.facetType();
- final Class<? extends Facet> cls = facetType;
- final List<FacetDecorator> decoratorList = facetDecoratorByFacetType.get(cls);
- if (decoratorList == null) {
- return;
- }
- for (final FacetDecorator facetDecorator : decoratorList) {
- final Facet decoratingFacet = facetDecorator.decorate(facet, requiredHolder);
- if (decoratingFacet == null) {
- continue;
- }
- ensureDecoratorMetContract(facetDecorator, decoratingFacet, facetType, requiredHolder);
- }
- }
-
- private static void ensureDecoratorMetContract(final FacetDecorator facetDecorator, final Facet decoratingFacet, final Class<? extends Facet> facetType, final FacetHolder originalFacetHolder) {
- if (decoratingFacet.facetType() != facetType) {
- throw new MetaModelException(MessageFormat.format("Problem with facet decorator '{0}'; inconsistent decorating facetType() for {1}; was {2} but expectected facetType() of {3}", facetDecorator.getClass().getName(), decoratingFacet.getClass().getName(), decoratingFacet.facetType()
- .getName(), facetType.getName()));
- }
- final Facet facetForFacetType = originalFacetHolder.getFacet(decoratingFacet.facetType());
- if (facetForFacetType != decoratingFacet) {
- throw new MetaModelException(MessageFormat.format("Problem with facet decorator '{0}'; has not replaced original facet for facetType() of {1}", facetDecorator.getClass().getName(), facetType.getName()));
- }
- }
-
- // ////////////////////////////////////////////////////////////
- // debugging
- // ////////////////////////////////////////////////////////////
-
- public void debugData(final DebugBuilder str) {
- str.appendTitle("Facet decorators");
- final Set<Class<? extends Facet>> facetTypes = facetDecoratorByFacetType.keySet();
- if (facetTypes.size() == 0) {
- str.append("none");
- } else {
- for (final Class<? extends Facet> cls : facetTypes) {
- str.appendln(cls.getName(), facetDecoratorByFacetType.get(cls));
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecorator.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecorator.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecorator.java
deleted file mode 100644
index b76cb13..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecorator.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help;
-
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-
-public interface HelpFacetDecorator extends FacetDecorator {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecoratorUsingHelpManager.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecoratorUsingHelpManager.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecoratorUsingHelpManager.java
deleted file mode 100644
index 3c27512..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetDecoratorUsingHelpManager.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecoratorAbstract;
-import org.apache.isis.core.metamodel.facets.all.help.HelpFacet;
-
-public class HelpFacetDecoratorUsingHelpManager extends FacetDecoratorAbstract implements HelpFacetDecorator {
- private final HelpManager helpManager;
-
- public HelpFacetDecoratorUsingHelpManager(final HelpManager manager) {
- helpManager = manager;
- }
-
- @Override
- public Facet decorate(final Facet facet, final FacetHolder facetHolder) {
- if (facet.facetType() != HelpFacet.class) {
- return facet;
- }
-
- if (!(facetHolder instanceof IdentifiedHolder)) {
- return null;
- }
-
- final IdentifiedHolder identifiedHolder = (IdentifiedHolder) facetHolder;
- return decorateWithHelpFacet(facet, identifiedHolder);
- }
-
- private Facet decorateWithHelpFacet(final Facet facet, final IdentifiedHolder identifiedHolder) {
- final Identifier identifier = identifiedHolder.getIdentifier();
-
- final String helpText = helpManager.getHelpText(identifier);
- if (helpText != null) {
- final HelpFacetLookedUpViaHelpManager decoratingFacet = new HelpFacetLookedUpViaHelpManager(helpText, facet.getFacetHolder());
- identifiedHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
- return null;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Class<? extends Facet>[] getFacetTypes() {
- return new Class[] { HelpFacet.class };
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetLookedUpViaHelpManager.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetLookedUpViaHelpManager.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetLookedUpViaHelpManager.java
deleted file mode 100644
index d275c4c..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpFacetLookedUpViaHelpManager.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.all.help.HelpFacetAbstract;
-
-/**
- * Looked up via the {@link HelpManager}.
- */
-public class HelpFacetLookedUpViaHelpManager extends HelpFacetAbstract {
-
- public HelpFacetLookedUpViaHelpManager(final String value, final FacetHolder holder) {
- super(value, holder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManager.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManager.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManager.java
deleted file mode 100644
index 457b67b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManager.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
-
-public interface HelpManager extends ApplicationScopedComponent {
-
- /**
- * Returns help text for the specified {@link Identifier}.
- *
- * <p>
- * If no help text is available then an empty String should be returned.
- */
- String getHelpText(Identifier identifier);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManagerAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManagerAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManagerAbstract.java
deleted file mode 100644
index b3b8916..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/HelpManagerAbstract.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help;
-
-import org.apache.isis.applib.Identifier;
-
-/**
- * Default implementation that does nothing.
- *
- */
-public abstract class HelpManagerAbstract implements HelpManager {
-
- /**
- * Does nothing.
- */
- public void init() {
- }
-
- /**
- * Does nothing.
- */
- public void shutdown() {
- }
-
- @Override
- public abstract String getHelpText(final Identifier identifier);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/HelpFacetDecoratorUsingFilesInstaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/HelpFacetDecoratorUsingFilesInstaller.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/HelpFacetDecoratorUsingFilesInstaller.java
deleted file mode 100644
index f720765..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/HelpFacetDecoratorUsingFilesInstaller.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help.file;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
-import org.apache.isis.core.metamodel.facetdecorator.help.HelpFacetDecoratorUsingHelpManager;
-import org.apache.isis.core.metamodel.facetdecorator.help.file.internal.HelpManagerUsingFiles;
-
-public class HelpFacetDecoratorUsingFilesInstaller extends InstallerAbstract implements FacetDecoratorInstaller {
-
- public HelpFacetDecoratorUsingFilesInstaller() {
- super(FacetDecoratorInstaller.TYPE, "help-file");
- }
-
- @Override
- public List<FacetDecorator> createDecorators() {
- final HelpManagerUsingFiles manager = new HelpManagerUsingFiles(getConfiguration());
- return Arrays.<FacetDecorator> asList(new HelpFacetDecoratorUsingHelpManager(manager));
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/HelpManagerUsingFiles.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/HelpManagerUsingFiles.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/HelpManagerUsingFiles.java
deleted file mode 100644
index 11d094e..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/HelpManagerUsingFiles.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help.file.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetdecorator.help.HelpManagerAbstract;
-
-public class HelpManagerUsingFiles extends HelpManagerAbstract {
-
- private static final Logger LOG = LoggerFactory.getLogger(HelpManagerUsingFiles.class);
-
- /**
- * The name of the file used unless overridden with
- * {@link #setFileName(String)}.
- */
- public static final String DEFAULT_FILE_NAME = "help.txt";
- private static final String CLASS_PREFIX = "c:";
- private static final String NAME_PREFIX = "m:";
-
- private String fileName = DEFAULT_FILE_NAME;
-
- @SuppressWarnings("unused")
- private final IsisConfiguration configuration;
-
- public HelpManagerUsingFiles(final IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void setFileName(final String fileName) {
- this.fileName = fileName;
- }
-
- @Override
- public String getHelpText(final Identifier identifier) {
- BufferedReader reader = null;
- try {
- reader = getReader();
-
- if (reader == null) {
- return "No help available (no file found)";
- }
-
- final String className = CLASS_PREFIX + identifier.getClassName().toLowerCase();
- final String name = NAME_PREFIX + identifier.getMemberName().toLowerCase();
-
- final StringBuffer str = new StringBuffer();
- String line;
-
- boolean lookingForClass = true;
- boolean lookingForName = identifier.getMemberName().length() > 0;
- /*
- * Read through each line in file.
- */
- while ((line = reader.readLine()) != null) {
- // Skip comments - lines begining with hash
- if (line.length() > 0 && line.charAt(0) == '#') {
- continue;
- }
-
- /*
- * Look for class.
- */
- if (line.toLowerCase().equals(className)) {
- lookingForClass = false;
- continue;
- }
-
- if (lookingForClass) {
- continue;
- } else if (line.toLowerCase().startsWith(CLASS_PREFIX)) {
- break;
- }
-
- /*
- * Look for field/method.
- */
- if (line.toLowerCase().equals(name)) {
- lookingForName = false;
- continue;
- }
-
- if (lookingForName) {
- continue;
- } else if (line.toLowerCase().startsWith(NAME_PREFIX)) {
- break;
- }
-
- str.append(line);
- str.append('\n');
- }
-
- return str.toString();
-
- } catch (final FileNotFoundException e) {
- LOG.error("opening help file", e);
- return "Failure opening help file: " + e.getMessage();
- } catch (final IOException e) {
- LOG.error("reading help file", e);
- return "Failure reading help file: " + e.getMessage();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (final IOException ignore) {
- }
- }
- }
- }
-
- protected BufferedReader getReader() throws FileNotFoundException {
- final File file = new File(fileName);
- if (!file.exists()) {
- final String message = "No help file found: " + file.getAbsolutePath();
- LOG.warn(message);
- return null;
- }
-
- return new BufferedReader(new FileReader(file));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/package-info.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/package-info.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/package-info.java
deleted file mode 100644
index db2b2d7..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/help/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Help API, utilizing the {@link org.apache.isis.core.metamodel.facetdecorator.FacetDecorator} mechanism..
- *
- * <p>
- * At the time of writing - unlike
- * authorisation - there is no help-proxy implementation. Therefore for client/server deployments
- * any help content must be deployed locally.
- */
-package org.apache.isis.core.metamodel.facetdecorator.help;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/i18n/resourcebundle/I18nDecoratorUsingResourceBundleInstaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/i18n/resourcebundle/I18nDecoratorUsingResourceBundleInstaller.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/i18n/resourcebundle/I18nDecoratorUsingResourceBundleInstaller.java
deleted file mode 100644
index 48f1747..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetdecorator/i18n/resourcebundle/I18nDecoratorUsingResourceBundleInstaller.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.i18n.resourcebundle;
-
-import java.util.List;
-import com.google.common.collect.Lists;
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
-
-/**
- * Replaced by {@link org.apache.isis.applib.services.i18n.TranslationService};
- * this file is retained just to ensure backward compatibility with <tt>isis.properties</tt> files
- * that might reference it.
- */
-public class I18nDecoratorUsingResourceBundleInstaller extends InstallerAbstract implements FacetDecoratorInstaller {
-
- public I18nDecoratorUsingResourceBundleInstaller() {
- super(FacetDecoratorInstaller.TYPE, "resource-i18n");
- }
-
- @Override
- public List<FacetDecorator> createDecorators() {
- return Lists.newArrayList();
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class); // ie, of List<FacetDecorator>
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/FacetDecoratorInstaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/FacetDecoratorInstaller.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/FacetDecoratorInstaller.java
deleted file mode 100644
index 4053510..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/FacetDecoratorInstaller.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.core.metamodel.specloader;
-
-import java.util.List;
-
-import org.apache.isis.core.commons.components.Installer;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-
-public interface FacetDecoratorInstaller extends Installer {
-
- static String TYPE = "facet-decorator";
-
- List<FacetDecorator> createDecorators();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java
index 4c4eda4..15adfac 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java
@@ -45,8 +45,6 @@ import org.apache.isis.core.commons.lang.ClassUtil;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecoratorSet;
import org.apache.isis.core.metamodel.facets.object.choices.ChoicesFacetUtils;
import org.apache.isis.core.metamodel.facets.object.objectspecid.ObjectSpecIdFacet;
import org.apache.isis.core.metamodel.layoutmetadata.LayoutMetadataReader;
@@ -122,13 +120,6 @@ public final class ObjectReflectorDefault
private final ProgrammingModel programmingModel;
private final FacetProcessor facetProcessor;
- /**
- * <p>
- * {@link FacetDecorator}s must be added prior to {@link SpecificationLoaderSpi#init(RuntimeContext)
- * initialization.}
- */
- private final FacetDecoratorSet facetDecoratorSet;
-
private final ServicesInjectorSpi servicesInjector;
private final MetaModelValidator metaModelValidator;
@@ -156,7 +147,6 @@ public final class ObjectReflectorDefault
final DeploymentCategory deploymentCategory,
final IsisConfiguration configuration,
final ProgrammingModel programmingModel,
- final Set<FacetDecorator> facetDecorators,
final MetaModelValidator metaModelValidator,
final List<LayoutMetadataReader> layoutMetadataReaders,
final ServicesInjectorSpi servicesInjector) {
@@ -165,7 +155,6 @@ public final class ObjectReflectorDefault
ensureThatArg(configuration, is(notNullValue()));
ensureThatArg(servicesInjector, is(notNullValue()));
ensureThatArg(programmingModel, is(notNullValue()));
- ensureThatArg(facetDecorators, is(notNullValue()));
ensureThatArg(metaModelValidator, is(notNullValue()));
ensureThatArg(layoutMetadataReaders, is(notNullValue()));
ensureThatArg(layoutMetadataReaders, is(not(emptyCollectionOf(LayoutMetadataReader.class))));
@@ -175,10 +164,6 @@ public final class ObjectReflectorDefault
this.programmingModel = programmingModel;
- this.facetDecoratorSet = new FacetDecoratorSet();
- for (final FacetDecorator facetDecorator : facetDecorators) {
- this.facetDecoratorSet.add(facetDecorator);
- }
this.metaModelValidator = metaModelValidator;
this.facetProcessor = new FacetProcessor(configuration, programmingModel);
@@ -245,7 +230,6 @@ public final class ObjectReflectorDefault
}
// initialize subcomponents
- facetDecoratorSet.init();
programmingModel.init();
facetProcessor.init();
metaModelValidator.init();
@@ -300,7 +284,6 @@ public final class ObjectReflectorDefault
initialized = false;
getCache().clear();
- facetDecoratorSet.shutdown();
}
@@ -521,7 +504,6 @@ public final class ObjectReflectorDefault
private void introspect(final ObjectSpecificationAbstract specSpi) {
specSpi.introspectTypeHierarchyAndMembers();
- facetDecoratorSet.decorate(specSpi);
specSpi.updateFromFacetValues();
specSpi.setIntrospectionState(IntrospectionState.INTROSPECTED);
@@ -569,7 +551,6 @@ public final class ObjectReflectorDefault
@Override
public void debugData(final DebugBuilder debug) {
- facetDecoratorSet.debugData(debug);
debug.appendln();
debug.appendTitle("Specifications");
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorInstaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorInstaller.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorInstaller.java
index a787f91..a78aec4 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorInstaller.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorInstaller.java
@@ -37,6 +37,4 @@ public interface ObjectReflectorInstaller extends Installer {
final DeploymentCategory deploymentCategory,
final Collection<MetaModelRefiner> metaModelRefiners, final ServicesInjectorSpi servicesInjector);
- void addFacetDecoratorInstaller(final FacetDecoratorInstaller decoratorInstaller);
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorHelper.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorHelper.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorHelper.java
index 8d468cf..745315f 100644
--- a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorHelper.java
+++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorHelper.java
@@ -21,13 +21,12 @@ package org.apache.isis.progmodels.dflt;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
import org.apache.isis.core.metamodel.layoutmetadata.LayoutMetadataReader;
import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
@@ -48,7 +47,6 @@ public final class JavaReflectorHelper {
final IsisConfiguration configuration,
final ProgrammingModel programmingModel,
final Collection<MetaModelRefiner> metaModelRefiners,
- final Set<FacetDecorator> facetDecorators,
final List<LayoutMetadataReader> layoutMetadataReaders,
final MetaModelValidator mmv,
final ServicesInjectorSpi servicesInjector) {
@@ -66,7 +64,7 @@ public final class JavaReflectorHelper {
return new ObjectReflectorDefault(
deploymentCategory, configuration,
- programmingModel, facetDecorators, metaModelValidator, layoutMetadataReaders, servicesInjector);
+ programmingModel, metaModelValidator, layoutMetadataReaders, servicesInjector);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstaller.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstaller.java
new file mode 100644
index 0000000..dfa0598
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstaller.java
@@ -0,0 +1,23 @@
+/*
+ * 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.progmodels.dflt;
+
+public class JavaReflectorInstaller extends JavaReflectorInstallerNoDecorators {
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstallerNoDecorators.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstallerNoDecorators.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstallerNoDecorators.java
index d958192..3380e2c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstallerNoDecorators.java
+++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/JavaReflectorInstallerNoDecorators.java
@@ -20,43 +20,34 @@
package org.apache.isis.progmodels.dflt;
import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Set;
+
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.apache.isis.core.commons.config.ConfigurationConstants;
import org.apache.isis.core.commons.config.InstallerAbstract;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.factory.InstanceUtil;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
import org.apache.isis.core.metamodel.facets.FacetFactory;
import org.apache.isis.core.metamodel.layoutmetadata.LayoutMetadataReader;
import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
import org.apache.isis.core.metamodel.specloader.ObjectReflectorInstaller;
import org.apache.isis.core.metamodel.specloader.ReflectorConstants;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
-/**
- * An implementation of {@link ObjectReflectorInstaller} without support for {@link FacetDecoratorInstaller}
- * being looked up (since this functionality is only available from <tt>core.runtime</tt>).
- */
public class JavaReflectorInstallerNoDecorators extends InstallerAbstract implements ObjectReflectorInstaller {
private static final Logger LOG = LoggerFactory.getLogger(JavaReflectorInstallerNoDecorators.class);
public static final String PROPERTY_BASE = ConfigurationConstants.ROOT;
- protected final LinkedHashSet<FacetDecoratorInstaller> decoratorInstallers = Sets.newLinkedHashSet();
-
// /////////////////////////////////////////////////////
// Constructor
// /////////////////////////////////////////////////////
@@ -81,11 +72,11 @@ public class JavaReflectorInstallerNoDecorators extends InstallerAbstract implem
final ServicesInjectorSpi servicesInjector) {
final ProgrammingModel programmingModel = createProgrammingModel(getConfiguration());
- final Set<FacetDecorator> facetDecorators = createFacetDecorators(getConfiguration());
final MetaModelValidator mmv = createMetaModelValidator(getConfiguration());
final List<LayoutMetadataReader> layoutMetadataReaders = createLayoutMetadataReaders(getConfiguration());
- return JavaReflectorHelper.createObjectReflector(deploymentCategory, getConfiguration(), programmingModel, metaModelRefiners, facetDecorators, layoutMetadataReaders, mmv,
+ return JavaReflectorHelper.createObjectReflector(deploymentCategory, getConfiguration(), programmingModel, metaModelRefiners,
+ layoutMetadataReaders, mmv,
servicesInjector);
}
@@ -143,13 +134,6 @@ public class JavaReflectorInstallerNoDecorators extends InstallerAbstract implem
ProgrammingModel.Util.excludeFacetFactories(configuration, programmingModel);
}
- /**
- * Hook method to allow subclasses to specify a different sets of
- * {@link FacetDecorator}s.
- */
- protected Set<FacetDecorator> createFacetDecorators(final IsisConfiguration configuration) {
- return Collections.emptySet();
- }
/**
@@ -180,21 +164,6 @@ public class JavaReflectorInstallerNoDecorators extends InstallerAbstract implem
- // /////////////////////////////////////////////////////
- // Optionally Injected: DecoratorInstallers
- // /////////////////////////////////////////////////////
-
- /**
- * Adds in {@link FacetDecoratorInstaller}; if <tt>null</tt> or if already
- * added then request will be silently ignored.
- */
- @Override
- public void addFacetDecoratorInstaller(final FacetDecoratorInstaller decoratorInstaller) {
- if (decoratorInstaller == null) {
- return;
- }
- decoratorInstallers.add(decoratorInstaller);
- }
// /////////////////////////////////////////////////////
// Guice
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/SimpleHelpManagerTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/SimpleHelpManagerTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/SimpleHelpManagerTest.java
deleted file mode 100644
index 22d4b5e..0000000
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetdecorator/help/file/internal/SimpleHelpManagerTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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.core.metamodel.facetdecorator.help.file.internal;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.StringReader;
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-
-public class SimpleHelpManagerTest extends TestCase {
-
- public static void main(final String[] args) {
- junit.textui.TestRunner.run(SimpleHelpManagerTest.class);
- }
-
- private TestHelpManager manager;
-
- @Override
- protected void setUp() throws Exception {
- manager = new TestHelpManager(new IsisConfigurationDefault());
- }
-
- public void testNoLines() {
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "mth");
- final String s = manager.getHelpText(identifier);
- assertEquals("", s);
- }
-
- public void testClass() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about class\n", s);
- }
-
- public void testClassWithNoText() {
- manager.addLine("C:cls");
- manager.addLine("C:cls2");
- manager.addLine("Help about class");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("", s);
- }
-
- public void testClassTextStopsAtNextClass() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
- manager.addLine("C:cls2");
- manager.addLine("Different text");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about class\n", s);
- }
-
- public void testMethodTextStopsAtNextClass() {
- manager.addLine("C:cls");
- manager.addLine("M:fld");
- manager.addLine("Help about method");
- manager.addLine("C:cls2");
- manager.addLine("Different text");
-
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "fld");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about method\n", s);
- }
-
- public void testMethodTextStopsAtNextMethod() {
- manager.addLine("C:cls");
- manager.addLine("M:fld");
- manager.addLine("Help about method");
- manager.addLine("M:fld2");
- manager.addLine("Different text");
-
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "fld");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about method\n", s);
- }
-
- public void testClassTextStopsAtFirstMethod() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
- manager.addLine("M:method");
- manager.addLine("Different text");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about class\n", s);
- }
-
- public void testEntryWithMultipleLines() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
- manager.addLine("line 2");
- manager.addLine("line 3");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about class\nline 2\nline 3\n", s);
- }
-
- public void testFieldWithNoEntry() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
-
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "fld2");
- final String s = manager.getHelpText(identifier);
- assertEquals("", s);
- }
-
- public void testMessageForFileError() {
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "fld2");
- final HelpManagerUsingFiles manager = new HelpManagerUsingFiles(new IsisConfigurationDefault()) {
- @Override
- protected BufferedReader getReader() throws FileNotFoundException {
- throw new FileNotFoundException("not found");
- }
- };
- final String s = manager.getHelpText(identifier);
- assertEquals("Failure opening help file: not found", s);
- }
-
- public void testField() {
- manager.addLine("C:cls");
- manager.addLine("Help about class");
- manager.addLine("M:fld1");
- manager.addLine("Help about field");
- manager.addLine("M:fld2");
- manager.addLine("Help about second field");
-
- final Identifier identifier = Identifier.propertyOrCollectionIdentifier("cls", "fld2");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about second field\n", s);
- }
-
- public void testReadBlankLines() {
- manager.addLine("C:cls");
- manager.addLine("");
- manager.addLine("");
- manager.addLine("Help about class");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("\n\nHelp about class\n", s);
-
- }
-
- public void testSkipComments() {
- manager.addLine("C:cls");
- manager.addLine("# comment");
- manager.addLine("Help about class");
-
- final Identifier identifier = Identifier.classIdentifier("cls");
- final String s = manager.getHelpText(identifier);
- assertEquals("Help about class\n", s);
-
- }
-}
-
-class TestHelpManager extends HelpManagerUsingFiles {
- public TestHelpManager(final IsisConfiguration configuration) {
- super(configuration);
- }
-
- private final StringBuffer file = new StringBuffer();
-
- public void addLine(final String string) {
- file.append(string);
- file.append('\n');
- }
-
- @Override
- protected BufferedReader getReader() throws FileNotFoundException {
- return new BufferedReader(new StringReader(file.toString()));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefaultTestAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefaultTestAbstract.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefaultTestAbstract.java
index cdf9399..27a465e 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefaultTestAbstract.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefaultTestAbstract.java
@@ -20,7 +20,6 @@
package org.apache.isis.core.metamodel.specloader;
import java.util.Collections;
-import java.util.HashSet;
import com.google.common.collect.Lists;
@@ -35,7 +34,6 @@ import org.junit.rules.ExpectedException;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacet;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
@@ -89,7 +87,6 @@ public abstract class ObjectReflectorDefaultTestAbstract {
new ObjectReflectorDefault(DeploymentCategory.PRODUCTION,
mockConfiguration,
new ProgrammingModelFacetsJava5(),
- new HashSet<FacetDecorator>(),
new MetaModelValidatorDefault(),
Lists.<LayoutMetadataReader>newArrayList(
new LayoutMetadataReaderFromJson()), mockServicesInjector);
@@ -111,7 +108,6 @@ public abstract class ObjectReflectorDefaultTestAbstract {
new ObjectReflectorDefault(DeploymentCategory.PRODUCTION ,
mockConfiguration,
new ProgrammingModelFacetsJava5(),
- new HashSet<FacetDecorator>(),
new MetaModelValidatorDefault(),
Lists.<LayoutMetadataReader>newArrayList(),
mockServicesInjector);
@@ -125,7 +121,6 @@ public abstract class ObjectReflectorDefaultTestAbstract {
new ObjectReflectorDefault(DeploymentCategory.PRODUCTION,
mockConfiguration,
new ProgrammingModelFacetsJava5(),
- new HashSet<FacetDecorator>(),
new MetaModelValidatorDefault(),
null,
mockServicesInjector);
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
deleted file mode 100644
index 6713530..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.core.runtime.progmodels;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
-import org.apache.isis.core.metamodel.specloader.ReflectorConstants;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookupAware;
-import org.apache.isis.progmodels.dflt.JavaReflectorInstallerNoDecorators;
-
-/**
- * in default runtime only for dynamic lookup of facet decorators
- */
-public class JavaReflectorInstaller extends JavaReflectorInstallerNoDecorators implements InstallerLookupAware {
-
- private static final Logger LOG = LoggerFactory.getLogger(JavaReflectorInstaller.class);
-
- private InstallerLookup installerLookup;
-
- /**
- * Hook method to allow subclasses to specify a different sets of
- * {@link FacetDecorator}s.
- *
- * <p>
- * By default, returns the {@link FacetDecorator}s that are specified in the
- * {@link IsisConfiguration} (using
- * {@link ReflectorConstants#FACET_DECORATOR_CLASS_NAMES}) along with any
- * {@link FacetDecorator}s explicitly registered using
- * {@link #addFacetDecoratorInstaller(FacetDecoratorInstaller)}. created
- * using the {@link FacetDecoratorInstaller}s.
- */
- protected Set<FacetDecorator> createFacetDecorators(final IsisConfiguration configuration) {
- addFacetDecoratorInstallers(configuration);
- return createFacetDecorators(decoratorInstallers);
- }
-
- private void addFacetDecoratorInstallers(final IsisConfiguration configuration) {
- final String[] decoratorNames = configuration.getList(ReflectorConstants.FACET_DECORATOR_CLASS_NAMES);
- for (final String decoratorName : decoratorNames) {
- if (LOG.isInfoEnabled()) {
- LOG.info("adding reflector facet decorator from configuration " + decoratorName);
- }
- addFacetDecoratorInstaller(lookupFacetDecorator(decoratorName));
- }
- }
-
- private FacetDecoratorInstaller lookupFacetDecorator(final String decoratorClassName) {
- return installerLookup.getInstaller(FacetDecoratorInstaller.class, decoratorClassName);
- }
-
- private Set<FacetDecorator> createFacetDecorators(final Set<FacetDecoratorInstaller> decoratorInstallers) {
- final LinkedHashSet<FacetDecorator> decorators = new LinkedHashSet<FacetDecorator>();
- if (decoratorInstallers.size() == 0) {
- if (LOG.isInfoEnabled()) {
- LOG.info("No facet decorators installers added");
- }
- }
- for (final FacetDecoratorInstaller installer : decoratorInstallers) {
- decorators.addAll(installer.createDecorators());
- }
- return Collections.unmodifiableSet(decorators);
- }
-
- // /////////////////////////////////////////////////////
- // Optionally Injected: InstallerLookup
- // /////////////////////////////////////////////////////
-
- /**
- * Injected by virtue of being {@link InstallerLookupAware}.
- */
- @Override
- public void setInstallerLookup(final InstallerLookup installerLookup) {
- this.installerLookup = installerLookup;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionUtils.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionUtils.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionUtils.java
deleted file mode 100644
index 2721c99..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.core.runtime.system.transaction;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.runtime.transaction.facets.CollectionClearFacetWrapTransaction;
-
-public class TransactionUtils {
- private final static Logger LOG = LoggerFactory.getLogger(CollectionClearFacetWrapTransaction.class);
-
- private TransactionUtils() {
- }
-
- public static void abort(final IsisTransactionManager transactionManager, final FacetHolder holder) {
- LOG.info("exception executing " + holder + ", aborting transaction");
- try {
- transactionManager.abortTransaction();
- } catch (final Exception e2) {
- LOG.error("failure during abort", e2);
- }
- }
-
- /**
- * TODO: need to downcast the FacetHolder and fetch out an identifier.
- */
- public static String getIdentifierFor(final FacetHolder facetHolder) {
- return facetHolder.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
index 2e128a0..159e2ac 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
@@ -21,10 +21,8 @@ package org.apache.isis.core.runtime.systemusinginstallers;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import org.apache.isis.applib.AppManifest;
import org.apache.isis.applib.fixtures.InstallableFixture;
@@ -34,7 +32,6 @@ import org.apache.isis.core.commons.config.IsisConfigurationDefault;
import org.apache.isis.core.commons.resource.ResourceStreamSourceContextLoaderClassPath;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
import org.apache.isis.core.metamodel.layoutmetadata.LayoutMetadataReader;
import org.apache.isis.core.metamodel.layoutmetadata.json.LayoutMetadataReaderFromJson;
import org.apache.isis.core.metamodel.metamodelvalidator.dflt.MetaModelValidatorDefault;
@@ -56,7 +53,6 @@ import org.apache.isis.core.runtime.services.ServicesInstallerFromConfigurationA
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.IsisSystemException;
import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.isis.core.runtime.transaction.facetdecorator.standard.StandardTransactionFacetDecorator;
import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
import org.apache.isis.progmodels.dflt.JavaReflectorHelper;
import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
@@ -244,8 +240,6 @@ public class IsisComponentProviderDefault2 extends IsisComponentProviderAbstract
final DeploymentCategory deploymentCategory = deploymentType.getDeploymentCategory();
- final Set<FacetDecorator> facetDecorators =
- Sets.newHashSet((FacetDecorator) new StandardTransactionFacetDecorator(getConfiguration()));
final List<LayoutMetadataReader> layoutMetadataReaders =
Lists.<LayoutMetadataReader>newArrayList(new LayoutMetadataReaderFromJson());
@@ -253,7 +247,7 @@ public class IsisComponentProviderDefault2 extends IsisComponentProviderAbstract
.createObjectReflector(
deploymentCategory, getConfiguration(), programmingModel,
metaModelRefiners,
- facetDecorators, layoutMetadataReaders,
+ layoutMetadataReaders,
metaModelValidator,
servicesInjector);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
index 29f14ac..2c99632 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
@@ -39,7 +39,6 @@ import org.apache.isis.core.runtime.services.ServicesInstallerFromConfigurationA
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.SystemConstants;
import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.isis.core.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
@@ -108,9 +107,6 @@ public class IsisComponentProviderUsingInstallers extends IsisComponentProviderA
reflectorInstaller = this.installerLookup.reflectorInstaller(
configProperty(SystemConstants.REFLECTOR_KEY));
- TransactionFacetDecoratorInstaller transactionFacetDecoratorInstaller =
- this.installerLookup.getInstaller(TransactionFacetDecoratorInstaller.class);
-
// ensure we were able to load all components via InstallerLookup (fail fast)
ensureThatState(authenticationInstaller, is(not(nullValue())),
@@ -121,17 +117,12 @@ public class IsisComponentProviderUsingInstallers extends IsisComponentProviderA
"servicesInstaller could not be looked up");
ensureThatState(fixturesInstaller, is(not(nullValue())),
"fixtureInstaller could not be looked up");
- ensureThatState(transactionFacetDecoratorInstaller, is(not(nullValue())),
- "transactionFacetDecoratorInstaller could not be looked up");
ensureThatState(persistenceMechanismInstaller, is(not(nullValue())),
"persistenceMechanismInstaller could not be looked up");
ensureThatState(reflectorInstaller, is(not(nullValue())),
"reflectorInstaller could not be looked up");
- // add in transaction support
- reflectorInstaller.addFacetDecoratorInstaller(transactionFacetDecoratorInstaller);
-
// capture the final configuration once all components have been loaded
configuration = this.installerLookup.getConfiguration();
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecorator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
deleted file mode 100644
index c515604..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.core.runtime.transaction.facetdecorator;
-
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-
-public interface TransactionFacetDecorator extends FacetDecorator {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
deleted file mode 100644
index 7b2c911..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.core.runtime.transaction.facetdecorator;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecoratorAbstract;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-
-public abstract class TransactionFacetDecoratorAbstract extends FacetDecoratorAbstract implements TransactionFacetDecorator {
-
- private final IsisConfiguration configuration;
-
- public TransactionFacetDecoratorAbstract(final IsisConfiguration configuration) {
- this.configuration = configuration;
- }
-
- protected IsisConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public Class<? extends Facet>[] getFacetTypes() {
- return new Class[] { ActionInvocationFacet.class, PropertyClearFacet.class, PropertySetterFacet.class, CollectionAddToFacet.class, CollectionRemoveFromFacet.class, CollectionClearFacet.class };
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/package-info.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/package-info.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/package-info.java
deleted file mode 100644
index 890242b..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Transaction API.
- *
- * <p>
- * Not generally intended to be implemented; the default implementation in
- * <tt>nof-core</tt> should normally suffice.
- */
-package org.apache.isis.core.runtime.transaction.facetdecorator;
\ No newline at end of file
[05/14] isis git commit: ISIS-1344: removing the WrapTransaction
facets,
and from that also the entire FacetDecorator infrastructure since is no longer
required.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
deleted file mode 100644
index 674de0d..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.core.runtime.transaction.facetdecorator.standard;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-import org.apache.isis.core.runtime.transaction.facetdecorator.TransactionFacetDecoratorAbstract;
-import org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction;
-import org.apache.isis.core.runtime.transaction.facets.CollectionAddToFacetWrapTransaction;
-import org.apache.isis.core.runtime.transaction.facets.CollectionClearFacetWrapTransaction;
-import org.apache.isis.core.runtime.transaction.facets.CollectionRemoveFromFacetWrapTransaction;
-import org.apache.isis.core.runtime.transaction.facets.PropertyClearFacetWrapTransaction;
-import org.apache.isis.core.runtime.transaction.facets.PropertySetterFacetWrapTransaction;
-
-public class StandardTransactionFacetDecorator extends TransactionFacetDecoratorAbstract {
-
- public StandardTransactionFacetDecorator(final IsisConfiguration configuration) {
- super(configuration);
- }
-
- @Override
- public Facet decorate(final Facet facet, final FacetHolder requiredHolder) {
- final Class<? extends Facet> facetType = facet.facetType();
- if (facetType == ActionInvocationFacet.class) {
- final ActionInvocationFacet decoratedFacet = (ActionInvocationFacet) facet;
- final Facet decoratingFacet = new ActionInvocationFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- if (facetType == CollectionAddToFacet.class) {
- final CollectionAddToFacet decoratedFacet = (CollectionAddToFacet) facet;
- final Facet decoratingFacet = new CollectionAddToFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- if (facetType == CollectionClearFacet.class) {
- final CollectionClearFacet decoratedFacet = (CollectionClearFacet) facet;
- final Facet decoratingFacet = new CollectionClearFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- if (facetType == CollectionRemoveFromFacet.class) {
- final CollectionRemoveFromFacet decoratedFacet = (CollectionRemoveFromFacet) facet;
- final Facet decoratingFacet = new CollectionRemoveFromFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- if (facetType == PropertyClearFacet.class) {
- final PropertyClearFacet decoratedFacet = (PropertyClearFacet) facet;
- final Facet decoratingFacet = new PropertyClearFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- if (facetType == PropertySetterFacet.class) {
- final PropertySetterFacet decoratedFacet = (PropertySetterFacet) facet;
- final Facet decoratingFacet = new PropertySetterFacetWrapTransaction(decoratedFacet);
- requiredHolder.addFacet(decoratingFacet);
- return decoratingFacet;
- }
-
- return facet;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
deleted file mode 100644
index 09fbf1e..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.core.runtime.transaction.facetdecorator.standard;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
-import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
-
-public class TransactionFacetDecoratorInstaller extends InstallerAbstract implements FacetDecoratorInstaller {
-
- public TransactionFacetDecoratorInstaller() {
- super(FacetDecoratorInstaller.TYPE, "transaction");
- }
-
- @Override
- public List<FacetDecorator> createDecorators() {
- return Lists.<FacetDecorator> newArrayList(new StandardTransactionFacetDecorator(getConfiguration()));
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class); // ie List<FacetDecorator>
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
deleted file mode 100644
index b17b269..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetAbstract;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosureWithReturn;
-
-public class ActionInvocationFacetWrapTransaction extends ActionInvocationFacetAbstract implements DecoratingFacet<ActionInvocationFacet> {
-
- private final static Logger LOG = LoggerFactory.getLogger(ActionInvocationFacetWrapTransaction.class);
-
- private final ActionInvocationFacet underlyingFacet;
-
- @Override
- public ActionInvocationFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- public ActionInvocationFacetWrapTransaction(final ActionInvocationFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public ObjectAdapter invoke(
- final ObjectAction owningAction,
- final ObjectAdapter targetAdapter,
- final ObjectAdapter[] argumentAdapters,
- final InteractionInitiatedBy interactionInitiatedBy) {
- final ObjectAdapter result = getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturn<ObjectAdapter>() {
- @Override
- public ObjectAdapter execute() {
- return underlyingFacet.invoke(owningAction, targetAdapter, argumentAdapters,
- interactionInitiatedBy);
- }
- });
- return result;
- }
-
-
- @Override
- public ObjectSpecification getReturnType() {
- return underlyingFacet.getReturnType();
- }
-
- @Override
- public ObjectSpecification getOnType() {
- return underlyingFacet.getOnType();
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
deleted file mode 100644
index f6e1f90..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacetAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-
-public class CollectionAddToFacetWrapTransaction extends CollectionAddToFacetAbstract implements DecoratingFacet<CollectionAddToFacet> {
-
- private final CollectionAddToFacet underlyingFacet;
-
- @Override
- public CollectionAddToFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- public CollectionAddToFacetWrapTransaction(final CollectionAddToFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public void add(
- final ObjectAdapter adapter,
- final ObjectAdapter referencedAdapter,
- final InteractionInitiatedBy interactionInitiatedBy) {
- if (adapter.isTransient()) {
- // NOT !adapter.isPersistent();
- // (value adapters are neither persistent or transient)
- underlyingFacet.add(adapter, referencedAdapter, interactionInitiatedBy);
- } else {
- getTransactionManager().executeWithinTransaction(new TransactionalClosure() {
- @Override
- public void execute() {
- underlyingFacet.add(adapter, referencedAdapter, interactionInitiatedBy);
- }
- });
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
deleted file mode 100644
index 682fda2..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacetAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-
-public class CollectionClearFacetWrapTransaction extends CollectionClearFacetAbstract implements DecoratingFacet<CollectionClearFacet> {
-
- private final CollectionClearFacet underlyingFacet;
-
- @Override
- public CollectionClearFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- public CollectionClearFacetWrapTransaction(final CollectionClearFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public void clear(final ObjectAdapter adapter) {
- if (adapter.isTransient()) {
- // NOT !adapter.isPersistent();
- // (value adapters are neither persistent or transient)
- underlyingFacet.clear(adapter);
- } else {
- getTransactionManager().executeWithinTransaction(new TransactionalClosure() {
- @Override
- public void execute() {
- underlyingFacet.clear(adapter);
- }
- });
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
deleted file mode 100644
index 57fd91a..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacetAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-
-public class CollectionRemoveFromFacetWrapTransaction extends CollectionRemoveFromFacetAbstract implements DecoratingFacet<CollectionRemoveFromFacet> {
-
- private final CollectionRemoveFromFacet underlyingFacet;
-
- @Override
- public CollectionRemoveFromFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- public CollectionRemoveFromFacetWrapTransaction(final CollectionRemoveFromFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public void remove(
- final ObjectAdapter adapter,
- final ObjectAdapter referencedAdapter,
- final InteractionInitiatedBy interactionInitiatedBy) {
- if (adapter.isTransient()) {
- // NOT !adapter.isPersistent();
- // (value adapters are neither persistent or transient)
- underlyingFacet.remove(adapter, referencedAdapter, interactionInitiatedBy);
- } else {
- getTransactionManager().executeWithinTransaction(new TransactionalClosure() {
- @Override
- public void execute() {
- underlyingFacet.remove(adapter, referencedAdapter, interactionInitiatedBy);
- }
- });
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
deleted file mode 100644
index 7d4f9f3..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacetAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-
-public class PropertyClearFacetWrapTransaction extends PropertyClearFacetAbstract implements DecoratingFacet<PropertyClearFacet> {
-
- private final PropertyClearFacet underlyingFacet;
-
- @Override
- public PropertyClearFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- public PropertyClearFacetWrapTransaction(final PropertyClearFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public void clearProperty(final ObjectAdapter adapter, final InteractionInitiatedBy interactionInitiatedBy) {
- if (adapter.isTransient()) {
- // NOT !adapter.isPersistent();
- // (value adapters are neither persistent or transient)
- underlyingFacet.clearProperty(adapter, interactionInitiatedBy);
- } else {
- getTransactionManager().executeWithinTransaction(new TransactionalClosure() {
- @Override
- public void execute() {
- underlyingFacet.clearProperty(adapter, interactionInitiatedBy);
- }
- });
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
deleted file mode 100644
index ab89497..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.core.runtime.transaction.facets;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacetAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-
-public class PropertySetterFacetWrapTransaction extends PropertySetterFacetAbstract implements DecoratingFacet<PropertySetterFacet> {
-
- private final PropertySetterFacet underlyingFacet;
-
- public PropertySetterFacetWrapTransaction(final PropertySetterFacet underlyingFacet) {
- super(underlyingFacet.getFacetHolder());
- this.underlyingFacet = underlyingFacet;
- }
-
- @Override
- public PropertySetterFacet getDecoratedFacet() {
- return underlyingFacet;
- }
-
- @Override
- public void setProperty(
- final ObjectAdapter adapter,
- final ObjectAdapter referencedAdapter,
- final InteractionInitiatedBy interactionInitiatedBy) {
- if (adapter.isTransient()) {
- // NOT !adapter.isPersistent();
- // (value adapters are neither persistent or transient)
- underlyingFacet.setProperty(adapter, referencedAdapter, interactionInitiatedBy);
- } else {
- getTransactionManager().executeWithinTransaction(new TransactionalClosure() {
- @Override
- public void execute() {
- underlyingFacet.setProperty(adapter, referencedAdapter, interactionInitiatedBy);
- }
- });
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " --> " + underlyingFacet.toString();
- }
-
- // ///////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////////////
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/624292a0/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties b/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
index 5808137..0c8be7ab 100644
--- a/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
+++ b/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
@@ -17,7 +17,7 @@
# ObjectReflectorInstaller
-org.apache.isis.core.runtime.progmodels.JavaReflectorInstaller # "java"
+org.apache.isis.progmodels.dflt.JavaReflectorInstaller # "java"
# FacetDecoratorInstaller
org.apache.isis.core.metamodel.facetdecorator.i18n.resourcebundle.I18nDecoratorUsingResourceBundleInstaller # "resource-i18n"
[08/14] isis git commit: ISIS-1374: refactoring ActionInvocationFacet
to remove duplicate between it and the
ObjectActionMixin/ObjectActionContributee.
Posted by da...@apache.org.
ISIS-1374: refactoring ActionInvocationFacet to remove duplicate between it and the ObjectActionMixin/ObjectActionContributee.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/52f80c04
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/52f80c04
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/52f80c04
Branch: refs/heads/ISIS-1291
Commit: 52f80c048e266b1b645aad8f500b384ba6d5fcfe
Parents: 7fcb167
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 16:21:15 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 16:21:15 2016 +0100
----------------------------------------------------------------------
...onInvocationFacetForDomainEventAbstract.java | 122 ++++++++++---------
1 file changed, 62 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/52f80c04/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index fc85208..46510c8 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -385,90 +385,92 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
}
- // deal with background commands
+ ObjectAdapter resultAdapter;
+
if( command != null &&
command.getExecutor() == Command.Executor.USER &&
command.getExecuteIn() == org.apache.isis.applib.annotation.Command.ExecuteIn.BACKGROUND) {
+ // deal with background commands
+
// persist command so can be this command can be in the 'background'
final CommandService commandService = getCommandService();
- if(commandService.persistIfPossible(command)) {
- // force persistence, then return the command itself.
- final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(command);
- return InvocationResult.forActionThatReturned(resultAdapter);
- } else {
+ if (!commandService.persistIfPossible(command)) {
throw new IsisException(
"Unable to schedule action '"
+ owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
+ "CommandService does not support persistent commands " );
}
- }
-
-
- // otherwise, go ahead and execute action in the 'foreground'
- if(command != null) {
- command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
- }
+ resultAdapter = getAdapterManager().adapterFor(command);
- final ActionSemanticsFacet semanticsFacet = getFacetHolder().getFacet(ActionSemanticsFacet.class);
- final boolean cacheable = semanticsFacet != null && semanticsFacet.value().isSafeAndRequestCacheable();
-
- Object result;
- if(cacheable) {
- final QueryResultsCache queryResultsCache = getQueryResultsCache();
- final Object[] targetPojoPlusExecutionParameters = ArrayExtensions.appendT(executionParameters, targetPojo);
- result = queryResultsCache.execute(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- return method.invoke(targetPojo, executionParameters);
- }
- }, targetPojo.getClass(), method.getName(), targetPojoPlusExecutionParameters);
} else {
- result = method.invoke(targetPojo, executionParameters);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug(" action result " + result);
- }
- if (result == null) {
- if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
- // if this was a void method on cloneable view model, then (to save boilerplate in the domain)
- // automatically do the clone and return the clone instead.
- final ViewModelFacet facet = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
- final Object clone = facet.clone(targetAdapter.getObject());
- final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
- return InvocationResult.forActionThatReturned(clonedAdapter);
+ // otherwise, go ahead and execute action in the 'foreground'
+ if(command != null) {
+ command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
}
- return InvocationResult.forActionThatReturned(null);
- }
- ObjectAdapter resultAdapter = getAdapterManager().adapterFor(result);
+ final ActionSemanticsFacet semanticsFacet = getFacetHolder().getFacet(ActionSemanticsFacet.class);
+ final boolean cacheable = semanticsFacet != null && semanticsFacet.value().isSafeAndRequestCacheable();
+
+ Object result;
+ if(cacheable) {
+ final QueryResultsCache queryResultsCache = getQueryResultsCache();
+ final Object[] targetPojoPlusExecutionParameters = ArrayExtensions.appendT(executionParameters, targetPojo);
+ result = queryResultsCache.execute(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ return method.invoke(targetPojo, executionParameters);
+ }
+ }, targetPojo.getClass(), method.getName(), targetPojoPlusExecutionParameters);
+ } else {
+ result = method.invoke(targetPojo, executionParameters);
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" action result " + result);
+ }
+ if (result == null) {
+ if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
+ // if this was a void method on cloneable view model, then (to save boilerplate in the domain)
+ // automatically do the clone and return the clone instead.
+ final ViewModelFacet facet = targetAdapter.getSpecification().getFacet(ViewModelFacet.class);
+ final Object clone = facet.clone(targetAdapter.getObject());
+ final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
+ return InvocationResult.forActionThatReturned(clonedAdapter);
+ }
+ return InvocationResult.forActionThatReturned(null);
+ }
- if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
- // if the object returned is cloneable, then
- // (to save boilerplate in the domain) automatically do the clone.
- final ViewModelFacet facet = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
- result = facet.clone(result);
resultAdapter = getAdapterManager().adapterFor(result);
- }
+
+ if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
+ // if the object returned is cloneable, then
+ // (to save boilerplate in the domain) automatically do the clone.
+ final ViewModelFacet facet = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
+ result = facet.clone(result);
+ resultAdapter = getAdapterManager().adapterFor(result);
+ }
- // copy over TypeOfFacet if required
- final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
- resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
+ // copy over TypeOfFacet if required
+ final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
+ resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
- if(command != null) {
- if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
- final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
- command.setResult(bookmark);
+ if(command != null) {
+ if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
+ final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
+ command.setResult(bookmark);
+ }
}
- }
- if(currentInvocation.get() == null) {
- final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
- if(publishedActionFacet != null) {
- currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(), arguments, resultAdapter, command));
+ if(currentInvocation.get() == null) {
+ final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
+ if(publishedActionFacet != null) {
+ currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(), arguments, resultAdapter, command));
+ }
}
+
}
return InvocationResult.forActionThatReturned(resultAdapter);
[03/14] isis git commit: ISIS-1386: suitable namespace prefixes for
'aim', 'cmd', 'common' memento XML instances.
Posted by da...@apache.org.
ISIS-1386: suitable namespace prefixes for 'aim', 'cmd', 'common' memento XML instances.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0a335327
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0a335327
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0a335327
Branch: refs/heads/ISIS-1291
Commit: 0a335327e3110249b61a46f3b24d42063c964922
Parents: a04ef99
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 13:18:10 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 13:34:50 2016 +0100
----------------------------------------------------------------------
core/schema/pom.xml | 11 +++++++++++
.../org/apache/isis/schema/aim/aim-2.0-binding.xml | 16 +++++++++++++++-
.../org/apache/isis/schema/cmd/cmd-1.0-binding.xml | 13 ++++++++++++-
3 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/0a335327/core/schema/pom.xml
----------------------------------------------------------------------
diff --git a/core/schema/pom.xml b/core/schema/pom.xml
index 50233c0..5417339 100644
--- a/core/schema/pom.xml
+++ b/core/schema/pom.xml
@@ -82,9 +82,20 @@
<bindingIncludes>
<bindingInclude>aim-2.0-binding.xml</bindingInclude>
</bindingIncludes>
+ <args>
+ <arg>-extension</arg>
+ <arg>-Xnamespace-prefix</arg>
+ </args>
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-namespace-prefix</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
http://git-wip-us.apache.org/repos/asf/isis/blob/0a335327/core/schema/src/main/resources/org/apache/isis/schema/aim/aim-2.0-binding.xml
----------------------------------------------------------------------
diff --git a/core/schema/src/main/resources/org/apache/isis/schema/aim/aim-2.0-binding.xml b/core/schema/src/main/resources/org/apache/isis/schema/aim/aim-2.0-binding.xml
index c8cf1ed..67d8e60 100644
--- a/core/schema/src/main/resources/org/apache/isis/schema/aim/aim-2.0-binding.xml
+++ b/core/schema/src/main/resources/org/apache/isis/schema/aim/aim-2.0-binding.xml
@@ -19,7 +19,12 @@
-->
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- jaxb:version="2.0">
+ jaxb:version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
+ http://jaxb2-commons.dev.java.net/namespace-prefix http://java.net/projects/jaxb2-commons/sources/svn/content/namespace-prefix/trunk/src/main/resources/prefix-namespace-schema.xsd"
+>
<jaxb:bindings schemaLocation="aim-2.0.xsd">
<jaxb:schemaBindings>
<!--
@@ -28,6 +33,9 @@
-->
<jaxb:package name="org.apache.isis.schema.aim.v2"/>
</jaxb:schemaBindings>
+ <jaxb:bindings>
+ <namespace:prefix name="aim" />
+ </jaxb:bindings>
</jaxb:bindings>
<!-- since aim-2.0.xsd does an xs:import of common-1.0.xsd, we need to specify common's package bindings -->
<jaxb:bindings schemaLocation="../common/common-1.0.xsd">
@@ -38,6 +46,9 @@
-->
<jaxb:package name="org.apache.isis.schema.common.v1"/>
</jaxb:schemaBindings>
+ <jaxb:bindings>
+ <namespace:prefix name="common" />
+ </jaxb:bindings>
</jaxb:bindings>
<!-- since aim-2.0.xsd does an xs:import of cmd-1.0.xsd, we need to specify common's package bindings -->
<jaxb:bindings schemaLocation="../cmd/cmd-1.0.xsd">
@@ -48,5 +59,8 @@
-->
<jaxb:package name="org.apache.isis.schema.cmd.v1"/>
</jaxb:schemaBindings>
+ <jaxb:bindings>
+ <namespace:prefix name="cmd" />
+ </jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/0a335327/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0-binding.xml
----------------------------------------------------------------------
diff --git a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0-binding.xml b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0-binding.xml
index 8e91ef3..1454688 100644
--- a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0-binding.xml
+++ b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.0-binding.xml
@@ -19,7 +19,12 @@
-->
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- jaxb:version="2.0">
+ jaxb:version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
+ http://jaxb2-commons.dev.java.net/namespace-prefix http://java.net/projects/jaxb2-commons/sources/svn/content/namespace-prefix/trunk/src/main/resources/prefix-namespace-schema.xsd"
+ >
<jaxb:bindings schemaLocation="cmd-1.0.xsd">
<jaxb:schemaBindings>
<!--
@@ -28,6 +33,9 @@
-->
<jaxb:package name="org.apache.isis.schema.cmd.v1"/>
</jaxb:schemaBindings>
+ <jaxb:bindings>
+ <namespace:prefix name="cmd" />
+ </jaxb:bindings>
</jaxb:bindings>
<!-- since cmd-1.0.xsd does an xs:import of common-1.0.xsd, we need to specify common's package bindings -->
<jaxb:bindings schemaLocation="../common/common-1.0.xsd">
@@ -38,5 +46,8 @@
-->
<jaxb:package name="org.apache.isis.schema.common.v1"/>
</jaxb:schemaBindings>
+ <jaxb:bindings>
+ <namespace:prefix name="common" />
+ </jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
\ No newline at end of file
[10/14] isis git commit: ISIS-1374: further minor refactoring of
ActionInvocationFacet, internalInvoke (preparing to inline)
Posted by da...@apache.org.
ISIS-1374: further minor refactoring of ActionInvocationFacet, internalInvoke (preparing to inline)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/d6057973
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/d6057973
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/d6057973
Branch: refs/heads/ISIS-1291
Commit: d60579739810e2c2ca6d4f060bd4b978078d627e
Parents: 7faee57
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 16:24:21 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 16:24:21 2016 +0100
----------------------------------------------------------------------
...onInvocationFacetForDomainEventAbstract.java | 45 +++++++++++---------
1 file changed, 24 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/d6057973/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 46510c8..8981bfc 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -431,6 +431,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
LOG.debug(" action result " + result);
}
if (result == null) {
+
if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
// if this was a void method on cloneable view model, then (to save boilerplate in the domain)
// automatically do the clone and return the clone instead.
@@ -439,35 +440,37 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
return InvocationResult.forActionThatReturned(clonedAdapter);
}
- return InvocationResult.forActionThatReturned(null);
- }
+ resultAdapter = null;
- resultAdapter = getAdapterManager().adapterFor(result);
+ } else {
- if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
- // if the object returned is cloneable, then
- // (to save boilerplate in the domain) automatically do the clone.
- final ViewModelFacet facet = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
- result = facet.clone(result);
resultAdapter = getAdapterManager().adapterFor(result);
- }
+ if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
+ // if the object returned is cloneable, then
+ // (to save boilerplate in the domain) automatically do the clone.
+ final ViewModelFacet facet = resultAdapter.getSpecification().getFacet(ViewModelFacet.class);
+ result = facet.clone(result);
+ resultAdapter = getAdapterManager().adapterFor(result);
+ }
- // copy over TypeOfFacet if required
- final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
- resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
- if(command != null) {
- if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
- final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
- command.setResult(bookmark);
+ // copy over TypeOfFacet if required
+ final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
+ resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
+
+ if(command != null) {
+ if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
+ final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
+ command.setResult(bookmark);
+ }
}
- }
- if(currentInvocation.get() == null) {
- final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
- if(publishedActionFacet != null) {
- currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(), arguments, resultAdapter, command));
+ if(currentInvocation.get() == null) {
+ final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
+ if(publishedActionFacet != null) {
+ currentInvocation.set(new CurrentInvocation(targetAdapter, owningAction, getIdentified(), arguments, resultAdapter, command));
+ }
}
}
[02/14] isis git commit: Merge branch 'master' into ISIS-1291
Posted by da...@apache.org.
Merge branch 'master' into ISIS-1291
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/a04ef990
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/a04ef990
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/a04ef990
Branch: refs/heads/ISIS-1291
Commit: a04ef990777d9bbbc903c6c4799022772d77378d
Parents: 43e919e 4846c96
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 21 13:34:36 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 21 13:34:36 2016 +0100
----------------------------------------------------------------------
.../org/apache/isis/applib/layout/component/package-info.java | 7 +++++--
.../isis/applib/layout/grid/bootstrap3/package-info.java | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------