This is an automated email from the ASF dual-hosted git repository. baedke pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push: new 854ef47ae4 OAK-6773: Convert oak-store-composite to OSGi R7 annotations (#1489) 854ef47ae4 is described below commit 854ef47ae47e754e8566b96c7d4b8e736ceab1a4 Author: mbaedke <manfred.bae...@gmail.com> AuthorDate: Mon Jul 22 15:57:24 2024 +0200 OAK-6773: Convert oak-store-composite to OSGi R7 annotations (#1489) done --- oak-store-composite/pom.xml | 9 +- .../oak/composite/CompositeNodeStoreService.java | 108 +++++++++++++++------ .../CrossMountReferenceValidatorProvider.java | 60 +++++++----- .../composite/PrivateStoreValidatorProvider.java | 44 ++++++--- .../checks/NamespacePrefixNodestoreChecker.java | 6 +- .../composite/checks/NodeStoreChecksService.java | 43 +++++--- .../checks/NodeTypeDefinitionNodeStoreChecker.java | 6 +- .../checks/NodeTypeMountedNodeStoreChecker.java | 38 +++++--- .../checks/UniqueIndexNodeStoreChecker.java | 6 +- .../oak/composite/checks/package-info.java | 20 ++++ .../jackrabbit/oak/composite/package-info.java | 2 +- .../NodeTypeDefinitionNodeStoreCheckerTest.java | 6 +- 12 files changed, 239 insertions(+), 109 deletions(-) diff --git a/oak-store-composite/pom.xml b/oak-store-composite/pom.xml index 6b708b92b5..73a55c69f3 100644 --- a/oak-store-composite/pom.xml +++ b/oak-store-composite/pom.xml @@ -93,8 +93,13 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.component.annotations</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.metatype.annotations</artifactId> <scope>provided</scope> </dependency> diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java index b3fe33f225..4fd946676d 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java @@ -17,14 +17,15 @@ package org.apache.jackrabbit.oak.composite; import org.apache.jackrabbit.guava.common.io.Closer; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.ConfigurationPolicy; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.ReferencePolicy; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ComponentPropertyType; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.metatype.annotations.AttributeDefinition; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.jmx.CheckpointMBean; import org.apache.jackrabbit.oak.commons.PropertiesUtil; @@ -57,7 +58,7 @@ import java.util.Set; import static org.apache.jackrabbit.guava.common.collect.Sets.newIdentityHashSet; import static java.util.stream.Collectors.toSet; -@Component(policy = ConfigurationPolicy.REQUIRE) +@Component(configurationPolicy = ConfigurationPolicy.REQUIRE) public class CompositeNodeStoreService { private static final Logger LOG = LoggerFactory.getLogger(CompositeNodeStoreService.class); @@ -66,35 +67,39 @@ public class CompositeNodeStoreService { private static final String MOUNT_ROLE_PREFIX = "composite-mount-"; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC) private MountInfoProvider mountInfoProvider; - @Reference(cardinality = ReferenceCardinality.MANDATORY_MULTIPLE, policy = ReferencePolicy.DYNAMIC, bind = "bindNodeStore", unbind = "unbindNodeStore", referenceInterface = NodeStoreProvider.class, target="(!(service.pid=org.apache.jackrabbit.oak.composite.CompositeNodeStore))") private List<NodeStoreWithProps> nodeStores = new ArrayList<>(); - @Reference private NodeStoreChecks checks; - @Reference private StatisticsProvider statisticsProvider = StatisticsProvider.NOOP; - @Property(label = "Enable node store checks", - description = "Whether the composite node store constraints should be checked before start", - boolValue = true - ) private static final String ENABLE_CHECKS = "enableChecks"; - - @Property(label = "Pre-populate seed mount", - description = "Setting this parameter to a mount name will enable pre-populating the empty default store" - ) private static final String PROP_SEED_MOUNT = "seedMount"; - - @Property(label = "Gather path statistics", - description = "Whether the CompositeNodeStoreStatsMBean should gather information about the most popular paths (may be expensive)", - boolValue = false - ) private static final String PATH_STATS = "pathStats"; + @ComponentPropertyType + @interface Config { + @AttributeDefinition( + name = "Enable node store checks", + description = "Whether the composite node store constraints should be checked before start" + ) + boolean enableChecks() default true; + + @AttributeDefinition( + name = "Pre-populate seed mount", + description = "Setting this parameter to a mount name will enable pre-populating the empty default store" + ) + String seedMount(); + + @AttributeDefinition( + name = "Gather path statistics", + description = "Whether the CompositeNodeStoreStatsMBean should gather information about the most popular paths (may be expensive)" + ) + boolean pathStats() default false; + } + private ComponentContext context; private final Set<NodeStoreProvider> nodeStoresInUse = newIdentityHashSet(); @@ -260,6 +265,12 @@ public class CompositeNodeStoreService { } @SuppressWarnings("unused") + @Reference(name = "nodeStores", + cardinality = ReferenceCardinality.AT_LEAST_ONE, + policy = ReferencePolicy.DYNAMIC, + service = NodeStoreProvider.class, + target="(!(service.pid=org.apache.jackrabbit.oak.composite.CompositeNodeStore))" + ) protected void bindNodeStore(NodeStoreProvider ns, Map<String, ?> config) throws IOException, CommitFailedException { NodeStoreWithProps newNs = new NodeStoreWithProps(ns, config); nodeStores.add(newNs); @@ -288,6 +299,49 @@ public class CompositeNodeStoreService { } } + @SuppressWarnings("unused") + @Reference(name = "mountInfoProvider", + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.STATIC, + service = MountInfoProvider.class + ) + protected void bindMountInfoProvider(MountInfoProvider mip) { + this.mountInfoProvider = mip; + } + + @SuppressWarnings("unused") + protected void unbindMountInfoProvider(MountInfoProvider mip) { + if (this.mountInfoProvider == mip) { + this.mountInfoProvider = null; + } + } + + @SuppressWarnings("unused") + @Reference(name = "checks", service = NodeStoreChecks.class) + protected void bindChecks(NodeStoreChecks checks) { + this.checks = checks; + } + + @SuppressWarnings("unused") + protected void unbindChecks(NodeStoreChecks checks) { + if (this.checks == checks) { + this.checks = null; + } + } + + @SuppressWarnings("unused") + @Reference(name = "statisticsProvider", service = StatisticsProvider.class) + protected void bindStatisticsProvider(StatisticsProvider sp) { + this.statisticsProvider = sp; + } + + @SuppressWarnings("unused") + protected void unbindStatisticsProvider(StatisticsProvider sp) { + if (this.statisticsProvider == sp) { + this.statisticsProvider = null; + } + } + private static class NodeStoreWithProps { private final NodeStoreProvider nodeStore; @@ -316,4 +370,4 @@ public class CompositeNodeStoreService { getNodeStoreProvider().getClass().toString()); } } -} \ No newline at end of file +} diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CrossMountReferenceValidatorProvider.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CrossMountReferenceValidatorProvider.java index 935fa0edc5..3852b9a70c 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CrossMountReferenceValidatorProvider.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CrossMountReferenceValidatorProvider.java @@ -16,13 +16,15 @@ */ package org.apache.jackrabbit.oak.composite; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.ConfigurationPolicy; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.jackrabbit.oak.commons.PropertiesUtil; +import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ComponentPropertyType; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.metatype.annotations.AttributeDefinition; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EditorProvider; import org.apache.jackrabbit.oak.spi.commit.Validator; @@ -30,27 +32,27 @@ import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider; import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider; import org.apache.jackrabbit.oak.spi.mount.Mounts; import org.apache.jackrabbit.oak.spi.state.NodeState; -import org.osgi.framework.BundleContext; - -import java.util.Map; /** * {@link Validator} which detects references crossing the mount boundaries */ -@Component(label = "Apache Jackrabbit Oak CrossMountReferenceValidatorProvider", policy = ConfigurationPolicy.REQUIRE) -@Property(name = "type", value = "crossMountRefValidator", propertyPrivate = true) -@Service({ValidatorProvider.class, EditorProvider.class}) +@Component(configurationPolicy = ConfigurationPolicy.REQUIRE, service = {ValidatorProvider.class, EditorProvider.class}) public class CrossMountReferenceValidatorProvider extends ValidatorProvider { - @Property( - boolValue = true, - label = "Fail when detecting commits cross-mount references", - description = "Commits will fail if set to true when detecting cross-mount references. If set to false the commit information is only logged." - ) - private static final String PROP_FAIL_ON_DETECTION = "failOnDetection"; + @ComponentPropertyType + @interface Config { + @AttributeDefinition + String type() default "crossMountRefValidator"; + + @AttributeDefinition( + name = "Fail when detecting commits cross-mount references", + description = "Commits will fail if set to true when detecting cross-mount references. If set to false the commit information is only logged." + ) + boolean failOnDetection() default true; + } + private boolean failOnDetection; - @Reference private MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider(); public CrossMountReferenceValidatorProvider() { @@ -62,8 +64,8 @@ public class CrossMountReferenceValidatorProvider extends ValidatorProvider { } @Activate - private void activate(BundleContext bundleContext, Map<String, ?> config) { - failOnDetection = PropertiesUtil.toBoolean(config.get(PROP_FAIL_ON_DETECTION), false); + private void activate(Config config) { + failOnDetection = config.failOnDetection(); } @Override @@ -80,4 +82,18 @@ public class CrossMountReferenceValidatorProvider extends ValidatorProvider { this.failOnDetection = failOnDetection; return this; } + + @SuppressWarnings("unused") + @Reference(name = "mountInfoProvider") + protected void bindMountInfoProvider(MountInfoProvider mip) { + this.mountInfoProvider = mip; + } + + @SuppressWarnings("unused") + protected void unbindMountInfoProvider(MountInfoProvider mip) { + if (this.mountInfoProvider == mip) { + this.mountInfoProvider = null; + } + + } } diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/PrivateStoreValidatorProvider.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/PrivateStoreValidatorProvider.java index 530def5a08..5dae99cf76 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/PrivateStoreValidatorProvider.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/PrivateStoreValidatorProvider.java @@ -17,10 +17,14 @@ package org.apache.jackrabbit.oak.composite; -import org.apache.felix.scr.annotations.*; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ComponentPropertyType; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.AttributeDefinition; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.commons.PropertiesUtil; import org.apache.jackrabbit.oak.spi.commit.*; import org.apache.jackrabbit.oak.spi.mount.Mount; import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider; @@ -36,20 +40,22 @@ import java.util.Map; /** * {@link Validator} which detects change commits to the read only mounts. */ -@Component(label = "Apache Jackrabbit Oak PrivateStoreValidatorProvider") +@Component public class PrivateStoreValidatorProvider extends ValidatorProvider { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final String ROOT_PATH = "/"; - @Property( - boolValue = true, - label = "Fail when detecting commits to the read-only stores", - description = "Commits will fail if set to true when detecting changes to any read-only store. If set to false the commit information is only logged." - ) - private static final String PROP_FAIL_ON_DETECTION = "failOnDetection"; + @ComponentPropertyType + @interface Config { + @AttributeDefinition( + name = "Fail when detecting commits to the read-only stores", + description = "Commits will fail if set to true when detecting changes to any read-only store. If set to false the commit information is only logged." + ) + boolean failOnDetection() default true; + } + private boolean failOnDetection; - @Reference private MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider(); private ServiceRegistration serviceRegistration; @@ -60,8 +66,8 @@ public class PrivateStoreValidatorProvider extends ValidatorProvider { } @Activate - private void activate(BundleContext bundleContext, Map<String, ?> config) { - failOnDetection = PropertiesUtil.toBoolean(config.get(PROP_FAIL_ON_DETECTION), true); + private void activate(BundleContext bundleContext, Config config) { + failOnDetection = config.failOnDetection(); if (mountInfoProvider.hasNonDefaultMounts()) { serviceRegistration = bundleContext.registerService(EditorProvider.class.getName(), this, null); @@ -91,6 +97,20 @@ public class PrivateStoreValidatorProvider extends ValidatorProvider { return failOnDetection; } + @SuppressWarnings("unused") + @Reference(name = "mountInfoProvider", service = MountInfoProvider.class) + protected void bindMountInfoProvider(MountInfoProvider mip) { + this.mountInfoProvider = mip; + } + + @SuppressWarnings("unused") + protected void unbindMountInfoProvider(MountInfoProvider mip) { + if (this.mountInfoProvider == mip) { + this.mountInfoProvider = null; + } + + } + private class PrivateStoreValidator extends DefaultValidator { private final String path; diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java index 4095c7ccaa..865022f291 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java @@ -18,8 +18,7 @@ package org.apache.jackrabbit.oak.composite.checks; import java.util.Set; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -32,8 +31,7 @@ import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.apache.jackrabbit.guava.common.collect.Sets; -@Component -@Service(MountedNodeStoreChecker.class) +@Component(service={MountedNodeStoreChecker.class}) public class NamespacePrefixNodestoreChecker implements MountedNodeStoreChecker<NamespacePrefixNodestoreChecker.Context> { @Override diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeStoreChecksService.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeStoreChecksService.java index c1f3fbb454..14ee6d25a8 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeStoreChecksService.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeStoreChecksService.java @@ -19,10 +19,9 @@ package org.apache.jackrabbit.oak.composite.checks; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.composite.MountedNodeStore; import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory; @@ -32,19 +31,13 @@ import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Component -@Service(NodeStoreChecks.class) +@Component(service = {NodeStoreChecks.class}) public class NodeStoreChecksService implements NodeStoreChecks { private final Logger log = LoggerFactory.getLogger(getClass()); - @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, - bind = "bindChecker", - unbind = "unbindChecker", - referenceInterface = MountedNodeStoreChecker.class) private List<MountedNodeStoreChecker<?>> checkers = new CopyOnWriteArrayList<>(); - @Reference private MountInfoProvider mip; // used by SCR @@ -102,13 +95,31 @@ public class NodeStoreChecksService implements NodeStoreChecks { if ( ( mounted || under ) && keepGoing ) { tree.getChildren().forEach( child -> visit(child, mountedStore, errorHolder, context, c)); } - } - - protected void bindChecker(MountedNodeStoreChecker<?> checker) { + } + + @SuppressWarnings("unused") + @Reference(name = "checkers", + cardinality = ReferenceCardinality.MULTIPLE, + service = MountedNodeStoreChecker.class) + protected void bindChecker(MountedNodeStoreChecker checker) { checkers.add(checker); } - - protected void unbindChecker(MountedNodeStoreChecker<?> checker) { + + @SuppressWarnings("unused") + protected void unbindChecker(MountedNodeStoreChecker checker) { checkers.remove(checker); } + + @SuppressWarnings("unused") + @Reference(name = "mip", service = MountInfoProvider.class) + protected void bindMip(MountInfoProvider mip) { + this.mip = mip; + } + + @SuppressWarnings("unused") + protected void unbindMip(MountInfoProvider mip) { + if (this.mip == mip) { + this.mip = null; + } + } } diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java index 5df639fb67..76c68e7419 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java @@ -26,8 +26,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Tree; @@ -48,8 +47,7 @@ import org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder; /** * Checks that nodes present in a mount are consistent with the global node type definitions */ -@Component -@Service(MountedNodeStoreChecker.class) +@Component(service = {MountedNodeStoreChecker.class}) public class NodeTypeDefinitionNodeStoreChecker implements MountedNodeStoreChecker<NodeTypeDefinitionNodeStoreChecker.Context> { @Override diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java index 7a2c6dfedd..88ddb19b12 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java @@ -20,10 +20,10 @@ import static org.apache.jackrabbit.guava.common.base.Preconditions.checkNotNull import java.util.Set; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.ConfigurationPolicy; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ComponentPropertyType; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.metatype.annotations.AttributeDefinition; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PropertiesUtil; @@ -39,23 +39,35 @@ import org.slf4j.LoggerFactory; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; -@Component(configurationFactory=true, - policy = ConfigurationPolicy.REQUIRE) -@Service(MountedNodeStoreChecker.class) +@Component(configurationPolicy = ConfigurationPolicy.REQUIRE, service = {MountedNodeStoreChecker.class}) public class NodeTypeMountedNodeStoreChecker implements MountedNodeStoreChecker<NodeTypeMountedNodeStoreChecker.Context> { private final Logger log = LoggerFactory.getLogger(getClass()); - - @Property(label = "The name of a node type that is invalid and will be rejected when found") + private static final String INVALID_NODE_TYPE = "invalidNodeType"; - @Property(label = "The error label to use when rejecting an invalid node type") private static final String ERROR_LABEL = "errorLabel"; - - @Property(label="Node types that will cause the check to succeeed, even in the invalid node type is also found.", - cardinality = Integer.MAX_VALUE) private static final String EXCLUDED_NODE_TYPES = "excludedNodeTypes"; + @ComponentPropertyType + @interface Config { + @AttributeDefinition( + name = "The name of a node type that is invalid and will be rejected when found" + ) + String invalidNodeType(); + + @AttributeDefinition( + name = "The error label to use when rejecting an invalid node type" + ) + String errorLabel(); + + @AttributeDefinition( + name = "Node types that will cause the check to succeeed, even in the invalid node type is also found.", + cardinality = Integer.MAX_VALUE + ) + String[] excludedNodeTypes() default {}; + } + private String invalidNodeType; private String errorLabel; private Set<String> excludedNodeTypes; diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java index 98078c3388..7f4621cc4e 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java @@ -33,8 +33,7 @@ import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.composite.MountedNodeStore; import org.apache.jackrabbit.oak.plugins.index.property.Multiplexers; @@ -62,8 +61,7 @@ import org.apache.jackrabbit.guava.common.collect.Maps; * on first access and skips all subsequent executions.</p> * */ -@Component -@Service(MountedNodeStoreChecker.class) +@Component(service = {MountedNodeStoreChecker.class}) public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<UniqueIndexNodeStoreChecker.Context> { private static final Logger LOG = LoggerFactory.getLogger(UniqueIndexNodeStoreChecker.class); diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/package-info.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/package-info.java new file mode 100755 index 0000000000..ecbd27d417 --- /dev/null +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ +@Version("0.0.1") +package org.apache.jackrabbit.oak.composite.checks; + +import org.osgi.annotation.versioning.Version; \ No newline at end of file diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/package-info.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/package-info.java index 9599d669c2..6efb8de2a2 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/package-info.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/package-info.java @@ -55,7 +55,7 @@ * This is obviously correct but may be slow. * {@link org.apache.jackrabbit.oak.composite.CompositionContext#getContributingStores(java.lang.String, java.util.function.Function)} */ -@Version("0.5.0") +@Version("0.5.1") package org.apache.jackrabbit.oak.composite; import org.osgi.annotation.versioning.Version; \ No newline at end of file diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreCheckerTest.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreCheckerTest.java index d710610c2c..64489a3a4b 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreCheckerTest.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreCheckerTest.java @@ -20,8 +20,7 @@ import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT; import java.io.IOException; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; +import org.osgi.service.component.annotations.Component; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.IllegalRepositoryStateException; @@ -45,8 +44,7 @@ import org.junit.Test; * that they are performed when needed.</p> * */ -@Component -@Service(MountedNodeStoreChecker.class) +@Component(service = {MountedNodeStoreChecker.class}) public class NodeTypeDefinitionNodeStoreCheckerTest { @Test