Class NCSpringModelFactory

  • All Implemented Interfaces:
    NCModelFactory

    public class NCSpringModelFactory
    extends Object
    implements NCModelFactory
    Factory that delegates construction of NCModels to the Spring Framework.

    This factory requires one of the following configuration properties:

    • "javaConfig" - name a class that is annotated with the Spring's Configuration annotation
    • "xmlConfig" - path to an XML files with Spring bean definitions
    Spring factory have to be specified in probe configuration. Here's a probe.conf from Names example using Spring-based factory:
     nlpcraft {
         probe {
             id = "names"
             token = "3141592653589793"
             upLink = "localhost:8201"   # Server to probe data pipe.
             downLink = "localhost:8202" # Probe to server data pipe.
             jarsFolder = null
             models = [
                 "org.apache.nlpcraft.examples.names.NamesModel"
             ]
             modelFactory = {
                 type = "org.apache.nlpcraft.model.factories.spring.NCSpringModelFactory"
                 properties = {
                     javaConfig = "org.apache.nlpcraft.examples.names.NamesConfig"
                 }
             }
             lifecycle = [
             ]
             resultMaxSizeBytes = 1048576
         }
         nlpEngine = "opennlp"
      }
     

    Lines 10-15 specify data model factory and its configuration properties.

    • Field Detail

      • JAVA_CONFIG_PROP

        public static final String JAVA_CONFIG_PROP
        Configuration property for Java Config-based Spring configuration.
        See Also:
        Constant Field Values
      • XML_CONFIG_PROP

        public static final String XML_CONFIG_PROP
        Configuration property for XML-based Spring configuration.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NCSpringModelFactory

        public NCSpringModelFactory()
    • Method Detail

      • initialize

        public void initialize​(Map<String,​String> props)
        Description copied from interface: NCModelFactory
        Initializes this factory with properties specified in probe configuration.
        Specified by:
        initialize in interface NCModelFactory
        Parameters:
        props - Configuration properties.