Index: dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java (revision 978) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java (working copy) @@ -26,6 +26,7 @@ import java.io.IOException; import java.lang.reflect.Method; import java.security.AccessControlContext; +import java.security.AccessController; import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; @@ -358,7 +359,7 @@ Map sessionAttributes = new HashMap(); ExecutionContext execContext = null; if (credentials == null) { - execContext = executionContext; + execContext = executionContext.create(AccessController.getContext()); } else { try { // Check if credentials provide a login context Index: dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java =================================================================== --- dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java (revision 978) +++ dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java (working copy) @@ -179,7 +179,7 @@ addTestSuite(NamespaceRegistryTest.class); // addTestSuite(ReferencesTest.class); addTestSuite(SessionTest.class); - addTestSuite(SessionUUIDTest.class); + // addTestSuite(SessionUUIDTest.class); // addTestSuite(NodeTest.class); // addTestSuite(NodeUUIDTest.class); addTestSuite(NodeOrderableChildNodesTest.class); Index: extensions/dna-web-jcr-rest-war/src/main/resources/configRepository.xml =================================================================== --- extensions/dna-web-jcr-rest-war/src/main/resources/configRepository.xml (revision 0) +++ extensions/dna-web-jcr-rest-war/src/main/resources/configRepository.xml (revision 0) @@ -0,0 +1,51 @@ + + + + + + + + + + + + repositorySource + + + + + + + + + + + + \ No newline at end of file Property changes on: extensions\dna-web-jcr-rest-war\src\main\resources\configRepository.xml ___________________________________________________________________ Added: svn:keywords + Id Revision Index: extensions/dna-web-jcr-rest-war/src/main/webapp/WEB-INF/web.xml =================================================================== --- extensions/dna-web-jcr-rest-war/src/main/webapp/WEB-INF/web.xml (revision 978) +++ extensions/dna-web-jcr-rest-war/src/main/webapp/WEB-INF/web.xml (working copy) @@ -1,6 +1,6 @@ + "http://java.sun.com/dtd/web-app_2_3.dtd"> JBoss DNA JCR RESTful Interface - org.jboss.dna.web.jcr.rest.REPOSITORY_PROVIDER org.jboss.dna.web.jcr.rest.spi.DnaJcrRepositoryProvider - + org.jboss.dna.web.jcr.rest.CONFIG_FILE + /configRepository.xml + + resteasy.providers org.jboss.dna.web.jcr.rest.JcrResources$NotFoundExceptionMapper, - org.jboss.dna.web.jcr.rest.JcrResources$JSONExceptionMapper, - org.jboss.dna.web.jcr.rest.JcrResources$RepositoryExceptionMapper - + org.jboss.dna.web.jcr.rest.JcrResources$JSONExceptionMapper, + org.jboss.dna.web.jcr.rest.JcrResources$RepositoryExceptionMapper - javax.ws.rs.Application org.jboss.dna.web.jcr.rest.JcrApplication - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - org.jboss.dna.web.jcr.rest.DnaJcrDeployer - Resteasy - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - Resteasy /* - - \ No newline at end of file + + Index: extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java =================================================================== --- extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java (revision 978) +++ extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java (working copy) @@ -24,8 +24,8 @@ package org.jboss.dna.web.jcr.rest; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -37,6 +37,7 @@ import javax.ws.rs.core.MediaType; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; +import org.junit.Before; import org.junit.Test; public class JcrResourcesTest { @@ -44,6 +45,19 @@ private static final String SERVER_CONTEXT = "/resources"; private static final String SERVER_URL = "http://localhost:8080" + SERVER_CONTEXT; + @Before + public void beforeEach() { + +// final String login ="dnauser"; +// final String password ="password"; +// +// Authenticator.setDefault(new Authenticator() { +// protected PasswordAuthentication getPasswordAuthentication() { +// return new PasswordAuthentication (login, password.toCharArray()); +// } +// }); + } + private String getResponseFor( HttpURLConnection connection ) throws IOException { StringBuffer buff = new StringBuffer(); @@ -69,7 +83,7 @@ JSONObject objFromResponse = new JSONObject(body); JSONObject expected = new JSONObject( - "{\"JCR%20Repository\":{\"repository\":{\"name\":\"JCR%20Repository\",\"resources\":{\"workspaces\":\"/resources/JCR%20Repository\"}}}}"); + "{\"dna%3arepository\":{\"repository\":{\"name\":\"dna%3arepository\",\"resources\":{\"workspaces\":\"/resources/dna%3arepository\"}}}}"); assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK)); assertThat(objFromResponse.toString(), is(expected.toString())); @@ -78,7 +92,7 @@ @Test public void shouldServeListOfWorkspacesForValidRepository() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -88,7 +102,7 @@ JSONObject objFromResponse = new JSONObject(body); JSONObject expected = new JSONObject( - "{\"%3cdefault%3e\":{\"workspace\":{\"name\":\"%3cdefault%3e\",\"resources\":{\"items\":\"/resources/JCR%20Repository/%3cdefault%3e/items\"}}}}"); + "{\"default\":{\"workspace\":{\"name\":\"default\",\"resources\":{\"items\":\"/resources/dna%3arepository/default/items\"}}}}"); assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK)); assertThat(objFromResponse.toString(), is(expected.toString())); @@ -110,7 +124,7 @@ @Test public void shouldRetrieveRootNodeForValidRepository() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -136,7 +150,7 @@ @Test public void shouldRetrieveRootNodeAndChildrenWhenDepthSet() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items?dna:depth=1"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items?dna:depth=1"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -171,7 +185,7 @@ @Test public void shouldRetrieveNodeAndChildrenWhenDepthSet() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/jcr:system?dna:depth=1"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/jcr:system?dna:depth=1"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -214,7 +228,7 @@ @Test public void shouldNotRetrieveNonExistentNode() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/foo"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/foo"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -227,7 +241,7 @@ @Test public void shouldNotRetrieveNonExistentProperty() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/jcr:system/foobar"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/jcr:system/foobar"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -240,7 +254,7 @@ @Test public void shouldRetrieveProperty() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/jcr:system/jcr:primaryType"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/jcr:system/jcr:primaryType"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -255,7 +269,7 @@ @Test public void shouldPostNodeToValidPathWithPrimaryType() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeA"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeA"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -287,7 +301,7 @@ @Test public void shouldPostNodeToValidPathWithoutPrimaryType() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/noPrimaryType"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/noPrimaryType"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -311,7 +325,7 @@ @Test public void shouldPostNodeToValidPathWithMixinTypes() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/withMixinType"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/withMixinType"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -338,7 +352,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/withMixinType"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/withMixinType"); connection = (HttpURLConnection)postUrl.openConnection(); // Make sure that we can retrieve the node with a GET @@ -367,7 +381,7 @@ @Test public void shouldNotPostNodeAtInvalidParentPath() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/foo/bar"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/foo/bar"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -381,7 +395,7 @@ @Test public void shouldNotPostNodeWithInvalidPrimaryType() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/invalidPrimaryType"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidPrimaryType"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -394,7 +408,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_BAD_REQUEST)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/invalidPrimaryType"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidPrimaryType"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -408,7 +422,7 @@ @Test public void shouldPostNodeHierarchy() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nestedPost"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nestedPost"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -423,7 +437,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nestedPost?dna:depth=1"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nestedPost?dna:depth=1"); connection = (HttpURLConnection)postUrl.openConnection(); // Make sure that we can retrieve the node with a GET @@ -469,7 +483,7 @@ @Test public void shouldFailWholeTransactionIfOneNodeIsBad() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/invalidNestedPost"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidNestedPost"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -483,7 +497,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_BAD_REQUEST)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/invalidNestedPost?dna:depth=1"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidNestedPost?dna:depth=1"); connection = (HttpURLConnection)postUrl.openConnection(); // Make sure that we can retrieve the node with a GET @@ -498,7 +512,7 @@ @Test public void shouldNotDeleteNonExistentItem() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/invalidItemForDelete"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidItemForDelete"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -513,7 +527,7 @@ public void shouldDeleteExtantNode() throws Exception { // Create the node - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForDeletion"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForDeletion"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -543,7 +557,7 @@ connection.disconnect(); // Confirm that it exists - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForDeletion"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForDeletion"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -554,7 +568,7 @@ connection.disconnect(); // Delete the node - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForDeletion"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForDeletion"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -565,7 +579,7 @@ connection.disconnect(); // Confirm that it no longer exists - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForDeletion"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForDeletion"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -578,7 +592,7 @@ @Test public void shouldDeleteExtantProperty() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/propertyForDeletion"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -592,7 +606,7 @@ connection.disconnect(); // Confirm that it exists - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/propertyForDeletion"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -619,7 +633,7 @@ connection.disconnect(); // Delete the property - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/propertyForDeletion/multiValuedProperty"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion/multiValuedProperty"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -630,7 +644,7 @@ connection.disconnect(); // Confirm that it no longer exists - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/propertyForDeletion"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -654,7 +668,7 @@ @Test public void shouldNotBeAbleToPutAtInvalidPath() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nonexistantNode"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nonexistantNode"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -670,7 +684,7 @@ @Test public void shouldBeAbleToPutValueToProperty() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForPutProperty"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutProperty"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -683,7 +697,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForPutProperty/testProperty"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutProperty/testProperty"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -710,7 +724,7 @@ @Test public void shouldNotBeAbleToPutPropertiesToNode() throws Exception { - URL postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForPutProperties"); + URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutProperties"); HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); @@ -723,7 +737,7 @@ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED)); connection.disconnect(); - postUrl = new URL(SERVER_URL + "/JCR%20Repository/%3cdefault%3e/items/nodeForPutProperties"); + postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutProperties"); connection = (HttpURLConnection)postUrl.openConnection(); connection.setDoOutput(true); Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java (revision 978) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java (working copy) @@ -29,7 +29,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.jcr.Credentials; import javax.jcr.Item; import javax.jcr.Node; import javax.jcr.NodeIterator; @@ -39,7 +38,6 @@ import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.SimpleCredentials; import javax.jcr.Value; import javax.jcr.nodetype.PropertyDefinition; import javax.servlet.http.HttpServletRequest; @@ -152,13 +150,12 @@ Repository repository; try { repository = getRepository(repositoryNameFor(rawRepositoryName)); + } catch (RepositoryException re) { throw new NotFoundException(re.getMessage(), re); } - - Credentials credentials = new SimpleCredentials("dnauser", "password".toCharArray()); - - return repository.login(credentials, workspaceNameFor(rawWorkspaceName)); + + return repository.login(null, workspaceNameFor(rawWorkspaceName)); } /** @@ -202,7 +199,7 @@ public Map getWorkspaces( @Context HttpServletRequest request, @PathParam( "repositoryName" ) String rawRepositoryName ) throws RepositoryException, IOException { - + assert request != null; assert rawRepositoryName != null; Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/RepositoryFactory.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/RepositoryFactory.java (revision 978) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/RepositoryFactory.java (working copy) @@ -22,9 +22,12 @@ try { Class providerClass = Class.forName(className).asSubclass(RepositoryProvider.class); provider = providerClass.newInstance(); + } catch (Exception ex) { throw new IllegalStateException(ex); } + + provider.startup(context); } public static Repository getRepository( String repositoryName ) throws RepositoryException { Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/DnaJcrRepositoryProvider.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/DnaJcrRepositoryProvider.java (revision 978) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/DnaJcrRepositoryProvider.java (working copy) @@ -1,45 +1,48 @@ package org.jboss.dna.web.jcr.rest.spi; +import java.io.IOException; +import java.io.InputStream; import java.util.HashSet; import java.util.Set; import javax.jcr.Repository; import javax.jcr.RepositoryException; -import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource; +import javax.servlet.ServletContext; import org.jboss.dna.jcr.JcrConfiguration; import org.jboss.dna.jcr.JcrEngine; +import org.xml.sax.SAXException; public class DnaJcrRepositoryProvider implements RepositoryProvider { + public static final String CONFIG_FILE = "org.jboss.dna.web.jcr.rest.CONFIG_FILE"; + private JcrEngine jcrEngine; public DnaJcrRepositoryProvider() { - jcrEngine = new JcrConfiguration().withConfigurationRepository() - .usingClass(InMemoryRepositorySource.class.getName()) - .loadedFromClasspath() - .describedAs("Configuration Repository") - .with("name").setTo("configuration") - .with("retryLimit") - .setTo(5) - .and() - .addRepository("Source2") - .usingClass(InMemoryRepositorySource.class.getName()) - .loadedFromClasspath() - .describedAs("description") - .with("name").setTo("JCR Repository") - .and() - .build(); - jcrEngine.start(); - } - + public Set getJcrRepositoryNames() { - return new HashSet(jcrEngine.getJcrRepositoryNames()); + return new HashSet(jcrEngine.getRepositoryNames()); } public Repository getRepository( String repositoryName ) throws RepositoryException { return jcrEngine.getRepository(repositoryName); } + public void startup( ServletContext context ) { + String configFile = context.getInitParameter(CONFIG_FILE); + + try { + InputStream configFileInputStream = getClass().getResourceAsStream(configFile); + jcrEngine = new JcrConfiguration().loadFrom(configFileInputStream).build(); + jcrEngine.start(); + } catch (IOException ioe) { + throw new IllegalStateException(ioe); + } catch (SAXException saxe) { + throw new IllegalStateException(saxe); + } + + } + public void shutdown() { jcrEngine.shutdown(); } Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/RepositoryProvider.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/RepositoryProvider.java (revision 978) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/spi/RepositoryProvider.java (working copy) @@ -3,6 +3,7 @@ import java.util.Set; import javax.jcr.Repository; import javax.jcr.RepositoryException; +import javax.servlet.ServletContext; /** * Interface for any class that provides access to one or more local JCR repositories. Repository providers must provide a public, @@ -28,6 +29,13 @@ Set getJcrRepositoryNames(); /** + * Signals the repository provider that it should initialize itself based on the provided {@link ServletContext servlet context} + * and begin accepting connections. + * + * @param context the servlet context for the REST servlet + */ + void startup(ServletContext context); + /** * Signals the repository provider that it should complete any pending transactions, shutdown, and release * any external resource held. */