simonbence commented on a change in pull request #5356: URL: https://github.com/apache/nifi/pull/5356#discussion_r725000059
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/StatusHistoryRepositoryFactory.java ########## @@ -0,0 +1,51 @@ +/* + * 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.nifi.controller.status.history; + +import org.apache.nifi.controller.status.history.exception.MissingStatusHistoryImplementationException; +import org.apache.nifi.nar.ExtensionManager; +import org.apache.nifi.nar.NarThreadContextClassLoader; +import org.apache.nifi.util.NiFiProperties; + +public class StatusHistoryRepositoryFactory { Review comment: Minor: it would worth to make this final to prevent inheritance ########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StatusHistoryRepositoryFactoryBean.java ########## @@ -61,8 +44,8 @@ public StatusHistoryRepository getObject() throws Exception { } @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; + public void setApplicationContext(ApplicationContext applicationContext) { Review comment: It would be better to actually remove this method. If you remove `ApplicationContextAware` from the implemented interfaces, you can remove this as well. It should work and does work (I tried it and it looks working properly) ########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/StatusHistoryRepositoryFactory.java ########## @@ -0,0 +1,51 @@ +/* + * 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.nifi.controller.status.history; + +import org.apache.nifi.controller.status.history.exception.MissingStatusHistoryImplementationException; +import org.apache.nifi.nar.ExtensionManager; +import org.apache.nifi.nar.NarThreadContextClassLoader; +import org.apache.nifi.util.NiFiProperties; + +public class StatusHistoryRepositoryFactory { + + private StatusHistoryRepositoryFactory() { + // factory class, not to instantiate + } + + private static final String DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION = "org.apache.nifi.controller.status.history.VolatileComponentStatusRepository"; + + public static StatusHistoryRepository createStatusHistoryRepositoryFactory(final NiFiProperties nifiProperties, final ExtensionManager extensionManager) { + final String implementationClassName = nifiProperties.getProperty(NiFiProperties.COMPONENT_STATUS_REPOSITORY_IMPLEMENTATION, DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION); + if (implementationClassName == null) { + throw new MissingStatusHistoryImplementationException( Review comment: Maybe an `IllegalArgumentException` would be enough here (I am not sure this would worth to introduce a new exception type) Note: in the original code ther was a simple `RuntimeException` but in retropsect, IAE would be more precise. -- 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]
