Author: rhauch
Date: 2009-06-10 17:21:36 -0400 (Wed, 10 Jun 2009)
New Revision: 1031
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.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
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
Log:
DNA-449 Federation connector does not find it's configuration when imported using the
JcrConfiguration
Cleaned up several unused constructors that added quite a bit of complication to the
classes.
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10
19:56:53 UTC (rev 1030)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10
21:21:36 UTC (rev 1031)
@@ -115,45 +115,13 @@
/**
* Create a new manager instance.
- */
- public RepositoryLibrary() {
- this(new ExecutionContext(), null);
- }
-
- /**
- * Create a new manager instance.
*
- * @param delegate the connection factory to which this instance should delegate in
the event that a source is not found in
- * this manager; may be null if there is no delegate
- */
- public RepositoryLibrary( RepositoryConnectionFactory delegate ) {
- this(new ExecutionContext(), delegate);
- }
-
- /**
- * Create a new manager instance.
- *
* @param executionContext the execution context, which can be used used by sources
to create other {@link ExecutionContext}
* instances with different JAAS security contexts
* @throws IllegalArgumentException if the
<code>executionContextFactory</code> reference is null
*/
- public RepositoryLibrary( ExecutionContext executionContext ) {
- this(executionContext, null);
- }
-
- /**
- * Create a new manager instance.
- *
- * @param executionContext the execution context, which can be used used by sources
to create other {@link ExecutionContext}
- * instances with different JAAS security contexts
- * @param delegate the connection factory to which this instance should delegate in
the event that a source is not found in
- * this manager; may be null if there is no delegate
- * @throws IllegalArgumentException if the
<code>executionContextFactory</code> reference is null
- */
- public RepositoryLibrary( final ExecutionContext executionContext,
- RepositoryConnectionFactory delegate ) {
+ public RepositoryLibrary( final ExecutionContext executionContext ) {
CheckArg.isNotNull(executionContext, "executionContext");
- this.delegate = delegate;
this.executionContext = executionContext;
final ObservationBus observationBus = this.observationBus;
this.repositoryContext = new RepositoryContext() {
@@ -213,26 +181,6 @@
}
/**
- * Get the delegate connection factory.
- *
- * @return the connection factory to which this instance should delegate in the event
that a source is not found in this
- * manager, or null if there is no delegate
- */
- public RepositoryConnectionFactory getDelegate() {
- return delegate;
- }
-
- /**
- * Set the delegate connection factory.
- *
- * @param delegate the connection factory to which this instance should delegate in
the event that a source is not found in
- * this manager; may be null if there is no delegate
- */
- public void setDelegate( RepositoryConnectionFactory delegate ) {
- this.delegate = delegate;
- }
-
- /**
* @return administrator
*/
public ServiceAdministrator getAdministrator() {
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-06-10
19:56:53 UTC (rev 1030)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-10
21:21:36 UTC (rev 1031)
@@ -107,55 +107,6 @@
private final AtomicBoolean started = new AtomicBoolean(false);
/**
- * Create a service instance, reading the configuration describing new {@link
RepositorySource} instances from the source with
- * the supplied name.
- *
- * @param sources the source manager
- * @param configurationSourceName the name of the {@link RepositorySource} that is
the configuration repository
- * @param configurationWorkspaceName the name of the workspace in the {@link
RepositorySource} that is the configuration
- * repository
- * @param context the execution context in which this service should run
- * @throws IllegalArgumentException if the bootstrap source is null or the execution
context is null
- */
- public RepositoryService( RepositoryLibrary sources,
- String configurationSourceName,
- String configurationWorkspaceName,
- ExecutionContext context ) {
- this(sources, configurationSourceName, configurationWorkspaceName, null,
context);
- }
-
- /**
- * Create a service instance, reading the configuration describing new {@link
RepositorySource} instances from the source with
- * the supplied name and path within the repository.
- *
- * @param sources the source manager
- * @param configurationSourceName the name of the {@link RepositorySource} that is
the configuration repository
- * @param configurationWorkspaceName the name of the workspace in the {@link
RepositorySource} that is the configuration
- * repository, or null if the default workspace of the source should be used
(if there is one)
- * @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
- * @throws IllegalArgumentException if the bootstrap source is null or the execution
context is null
- */
- public RepositoryService( RepositoryLibrary sources,
- String configurationSourceName,
- String configurationWorkspaceName,
- Path pathToConfigurationRoot,
- ExecutionContext context ) {
- CheckArg.isNotNull(configurationSourceName,
"configurationSourceName");
- CheckArg.isNotNull(sources, "sources");
- CheckArg.isNotNull(context, "context");
- if (pathToConfigurationRoot == null) pathToConfigurationRoot =
context.getValueFactories()
-
.getPathFactory()
-
.create("/dna:system");
- this.sources = sources;
- this.pathToConfigurationRoot = pathToConfigurationRoot;
- this.configurationSourceName = configurationSourceName;
- this.configurationWorkspaceName = configurationWorkspaceName;
- this.context = context;
- }
-
- /**
* Create a service instance, reading the configuration describing new {@link
RepositorySource} instances from the supplied
* configuration repository.
*
@@ -176,7 +127,7 @@
if (pathToConfigurationRoot == null) pathToConfigurationRoot =
context.getValueFactories()
.getPathFactory()
.create("/dna:system");
- this.sources = new RepositoryLibrary();
+ this.sources = new RepositoryLibrary(context);
this.sources.addSource(configurationSource);
this.pathToConfigurationRoot = pathToConfigurationRoot;
this.configurationSourceName = configurationSource.getName();
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-06-10
19:56:53 UTC (rev 1030)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-06-10
21:21:36 UTC (rev 1031)
@@ -29,14 +29,10 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.mockito.Mockito.stub;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.connector.federation.FederationException;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
@@ -80,7 +76,7 @@
RepositoryConnection configRepositoryConnection =
configRepositorySource.getConnection();
stub(sources.createConnection(configSourceName)).toReturn(configRepositoryConnection);
root = context.getValueFactories().getPathFactory().createRootPath();
- service = new RepositoryService(sources, configSourceName, configWorkspaceName,
context);
+ service = new RepositoryService(configRepositorySource, configWorkspaceName,
root, context);
}
@After
@@ -120,66 +116,7 @@
assertThat(service.getAdministrator().getState(),
is(ServiceAdministrator.State.TERMINATED));
}
- @Test( expected = FederationException.class )
- public void shouldFailToStartUpIfConfigurationRepositorySourceIsNotFound() throws
Exception {
- stub(sources.createConnection(configSourceName)).toReturn(null);
- service.getAdministrator().start();
- }
-
- @Test( expected = FederationException.class )
- public void shouldFailToStartUpIfUnableToConnectToConfigurationRepository() throws
Exception {
- stub(sources.createConnection(configSourceName)).toThrow(new
UnsupportedOperationException());
- service.getAdministrator().start();
- }
-
@Test
- public void shouldStartUpUsingConfigurationRepositoryThatContainsSomeSources() throws
Exception {
- // Use a real source manager for this test ...
- sources = new RepositoryLibrary(sources);
- sources.addSource(configRepositorySource);
- assertThat(sources.getSources(),
hasItems((RepositorySource)configRepositorySource));
- assertThat(sources.getSources().size(), is(1));
- service = new RepositoryService(sources, configSourceName, configWorkspaceName,
root, context);
-
- // Set up the configuration repository to contain 3 sources ...
- final String className = InMemoryRepositorySource.class.getName();
- configRepository.create("/dna:sources");
- configRepository.create("/dna:sources/source A");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source
A").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source
A").to("");
- configRepository.set("retryLimit").on("/dna:sources/source
A").to(3);
-
- configRepository.create("/dna:sources/source B");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source
B").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source
B").to("");
-
- configRepository.create("/dna:sources/source C");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source
C").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source
C").to("");
-
- // Now, start up the service ...
- service.getAdministrator().start();
-
- // and verify that the sources were added to the manager...
- assertThat(sources.getSources().size(), is(4));
- assertThat(sources.getSource("source A"),
is(instanceOf(InMemoryRepositorySource.class)));
- assertThat(sources.getSource("source B"),
is(instanceOf(InMemoryRepositorySource.class)));
- assertThat(sources.getSource("source C"),
is(instanceOf(InMemoryRepositorySource.class)));
-
- InMemoryRepositorySource sourceA =
(InMemoryRepositorySource)sources.getSource("source A");
- assertThat(sourceA.getName(), is("source A"));
- assertThat(sourceA.getRetryLimit(), is(3));
-
- InMemoryRepositorySource sourceB =
(InMemoryRepositorySource)sources.getSource("source B");
- assertThat(sourceB.getName(), is("source B"));
- assertThat(sourceB.getRetryLimit(),
is(InMemoryRepositorySource.DEFAULT_RETRY_LIMIT));
-
- InMemoryRepositorySource sourceC =
(InMemoryRepositorySource)sources.getSource("source C");
- assertThat(sourceC.getName(), is("source C"));
- assertThat(sourceC.getRetryLimit(),
is(InMemoryRepositorySource.DEFAULT_RETRY_LIMIT));
- }
-
- @Test
public void shouldStartUpUsingConfigurationRepositoryThatContainsNoSources() throws
Exception {
// Set up the configuration repository to contain NO sources ...
configRepository.create("/dna:sources");
@@ -187,9 +124,6 @@
// Now, start up the service ...
service.getAdministrator().start();
- // and verify that the configuration source was obtained from the manager ...
- verify(sources, times(2)).createConnection(configSourceName); // once for
checking source, second for getting
-
// and verify that the sources were never added to the manager...
verifyNoMoreInteractions(sources);
}
@@ -254,9 +188,8 @@
@Test
public void
shouldConfigureRepositorySourceWithSetterThatTakesArrayButWithSingleValues() {
- RepositoryLibrary sources = new RepositoryLibrary(context);
- sources.addSource(configRepositorySource);
- service = new RepositoryService(sources, configSourceName, configWorkspaceName,
context);
+ Path configPath =
context.getValueFactories().getPathFactory().create("/dna:system");
+ service = new RepositoryService(configRepositorySource, configWorkspaceName,
configPath, context);
// Set up the configuration repository ...
configRepository.useWorkspace("default");
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10
19:56:53 UTC (rev 1030)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10
21:21:36 UTC (rev 1031)
@@ -59,7 +59,7 @@
@Before
public void beforeEach() {
- sources = new RepositoryLibrary();
+ sources = new RepositoryLibrary(new ExecutionContext());
InMemoryRepositorySource source = new InMemoryRepositorySource();
source.setName(REPOSITORY_SOURCE_NAME);
sources.addSource(source);