davsclaus commented on code in PR #28086:
URL: https://github.com/apache/camel/pull/28086#discussion_r4311715817
##########
components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreComponent.java:
##########
@@ -68,9 +74,15 @@ KeyValueRepository getOrCreateBackend(String storeName,
KeyValueRepository expli
return explicitBackend;
}
return backends.computeIfAbsent(storeName, k -> {
+ KeyValueRepository backend = backendFactory != null ?
backendFactory.createBackend(storeName) : null;
Review Comment:
Optional, not blocking: the component already logs a WARN when it finds more
than one `KeyValueRepository` and cannot pick one. The same case for factories
is silent: `doAutoWire` uses `findSingleByType` and logs only on a hit, which
the new NOTE in the docs says. A WARN here would make the two cases behave
alike, for example in `doInit()`:
```java
@Override
protected void doInit() throws Exception {
super.doInit();
if (backendFactory == null) {
int count =
getCamelContext().getRegistry().findByType(StateStoreBackendFactory.class).size();
if (count > 1) {
LOG.warn("Found {} StateStoreBackendFactory instances in the
registry. None is autowired;"
+ " set the backendFactory option to choose one.",
count);
}
}
}
```
Then `StateStoreBackendFactoryAmbiguousTest` could also check the log, and
the docs NOTE could drop "silently".
##########
components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreBackendFactory.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.camel.component.statestore;
+
+import org.apache.camel.spi.KeyValueRepository;
+
+/**
+ * Creates the {@link KeyValueRepository} backend for a given state store name.
+ * <p/>
+ * Use this when each store name should map to its own backend instance, for
example a separate cache per store. The
+ * returned backend is owned by the {@link StateStoreComponent}, which starts
and stops it.
+ *
+ * @since 4.24
+ */
+@FunctionalInterface
+public interface StateStoreBackendFactory {
+
+ /**
+ * Creates the backend for the given store name.
+ *
+ * @param storeName the name of the state store, as used in the endpoint
URI
+ * @return the backend for the store, or <tt>null</tt> to fall
back to the default backend resolution
Review Comment:
Nit: `<tt>` is not valid HTML5 in Javadoc.
```suggestion
* @return the backend for the store, or {@code null} to fall
back to the default backend resolution
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]