Github user kevdoran commented on a diff in the pull request:
https://github.com/apache/nifi-minifi/pull/119#discussion_r176803697
--- Diff:
minifi-c2/minifi-c2-framework/src/main/java/org/apache/nifi/minifi/c2/core/service/flow/client/NiFiRegistryClientFactory.java
---
@@ -0,0 +1,126 @@
+/*
+ * 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.minifi.c2.core.service.flow.client;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
+import org.apache.nifi.minifi.c2.properties.C2Properties;
+import org.apache.nifi.registry.client.NiFiRegistryClient;
+import org.apache.nifi.registry.client.NiFiRegistryClientConfig;
+import org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient;
+import org.apache.nifi.registry.security.util.KeystoreType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class does not follow the typical "factory bean" pattern of having
a method annotated with @Bean because
+ * we want to support running a C2 server that may not be configured to do
flow deployments, which means we don't want
+ * to create a NiFiRegistryClient during start-up because the registry URL
may not be populated.
+ *
+ * An instance of this class can be injected into other services that need
a NiFiRegistryClient, and if those services
+ * get called then they can use this class to lazily obtain an instance,
which can then throw an exception if the
+ * appropriate configuration is not provided.
+ */
+@Component
+public class NiFiRegistryClientFactory {
+
+ private volatile NiFiRegistryClient client;
+
+ private final C2Properties c2Properties;
+
+ @Autowired
+ public NiFiRegistryClientFactory(final C2Properties c2Properties) {
+ this.c2Properties = c2Properties;
+ Validate.notNull(this.c2Properties);
--- End diff --
This is minor, but I think \@ Autowired beans are validated to be not null
by default, unless annotated with \@ Nullable, right?
---