You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/02/20 16:15:25 UTC
svn commit: r1731411 - in /sling/trunk/bundles/jcr/base: ./
src/main/java/org/apache/sling/jcr/base/
src/test/java/org/apache/sling/jcr/base/
Author: cziegeler
Date: Sat Feb 20 15:15:25 2016
New Revision: 1731411
URL: http://svn.apache.org/viewvc?rev=1731411&view=rev
Log:
Reverting SLING-5456 in order to release 2.3.2 (SLING-5531)
Modified:
sling/trunk/bundles/jcr/base/pom.xml
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/RepositoryInitializersTest.java
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/TestInitializer.java
Modified: sling/trunk/bundles/jcr/base/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/pom.xml?rev=1731411&r1=1731410&r2=1731411&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/pom.xml (original)
+++ sling/trunk/bundles/jcr/base/pom.xml Sat Feb 20 15:15:25 2016
@@ -80,7 +80,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
- <version>2.3.1-SNAPSHOT</version>
+ <version>2.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java?rev=1731411&r1=1731410&r2=1731411&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java (original)
+++ sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java Sat Feb 20 15:15:25 2016
@@ -18,20 +18,16 @@
*/
package org.apache.sling.jcr.base;
-import java.util.Arrays;
import java.util.Dictionary;
import javax.jcr.Repository;
import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.api.SlingRepositoryInitializer;
import org.apache.sling.serviceusermapping.ServiceUserMapper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,8 +91,8 @@ public abstract class AbstractSlingRepos
private volatile String defaultWorkspace;
private volatile boolean disableLoginAdministrative;
-
- private volatile ServiceTracker repoInitializerTracker;
+
+// private volatile ServiceTracker repoInitializerTracker;
/**
* Returns the default workspace, which may be <code>null</code> meaning to
@@ -306,9 +302,9 @@ public abstract class AbstractSlingRepos
this.bundleContext = bundleContext;
this.defaultWorkspace = defaultWorkspace;
this.disableLoginAdministrative = disableLoginAdministrative;
-
- this.repoInitializerTracker = new ServiceTracker(bundleContext, SlingRepositoryInitializer.class.getName(), null);
- this.repoInitializerTracker.open();
+
+// this.repoInitializerTracker = new ServiceTracker(bundleContext, SlingRepositoryInitializer.class.getName(), null);
+// this.repoInitializerTracker.open();
try {
log.debug("start: calling acquireRepository()");
@@ -322,7 +318,7 @@ public abstract class AbstractSlingRepos
log.debug("start: setting up NamespaceMapping support");
this.setup(this.bundleContext, this.masterSlingRepository);
-
+/*
log.debug("start: calling SlingRepositoryInitializer");
Throwable t = null;
try {
@@ -336,7 +332,7 @@ public abstract class AbstractSlingRepos
log.error("Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted", t);
return false;
}
-
+*/
log.debug("start: calling registerService()");
this.repositoryService = registerService();
@@ -354,7 +350,7 @@ public abstract class AbstractSlingRepos
// fallback to failure to start the repository
return false;
}
-
+/*
private void executeRepositoryInitializers(SlingRepository repo) throws Exception {
final ServiceReference [] refs = repoInitializerTracker.getServiceReferences();
if(refs == null || refs.length == 0) {
@@ -372,16 +368,16 @@ public abstract class AbstractSlingRepos
}
}
}
-
+*/
/**
* This method must be called if overwritten by implementations !!
*/
protected final void stop() {
- if(repoInitializerTracker != null) {
- repoInitializerTracker.close();
- repoInitializerTracker = null;
- }
-
+// if(repoInitializerTracker != null) {
+// repoInitializerTracker.close();
+// repoInitializerTracker = null;
+// }
+
// ensure the repository is really disposed off
if (repository != null || repositoryService != null) {
log.info("stop: Repository still running, forcing shutdown");
Modified: sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/RepositoryInitializersTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/RepositoryInitializersTest.java?rev=1731411&r1=1731410&r2=1731411&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/RepositoryInitializersTest.java (original)
+++ sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/RepositoryInitializersTest.java Sat Feb 20 15:15:25 2016
@@ -21,23 +21,19 @@ package org.apache.sling.jcr.base;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.Hashtable;
-
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.sling.commons.osgi.SortingServiceTracker;
import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.api.SlingRepositoryInitializer;
+//import org.apache.sling.jcr.api.SlingRepositoryInitializer;
import org.apache.sling.testing.mock.jcr.MockJcr;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
-import org.junit.Test;
-import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
/** Test the SlingRepositoryInitializer mechanism */
@@ -45,19 +41,19 @@ public class RepositoryInitializersTest
@Rule
public final SlingContext context = new SlingContext(ResourceResolverType.JCR_MOCK);
-
+
private static final String DEFAULT_WORKSPACE = "defws";
private AbstractSlingRepositoryManager asrm;
private Repository repository;
private Session session;
private SortingServiceTracker<SlingRepository> repoTracker;
-
+
/** We initially get a SlingRepository service from the Sling Mocks, and we're
* interested to find out whether the repository manager also registers one
* in our tests.
*/
private int initialRepoServicesCount;
-
+
@Before
public void setup() throws RepositoryException {
repoTracker = new SortingServiceTracker<SlingRepository>(context.bundleContext(), SlingRepository.class.getName());
@@ -65,75 +61,75 @@ public class RepositoryInitializersTest
repository = MockJcr.newRepository();
session = repository.login();
asrm = new MockSlingRepositoryManager(repository);
-
+
initialRepoServicesCount = countRepositoryServices();
assertAdditionalRepositoryServices(0);
}
-
+
@After
public void cleanup() {
repoTracker.close();
asrm.stop();
session.logout();
}
-
+/*
private void registerInitializer(String id, int serviceRanking) {
final SlingRepositoryInitializer init = new TestInitializer(id);
final Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_RANKING, new Integer(serviceRanking));
context.bundleContext().registerService(SlingRepositoryInitializer.class.getName(), init, props);
}
-
+*/
private void assertTestInitializerProperty(String expected) throws RepositoryException {
final String path = TestInitializer.getPropertyPath();
assertTrue("Expecting property at " + path, session.propertyExists(path));
assertEquals("Expecting correct value at " + path, expected, session.getProperty(path).getString());
}
-
+
private int countRepositoryServices() {
final ServiceReference [] refs = repoTracker.getServiceReferences();
return (refs == null ? 0 : refs.length);
}
-
+
private void assertAdditionalRepositoryServices(int expected) {
- assertEquals("Expecting " + expected + " SlingRepository services",
+ assertEquals("Expecting " + expected + " SlingRepository services",
expected + initialRepoServicesCount, countRepositoryServices());
}
-
+
private void assertStart(boolean expected) {
final boolean actual = asrm.start(context.bundleContext(), DEFAULT_WORKSPACE, false);
assertEquals("Expecting start to return " + expected, expected, actual);
}
-
+ /*
@Test
public void inOrderInitializers() throws RepositoryException {
for(int i=1; i < 4; i++) {
registerInitializer(String.valueOf(i), i * 100);
}
-
+
assertStart(true);
-
- // TODO this should really be 1,2,3 but the Sling OSGi mocks sort
+
+ // TODO this should really be 1,2,3 but the Sling OSGi mocks sort
// in the wrong order w.r.t service ranking, see SLING-5462,
// will be fixed in osgi-mock 2.0.2
assertTestInitializerProperty("3,2,1,");
assertAdditionalRepositoryServices(1);
}
-
+
@Test
public void reverseOrderInitializers() throws RepositoryException {
for(int i=1; i < 4; i++) {
registerInitializer(String.valueOf(i), i * -100);
}
-
+
assertStart(true);
-
+
// TODO see comment in inOrderInitializers, this should really
// be 3,2,1, caused by SLING-5462
assertTestInitializerProperty("1,2,3,");
assertAdditionalRepositoryServices(1);
}
-
+
@Test
public void noRepositoryOnException() throws RepositoryException {
registerInitializer("a", 1);
@@ -141,20 +137,20 @@ public class RepositoryInitializersTest
registerInitializer("c", 3);
assertStart(false);
-
- // The repository manager does not register a service in this case
+
+ // The repository manager does not register a service in this case
assertAdditionalRepositoryServices(0);
}
-
+
@Test
public void noRepositoryOnError() throws RepositoryException {
registerInitializer("a", 1);
registerInitializer("ERROR", 2);
registerInitializer("c", 3);
-
+
assertStart(false);
-
- // The repository manager does not register a service in this case
+
+ // The repository manager does not register a service in this case
assertAdditionalRepositoryServices(0);
- }
+ }*/
}
Modified: sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/TestInitializer.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/TestInitializer.java?rev=1731411&r1=1731410&r2=1731411&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/TestInitializer.java (original)
+++ sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/TestInitializer.java Sat Feb 20 15:15:25 2016
@@ -18,26 +18,20 @@
*/
package org.apache.sling.jcr.base;
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.api.SlingRepositoryInitializer;
-
-/** SlingRepositoryInitializer used to test that all initializers are
+/** SlingRepositoryInitializer used to test that all initializers are
* called in the right order.
*/
-class TestInitializer implements SlingRepositoryInitializer {
+class TestInitializer { //implements SlingRepositoryInitializer {
private final String id;
private static final String NODE_NAME = TestInitializer.class.getName();
private static final String NODE_PATH = "/" + NODE_NAME;
private static final String PROP = "value";
-
+
TestInitializer(String id) {
this.id = id;
}
-
+ /*
@Override
public void processRepository(SlingRepository repo) throws Exception {
if(id.equals("EXCEPTION")) {
@@ -46,7 +40,7 @@ class TestInitializer implements SlingRe
if(id.equals("ERROR")) {
throw new Error("Erroring due to id=" + id);
}
-
+
final Session s = repo.loginAdministrative(null);
try {
Node n = null;
@@ -62,16 +56,16 @@ class TestInitializer implements SlingRe
s.logout();
}
}
-
+ */
static String getPropertyPath() {
return NODE_PATH + "/" + PROP;
}
-
+
@Override
public String toString() {
return getClass().getSimpleName() + " " + id;
}
-
+
public String getId() {
return id;
}