keith-turner commented on a change in pull request #1715:
URL: https://github.com/apache/accumulo/pull/1715#discussion_r511176220



##########
File path: 
core/src/main/java/org/apache/accumulo/core/spi/common/ContextClassLoaderFactory.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.accumulo.core.spi.common;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * The ClassLoaderFactory is defined by the property general.context.factory. 
The factory
+ * implementation is configured externally to Accumulo and will return a 
ClassLoader for a given
+ * contextName.
+ *
+ * @since 2.1.0
+ *
+ */
+public interface ContextClassLoaderFactory {
+
+  /**
+   * Initialize the ClassLoaderFactory. Implementations may need a reference 
to the configuration so
+   * that it can clean up contexts that are no longer being used.
+   *
+   * @param contextProperties
+   *          Accumulo configuration properties
+   * @throws Exception
+   *           if error initializing ClassLoaderFactory
+   */
+  void initialize(Supplier<Map<String,String>> contextProperties) throws 
Exception;

Review comment:
       The following are the rational behind the suggestion below.
    * Using a parameters interface makes evolving the SPI over time much 
simpler.  Its easy to add additional parameters in the future w/o breaking 
existing code that was written against the SPI.
    * Using the 
[Configuration](https://github.com/apache/accumulo/blob/353c611891a8b88b307dcba5e884467d4191b1f2/core/src/main/java/org/apache/accumulo/core/spi/common/ServiceEnvironment.java#L40)
 interface used by other SPI interface is consistent and offers more options.  
For example this interface offers an isSet() method that allows checking if a 
user set a property.  There is no way to do this by analyzing the values 
because some props have default values.
   
   ```suggestion
     public interface InitParameters {
         /**
      * @return A view of Accumulo's system level configuration. This is backed 
by system level config
      *         in zookeeper, which falls back to site configuration, which 
falls back to the default
      *         configuration.
      */
       Configuration getConfiguration();
     }
   
     /**
      * Initialize the ClassLoaderFactory. Implementations may need a reference 
to the configuration so
      * that it can clean up contexts that are no longer being used.
      *
      * @throws Exception
      *           if error initializing ClassLoaderFactory
      */
     void initialize(InitParameters initParam) throws Exception;
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to