diff --git a/oak-solr-core/pom.xml b/oak-solr-core/pom.xml
index c655ef50c2c..57b53947264 100644
--- a/oak-solr-core/pom.xml
+++ b/oak-solr-core/pom.xml
@@ -214,6 +214,7 @@
org.jetbrains
annotations
+
org.osgi
osgi.core
@@ -226,6 +227,12 @@
provided
true
+
+ org.osgi
+ org.osgi.service.component.annotations
+ provided
+
+
javax.jcr
jcr
@@ -301,12 +308,6 @@
provided
-
- org.apache.felix
- org.apache.felix.scr.annotations
- provided
-
-
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
index 54a0d122e35..be3c89188da 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
@@ -181,4 +181,22 @@ enum CommitPolicy {
*/
AUTO
}
+
+ /**
+ * Enum to designate the type of the Solr server.
+ */
+ enum ServerType {
+ /**
+ * no server
+ */
+ none,
+ /**
+ * embedded server
+ */
+ embedded,
+ /**
+ * remote server
+ */
+ remote
+ }
}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java
index 7391c068a5b..15e8ad6be1f 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java
@@ -19,31 +19,47 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.jackrabbit.oak.commons.PropertiesUtil;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+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.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver;
import org.apache.jackrabbit.oak.spi.commit.BackgroundObserver;
import org.apache.jackrabbit.oak.spi.commit.Observer;
import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
/**
* An OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver}.
* This allows correct cleanup of any persisted Solr server configurations once they get changed or deleted.
*/
-@Component(metatype = true,
- immediate = true,
- label = "Apache Jackrabbit Oak Solr persisted configuration observer"
+@Component(
+ immediate = true
+)
+@Designate(
+ ocd = NodeStateSolrServersObserverService.Configuration.class
)
public class NodeStateSolrServersObserverService {
+ @ObjectClassDefinition(
+ id ="org.apache.jackrabbit.oak.plugins.index.solr.osgi.NodeStateSolrServersObserverService",
+ name = "Apache Jackrabbit Oak Solr persisted configuration observer"
+ )
+ @interface Configuration {
+ @AttributeDefinition(
+ name = "enabled",
+ description = "enable persisted configuration observer"
+ )
+ boolean enabled() default false;
+ }
+
private final NodeStateSolrServersObserver nodeStateSolrServersObserver = new NodeStateSolrServersObserver();
private WhiteboardExecutor executor;
@@ -52,13 +68,10 @@ public class NodeStateSolrServersObserverService {
private List regs = new ArrayList();
- @Property(boolValue = false, label = "enabled", description = "enable persisted configuration observer")
- private static final String ENABLED = "enabled";
-
@Activate
- protected void activate(ComponentContext componentContext) throws Exception {
+ protected void activate(ComponentContext componentContext, Configuration configuration) throws Exception {
- boolean enabled = PropertiesUtil.toBoolean(componentContext.getProperties().get(ENABLED), false);
+ boolean enabled = configuration.enabled();
if (enabled) {
BundleContext bundleContext = componentContext.getBundleContext();
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
index 2d667c1626c..8b7e7843aa4 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
@@ -19,99 +19,140 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyOption;
-import org.apache.felix.scr.annotations.PropertyUnbounded;
-import org.apache.felix.scr.annotations.Service;
+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.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.commons.PropertiesUtil;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationDefaults;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.osgi.service.component.ComponentContext;
+import org.osgi.service.metatype.annotations.Option;
/**
* OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider}
*/
-@Component(label = "Apache Jackrabbit Oak Solr indexing / search configuration", metatype = true, immediate = true)
-@Service(OakSolrConfigurationProvider.class)
+@Component(
+ immediate = true,
+ service = { OakSolrConfigurationProvider.class }
+)
+@Designate(
+ ocd = OakSolrConfigurationProviderService.Configuration.class
+)
public class OakSolrConfigurationProviderService implements OakSolrConfigurationProvider {
- @Property(value = OakSolrConfigurationDefaults.DESC_FIELD_NAME, label = "field for descendants search")
- private static final String PATH_DESCENDANTS_FIELD = "path.desc.field";
-
- @Property(value = OakSolrConfigurationDefaults.CHILD_FIELD_NAME, label = "field for children search")
- private static final String PATH_CHILDREN_FIELD = "path.child.field";
-
- @Property(value = OakSolrConfigurationDefaults.ANC_FIELD_NAME, label = "field for parent search")
- private static final String PATH_PARENT_FIELD = "path.parent.field";
-
- @Property(value = OakSolrConfigurationDefaults.PATH_FIELD_NAME, label = "field for path search")
- private static final String PATH_EXACT_FIELD = "path.exact.field";
-
- @Property(value = OakSolrConfigurationDefaults.CATCHALL_FIELD, label = "catch all field")
- private static final String CATCH_ALL_FIELD = "catch.all.field";
-
- @Property(value = OakSolrConfigurationDefaults.COLLAPSED_PATH_FIELD, label = "field for collapsing jcr:content paths")
- private static final String COLLAPSED_PATH_FIELD = "collapsed.path.field";
-
- @Property(value = OakSolrConfigurationDefaults.PATH_DEPTH_FIELD, label = "field for path depth")
- private static final String PATH_DEPTH_FIELD = "path.depth.field";
-
- @Property(options = {
- @PropertyOption(name = "HARD",
- value = "Hard commit"
- ),
- @PropertyOption(name = "SOFT",
- value = "Soft commit"
- ),
- @PropertyOption(name = "AUTO",
- value = "Auto commit"
- )},
- value = "SOFT"
- )
- private static final String COMMIT_POLICY = "commit.policy";
-
- @Property(intValue = OakSolrConfigurationDefaults.ROWS, label = "rows")
- private static final String ROWS = "rows";
-
- @Property(boolValue = OakSolrConfigurationDefaults.PATH_RESTRICTIONS, label = "path restrictions")
- private static final String PATH_RESTRICTIONS = "path.restrictions";
-
- @Property(boolValue = OakSolrConfigurationDefaults.PROPERTY_RESTRICTIONS, label = "property restrictions")
- private static final String PROPERTY_RESTRICTIONS = "property.restrictions";
-
- @Property(boolValue = OakSolrConfigurationDefaults.PRIMARY_TYPES, label = "primary types restrictions")
- private static final String PRIMARY_TYPES_RESTRICTIONS = "primarytypes.restrictions";
-
- @Property(value = {"rep:members", "rep:authorizableId", "jcr:uuid", "rep:principalName", "rep:password"},
- label = "ignored properties", unbounded = PropertyUnbounded.ARRAY)
- private static final String IGNORED_PROPERTIES = "ignored.properties";
-
- @Property(value = {}, label = "used properties", unbounded = PropertyUnbounded.ARRAY)
- private static final String USED_PROPERTIES = "used.properties";
-
- @Property(value = OakSolrConfigurationDefaults.TYPE_MAPPINGS, cardinality = 13, description =
- "each item should be in the form TypeString=FieldName (e.g. STRING=text_general)", label =
- "mappings from Oak Types to Solr fields")
- private static final String TYPE_MAPPINGS = "type.mappings";
-
- @Property(value = OakSolrConfigurationDefaults.PROPERTY_MAPPINGS, unbounded = PropertyUnbounded.ARRAY, description =
- "each item should be in the form PropertyName=FieldName (e.g. jcr:title=text_en)", label =
- "mappings from JCR property names to Solr fields")
- private static final String PROPERTY_MAPPINGS = "property.mappings";
-
- @Property(boolValue = OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_NODES, label = "collapse jcr:content nodes")
- private static final String COLLAPSE_JCR_CONTENT_NODES = "collapse.jcrcontent.nodes";
-
- @Property(boolValue = OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_PARENTS, label = "collapse jcr:content parents")
- private static final String COLLAPSE_JCR_CONTENT_PARENTS = "collapse.jcrcontent.parents";
+ @ObjectClassDefinition(
+ id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.OakSolrConfigurationProviderService",
+ name = "Apache Jackrabbit Oak Solr indexing / search configuration" )
+ @interface Configuration {
+ @AttributeDefinition(
+ name = "field for descendants search"
+ )
+ String path_desc_field() default OakSolrConfigurationDefaults.DESC_FIELD_NAME;
+
+ @AttributeDefinition(
+ name = "field for children search"
+ )
+ String path_child_field() default OakSolrConfigurationDefaults.CHILD_FIELD_NAME;
+
+ @AttributeDefinition(
+ name = "field for parent search"
+ )
+ String path_parent_field() default OakSolrConfigurationDefaults.ANC_FIELD_NAME;
+
+ @AttributeDefinition(
+ name = "field for path search"
+ )
+ String path_exact_field() default OakSolrConfigurationDefaults.PATH_FIELD_NAME;
+
+ @AttributeDefinition(
+ name = "catch all field"
+ )
+ String catch_all_field() default OakSolrConfigurationDefaults.CATCHALL_FIELD;
+
+ @AttributeDefinition(
+ name = "field for collapsing jcr:content paths"
+ )
+ String collapsed_path_field() default OakSolrConfigurationDefaults.COLLAPSED_PATH_FIELD;
+
+ @AttributeDefinition(
+ name = "field for path depth"
+ )
+ String path_depth_field() default OakSolrConfigurationDefaults.PATH_DEPTH_FIELD;
+
+ @AttributeDefinition(
+ name = "Property commit.policy",
+ options = {
+ @Option(value = "HARD",
+ label = "Hard commit"
+ ),
+ @Option(value = "SOFT",
+ label = "Soft commit"
+ ),
+ @Option(value = "AUTO",
+ label = "Auto commit"
+ )}
+ )
+ OakSolrConfiguration.CommitPolicy commit_policy() default OakSolrConfiguration.CommitPolicy.SOFT;
+
+ @AttributeDefinition(
+ name = "rows"
+ )
+ int rows() default OakSolrConfigurationDefaults.ROWS;
+
+ @AttributeDefinition(
+ name = "path restrictions"
+ )
+ boolean path_restrictions() default OakSolrConfigurationDefaults.PATH_RESTRICTIONS;
+
+ @AttributeDefinition(
+ name = "property restrictions"
+ )
+ boolean property_restrictions() default OakSolrConfigurationDefaults.PROPERTY_RESTRICTIONS;
+
+ @AttributeDefinition(
+ name = "primary types restrictions"
+ )
+ boolean primarytypes_restrictions() default OakSolrConfigurationDefaults.PRIMARY_TYPES;
+
+ @AttributeDefinition(
+ name = "ignored properties"
+ )
+ String[] ignored_properties() default {"rep:members", "rep:authorizableId", "jcr:uuid", "rep:principalName", "rep:password"};
+
+ @AttributeDefinition(
+ name = "used properties"
+ )
+ String[] used_properties();
+
+ @AttributeDefinition(
+ name = "mappings from Oak Types to Solr fields",
+ description = "each item should be in the form TypeString=FieldName (e.g. STRING=text_general)",
+ cardinality = 13
+ )
+ String[] type_mappings() default OakSolrConfigurationDefaults.TYPE_MAPPINGS;
+
+ @AttributeDefinition(
+ name = "mappings from JCR property names to Solr fields",
+ description = "each item should be in the form PropertyName=FieldName (e.g. jcr:title=text_en)"
+ )
+ String[] property_mappings() default OakSolrConfigurationDefaults.PROPERTY_MAPPINGS;
+
+ @AttributeDefinition(
+ name = "collapse jcr:content nodes"
+ )
+ boolean collapse_jcrcontent_nodes() default OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_NODES;
+
+ @AttributeDefinition(
+ name = "collapse jcr:content parents"
+ )
+ boolean collapse_jcrcontent_parents() default OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_PARENTS;
+ }
private String pathChildrenFieldName;
private String pathParentFieldName;
@@ -135,25 +176,25 @@ public class OakSolrConfigurationProviderService implements OakSolrConfiguration
private OakSolrConfiguration oakSolrConfiguration;
@Activate
- protected void activate(ComponentContext componentContext) throws Exception {
- pathChildrenFieldName = String.valueOf(componentContext.getProperties().get(PATH_CHILDREN_FIELD));
- pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD));
- pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD));
- collapsedPathField= String.valueOf(componentContext.getProperties().get(COLLAPSED_PATH_FIELD));
- pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD));
- catchAllField = String.valueOf(componentContext.getProperties().get(CATCH_ALL_FIELD));
- depthField = String.valueOf(componentContext.getProperties().get(PATH_DEPTH_FIELD));
- rows = Integer.parseInt(String.valueOf(componentContext.getProperties().get(ROWS)));
- commitPolicy = OakSolrConfiguration.CommitPolicy.valueOf(String.valueOf(componentContext.getProperties().get(COMMIT_POLICY)));
- useForPathRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PATH_RESTRICTIONS)));
- useForPropertyRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PROPERTY_RESTRICTIONS)));
- useForPrimaryTypes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PRIMARY_TYPES_RESTRICTIONS)));
- typeMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(TYPE_MAPPINGS));
- ignoredProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(IGNORED_PROPERTIES));
- usedProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(USED_PROPERTIES));
- propertyMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(PROPERTY_MAPPINGS));
- collapseJcrContentNodes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(COLLAPSE_JCR_CONTENT_NODES)));
- collapseJcrContentParents = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(COLLAPSE_JCR_CONTENT_PARENTS)));
+ protected void activate(Configuration configuration) {
+ pathChildrenFieldName = configuration.path_child_field();
+ pathParentFieldName = configuration.path_parent_field();
+ pathExactFieldName = configuration.path_exact_field();
+ collapsedPathField = configuration.collapsed_path_field();
+ pathDescendantsFieldName = configuration.path_desc_field();
+ catchAllField = configuration.catch_all_field();
+ depthField = configuration.path_depth_field();
+ rows = configuration.rows();
+ commitPolicy = configuration.commit_policy();
+ useForPathRestrictions = configuration.path_restrictions();
+ useForPropertyRestrictions = configuration.property_restrictions();
+ useForPrimaryTypes = configuration.primarytypes_restrictions();
+ typeMappings = configuration.type_mappings();
+ ignoredProperties = configuration.ignored_properties();
+ usedProperties = configuration.used_properties();
+ propertyMappings = configuration.property_mappings();
+ collapseJcrContentNodes = configuration.collapse_jcrcontent_nodes();
+ collapseJcrContentParents = configuration.collapse_jcrcontent_parents();
}
@Deactivate
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java
index 6e206c071e2..3ecb9faea48 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java
@@ -16,50 +16,80 @@
*/
package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Service;
+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.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
import org.apache.jackrabbit.oak.plugins.index.solr.server.RemoteSolrServerProvider;
+
import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.ComponentContext;
/**
* {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider} for remote Solr installations.
*/
-@Component(metatype = true, immediate = true, label = "Apache Jackrabbit Oak Solr remote server configuration")
-@Service(SolrServerConfigurationProvider.class)
-@Property(name = "name", value = "remote", propertyPrivate = true)
+@Component(
+ immediate = true,
+ service = { SolrServerConfigurationProvider.class }
+)
+@Designate(
+ ocd = RemoteSolrServerConfigurationProvider.Configuration.class
+)
public class RemoteSolrServerConfigurationProvider implements SolrServerConfigurationProvider {
- @Property(value = SolrServerConfigurationDefaults.HTTP_URL, label = "Solr HTTP URL")
- private static final String SOLR_HTTP_URL = "solr.http.url";
+ @ObjectClassDefinition(
+ id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.RemoteSolrServerConfigurationProvider",
+ name = "Apache Jackrabbit Oak Solr remote server configuration"
+ )
+ @interface Configuration {
+ @AttributeDefinition(
+ name = "Solr HTTP URL"
+ )
+ String solr_http_url() default SolrServerConfigurationDefaults.HTTP_URL;
- @Property(value = SolrServerConfigurationDefaults.ZK_HOST, label = "ZooKeeper host")
- private static final String SOLR_ZK_HOST = "solr.zk.host";
+ @AttributeDefinition(
+ name = "ZooKeeper host"
+ )
+ String solr_zk_host() default SolrServerConfigurationDefaults.ZK_HOST;
- @Property(value = SolrServerConfigurationDefaults.COLLECTION, label = "Solr collection")
- private static final String SOLR_COLLECTION = "solr.collection";
+ @AttributeDefinition(
+ name = "Solr collection"
+ )
+ String solr_collection() default SolrServerConfigurationDefaults.COLLECTION;
- @Property(intValue = SolrServerConfigurationDefaults.SOCKET_TIMEOUT, label = "Socket timeout (ms)")
- private static final String SOCKET_TIMEOUT = "solr.socket.timeout";
+ @AttributeDefinition(
+ name = "Socket timeout (ms)"
+ )
+ int solr_socket_timeout() default SolrServerConfigurationDefaults.SOCKET_TIMEOUT;
- @Property(intValue = SolrServerConfigurationDefaults.CONNECTION_TIMEOUT, label = "Connection timeout (ms)")
- private static final String CONNECTION_TIMEOUT = "solr.connection.timeout";
+ @AttributeDefinition(
+ name = "Connection timeout (ms)"
+ )
+ int solr_connection_timeout() default SolrServerConfigurationDefaults.CONNECTION_TIMEOUT;
- @Property(intValue = SolrServerConfigurationDefaults.SHARDS_NO, label = "No. of collection shards")
- private static final String SOLR_SHARDS_NO = "solr.shards.no";
+ @AttributeDefinition(
+ name = "No. of collection shards"
+ )
+ int solr_shards_no() default SolrServerConfigurationDefaults.SHARDS_NO;
- @Property(intValue = SolrServerConfigurationDefaults.REPLICATION_FACTOR, label = "Replication factor")
- private static final String SOLR_REPLICATION_FACTOR = "solr.replication.factor";
+ @AttributeDefinition(
+ name = "Replication factor"
+ )
+ int solr_replication_factor() default SolrServerConfigurationDefaults.REPLICATION_FACTOR;
- @Property(value = SolrServerConfigurationDefaults.CONFIGURATION_DIRECTORY, label = "Solr configuration directory")
- private static final String SOLR_CONF_DIR = "solr.conf.dir";
+ @AttributeDefinition(
+ name = "Solr configuration directory"
+ )
+ String solr_conf_dir() default SolrServerConfigurationDefaults.CONFIGURATION_DIRECTORY;
+
+ String name() default "remote";
+ }
private String solrHttpUrl;
private String solrZkHost;
@@ -70,15 +100,15 @@ public class RemoteSolrServerConfigurationProvider implements SolrServerConfigur
private RemoteSolrServerConfiguration remoteSolrServerConfiguration;
@Activate
- protected void activate(ComponentContext componentContext) throws Exception {
- solrHttpUrl = String.valueOf(componentContext.getProperties().get(SOLR_HTTP_URL));
- solrZkHost = String.valueOf(componentContext.getProperties().get(SOLR_ZK_HOST));
- solrCollection = String.valueOf(componentContext.getProperties().get(SOLR_COLLECTION));
- solrShardsNo = Integer.valueOf(componentContext.getProperties().get(SOLR_SHARDS_NO).toString());
- solrReplicationFactor = Integer.valueOf(componentContext.getProperties().get(SOLR_REPLICATION_FACTOR).toString());
- solrConfDir = String.valueOf(componentContext.getProperties().get(SOLR_CONF_DIR));
- int socketTimeout = Integer.valueOf(componentContext.getProperties().get(SOCKET_TIMEOUT).toString());
- int connectionTimeout = Integer.valueOf(componentContext.getProperties().get(CONNECTION_TIMEOUT).toString());
+ protected void activate(Configuration configuration) throws Exception {
+ solrHttpUrl = configuration.solr_http_url();
+ solrZkHost = configuration.solr_zk_host();
+ solrCollection = configuration.solr_collection();
+ solrShardsNo = configuration.solr_shards_no();
+ solrReplicationFactor = configuration.solr_replication_factor();
+ solrConfDir = configuration.solr_conf_dir();
+ int socketTimeout = configuration.solr_socket_timeout();
+ int connectionTimeout = configuration.solr_connection_timeout();
remoteSolrServerConfiguration = new RemoteSolrServerConfiguration(solrZkHost, solrCollection, solrShardsNo,
solrReplicationFactor, solrConfDir, socketTimeout, connectionTimeout, solrHttpUrl);
}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
index 1af50e58909..8ff5545607d 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
@@ -16,9 +16,9 @@
*/
package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
@@ -28,6 +28,7 @@
import org.apache.jackrabbit.oak.spi.commit.Editor;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
+
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,8 +38,10 @@
* @see org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider
* @see org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider
*/
-@Component(metatype = false, immediate = true)
-@Service(value = IndexEditorProvider.class)
+@Component(
+ immediate = true,
+ service = { IndexEditorProvider.class }
+)
public class SolrIndexEditorProviderService implements IndexEditorProvider {
@Reference
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
index cf499a66216..39cad59730d 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
@@ -19,14 +19,18 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-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.apache.felix.scr.annotations.ReferencePolicyOption;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+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.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.apache.jackrabbit.oak.commons.PropertiesUtil;
import org.apache.jackrabbit.oak.plugins.index.aggregate.AggregateIndexProvider;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
@@ -34,8 +38,7 @@
import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,9 +48,26 @@
* @see org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider
* @see QueryIndexProvider
*/
-@Component(metatype = true, immediate = true, label = "Apache Jackrabbit Oak Solr Query index provider configuration")
+@Component(
+ immediate = true
+)
+@Designate(
+ ocd = SolrQueryIndexProviderService.Configuration.class
+)
public class SolrQueryIndexProviderService {
+ @ObjectClassDefinition(
+ id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrQueryIndexProviderService",
+ name = "Apache Jackrabbit Oak Solr Query index provider configuration"
+ )
+ @interface Configuration {
+ @AttributeDefinition(
+ name ="query time aggregation",
+ description = "enable query time aggregation for Solr index"
+ )
+ boolean query_aggregation() default QUERY_TIME_AGGREGATION_DEFAULT;
+ }
+
private static final boolean QUERY_TIME_AGGREGATION_DEFAULT = true;
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -60,21 +80,16 @@ public class SolrQueryIndexProviderService {
@Reference
private OakSolrConfigurationProvider oakSolrConfigurationProvider;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,
+ @Reference(cardinality = ReferenceCardinality.MANDATORY,
policyOption = ReferencePolicyOption.GREEDY,
policy = ReferencePolicy.DYNAMIC
)
private volatile QueryIndex.NodeAggregator nodeAggregator;
- @Property(boolValue = QUERY_TIME_AGGREGATION_DEFAULT, label = "query time aggregation",
- description = "enable query time aggregation for Solr index")
- private static final String QUERY_TIME_AGGREGATION = "query.aggregation";
-
@SuppressWarnings("UnusedDeclaration")
@Activate
- protected void activate(ComponentContext componentContext) {
- Object value = componentContext.getProperties().get(QUERY_TIME_AGGREGATION);
- boolean queryTimeAggregation = PropertiesUtil.toBoolean(value, QUERY_TIME_AGGREGATION_DEFAULT);
+ protected void activate(ComponentContext componentContext, Configuration configuration) {
+ boolean queryTimeAggregation = configuration.query_aggregation();
if (solrServerProvider != null && oakSolrConfigurationProvider != null) {
QueryIndexProvider solrQueryIndexProvider = new SolrQueryIndexProvider(solrServerProvider,
oakSolrConfigurationProvider, nodeAggregator);
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java
index 6cff907afe4..e87faa4c3d2 100644
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java
+++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java
@@ -19,57 +19,74 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyOption;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.References;
-import org.apache.felix.scr.annotations.Service;
+
+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.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Option;
+
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer;
import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
+
import org.apache.solr.client.solrj.SolrClient;
+
import org.jetbrains.annotations.Nullable;
-import org.osgi.service.component.ComponentContext;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider}
*/
-@Component(metatype = true, label = "Apache Jackrabbit Oak Solr server provider", immediate = true)
-@References({
- @Reference(name = "solrServerConfigurationProvider",
- referenceInterface = SolrServerConfigurationProvider.class,
- cardinality = ReferenceCardinality.MANDATORY_MULTIPLE,
- policy = ReferencePolicy.DYNAMIC,
- bind = "bindSolrServerConfigurationProvider",
- unbind = "unbindSolrServerConfigurationProvider",
- updated = "updatedSolrServerConfigurationProvider"
- )
-})
-@Service(SolrServerProvider.class)
+@Component(
+ immediate = true,
+ service = { SolrServerProvider.class },
+ reference = {
+ @Reference(
+ name = "solrServerConfigurationProvider",
+ service = SolrServerConfigurationProvider.class,
+ cardinality = ReferenceCardinality.AT_LEAST_ONE,
+ policy = ReferencePolicy.DYNAMIC,
+ bind = "bindSolrServerConfigurationProvider",
+ unbind = "unbindSolrServerConfigurationProvider",
+ updated = "updatedSolrServerConfigurationProvider"
+ )
+ }
+)
+@Designate(
+ ocd = SolrServerProviderService.Configuration.class
+)
public class SolrServerProviderService implements SolrServerProvider {
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Property(options = {
- @PropertyOption(name = "none",
- value = "None"
- ),
- @PropertyOption(name = "embedded",
- value = "Embedded Solr"
- ),
- @PropertyOption(name = "remote",
- value = "Remote Solr"
- )},
- value = "none"
+ @ObjectClassDefinition(
+ id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrServerProviderService",
+ name = "Apache Jackrabbit Oak Solr server provider"
)
- private static final String SERVER_TYPE = "server.type";
+ @interface Configuration {
+ @AttributeDefinition(
+ name = "Property server.type",
+ options = {
+ @Option(value = "none",
+ label = "None"
+ ),
+ @Option(value = "embedded",
+ label = "Embedded Solr"
+ ),
+ @Option(value = "remote",
+ label = "Remote Solr"
+ )}
+ )
+ OakSolrConfiguration.ServerType server_type() default OakSolrConfiguration.ServerType.none;
+ }
+ private final Logger log = LoggerFactory.getLogger(getClass());
private final Map solrServerConfigurationProviders = new HashMap();
@@ -78,8 +95,8 @@ public class SolrServerProviderService implements SolrServerProvider {
private SolrClient cachedSolrServer;
@Activate
- protected void activate(ComponentContext context) throws Exception {
- serverType = String.valueOf(context.getProperties().get(SERVER_TYPE));
+ protected void activate(Configuration configuration) throws Exception {
+ serverType = configuration.server_type().toString();
}
@Deactivate
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java
index b7ccaa4c4b8..4dd15162c1a 100644
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java
+++ b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java
@@ -17,33 +17,49 @@
package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
import java.io.File;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Service;
+
+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.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
+
import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.ComponentContext;
/**
* An OSGi service {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider}
*/
-@Component(metatype = true, immediate = true,
- label = "Apache Jackrabbit Oak Solr embedded server configuration")
-@Service(value = SolrServerConfigurationProvider.class)
-@Property(name = "name", value = "embedded", propertyPrivate = true)
+@Component(
+ immediate = true,
+ service = { SolrServerConfigurationProvider.class }
+)
+@Designate( ocd = EmbeddedSolrServerConfigurationProvider.Configuration.class )
public class EmbeddedSolrServerConfigurationProvider implements SolrServerConfigurationProvider {
- @Property(value = SolrServerConfigurationDefaults.SOLR_HOME_PATH, label = "Solr home directory")
- private static final String SOLR_HOME_PATH = "solr.home.path";
+ @ObjectClassDefinition(
+ id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.EmbeddedSolrServerConfigurationProvider",
+ name = "Apache Jackrabbit Oak Solr embedded server configuration"
+ )
+ @interface Configuration {
+ @AttributeDefinition(
+ name = "Solr home directory"
+ )
+ String solr_home_path() default SolrServerConfigurationDefaults.SOLR_HOME_PATH;
- @Property(value = SolrServerConfigurationDefaults.CORE_NAME, label = "Solr Core name")
- private static final String SOLR_CORE_NAME = "solr.core.name";
+ @AttributeDefinition(
+ name = "Solr Core name"
+ )
+ String solr_core_name() default SolrServerConfigurationDefaults.CORE_NAME;
+
+ String name() default "embedded";
+ }
private String solrHome;
private String solrCoreName;
@@ -52,13 +68,13 @@ public class EmbeddedSolrServerConfigurationProvider implements SolrServerConfig
@Activate
- protected void activate(ComponentContext componentContext) throws Exception {
- solrHome = String.valueOf(componentContext.getProperties().get(SOLR_HOME_PATH));
+ protected void activate(Configuration configuration) throws Exception {
+ solrHome = configuration.solr_home_path();
File file = new File(solrHome);
if (!file.exists()) {
assert file.createNewFile();
}
- solrCoreName = String.valueOf(componentContext.getProperties().get(SOLR_CORE_NAME));
+ solrCoreName = configuration.solr_core_name();
solrServerConfiguration = new EmbeddedSolrServerConfiguration(solrHome, solrCoreName);
}
diff --git a/oak-solr-osgi/pom.xml b/oak-solr-osgi/pom.xml
index 5133b652e95..5570e190d80 100644
--- a/oak-solr-osgi/pom.xml
+++ b/oak-solr-osgi/pom.xml
@@ -57,14 +57,6 @@
*
*;scope=runtime;inline=true
-
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrQueryIndexProviderService.xml,
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrServerProviderService.xml,
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrIndexEditorProviderService.xml,
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.RemoteSolrServerConfigurationProvider.xml,
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.OakSolrConfigurationProviderService.xml,
- OSGI-INF/org.apache.jackrabbit.oak.plugins.index.solr.osgi.NodeStateSolrServersObserverService.xml
-