forked from apache/jackrabbit-oak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OAK-5223 - Let SegmentNodeStoreService unregister services correctly
SegmentNodeStoreService now uniformly unregisters the services it owns, even when an external BlobStore is used. Moreover, the reference to the BlobStore has been changed from dynamic and reluctant to static and greedy to simplify the implementation of the SegmentNodeStoreService. git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1773038 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
1 parent
1a5a4fb
commit dd3f621
Showing
7 changed files
with
213 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...r/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/TarSegmentNodeStoreConfigTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.jackrabbit.oak.run.osgi | ||
|
||
import org.apache.felix.connect.launch.PojoServiceRegistry | ||
import org.apache.jackrabbit.oak.spi.blob.BlobStore | ||
import org.apache.jackrabbit.oak.spi.state.NodeStore | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
import static org.junit.Assert.assertNotNull | ||
import static org.junit.Assert.assertNull | ||
import static org.mockito.Mockito.mock | ||
|
||
class TarSegmentNodeStoreConfigTest extends AbstractRepositoryFactoryTest { | ||
|
||
private static final String SEGMENT_TAR_BUNDLE_FILTER = "(&" + | ||
"(|" + | ||
"(Bundle-SymbolicName=org.apache.jackrabbit*)" + | ||
"(Bundle-SymbolicName=org.apache.sling*)" + | ||
"(Bundle-SymbolicName=org.apache.felix*)" + | ||
"(Bundle-SymbolicName=org.apache.aries*)" + | ||
"(Bundle-SymbolicName=groovy-all)" + | ||
")" + | ||
"(!(Bundle-SymbolicName=org.apache.jackrabbit.oak-segment))" + | ||
")" | ||
|
||
private PojoServiceRegistry registry | ||
|
||
@Before | ||
void adjustConfig() { | ||
config[OakOSGiRepositoryFactory.REPOSITORY_BUNDLE_FILTER] = SEGMENT_TAR_BUNDLE_FILTER | ||
registry = repositoryFactory.initializeServiceRegistry(config) | ||
} | ||
|
||
@Override | ||
protected PojoServiceRegistry getRegistry() { | ||
return registry | ||
} | ||
|
||
@Test | ||
void testDynamicBlobStore() { | ||
createConfig([ | ||
'org.apache.jackrabbit.oak.segment.SegmentNodeStoreService': [ | ||
"customBlobStore": true | ||
] | ||
]) | ||
assertNull(registry.getServiceReference(NodeStore.class.name)) | ||
def registration = registry.registerService(BlobStore.class.name, mock(BlobStore.class), null) | ||
assertNotNull(getServiceWithWait(NodeStore.class)) | ||
registration.unregister() | ||
assertNull(registry.getServiceReference(NodeStore.class.name)) | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...ment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentStoreProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.jackrabbit.oak.segment; | ||
|
||
/** | ||
* A {@link SegmentStoreProvider} that returns a {@link SegmentStore} instance | ||
* provided by the user. | ||
*/ | ||
class DefaultSegmentStoreProvider implements SegmentStoreProvider { | ||
|
||
private final SegmentStore segmentStore; | ||
|
||
DefaultSegmentStoreProvider(SegmentStore segmentStore) { | ||
this.segmentStore = segmentStore; | ||
} | ||
|
||
@Override | ||
public SegmentStore getSegmentStore() { | ||
return segmentStore; | ||
} | ||
|
||
} |
Oops, something went wrong.