gerlowskija commented on code in PR #1778:
URL: https://github.com/apache/solr/pull/1778#discussion_r1274929708


##########
solr/core/src/java/org/apache/solr/core/PluginBag.java:
##########
@@ -288,6 +294,20 @@ public PluginHolder<T> put(String name, PluginHolder<T> 
plugin) {
     return old;
   }
 
+  static final class APIConfigProviderBinder extends AbstractBinder {

Review Comment:
   [-0] It might be better to have this live as a public class in 
`org.apache.solr.jersey`.  I couldn't avoid dragging some JAX-RS/api logic into 
PluginBag, but IMO the less that lives in here the better.  



##########
solr/core/src/java/org/apache/solr/core/PluginBag.java:
##########
@@ -288,6 +294,20 @@ public PluginHolder<T> put(String name, PluginHolder<T> 
plugin) {
     return old;
   }
 
+  static final class APIConfigProviderBinder extends AbstractBinder {
+
+    private final APIConfigProvider<?> cfgProvider;
+
+    public APIConfigProviderBinder(APIConfigProvider<?> cfgProvider) {
+      this.cfgProvider = cfgProvider;
+    }
+
+    @Override
+    protected void configure() {
+      bindFactory(cfgProvider).to(cfgProvider.getConfigClass());

Review Comment:
   [Q] In HK2 you can set a "scope" for bindings, that impacts how often 
factories are asked to produce a new instance.  e.g. We have a few bindings in 
`JerseyApplications` that are `RequestScoped` - meaning that Jersey prompts the 
factory on each API call.
   
   In the case of these config objects - I think right now we expect them to be 
driven by solrconfig.xml config, which should be static through the life of the 
Jersey application.  Tbh I forget what "scope" is used as a default when no 
explicit value is provided, but we should make sure it fits this expectations.  
It'd prob be wasteful if each API call triggered `provide()`, returning a 
functionally equivalent object each time.



##########
solr/core/src/test/org/apache/solr/core/PluginBagTest.java:
##########
@@ -90,4 +102,66 @@ public void 
testRegistersJerseyResourcesAssociatedWithRequestHandlers() {
 
     
assertTrue(handlerPluginBag.getJerseyEndpoints().isRegistered(ListConfigSetsAPI.class));
   }
+
+  @Test
+  public void testApiConfig() {

Review Comment:
   [+1] Idk that I would've gone through this effort 😛 Great test!



##########
solr/core/src/java/org/apache/solr/handler/admin/api/APIConfigProvider.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.solr.handler.admin.api;
+
+import org.apache.solr.handler.admin.api.APIConfigProvider.APIConfig;
+import org.glassfish.hk2.api.Factory;
+
+/**
+ * Interface to be implemented by the Request Handlers that need to provide 
some custom

Review Comment:
   [Q] Could v2 API classes that are unaffiliated with any request handler 
implement this interface, or does this only work with RequestHandler's for now? 
 (Either is fine; just trying to understand.)
   
   [-0] I don't feel strongly, but maybe this interface should live in 
`o.a.s.jersey`, since it's pretty tied in to JAX-RS/Jersey.



##########
solr/core/src/test/org/apache/solr/core/PluginBagTest.java:
##########
@@ -90,4 +102,66 @@ public void 
testRegistersJerseyResourcesAssociatedWithRequestHandlers() {
 
     
assertTrue(handlerPluginBag.getJerseyEndpoints().isRegistered(ListConfigSetsAPI.class));
   }
+
+  @Test
+  public void testApiConfig() {

Review Comment:
   [+1] Idk that I would've gone through this effort 😛 Great test!



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to