Class NCSpringModelFactory
- java.lang.Object
-
- org.apache.nlpcraft.model.factories.spring.NCSpringModelFactory
-
- All Implemented Interfaces:
NCModelFactory
public class NCSpringModelFactory extends Object implements NCModelFactory
Factory that delegates construction ofNCModel
s 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
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 Summary
Fields Modifier and Type Field Description static String
JAVA_CONFIG_PROP
Configuration property for Java Config-based Spring configuration.static String
XML_CONFIG_PROP
Configuration property for XML-based Spring configuration.
-
Constructor Summary
Constructors Constructor Description NCSpringModelFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initialize(Map<String,String> props)
Initializes this factory with properties specified in probe configuration.NCModel
mkModel(Class<? extends NCModel> claxx)
Constructs a model instance.void
terminate()
Terminates this factory when probe stops.
-
-
-
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
-
-
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 interfaceNCModelFactory
- Parameters:
props
- Configuration properties.
-
mkModel
public NCModel mkModel(Class<? extends NCModel> claxx)
Description copied from interface:NCModelFactory
Constructs a model instance.- Specified by:
mkModel
in interfaceNCModelFactory
- Parameters:
claxx
- Model type.- Returns:
- Model.
-
terminate
public void terminate()
Description copied from interface:NCModelFactory
Terminates this factory when probe stops.- Specified by:
terminate
in interfaceNCModelFactory
-
-