mbeckerle commented on a change in pull request #651:
URL: https://github.com/apache/daffodil/pull/651#discussion_r728168753
##########
File path:
daffodil-lib/src/main/scala/org/apache/daffodil/validation/Validators.scala
##########
@@ -17,25 +17,18 @@
package org.apache.daffodil.validation
-import java.util.ServiceLoader
-
import org.apache.daffodil.api.ValidatorFactory
-
-import scala.collection.JavaConverters._
+import org.apache.daffodil.util.DynamicLoader
/**
* Access SPI registered [[org.apache.daffodil.api.ValidatorFactory]]
instances.
*
* Registered instances provide a unique name for lookup.
*/
object Validators {
- private lazy val impls: Map[String, ValidatorFactory] =
- ServiceLoader
- .load(classOf[ValidatorFactory])
- .iterator()
- .asScala
- .map(v => v.name() -> v)
- .toMap
+ private lazy val impls: Map[String, ValidatorFactory] = {
+ DynamicLoader.loadClass[ValidatorFactory](classOf[ValidatorFactory])
+ }
Review comment:
I think perhaps the right thing is that I'll just add a comment to the
UDF code mentioning that it does *not* use the SimpleNamedServiceLoader (new
name for what I had called DynamicLoader) because it's not quite as simple, but
this will give a user hoping to copy a ServiceLoader pattern a hint to look at
how the Validator and Layering stuff do it.
--
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]