stevedlawrence commented on a change in pull request #651:
URL: https://github.com/apache/daffodil/pull/651#discussion_r727064106



##########
File path: 
daffodil-lib/src/main/scala/org/apache/daffodil/util/DynamicLoader.scala
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.daffodil.util
+
+import java.util.ServiceConfigurationError
+import java.util.ServiceLoader
+import scala.collection.mutable.ArrayBuffer
+import scala.language.reflectiveCalls
+
+/**
+ * Contains methods for dynamic loading of classes from the class path.
+ */
+object DynamicLoader {
+
+  /**
+   * Load all instances of a particular class from the class path that are
+   * declared service providers
+   * @param clazz The class to be loaded. E.g., classOf[LayerCompiler]
+   * @tparam T The type to be loaded. Usually this is inferred and isn't 
explicitly supplied.
+   *           It must have a name member returning a string. It must have a 
default (no-arg) constructor.
+   * @return A map from the name (string) to the corresponding instance of the 
class.
+   */
+  def loadClass[T <: { def name(): String }](clazz : Class[T]): Map[String, T] 
=  {
+    val thingName = {
+      val classNameWithPackage = clazz.getName
+      val packageName = clazz.getPackageName

Review comment:
       I would say as long as Java 8 is LTS, which it is for many more years 
unfortunately, we should try to support it unless there is some critical 
feature that we need that is only available in newer versions. In this case, 
it's easy enough to support Java 8.




-- 
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