Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-347

Expose XStream non-annotation alias options for Solver and Benchmarker configs

XMLWordPrintable

      In order to allow users to extend classes in the Solver Configuration and Solver Benchmarked Configuration XML files a set of XStream method needs to be exposed.

      The following XStream methods need be added to the XStreamXmlPlannerBenchmarkFactory and XStreamXmlSolverFactory
      classes:

      XStreamXmlSolverFactory.java
      public void alias(String alias, Class clazz) {
      	xStream.alias(alias, clazz);
      }
      public void aliasAttribute(Class clazz, String attributeName, String alias) {
      	xStream.aliasAttribute(clazz, attributeName, alias);
      }
      public void addDefaultImplementation(Class defaultImplementation, Class ofType) {
      	xStream.addDefaultImplementation(defaultImplementation, ofType);
      }
      

      For example in order to override the scoreDirectorFactory the following methods would need to be executed:

      ConfigureSolver.java
      TempXStreamXMLSolverFactory xmlSolverFactory = new TempXStreamXMLSolverFactory();
      xmlSolverFactory.aliasAttribute(SolverConfig.class, "scoreDirectorFactoryConfig", "flexScoreDirectorFactory");
      xmlSolverFactory.alias("flexScoreDirectorFactory", FlexScoreLevelDirectoryFactoryConfig.class);
      	xmlSolverFactory.addDefaultImplementation(FlexScoreLevelDirectoryFactoryConfig.class,
      ScoreDirectorFactoryConfig.class);
      xmlSolverFactory.configure(configPath);
      

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              code4dc@gmail.com Eugene Shvartsman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: