Github user bbende commented on a diff in the pull request: https://github.com/apache/nifi-minifi/pull/120#discussion_r177763765 --- Diff: minifi-c2/minifi-c2-framework/src/main/java/org/apache/nifi/minifi/c2/api/provider/device/DevicePersistenceProvider.java --- @@ -0,0 +1,78 @@ +/* + * 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.api.provider.device; + +import org.apache.nifi.minifi.c2.api.provider.Provider; +import org.apache.nifi.minifi.c2.model.Device; + +import java.util.List; +import java.util.Optional; + +/** + * NOTE: Although this interface is intended to be an extension point, it is not yet considered stable and thus may + * change across releases until the the C2 Server APIs mature. + * + * TODO, we may want to consider creating a separate entity model rather than reusing the REST API object model. + * Currently, this design assumes the Provider implementation will do that translation. + * This requires adding a dependency on minifi-c2-commons here for the data model. + */ +public interface DevicePersistenceProvider extends Provider { --- End diff -- Would it make sense to have a base interface kind of like the Spring Data repositories, something like: ``` interface PersistenceProvider<T> { long getCount(); T save(T t); List<T> getAll(); Optional<T> get(String id); void delete(T t); } ``` Then some of the interfaces just become empty: ``` interface DevicePersistenceProvider extends PersistenceProvider<Device> { // add any specific methods that only make sense for devices } ``` The only case where it doesn't fully work is the AgentPersistenceProvider which has the CRUD operations for multiple domain objects in a single interface, which makes sense to enforce that they are persisted to the same provider. Maybe that interface could provider sub-services for each domain type? ``` interface AgentPersistenceProvider { PersistenceProvider<AgentClass> getAgentClassPersistenceProvider(); PersistenceProvider<AgentManifest> getAgentManifestPersistenceProvider(); PersistenceProvider<Agent> getAgentPersistenceProvider(); } ``` So the only pluggable provider is the top-level AgentPersistenceProvider, but then it is up to that provider to provider implementations of the sub-providers. Feel free to tell me this makes no sense, just throwing out ideas.
---