Solution_ - the solution type, the class with the PlanningSolution annotationpublic abstract class SolverFactory<Solution_> extends Object
Solver instances.
Most applications only need one SolverFactory.
To create a SolverFactory, use createFromXmlResource(String).
To change the configuration programmatically, create a SolverConfig first
and then use create(SolverConfig).
These methods are thread-safe unless explicitly stated otherwise.
| Constructor and Description |
|---|
SolverFactory() |
| Modifier and Type | Method and Description |
|---|---|
abstract Solver<Solution_> |
buildSolver()
Creates a new
Solver instance. |
abstract SolverFactory<Solution_> |
cloneSolverFactory()
Deprecated.
in favor of
SolverConfig.SolverConfig(SolverConfig)
and create(SolverConfig). Will be removed in 8.0. |
static <Solution_> |
create(SolverConfig solverConfig)
Uses a
SolverConfig to build a SolverFactory. |
static <Solution_> |
createEmpty()
Deprecated.
in favor of
SolverConfig() and create(SolverConfig).
Will be removed in 8.0. |
static <Solution_> |
createEmpty(ClassLoader classLoader)
Deprecated.
in favor of
SolverConfig(ClassLoader) and create(SolverConfig).
Will be removed in 8.0. |
static <Solution_> |
createEmptyFromKieContainer(org.kie.api.runtime.KieContainer kieContainer) |
static <Solution_> |
createEmptyFromKieContainer(org.kie.api.builder.ReleaseId releaseId) |
static <Solution_> |
createFromKieContainerXmlResource(org.kie.api.runtime.KieContainer kieContainer,
String solverConfigResource) |
static <Solution_> |
createFromKieContainerXmlResource(org.kie.api.builder.ReleaseId releaseId,
String solverConfigResource) |
static <Solution_> |
createFromKieContainerXmlResource(String solverConfigResource)
Uses
KieServices.getKieClasspathContainer(). |
static <Solution_> |
createFromXmlFile(File solverConfigFile)
Reads an XML solver configuration from the file system
and uses that
SolverConfig to build a SolverFactory. |
static <Solution_> |
createFromXmlFile(File solverConfigFile,
ClassLoader classLoader)
As defined by
createFromXmlFile(File). |
static <Solution_> |
createFromXmlInputStream(InputStream in)
Deprecated.
in favor of
SolverConfig.createFromXmlInputStream(InputStream)
and create(SolverConfig). Will be removed in 8.0. |
static <Solution_> |
createFromXmlInputStream(InputStream in,
ClassLoader classLoader)
Deprecated.
in favor of
SolverConfig.createFromXmlInputStream(InputStream, ClassLoader)
and create(SolverConfig). Will be removed in 8.0. |
static <Solution_> |
createFromXmlReader(Reader reader)
Deprecated.
in favor of
SolverConfig.createFromXmlReader(Reader)
and create(SolverConfig). Will be removed in 8.0. |
static <Solution_> |
createFromXmlReader(Reader reader,
ClassLoader classLoader)
Deprecated.
in favor of
SolverConfig.createFromXmlReader(Reader, ClassLoader)
and create(SolverConfig). Will be removed in 8.0. |
static <Solution_> |
createFromXmlResource(String solverConfigResource)
Reads an XML solver configuration from the classpath
and uses that
SolverConfig to build a SolverFactory. |
static <Solution_> |
createFromXmlResource(String solverConfigResource,
ClassLoader classLoader)
As defined by
createFromXmlResource(String). |
abstract ScoreDirectorFactory<Solution_> |
getScoreDirectorFactory()
Useful to reuse the
Score calculation (for example in a UI)
and to explain the Score to the user
with the ConstraintMatchTotal and Indictment API. |
abstract SolverConfig |
getSolverConfig()
Deprecated.
in favor of
SolverConfig.SolverConfig(SolverConfig)
and create(SolverConfig). Will be removed in 8.0. |
public static <Solution_> SolverFactory<Solution_> createFromXmlResource(String solverConfigResource)
SolverConfig to build a SolverFactory.
The XML root element must be <solver>.Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfigResource - never null, a classpath resource
as defined by ClassLoader.getResource(String)public static <Solution_> SolverFactory<Solution_> createFromXmlResource(String solverConfigResource, ClassLoader classLoader)
createFromXmlResource(String).Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfigResource - never null, a classpath resource
as defined by ClassLoader.getResource(String)classLoader - sometimes null, the ClassLoader to use for loading all resources and Classes,
null to use the default ClassLoaderpublic static <Solution_> SolverFactory<Solution_> createFromXmlFile(File solverConfigFile)
SolverConfig to build a SolverFactory.
Warning: this leads to platform dependent code,
it's recommend to use createFromXmlResource(String) instead.
Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfigFile - never nullpublic static <Solution_> SolverFactory<Solution_> createFromXmlFile(File solverConfigFile, ClassLoader classLoader)
createFromXmlFile(File).Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfigFile - never nullclassLoader - sometimes null, the ClassLoader to use for loading all resources and Classes,
null to use the default ClassLoader@Deprecated public static <Solution_> SolverFactory<Solution_> createFromXmlInputStream(InputStream in)
SolverConfig.createFromXmlInputStream(InputStream)
and create(SolverConfig). Will be removed in 8.0.Solution_ - the solution type, the class with the PlanningSolution annotationin - never null, gets closed@Deprecated public static <Solution_> SolverFactory<Solution_> createFromXmlInputStream(InputStream in, ClassLoader classLoader)
SolverConfig.createFromXmlInputStream(InputStream, ClassLoader)
and create(SolverConfig). Will be removed in 8.0.Solution_ - the solution type, the class with the PlanningSolution annotationin - never null, gets closedclassLoader - sometimes null, the ClassLoader to use for loading all resources and Classes,
null to use the default ClassLoader@Deprecated public static <Solution_> SolverFactory<Solution_> createFromXmlReader(Reader reader)
SolverConfig.createFromXmlReader(Reader)
and create(SolverConfig). Will be removed in 8.0.Solution_ - the solution type, the class with the PlanningSolution annotationreader - never null, gets closed@Deprecated public static <Solution_> SolverFactory<Solution_> createFromXmlReader(Reader reader, ClassLoader classLoader)
SolverConfig.createFromXmlReader(Reader, ClassLoader)
and create(SolverConfig). Will be removed in 8.0.Solution_ - the solution type, the class with the PlanningSolution annotationreader - never null, gets closedclassLoader - sometimes null, the ClassLoader to use for loading all resources and Classes,
null to use the default ClassLoaderpublic static <Solution_> SolverFactory<Solution_> create(SolverConfig solverConfig)
SolverConfig to build a SolverFactory.
If you don't need to manipulate the SolverConfig programmatically,
use createFromXmlResource(String) instead.Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfig - never null@Deprecated public static <Solution_> SolverFactory<Solution_> createEmpty()
SolverConfig() and create(SolverConfig).
Will be removed in 8.0.SolverConfig() instead,
although it's often recommended to instead load a partial configuration
with SolverConfig.createFromXmlResource(String).Solution_ - the solution type, the class with the PlanningSolution annotation@Deprecated public static <Solution_> SolverFactory<Solution_> createEmpty(ClassLoader classLoader)
SolverConfig(ClassLoader) and create(SolverConfig).
Will be removed in 8.0.createEmpty().Solution_ - the solution type, the class with the PlanningSolution annotationclassLoader - sometimes null, the ClassLoader to use for loading all resources and Classes,
null to use the default ClassLoaderpublic static <Solution_> SolverFactory<Solution_> createFromKieContainerXmlResource(String solverConfigResource)
KieServices.getKieClasspathContainer().Solution_ - the solution type, the class with the PlanningSolution annotationsolverConfigResource - never null, a classpath resource in the KieContainer
as defined by ClassLoader.getResource(String)public static <Solution_> SolverFactory<Solution_> createFromKieContainerXmlResource(org.kie.api.builder.ReleaseId releaseId, String solverConfigResource)
Solution_ - the solution type, the class with the PlanningSolution annotationreleaseId - never nullsolverConfigResource - never null, a classpath resource in the KieContainer
as defined by ClassLoader.getResource(String)public static <Solution_> SolverFactory<Solution_> createFromKieContainerXmlResource(org.kie.api.runtime.KieContainer kieContainer, String solverConfigResource)
Solution_ - the solution type, the class with the PlanningSolution annotationkieContainer - never nullsolverConfigResource - never null, a classpath resource in the KieContainer
as defined by ClassLoader.getResource(String)public static <Solution_> SolverFactory<Solution_> createEmptyFromKieContainer(org.kie.api.builder.ReleaseId releaseId)
Solution_ - the solution type, the class with the PlanningSolution annotationreleaseId - never nullpublic static <Solution_> SolverFactory<Solution_> createEmptyFromKieContainer(org.kie.api.runtime.KieContainer kieContainer)
Solution_ - the solution type, the class with the PlanningSolution annotationkieContainer - never nullpublic abstract Solver<Solution_> buildSolver()
Solver instance.public abstract ScoreDirectorFactory<Solution_> getScoreDirectorFactory()
Score calculation (for example in a UI)
and to explain the Score to the user
with the ConstraintMatchTotal and Indictment API.@Deprecated public abstract SolverConfig getSolverConfig()
SolverConfig.SolverConfig(SolverConfig)
and create(SolverConfig). Will be removed in 8.0.SolverFactory dynamically (without parsing XML each time),
use create(SolverConfig) instead.
This method is not thread-safe. To configure a SolverConfig differently for parallel requests,
build a template SolverFactory from XML
and clone it cloneSolverFactory() for each request, before before calling this method.
@Deprecated public abstract SolverFactory<Solution_> cloneSolverFactory()
SolverConfig.SolverConfig(SolverConfig)
and create(SolverConfig). Will be removed in 8.0.SolverFactory dynamically (without parsing XML each time),
use SolverConfig.SolverConfig(SolverConfig) and create(SolverConfig) instead.
Build a SolverFactory quickly (without parsing XML) that builds the exact same Solver
with buildSolver(), but can also be modified with getSolverConfig() to build a different
Solver without affecting the original SolverFactory.
SolverFactory subclass implementation than this instanceCopyright © 2006–2020 JBoss by Red Hat. All rights reserved.