gortiz commented on code in PR #13907:
URL: https://github.com/apache/pinot/pull/13907#discussion_r1740986110


##########
pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PinotPluginHandler.java:
##########
@@ -0,0 +1,133 @@
+/**
+ * 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.pinot.spi.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.function.Predicate.not;
+
+
+/**
+ * This handler assumes the following:
+ * Packed:
+ * [plugins-directory]/[plugin-name]/[plugin].zip
+ *
+ * Unpacked
+ * [plugins-directory]/[plugin-name]/classes/[**]/*.class
+ * [plugins-directory]/[plugin-name]/lib/*.jar
+ */
+class PinotPluginHandler {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(PinotPluginHandler.class);
+
+  Collection<URL> toURLs(String pluginName, File directory) {
+    LOGGER.info("Trying to load plugin [{}] from location [{}]", pluginName, 
directory);
+
+    Collection<URL> urlList = new ArrayList<>();
+
+    // classes directory always has to go first
+    Path classes = directory.toPath().resolve("classes");
+    if (Files.isDirectory(classes)) {
+      try {
+        urlList.add(classes.toUri().toURL());
+      } catch (MalformedURLException e) {
+        LOGGER.error("Unable to load plugin [{}] classes directory", 
pluginName, e);
+      }
+    }
+
+    try (var stream = 
Files.newDirectoryStream(directory.toPath().resolve("lib"), e -> 
e.getFileName().toString().endsWith(".jar"))) {

Review Comment:
   Bad news! We cannot use `var`, given we need to be compatible with Java 11



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to