You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2023/10/22 10:57:42 UTC

[jena] 04/05: GH-2020: Remove deprecated methods (Fuseki)

This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch jena5
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 23799d78378a2835013881e5cbad35495f9a7132
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Fri Oct 20 12:24:19 2023 +0100

    GH-2020: Remove deprecated methods (Fuseki)
---
 .../org/apache/jena/fuseki/build/FusekiConfig.java |   2 -
 .../org/apache/jena/fuseki/build/FusekiExt.java    |  42 +------
 .../fuseki/server/DataAccessPointRegistry.java     |  10 --
 .../apache/jena/fuseki/system/FusekiNetLib.java    |  13 --
 .../org/apache/jena/fuseki/main/FusekiLib.java     |  36 +-----
 .../org/apache/jena/fuseki/main/FusekiServer.java  |  19 ---
 .../org/apache/jena/fuseki/main/JettyServer.java   |   6 -
 .../ExFuseki_99_CustomOperation_GlobalDefault.java | 136 ---------------------
 8 files changed, 8 insertions(+), 256 deletions(-)

diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
index 6bfcfbc8f6..af3b0b8eef 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
@@ -104,8 +104,6 @@ public class FusekiConfig {
         if ( allowUpdate ) {
             stdWrite.forEach((name, op) -> accEndpoint(endpoints, op, name));
             stdDatasetWrite.forEach(op -> accEndpoint(endpoints, op));
-            if ( FusekiExt.extraOperationServicesWrite != null )
-                FusekiExt.extraOperationServicesWrite.forEach((name, op) -> accEndpoint(endpoints, op, name));
         } else {
             stdRead.forEach((name, op) -> accEndpoint(endpoints, op, name));
             stdDatasetRead.forEach(op -> accEndpoint(endpoints, op));
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiExt.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiExt.java
index a503be8877..a982c76f12 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiExt.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiExt.java
@@ -18,7 +18,6 @@
 
 package org.apache.jena.fuseki.build;
 
-import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.jena.fuseki.server.Operation;
@@ -31,42 +30,11 @@ import org.apache.jena.fuseki.servlets.ActionService;
 public class FusekiExt {
 
     // Additional operations provided by extension, added via Jena init / typically ServiceLoader
-    static Map<String, Operation> extraOperationServicesRead;
-    static Map<String, Operation> extraOperationServicesWrite;
-
-    /**
-     * Add a new operation, which will be included in a default configuration.
-     * The operation must have been added with {@link #registerOperation} first.
-     * @deprecated Use {@code FusekiModules} with FusekiMain.
-     */
-    @Deprecated
-    public static void addDefaultEndpoint(Operation op, String serviceName) {
-        // Include in both sets.
-        addDefaultEndpoint(op, serviceName, false);
-        addDefaultEndpoint(op, serviceName, true);
-    }
-
-    /**
-     * Add a new operation, which will be included in a default configuration,
-     * depending on whether it is for general inclusion or for inclusion for update
-     * only configuration.
-     * The operation must have been added with {@link #registerOperation} first.
-     * @deprecated Use {@code FusekiModules} with FusekiMain.
-     */
-    @Deprecated
-    public static void addDefaultEndpoint(Operation op, String serviceName, boolean forUpdate) {
-        // Due to class loading and ServiceLoader interaction, it is not reliable to
-        // set extraOperationServices as it is declared.
-        if ( extraOperationServicesRead == null )
-            extraOperationServicesRead = new HashMap<>();
-        if ( extraOperationServicesWrite == null )
-            extraOperationServicesWrite = new HashMap<>();
-
-        if ( forUpdate )
-            extraOperationServicesWrite.put(serviceName, op);
-        else
-            extraOperationServicesRead.put(serviceName, op);
-    }
+    // These are used in FuskeiConfig.
+    // Left in case in the future we want to have customized defautl setup.
+    // Currently, Jena5, the preferred way is to have control via config.ttl or FusekiServer.Builder.
+    /*package*/ static Map<String, Operation> extraOperationServicesRead = null;
+    /*package*/ static Map<String, Operation> extraOperationServicesWrite = null;
 
     /** Make a new operation available. */
     public static void registerOperation(Operation op, ActionService handler) {
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
index d859138dba..14566f0977 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
@@ -71,16 +71,6 @@ public class DataAccessPointRegistry extends Registry<String, DataAccessPoint>
         return accessPoints;
     }
 
-    /**
-     *  @deprecated Use {@link #register(DataAccessPoint)}.
-     * This method ignores the accessPointName argument.
-     */
-    @Override
-    @Deprecated
-    public void put(String accessPointName, DataAccessPoint dap) {
-        register(dap);
-    }
-
     @Override
     public DataAccessPoint get(String key) {
         return super.get(key);
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiNetLib.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiNetLib.java
index 35b5a38853..9739332efb 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiNetLib.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiNetLib.java
@@ -22,12 +22,9 @@ import java.util.Enumeration;
 import java.util.Iterator;
 
 import jakarta.servlet.http.HttpServletRequest;
-
 import org.apache.commons.collections4.MultiMapUtils;
 import org.apache.commons.collections4.MultiValuedMap;
 import org.apache.jena.atlas.web.ContentType;
-import org.apache.jena.atlas.web.WebLib;
-import org.apache.jena.fuseki.FusekiException;
 import org.apache.jena.fuseki.servlets.HttpAction;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.Node;
@@ -173,14 +170,4 @@ public class FusekiNetLib {
         PrefixMapping pmapDest = dest.getDefaultGraph().getPrefixMapping();
         pmapDest.withDefaultMappings(pmapSrc);
     }
-
-    /** Use {@link WebLib#choosePort} or start servers with port 0 and then ask which port was allocated. */
-    @Deprecated
-    public static int choosePort() {
-        try {
-            return WebLib.choosePort();
-        } catch (RuntimeException ex) {
-            throw new FusekiException(ex.getMessage());
-        }
-    }
 }
diff --git a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiLib.java b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiLib.java
index efbcfe4fdd..0b0d152525 100644
--- a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiLib.java
+++ b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiLib.java
@@ -25,18 +25,17 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.jena.fuseki.FusekiConfigException;
 import org.apache.jena.fuseki.access.AccessCtl_AllowGET;
 import org.apache.jena.fuseki.access.AccessCtl_Deny;
 import org.apache.jena.fuseki.access.AccessCtl_GSP_R;
 import org.apache.jena.fuseki.access.AccessCtl_SPARQL_QueryDataset;
-import org.apache.jena.fuseki.build.FusekiConfig;
-import org.apache.jena.fuseki.server.*;
+import org.apache.jena.fuseki.server.DataAccessPointRegistry;
+import org.apache.jena.fuseki.server.Endpoint;
+import org.apache.jena.fuseki.server.Operation;
 import org.apache.jena.fuseki.servlets.ActionService;
 import org.apache.jena.fuseki.servlets.GSP_RW;
 import org.apache.jena.fuseki.servlets.HttpAction;
 import org.apache.jena.riot.WebContent;
-import org.apache.jena.sparql.core.DatasetGraph;
 
 /** Actions on and about a {@link FusekiServer} */
 public class FusekiLib {
@@ -53,35 +52,6 @@ public class FusekiLib {
         return names;
     }
 
-    /**
-     * Add a dataset to a server, with the default set of services.
-     * @deprecated Construct the server with the a {@link FusekiServer.Builder}.
-     */
-    @Deprecated
-    public static FusekiServer addDataset(FusekiServer server, String name, DatasetGraph dsg, boolean withUpdate) {
-        DataService dataService = FusekiConfig.buildDataServiceStd(dsg, withUpdate);
-        return addDataset(server, name, dataService);
-    }
-
-    @Deprecated
-    /** Add a {@link DataService} to a server */
-    public static FusekiServer addDataset(FusekiServer server, String name, DataService dataService) {
-        DataAccessPointRegistry dataAccessPoints = DataAccessPointRegistry.get(server.getServletContext());
-        name = DataAccessPoint.canonical(name);
-        if ( dataAccessPoints.isRegistered(name) )
-            throw new FusekiConfigException("Data service name already registered: "+name);
-        FusekiConfig.addDataService(dataAccessPoints, name, dataService);
-        return server;
-    }
-
-    /** Remove dataset from a server */
-    @Deprecated
-    public static FusekiServer removeDataset(FusekiServer server, String name) {
-        DataAccessPointRegistry dataAccessPoints = DataAccessPointRegistry.get(server.getServletContext());
-        FusekiConfig.removeDataset(dataAccessPoints, name);
-        return server;
-    }
-
     /**
      * Return a {@code FusekiServer.Builder} setup for data access control.
      */
diff --git a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiServer.java b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiServer.java
index 37bf0ef6b6..bf5688849f 100644
--- a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiServer.java
+++ b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/FusekiServer.java
@@ -1078,25 +1078,6 @@ public class FusekiServer {
             return this;
         }
 
-        /** @deprecated Use {@link #fusekiModules(FusekiModules)}. */
-        @Deprecated
-        public Builder setModules(FusekiModules modules) {
-            return fusekiModules(modules);
-        }
-
-        // Conflict with fusekiModules()
-//        /**
-//         * Set the {@link FusekiModules Fuseki Modules} for a server.
-//         * If no modules are added to a builder, then the system-wide default set (found by loading FusekiModules
-//         * via Java's {@link ServiceLoader} mechanism) is used.
-//         * <p>Pass {@code null} to switch back the system-wide default set.
-//         *
-//         * @see FusekiModules
-//         */
-//        public Builder fusekiModules(FusekiModule ...fmods) {
-//            return fusekiModules(FusekiModules.create(fmods));
-//        }
-
         /**
          * Set the {@link FusekiModule Fuseki Module} for a server.
          * If no modules are added to a builder, then the system-wide default set (found by loading FusekiModule
diff --git a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/JettyServer.java b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/JettyServer.java
index 3ef6689ccc..80641c76f6 100644
--- a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/JettyServer.java
+++ b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/JettyServer.java
@@ -314,12 +314,6 @@ public class JettyServer {
             return this;
         }
 
-        /** @deprecated Renamed as {@link #maxServerThreads} */
-        @Deprecated
-        public Builder maxServerNumThreads(int maxThreads) {
-            return maxServerThreads(maxThreads);
-        }
-
         /**
          * Set the maximum number threads used by Jetty.
          * This is equivalent to {@code numServerThreads(-1, maxThreads)}
diff --git a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_99_CustomOperation_GlobalDefault.java b/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_99_CustomOperation_GlobalDefault.java
deleted file mode 100644
index 35ffbd2698..0000000000
--- a/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFuseki_99_CustomOperation_GlobalDefault.java
+++ /dev/null
@@ -1,136 +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.jena.fuseki.main.examples;
-
-import java.io.IOException;
-import java.util.ServiceLoader;
-
-import org.apache.jena.atlas.lib.DateTimeUtils;
-import org.apache.jena.fuseki.Fuseki;
-import org.apache.jena.fuseki.FusekiException;
-import org.apache.jena.fuseki.build.FusekiExt;
-import org.apache.jena.fuseki.main.FusekiServer;
-import org.apache.jena.fuseki.main.sys.FusekiModule;
-import org.apache.jena.fuseki.server.Operation;
-import org.apache.jena.fuseki.servlets.ActionService;
-import org.apache.jena.fuseki.servlets.HttpAction;
-import org.apache.jena.fuseki.system.FusekiLogging;
-import org.apache.jena.http.HttpOp;
-import org.apache.jena.riot.WebContent;
-import org.apache.jena.sparql.core.DatasetGraphFactory;
-import org.apache.jena.sys.JenaSubsystemLifecycle;
-import org.apache.jena.sys.JenaSystem;
-import org.apache.jena.web.HttpSC;
-
-/**
- * Example of adding a new operation to a Fuseki server by registering it with the
- * global Fuseki registries and adding it to the global default services.
- * <p>
- * <i>The preferred way of doing this is now to use {@link FusekiModule FusekiModules}.</i>
- * <p>
- * The custom operation is loaded using {@link ServiceLoader} as shown in
- * {@link InitFusekiCustomOperation}.
- * <p>
- * {@link ExFuseki_04_CustomOperation_Module}
- * <p>
- * Doing this, adding the jar to the classpath, including the {@link ServiceLoader}
- * setup, will automatically add it to the server.
- * <p>
- * See <a href="https://jena.apache.org/documentation/notes/jena-repack.html">Repacking Jena jars</a>.
- * <p>
- * See <a href="https://jena.apache.org/documentation/notes/system-initialization.html">System Initialization</a>
- * <p>
- * <b>This example code predates {@link FusekiModule FusekiModules}.</b>
- */
-@Deprecated
-public class ExFuseki_99_CustomOperation_GlobalDefault {
-
-    static {
-        JenaSystem.init();
-        FusekiLogging.setLogging();
-    }
-
-    // Example usage.
-    public static void main(String...args) {
-
-        // Imitate Service loader behaviour for Jena initialization.
-        new InitFusekiCustomOperation().start();
-
-        FusekiServer.create().port(3230).add("/ds", DatasetGraphFactory.createTxnMem()).build().start();
-
-        callOperation("extra");
-        System.exit(0);
-    }
-
-    private static void callOperation(String name) {
-        String x = HttpOp.httpGetString("http://localhost:3230/ds/"+name);
-        if ( x == null ) {
-            System.out.println("Not found : <null>");
-        } else {
-            System.out.print(x);
-            if ( ! x.endsWith("\n") )
-                System.out.println();
-        }
-    }
-
-    public static class InitFusekiCustomOperation implements JenaSubsystemLifecycle {
-
-        public InitFusekiCustomOperation() {}
-
-        @Override
-        public void start() {
-            // Can use Fuseki server logging.
-            Fuseki.configLog.info("Add custom operation");
-            System.err.println("**** Fuseki extension (global) ****");
-            Operation op = Operation.alloc("http://example/extra-service", "extra-service", "Test");
-            FusekiExt.registerOperation(op, new MyCustomService());
-            FusekiExt.addDefaultEndpoint(op, "extra");
-        }
-
-        @Override
-        public void stop() {}
-
-        @Override
-        public int level() { return 1000; }
-    }
-
-    // For convenience of the example - include the implementation of the custom operation in the same file.
-    private static class MyCustomService extends ActionService {
-
-        // Choose.
-        @Override
-        public void execGet(HttpAction action) {
-            executeLifecycle(action);
-        }
-
-        @Override
-        public void validate(HttpAction action) { }
-
-        @Override
-        public void execute(HttpAction action) {
-            action.setResponseStatus(HttpSC.OK_200);
-            action.setResponseContentType(WebContent.contentTypeTextPlain);
-            try {
-                action.getResponseOutputStream().print("** GET ** "+DateTimeUtils.nowAsXSDDateTimeString());
-            } catch (IOException e) {
-                throw new FusekiException(e);
-            }
-        }
-    }
-}