Aklakan commented on code in PR #3027: URL: https://github.com/apache/jena/pull/3027#discussion_r2109873042
########## jena-fuseki2/jena-fuseki-mod-geosparql/src/main/java/org/apache/jena/fuseki/mod/geosparql/FMod_SpatialIndexer.java: ########## @@ -0,0 +1,148 @@ +/* + * 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.mod.geosparql; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.jena.fuseki.Fuseki; +import org.apache.jena.fuseki.auth.AuthPolicy; +import org.apache.jena.fuseki.main.FusekiServer; +import org.apache.jena.fuseki.main.sys.FusekiAutoModule; +import org.apache.jena.fuseki.server.DataAccessPoint; +import org.apache.jena.fuseki.server.DataAccessPointRegistry; +import org.apache.jena.fuseki.server.DataService; +import org.apache.jena.fuseki.server.Endpoint; +import org.apache.jena.fuseki.server.Operation; +import org.apache.jena.rdf.model.Model; + +public class FMod_SpatialIndexer implements FusekiAutoModule { + + private Operation spatialOperation = null; + + public Operation getOperation() { + if (spatialOperation == null) { + synchronized (this) { + if (spatialOperation == null) { + Fuseki.configLog.info(name() + ": Add spatial indexer operation into global registry."); + spatialOperation = Operation.alloc("http://org.apache.jena/spatial-index-service", + "spatial-indexer", + "Spatial index computation service"); + } + } + } + return spatialOperation; + } + + public FMod_SpatialIndexer() { + super(); + } + + @Override + public String name() { + return "Spatial Indexer"; + } + + @Override + public void start() { + } + + @Override + public void prepare(FusekiServer.Builder builder, Set<String> datasetNames, Model configModel) { + Fuseki.configLog.info(name() + ": Module adds spatial index servlet"); + Operation op = getOperation(); + builder.registerOperation(op, new SpatialIndexComputeService()); + + // This does not appear to do anything - datasetNames may be empty but data access points may exist. + // datasetNames.forEach(name -> builder.addEndpoint(name, "spatial", op)); + // datasetNames.forEach(name -> builder.addEndpoint(name, "spatial-events", op)); + } + + /** + * The indexer is only created if there is a SPARQL update endpoint. The update endpoint's auth policy is inherited. + */ + @Override + public void configured(FusekiServer.Builder serverBuilder, DataAccessPointRegistry dapRegistry, Model configModel) { Review Comment: Disabled the auto registration of `<updateEndpointName>-spatial` endpoints at least for this PR. It could be enabled at a later stage, but for now I think it safer to require explicit endpoint declarations. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
