gnodet commented on code in PR #13613:
URL: https://github.com/apache/maven/pull/13613#discussion_r4428241424


##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/ModelDialectManager.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.maven.api.services;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import org.apache.maven.api.Dialect;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+import org.apache.maven.api.model.Model;
+
+/**
+ * The {@code ModelDialectManager} provides a mechanism for managing and
+ * translating between different dialects of Maven models.
+ * It allows reading and writing models in various dialects supported by the 
system.
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public interface ModelDialectManager extends Service {

Review Comment:
   Good question. The indirection is justified by the API/SPI layering.
   
   `Dialect` is an intentionally pure token (like `Language`) — it carries no 
behaviour. `DialectRegistry` only maps string IDs to `Dialect` constants; it 
knows nothing about how to actually read or write a model.
   
   To do that, you need a `ModelDialectProvider` (parser + writer pair) — but 
that type lives in `maven-api-spi`, which is not visible from `maven-api-core` 
consumer code. `ModelDialectManager` is the only `Service` that bridges the two 
layers: callers in API-land get a single injection point 
(`session.getService(ModelDialectManager.class)`) without having to depend on 
SPI types.
   
   There is also the built-in XML dialect, which is bootstrapped internally 
from `ModelXmlFactory` (not registered as a `ModelDialectProvider` via DI), so 
a registry-only approach would either miss it or expose implementation details 
to callers.
   
   The pattern is the same as `ArtifactManager` or `DependencyResolver`: a 
`Service` that coordinates SPI providers and exposes a clean, SPI-free API 
surface.
   
   If `Dialect` were a strategy object carrying its own parser/writer (like a 
`Codec`), the manager would be redundant — but with the extensible-enum 
approach we chose (consistent with `Language`), the indirection is the price of 
the clean separation.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to