Class UserDefinedFunctionProvider

java.lang.Object
org.apache.daffodil.api.udf.UserDefinedFunctionProvider

public abstract class UserDefinedFunctionProvider extends Object
Abstract class used by ServiceLoader to poll for UDF providers on classpath.

Through this class, several User Defined Functions can be made available to Daffodil via a single entry in the META-INF/services file.

UDF Providers must subclass this, and must initialize the userDefinedFunctionClasses array with all the UDF classes it is providing.

If the UDFs being provided have constructors with arguments, the provider subclass must also implement the createUserDefinedFunction to return an initialized function class object based on the supplied namespace and name.

Subclasses must also supply a src/META-INF/services/org.apache.daffodil.api.udf.UserDefinedFunctionProvider file in their JAVA project in order to be discoverable by Daffodil.

  • Constructor Details

    • UserDefinedFunctionProvider

      public UserDefinedFunctionProvider()
  • Method Details

    • getUserDefinedFunctionClasses

      public abstract Class<?>[] getUserDefinedFunctionClasses()
      Must be implemented to return the classes of the User Defined Function this provider is aware of/providing
      Returns:
      array of the different UserDefinedFunction classes it provides
    • createUserDefinedFunction

      Finds and initializes User Defined Function class based on namespace and name provided. The UserDefinedFunctionIdentification annotation applied to the function class must match name and namespaceURI field passed in from the schema.

      Must be overloaded if the function class's constructor takes arguments. Otherwise it will throw exceptions.

      Parameters:
      namespaceURI - XML namespace associated with schema function call
      fName - function name called in schema
      Returns:
      initialized UserDefinedFunction object that must contain evaluate function with desired functionality
      Throws:
      SecurityException - if security manager exists and disallows access
      IllegalArgumentException - if the UDF doesn't have a no-argument constructor
      ExceptionInInitializerError - if there is an issue initializing the UDF object
      ReflectiveOperationException - if the UDF doesn't have a no-argument constructor or if there is an issue initializing the UDF object