This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/causeway.git
commit d0799d247a32d1f48d4b6d646c85331f7411b3a4 Author: andi-huber <[email protected]> AuthorDate: Thu Mar 12 09:45:04 2026 +0100 CAUSEWAY-3979: DefaultRoutingService is no longer used (since v2) Task-Url: https://issues.apache.org/jira/browse/CAUSEWAY-3979 --- .../index/services/routing/RoutingService.adoc | 41 +++++++------- .../routing/RoutingServiceDefault.adoc | 16 ------ .../how-to-handle-void-and-null-results.adoc | 2 +- .../applib/services/routing/RoutingService.java | 54 ++++++------------- .../runtimeservices/src/main/java/module-info.java | 1 - .../CausewayModuleCoreRuntimeServices.java | 4 -- .../routing/RoutingServiceDefault.java | 63 ---------------------- 7 files changed, 36 insertions(+), 145 deletions(-) diff --git a/antora/components/refguide-index/modules/applib/pages/index/services/routing/RoutingService.adoc b/antora/components/refguide-index/modules/applib/pages/index/services/routing/RoutingService.adoc index 2e52d1bd539..d8e5dbac5c8 100644 --- a/antora/components/refguide-index/modules/applib/pages/index/services/routing/RoutingService.adoc +++ b/antora/components/refguide-index/modules/applib/pages/index/services/routing/RoutingService.adoc @@ -1,20 +1,17 @@ = RoutingService :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 ag [...] -Provides the ability to return (and therefore have rendered) an alternative object from an action invocation. - -There are two primary use cases: - -* if an action returns an aggregate leaf (that is, a child object which has an owning parent), then the parent object can be * returned instead. -+ --- -For example, an action returning `OrderItem` might instead render the owning `Order` object. It is the responsibility of the implementation to figure out what the "owning" object might be. --- -* if an action returns `null` or is `void`, then return some other "useful" object. -+ --- -For example, return the home page (eg as defined by the _org.apache.causeway.applib.annotation.HomePage_ annotation). --- +Provides the ability to return (and therefore have rendered) an alternative +object from an action invocation. + +Primary use case: if an action returns an aggregate leaf (that is, a child +object which has an owning parent), then the parent object can +be returned instead. + +For example, an action returning `OrderItem` might instead +render the owning `Order` object. It is the responsibility +of the implementation to figure out what the "owning" object +might be. Currently this service is used only by the Wicket viewer; it is ignored by the Restful Objects viewer. @@ -24,17 +21,17 @@ Currently this service is used only by the Wicket viewer; it is ignored by the R .RoutingService.java ---- interface RoutingService { - boolean canRoute(Object original) // <.> - Object route(Object original) // <.> + boolean canRoute(@NonNull Object original) // <.> + Object route(@NonNull Object original) // <.> } ---- -<.> xref:#canRoute_Object[canRoute(Object)] +<.> xref:#canRoute_Object[canRoute(@NonNull Object)] + -- whether this implementation recognizes and can "route" the object. -- -<.> xref:#route_Object[route(Object)] +<.> xref:#route_Object[route(@NonNull Object)] + -- The object to route to instead; this may be the same as the original object, some other object, or (indeed) `null`. @@ -43,17 +40,17 @@ The object to route to instead; this may be the same as the original object, som == Members [#canRoute_Object] -=== canRoute(Object) +=== canRoute(@NonNull Object) whether this implementation recognizes and can "route" the object. The _#route(Object)_ method is only called if this method returns `true` . [#route_Object] -=== route(Object) +=== route(@NonNull Object) The object to route to instead; this may be the same as the original object, some other object, or (indeed) `null`. -include::hooks/RoutingService_010-implementation.adoc[] +//include::hooks/RoutingService_010-implementation.adoc[] -include::hooks/RoutingService_020-examples-and-usage.adoc[] +//include::hooks/RoutingService_020-examples-and-usage.adoc[] diff --git a/antora/components/refguide-index/modules/core/pages/index/runtimeservices/routing/RoutingServiceDefault.adoc b/antora/components/refguide-index/modules/core/pages/index/runtimeservices/routing/RoutingServiceDefault.adoc deleted file mode 100644 index 3e935cbbfc7..00000000000 --- a/antora/components/refguide-index/modules/core/pages/index/runtimeservices/routing/RoutingServiceDefault.adoc +++ /dev/null @@ -1,16 +0,0 @@ -= RoutingServiceDefault -: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 ag [...] - -Default implementation of xref:refguide:applib:index/services/routing/RoutingService.adoc[RoutingService] , which will route any `void` action or action returning `null` to the home page (as per xref:refguide:applib:index/services/homepage/HomePageResolverService.adoc[HomePageResolverService] . - -== API - -[source,java] -.RoutingServiceDefault.java ----- -class RoutingServiceDefault { - boolean canRoute(Object original) - Object route(Object original) -} ----- - diff --git a/antora/components/userguide/modules/btb/partials/hints-and-tips/how-to-handle-void-and-null-results.adoc b/antora/components/userguide/modules/btb/partials/hints-and-tips/how-to-handle-void-and-null-results.adoc index a63f35fae54..ae521cbba26 100644 --- a/antora/components/userguide/modules/btb/partials/hints-and-tips/how-to-handle-void-and-null-results.adoc +++ b/antora/components/userguide/modules/btb/partials/hints-and-tips/how-to-handle-void-and-null-results.adoc @@ -4,7 +4,7 @@ :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 ag [...] :page-partial: - +WARNING: This is an outdated solution, because `RoutingServiceDefault#route(Object original)` is not allowed to handle the pojo==null case. From this link:http://causeway.markmail.org/thread/yf7qdeiu3vrvk2ei[thread] on the Apache Causeway users mailing list: diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/routing/RoutingService.java b/api/applib/src/main/java/org/apache/causeway/applib/services/routing/RoutingService.java index 4905071db6e..066cb65802e 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/services/routing/RoutingService.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/services/routing/RoutingService.java @@ -18,44 +18,24 @@ */ package org.apache.causeway.applib.services.routing; +import org.jspecify.annotations.NonNull; + /** * Provides the ability to return (and therefore have rendered) an alternative * object from an action invocation. * - * <p> - * There are two primary use cases: - * </p> + * <p>Primary use case: if an action returns an aggregate leaf (that is, a child + * object which has an owning parent), then the parent object can + * be returned instead. * - * <ul> - * <li> - * <p> - * if an action returns an aggregate leaf (that is, a child - * object which has an owning parent), then the parent object can - * be * returned instead. - * </p> - * <p> - * For example, an action returning `OrderItem` might instead - * render the owning `Order` object. It is the responsibility - * of the implementation to figure out what the "owning" object - * might be. - * </p> - * </li> - * <li> - * <p> - * if an action returns `null` or is `void`, then return some - * other "useful" object. - * </p> - * <p> - * For example, return the home page (eg as defined by the - * {@link org.apache.causeway.applib.annotation.HomePage} annotation). - * </p> - * </li> - * </ul> + * <p>For example, an action returning `OrderItem` might instead + * render the owning `Order` object. It is the responsibility + * of the implementation to figure out what the "owning" object + * might be. * - * <p> - * Currently this service is used only by the Wicket viewer; it is ignored by - * the Restful Objects viewer. - * </p> + * @apiNote Chain of Responsibility pattern, where order is according to Spring Bean priority. + * Currently this service is used only by the Wicket viewer; it is ignored by + * the Restful Objects viewer. * * @since 1.x {@index} */ @@ -64,14 +44,12 @@ public interface RoutingService { /** * whether this implementation recognizes and can "route" the object. * - * <p> - * The {@link #route(Object)} method is only called if this method - * returns <code>true</code>. - * </p> + * <p>The {@link #route(Object)} method is only called if this method + * returns <code>true</code>. * * @param original */ - boolean canRoute(Object original); + boolean canRoute(@NonNull Object original); /** * The object to route to instead; this may be the same as the original @@ -79,6 +57,6 @@ public interface RoutingService { * * @param original */ - Object route(Object original); + Object route(@NonNull Object original); } diff --git a/core/runtimeservices/src/main/java/module-info.java b/core/runtimeservices/src/main/java/module-info.java index 23e9b93a01e..cecb8d28c54 100644 --- a/core/runtimeservices/src/main/java/module-info.java +++ b/core/runtimeservices/src/main/java/module-info.java @@ -36,7 +36,6 @@ exports org.apache.causeway.core.runtimeservices.publish; exports org.apache.causeway.core.runtimeservices.recognizer; exports org.apache.causeway.core.runtimeservices.recognizer.dae; - exports org.apache.causeway.core.runtimeservices.routing; exports org.apache.causeway.core.runtimeservices.scratchpad; exports org.apache.causeway.core.runtimeservices.session; exports org.apache.causeway.core.runtimeservices.sitemap; diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/CausewayModuleCoreRuntimeServices.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/CausewayModuleCoreRuntimeServices.java index d51043e4882..bee6e2db2ce 100644 --- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/CausewayModuleCoreRuntimeServices.java +++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/CausewayModuleCoreRuntimeServices.java @@ -59,7 +59,6 @@ import org.apache.causeway.core.runtimeservices.recognizer.ExceptionRecognizerServiceDefault; import org.apache.causeway.core.runtimeservices.recognizer.dae.ExceptionRecognizerForDataAccessException; import org.apache.causeway.core.runtimeservices.render.PlaceholderRenderServiceDefault; -import org.apache.causeway.core.runtimeservices.routing.RoutingServiceDefault; import org.apache.causeway.core.runtimeservices.scratchpad.ScratchpadDefault; import org.apache.causeway.core.runtimeservices.session.InteractionIdGeneratorDefault; import org.apache.causeway.core.runtimeservices.session.InteractionServiceDefault; @@ -122,9 +121,6 @@ XmlServiceDefault.class, XmlSnapshotServiceDefault.class, - // @Controller - RoutingServiceDefault.class, - // @DomainService's TranslationServicePoMenu.class, diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/routing/RoutingServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/routing/RoutingServiceDefault.java deleted file mode 100644 index 25b60049757..00000000000 --- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/routing/RoutingServiceDefault.java +++ /dev/null @@ -1,63 +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.causeway.core.runtimeservices.routing; - -import jakarta.annotation.Priority; -import jakarta.inject.Inject; -import jakarta.inject.Named; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import org.apache.causeway.applib.annotation.PriorityPrecedence; -import org.apache.causeway.applib.services.homepage.HomePageResolverService; -import org.apache.causeway.applib.services.routing.RoutingService; -import org.apache.causeway.core.runtimeservices.CausewayModuleCoreRuntimeServices; - -import lombok.RequiredArgsConstructor; - -/** - * Default implementation of {@link RoutingService}, which will route any <code>void</code>action or action - * returning <code>null</code> to the home page (as per {@link HomePageResolverService}. - * - * @since 2.0 {@index} - * - * @see HomePageResolverService - */ -@Service -@Named(CausewayModuleCoreRuntimeServices.NAMESPACE + ".RoutingServiceDefault") -@Priority(PriorityPrecedence.EARLY) -@Qualifier("Default") -@RequiredArgsConstructor(onConstructor_ = {@Inject}) -//@Slf4j -public class RoutingServiceDefault implements RoutingService { - - private final HomePageResolverService homePageResolverService; - - @Override - public boolean canRoute(final Object original) { - return original == null; - } - - @Override - public Object route(final Object original) { - return homePageResolverService.getHomePage(); - } - -}
