mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
Refactor: don't reuse JAXB objects for internal configuration; create a Configuration interface.
This commit is contained in:
parent
c8b3c1977c
commit
7a86f049ac
30 changed files with 871 additions and 517 deletions
|
|
@ -20,24 +20,31 @@
|
|||
package de.kosit.validationtool.api;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import de.kosit.validationtool.impl.RelativeUriResolver;
|
||||
import de.kosit.validationtool.config.LoadConfiguration;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
|
||||
import net.sf.saxon.s9api.Processor;
|
||||
|
||||
/**
|
||||
* Zentrale Konfigration einer Prüf-Instanz.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
* @deprecated since 2.0 use {@link Configuration} instead
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class CheckConfiguration {
|
||||
@Deprecated
|
||||
public class CheckConfiguration implements Configuration {
|
||||
|
||||
/**
|
||||
* URL, die auf die scenerio.xml Datei zeigt.
|
||||
|
|
@ -49,22 +56,52 @@ public class CheckConfiguration {
|
|||
*/
|
||||
private URI scenarioRepository;
|
||||
|
||||
private LoadConfiguration delegate;
|
||||
|
||||
/**
|
||||
* Liefert das Repository mit den Artefakten der einzelnen Szenarien.
|
||||
*
|
||||
* @return uri die durch entsprechende resolver aufgelöst werden kann
|
||||
*/
|
||||
public URI getScenarioRepository() {
|
||||
if (this.scenarioRepository == null) {
|
||||
this.scenarioRepository = createDefaultRepository();
|
||||
private LoadConfiguration getDelegate() {
|
||||
if (this.delegate == null) {
|
||||
this.delegate = Configuration.load(this.scenarioDefinition, this.scenarioRepository);
|
||||
}
|
||||
return this.scenarioRepository;
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
private URI createDefaultRepository() {
|
||||
log.info("Creating default scenario repository (alongside scenario definition)");
|
||||
return RelativeUriResolver.resolve(URI.create("."), this.scenarioDefinition);
|
||||
@Override
|
||||
public List<Scenario> getScenarios() {
|
||||
return getDelegate().getScenarios();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scenario getFallbackScenario() {
|
||||
return getDelegate().getFallbackScenario();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
getDelegate().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDate() {
|
||||
return getDelegate().getDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getDelegate().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return getDelegate().getAuthor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Processor getProcessor() {
|
||||
return getDelegate().getProcessor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentRepository getContentRepository() {
|
||||
return getDelegate().getContentRepository();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
59
src/main/java/de/kosit/validationtool/api/Configuration.java
Normal file
59
src/main/java/de/kosit/validationtool/api/Configuration.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
package de.kosit.validationtool.api;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import de.kosit.validationtool.config.ConfigurationBuilder;
|
||||
import de.kosit.validationtool.config.LoadConfiguration;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
|
||||
import net.sf.saxon.s9api.Processor;
|
||||
|
||||
/**
|
||||
* Configuration of the actual {@link Check} instance. This is a contruct and can be used implemented by custom
|
||||
* configuration classes. There are two implementations supported out of the box:
|
||||
*
|
||||
* <ol>
|
||||
* <li>{@link LoadConfiguration} implements loading {@link Check} configurations from a scenario.xml file</li>
|
||||
* <li>Using a builder style api {@link de.kosit.validationtool.config.ConfigurationBuilder}to configure the
|
||||
* {@link Check}</li>
|
||||
* </ol>
|
||||
*
|
||||
* Both methods can be used via convinience methods. See below.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
|
||||
public interface Configuration {
|
||||
|
||||
List<Scenario> getScenarios();
|
||||
|
||||
static LoadConfiguration load(final URI scenarioDefinition) {
|
||||
return load(scenarioDefinition, null);
|
||||
}
|
||||
|
||||
static LoadConfiguration load(final URI scenarioDefinition, final URI repository) {
|
||||
final LoadConfiguration config = new LoadConfiguration(scenarioDefinition, repository);
|
||||
config.build();
|
||||
return config;
|
||||
}
|
||||
|
||||
static ConfigurationBuilder create() {
|
||||
return new ConfigurationBuilder();
|
||||
}
|
||||
|
||||
Scenario getFallbackScenario();
|
||||
|
||||
void build();
|
||||
|
||||
String getAuthor();
|
||||
|
||||
String getName();
|
||||
|
||||
String getDate();
|
||||
|
||||
Processor getProcessor();
|
||||
|
||||
ContentRepository getContentRepository();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue