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 2017/10/16 19:51:22 UTC
[isis] 07/09: ISIS-1742: rolls ExceptionRecognizer2 up into
ExceptionRecognizer
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch dev/2.0.0/ISIS-1742-remove-deprecations
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 0dcb44d092e27e2e848c1b67401f504bc20b6461
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Oct 16 20:32:02 2017 +0100
ISIS-1742: rolls ExceptionRecognizer2 up into ExceptionRecognizer
---
.../rgsvc/_rgsvc_presentation-layer-spi.adoc | 2 +-
...presentation-layer-spi_ExceptionRecognizer.adoc | 6 +-
.../services/exceprecog/ExceptionRecognizer.java | 59 +++++++++++++++
.../services/exceprecog/ExceptionRecognizer2.java | 86 ----------------------
.../exceprecog/ExceptionRecognizerAbstract.java | 4 +-
.../exceprecog/ExceptionRecognizerComposite.java | 21 ++----
.../system/persistence/PersistenceSession.java | 13 ++--
todo-deprecation-list.txt | 9 +++
8 files changed, 87 insertions(+), 113 deletions(-)
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi.adoc
index 9edb262..dd73d1c 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi.adoc
@@ -56,7 +56,7 @@ a configured `EmailService`
|xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_ExceptionRecognizer[`o.a.i.applib.` +
`services.exceprecog` +
-`ExceptionRecognizer2`]
+`ExceptionRecognizer`]
|Convert certain exceptions (eg foreign or unique key violation in the database) into a format that can be rendered to the end-user.
|`ExceptionRecognizer-` +
`CompositeFor-` +
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_ExceptionRecognizer.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_ExceptionRecognizer.adoc
index 2d2a1ee..b7bdfe3 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_ExceptionRecognizer.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_ExceptionRecognizer.adoc
@@ -20,7 +20,7 @@ The SPI defined by this service is:
[source,java]
----
-public interface ExceptionRecognizer2 ... {
+public interface ExceptionRecognizer ... {
public enum Category { // <1>
...
}
@@ -48,7 +48,7 @@ The categories are:
[source,java]
----
-public interface ExceptionRecognizer2 ... {
+public interface ExceptionRecognizer ... {
public enum Category {
CONSTRAINT_VIOLATION, // <1>
NOT_FOUND, // <2>
@@ -89,7 +89,7 @@ The framework provides two default implementations:
** `ExceptionRecognizerForJDODataStoreException`
-If you want to recognize and handle additional exceptions (for example to capture error messages specific to the JDBC driver you might be using), then create a fine-grained implementation of `ExceptionRecognizer2` for the particular error message (there are some convenience implementations of the interface that you can subclass from if required) and register in `isis.properties`.
+If you want to recognize and handle additional exceptions (for example to capture error messages specific to the JDBC driver you might be using), then create a fine-grained implementation of `ExceptionRecognizer` for the particular error message (there are some convenience implementations of the interface that you can subclass from if required) and register in `isis.properties`.
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer.java
index 258fa0e..53cb3ca 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer.java
@@ -63,6 +63,13 @@ public interface ExceptionRecognizer {
@Programmatic
public String recognize(Throwable ex);
+ /**
+ * An extension to {@link #recognize(Throwable)} that allows recognized exceptions
+ * to be {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer.Category categorize}d.
+ */
+ @Programmatic
+ Recognition recognize2(Throwable ex);
+
@Programmatic
@PostConstruct
public void init(Map<String, String> properties);
@@ -71,4 +78,56 @@ public interface ExceptionRecognizer {
@PreDestroy
public void shutdown();
+ enum Category {
+ /**
+ * A violation of some declarative constraint (eg uniqueness or referential integrity) was detected.
+ */
+ CONSTRAINT_VIOLATION,
+ /**
+ * The object to be acted upon cannot be found (404)
+ */
+ NOT_FOUND,
+ /**
+ * A concurrency exception, in other words some other user has changed this object.
+ */
+ CONCURRENCY,
+ /**
+ * Recognized, but for some other reason... 40x error
+ */
+ CLIENT_ERROR,
+ /**
+ * 50x error
+ */
+ SERVER_ERROR,
+ /**
+ * Recognized, but uncategorized (typically: a recognizer of the original ExceptionRecognizer API).
+ */
+ OTHER
+ }
+
+ class Recognition {
+
+ /**
+ * Returns a recognition of the specified type (assuming a non-null reason); else null.
+ */
+ public static Recognition of(final Category category, final String reason) {
+ return reason != null? new Recognition(category, reason): null;
+ }
+
+ private final Category category;
+ private final String reason;
+
+ public Recognition(final Category category, final String reason) {
+ this.category = category;
+ this.reason = reason;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+ }
}
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer2.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer2.java
deleted file mode 100644
index 2667014..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizer2.java
+++ /dev/null
@@ -1,86 +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.applib.services.exceprecog;
-
-import org.apache.isis.applib.annotation.Programmatic;
-
-/**
- * An extension of the {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer} interface that
- * allows recognized exceptions to be {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2.Category categorize}d.
- */
-public interface ExceptionRecognizer2 extends ExceptionRecognizer {
-
-
- public enum Category {
- /**
- * A violation of some declarative constraint (eg uniqueness or referential integrity) was detected.
- */
- CONSTRAINT_VIOLATION,
- /**
- * The object to be acted upon cannot be found (404)
- */
- NOT_FOUND,
- /**
- * A concurrency exception, in other words some other user has changed this object.
- */
- CONCURRENCY,
- /**
- * Recognized, but for some other reason... 40x error
- */
- CLIENT_ERROR,
- /**
- * 50x error
- */
- SERVER_ERROR,
- /**
- * Recognized, but uncategorized (typically: a recognizer of the original ExceptionRecognizer API).
- */
- OTHER
- }
-
- public static class Recognition {
-
- /**
- * Returns a recognition of the specified type (assuming a non-null reason); else null.
- */
- public static Recognition of(final Category category, final String reason) {
- return reason != null? new Recognition(category, reason): null;
- }
-
- private final Category category;
- private final String reason;
-
- public Recognition(final Category category, final String reason) {
- this.category = category;
- this.reason = reason;
- }
-
- public Category getCategory() {
- return category;
- }
-
- public String getReason() {
- return reason;
- }
- }
-
- @Programmatic
- public Recognition recognize2(final Throwable ex);
-
-}
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
index 34006db..43628bd 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-import javax.inject.Inject;
+
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Predicate;
@@ -43,7 +43,7 @@ import org.apache.isis.applib.services.i18n.TranslationService;
* If a messaging-parsing {@link Function} is provided through the constructor,
* then the message can be altered. Otherwise the exception's {@link Throwable#getMessage() message} is returned as-is.
*/
-public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer2 {
+public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer {
public static final Logger LOG = LoggerFactory.getLogger(ExceptionRecognizerAbstract.class);
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
index b3d218e..f72829d 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
@@ -44,7 +44,7 @@ import org.apache.isis.applib.services.registry.ServiceRegistry;
* recognize various types of constraint violations. These are grouped together as a single
* set through the use of this class.
*/
-public class ExceptionRecognizerComposite implements ExceptionRecognizer2 {
+public class ExceptionRecognizerComposite implements ExceptionRecognizer {
private final List<ExceptionRecognizer> exceptionRecognizers = Lists.newArrayList();
@@ -89,25 +89,20 @@ public class ExceptionRecognizerComposite implements ExceptionRecognizer2 {
/**
- * Returns the non-<tt>null</tt> recognition of the first {@link #add(ExceptionRecognizer) add}ed
- * (that is also an {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2}).
+ * Returns the non-<tt>null</tt> recognition of the first {@link #add(ExceptionRecognizer) add}ed {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer}.
*
* <p>
- * If none (as {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2}) recognize
- * the exception, then falls back to using {@link #recognize(Throwable)}, returning a
- * {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2.Recognition} with a
- * category of {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2.Category#CLIENT_ERROR}.
+ * If none recognize the exception, then falls back to using {@link #recognize(Throwable)}, returning a
+ * {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer.Recognition} with a
+ * category of {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer.Category#CLIENT_ERROR}.
* </p>
*/
@Programmatic
public final Recognition recognize2(final Throwable ex) {
for (final ExceptionRecognizer ers : exceptionRecognizers) {
- if(ers instanceof ExceptionRecognizer2) {
- final ExceptionRecognizer2 recognizer2 = (ExceptionRecognizer2) ers;
- final Recognition recognition = recognizer2.recognize2(ex);
- if(recognition != null) {
- return recognition;
- }
+ final Recognition recognition = ers.recognize2(ex);
+ if(recognition != null) {
+ return recognition;
}
}
// backward compatible so far as possible.
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index ddb8d70..ce80c60 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -50,7 +50,6 @@ import org.apache.isis.applib.services.command.spi.CommandService;
import org.apache.isis.applib.services.eventbus.AbstractLifecycleEvent;
import org.apache.isis.applib.services.eventbus.EventBusService;
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2;
import org.apache.isis.applib.services.factory.FactoryService;
import org.apache.isis.applib.services.iactn.Interaction;
import org.apache.isis.applib.services.iactn.InteractionContext;
@@ -945,13 +944,11 @@ public class PersistenceSession implements
Class<ExceptionRecognizer> serviceClass = ExceptionRecognizer.class;
final List<ExceptionRecognizer> exceptionRecognizers = lookupServices(serviceClass);
for (ExceptionRecognizer exceptionRecognizer : exceptionRecognizers) {
- if(exceptionRecognizer instanceof ExceptionRecognizer2) {
- final ExceptionRecognizer2 recognizer = (ExceptionRecognizer2) exceptionRecognizer;
- final ExceptionRecognizer2.Recognition recognition = recognizer.recognize2(e);
- if(recognition != null) {
- if(recognition.getCategory() == ExceptionRecognizer2.Category.NOT_FOUND) {
- throw new ObjectNotFoundException(rootOid, e);
- }
+ final ExceptionRecognizer.Recognition recognition =
+ exceptionRecognizer.recognize2(e);
+ if(recognition != null) {
+ if(recognition.getCategory() == ExceptionRecognizer.Category.NOT_FOUND) {
+ throw new ObjectNotFoundException(rootOid, e);
}
}
}
diff --git a/todo-deprecation-list.txt b/todo-deprecation-list.txt
index 05ca6eb..2e233b6 100644
--- a/todo-deprecation-list.txt
+++ b/todo-deprecation-list.txt
@@ -150,6 +150,9 @@ org.apache.isis.applib.fixtures.switchuser
SwitchUserService.java
SwitchUserServiceAware.java
+
+
+
org.apache.isis.applib.services.command
Command.java - methods that pertain to the execution of the command and its completion (for that, use Interaction) [suggest we retain for now]
getCompletedAt()
@@ -413,6 +416,12 @@ org.apache.isis.applib.services.eventbus
PropertyChangedEvent.java - remove
PropertyInteractionEvent.java - remove
+
+org.apache.isis.applib.services.exceprecog
+
+ rolls ExceptionRecognizer2 up into ExceptionRecognizer
+
+
org.apache.isis.applib.services.metamodel
MetaModelService2.java and MetaModelService3 - pulled up to MetaModelService supertype
--
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.