Author: bcarothers
Date: 2009-07-20 15:05:35 -0400 (Mon, 20 Jul 2009)
New Revision: 1117
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
Log:
DNA-483 RepositoryService Doesn't Expose Problems from startService
Committed a patch (DNA-483_take_2.patch) that reuses the existing DnaEngine problems sink
instead of adding a new one and setting a precedent that users will have to check problems
in many different places.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-07-20
12:44:32 UTC (rev 1116)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-07-20
19:05:35 UTC (rev 1117)
@@ -106,7 +106,7 @@
Path pathToConfigurationRoot = this.configuration.getPath();
String configWorkspaceName = this.configuration.getWorkspace();
final RepositorySource configSource = this.configuration.getRepositorySource();
- repositoryService = new RepositoryService(configSource, configWorkspaceName,
pathToConfigurationRoot, context);
+ repositoryService = new RepositoryService(configSource, configWorkspaceName,
pathToConfigurationRoot, context, problems);
// Create the sequencing service ...
executorService = new ScheduledThreadPoolExecutor(10); // Use a magic number for
now
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-07-20
12:44:32 UTC (rev 1116)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-07-20
19:05:35 UTC (rev 1117)
@@ -106,6 +106,8 @@
private final Path pathToConfigurationRoot;
private final Administrator administrator = new Administrator();
private final AtomicBoolean started = new AtomicBoolean(false);
+ /** The problem sink used when encountering problems while starting repositories */
+ private final Problems problems;
/**
* Create a service instance, reading the configuration describing new {@link
RepositorySource} instances from the supplied
@@ -117,16 +119,19 @@
* @param pathToConfigurationRoot the path of the node in the configuration source
repository that should be treated by this
* service as the root of the service's configuration; if null, then
"/dna:system" is used
* @param context the execution context in which this service should run
+ * @param problems the {@link Problems} instance that this service should use to
report problems starting repositories
* @throws IllegalArgumentException if the bootstrap source is null or the execution
context is null
*/
public RepositoryService( RepositorySource configurationSource,
String configurationWorkspaceName,
Path pathToConfigurationRoot,
- ExecutionContext context ) {
+ ExecutionContext context,
+ Problems problems ) {
CheckArg.isNotNull(configurationSource, "configurationSource");
CheckArg.isNotNull(context, "context");
PathFactory pathFactory = context.getValueFactories().getPathFactory();
if (pathToConfigurationRoot == null) pathToConfigurationRoot =
pathFactory.create("/dna:system");
+ if (problems == null) problems = new SimpleProblems();
Path sourcesPath = pathFactory.create(pathToConfigurationRoot,
DnaLexicon.SOURCES);
this.sources = new RepositoryLibrary(configurationSource,
configurationWorkspaceName, sourcesPath, context);
@@ -135,6 +140,7 @@
this.configurationSourceName = configurationSource.getName();
this.configurationWorkspaceName = configurationWorkspaceName;
this.context = context;
+ this.problems = problems;
}
/**
@@ -180,9 +186,7 @@
}
protected synchronized void startService() {
- if (this.started.get() == false) {
- Problems problems = new SimpleProblems();
-
+ if (this.started.get() == false) {
//
------------------------------------------------------------------------------------
// Read the configuration ...
//
------------------------------------------------------------------------------------
@@ -207,6 +211,7 @@
} catch (Throwable err) {
throw new
FederationException(RepositoryI18n.errorStartingRepositoryService.text(), err);
}
+
this.started.set(true);
}
}
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-07-20
12:44:32 UTC (rev 1116)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-07-20
19:05:35 UTC (rev 1117)
@@ -32,6 +32,8 @@
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.concurrent.TimeUnit;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
@@ -59,6 +61,7 @@
private InMemoryRepositorySource configRepositorySource;
private ExecutionContext context;
private Path root;
+ private Problems problems;
@Mock
private RepositoryLibrary sources;
@@ -76,7 +79,8 @@
RepositoryConnection configRepositoryConnection =
configRepositorySource.getConnection();
stub(sources.createConnection(configSourceName)).toReturn(configRepositoryConnection);
root = context.getValueFactories().getPathFactory().createRootPath();
- service = new RepositoryService(configRepositorySource, configWorkspaceName,
root, context);
+ problems = new SimpleProblems();
+ service = new RepositoryService(configRepositorySource, configWorkspaceName,
root, context, problems);
}
@After
@@ -189,7 +193,7 @@
@Test
public void
shouldConfigureRepositorySourceWithSetterThatTakesArrayButWithSingleValues() {
Path configPath =
context.getValueFactories().getPathFactory().create("/dna:system");
- service = new RepositoryService(configRepositorySource, configWorkspaceName,
configPath, context);
+ service = new RepositoryService(configRepositorySource, configWorkspaceName,
configPath, context, problems);
// Set up the configuration repository ...
configRepository.useWorkspace("default");