exceptionfactory commented on code in PR #26:
URL: https://github.com/apache/nifi-api/pull/26#discussion_r2481782120


##########
src/main/java/org/apache/nifi/components/listen/ListenPort.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.components.listen;
+
+import java.util.List;
+
+/**
+ * Represents a dynamically discoverable ingress port provided by a {@link 
ListenComponent}.
+ */
+public interface ListenPort {
+
+    /**
+     * Get The operating system numbered port that is listening for network 
traffic.
+     *
+     * @return the port number
+     */
+    int getPortNumber();
+
+    /**
+     * Get the layer 4 transport protocol that is used at the OS networking 
level for this port.
+     *
+     * @return the transport protocol
+     */
+    TransportProtocol getTransportProtocol();
+
+    /**
+     * Get the currently configured application protocol(s) that this port 
supports.

Review Comment:
   ```suggestion
        * Get the currently configured application protocols that this port 
supports.
   ```



##########
src/main/java/org/apache/nifi/components/listen/ListenComponent.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.components.listen;
+
+import org.apache.nifi.controller.ConfigurationContext;
+
+import java.util.List;
+
+/**
+ * An extension component (e.g., Processor or ControllerService) that creates 
one or more ingress network ports.
+ * <p>
+ *   Implementing this interface allows {@link ListenPort}s provided by this 
component to be dynamically discoverable by the framework.
+ * </p>
+ * <p>
+ *   Typically, components implementing this interface should have at least 
one property described using a {@link 
org.apache.nifi.components.PropertyDescriptor}
+ *   that identifies a {@link ListenPortDefinition}. The Property Descriptor 
identifies a possible Listen Port that could be created.
+ *   This interface provides actual the port(s) configured based on component 
property values, along with additional ingress metadata.
+ * </p>
+ */
+public interface ListenComponent {
+
+    /**
+     * A list of listen ports provided by this component based on its current 
configuration.
+     *
+     * @param context provides access to convenience methods for obtaining 
property values
+     * @return one or more listen ports that are actively configured to be 
provided by this component.

Review Comment:
   Is an empty List valid? If so, would recommend changing this to "zero or 
more..."



##########
src/main/java/org/apache/nifi/components/listen/StandardListenPortDefinition.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.components.listen;
+
+import org.apache.nifi.components.PropertyDescriptor;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a Listen Port definition for a {@link PropertyDescriptor} that 
specifies a listen port
+ */
+public class StandardListenPortDefinition implements ListenPortDefinition {
+
+    private final TransportProtocol transportProtocol;
+    private final List<String> applicationProtocols;
+
+    /**
+     * Create a {@link ListenPortDefinition}.
+     *
+     * @param transportProtocol - the layer 4 transport protocol used by the 
listen port
+     * @param applicationProtocols - if applicable, one or more application 
protocols supported by the listen port

Review Comment:
   I recommend requiring this argument to be non-null, instead of the 
transparent null handling and default to empty list.



##########
src/main/java/org/apache/nifi/components/listen/StandardListenPort.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.components.listen;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class StandardListenPort implements ListenPort {
+
+    private final int portNumber;
+    private final TransportProtocol transportProtocol;
+    private final List<String> applicationProtocols;
+
+    private StandardListenPort(final Builder builder) {
+        Objects.requireNonNull(builder.transportProtocol, "Transport protocol 
is required");
+        Objects.requireNonNull(builder.applicationProtocols, "Application 
protocols is required. Use empty list if there are no application protocols.");
+
+        this.portNumber = builder.portNumber;
+        this.transportProtocol = builder.transportProtocol;
+        this.applicationProtocols = builder.applicationProtocols;
+    }
+
+    @Override
+    public int getPortNumber() {
+        return portNumber;
+    }
+
+    @Override
+    public TransportProtocol getTransportProtocol() {
+        return transportProtocol;
+    }
+
+    @Override
+    public List<String> getApplicationProtocols() {
+        return applicationProtocols;
+    }
+
+    @Override
+    public String toString() {
+        return "StandardListenPort{" +
+            "portNumber=" + portNumber +
+            ", transportProtocol=" + transportProtocol +
+            ", applicationProtocols=" + applicationProtocols +
+            '}';

Review Comment:
   Recommend using `"...".formatted()` for improved readability over the 
concatenation.



##########
src/main/java/org/apache/nifi/components/listen/ListenPort.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.components.listen;
+
+import java.util.List;
+
+/**
+ * Represents a dynamically discoverable ingress port provided by a {@link 
ListenComponent}.
+ */
+public interface ListenPort {
+
+    /**
+     * Get The operating system numbered port that is listening for network 
traffic.
+     *
+     * @return the port number
+     */
+    int getPortNumber();
+
+    /**
+     * Get the layer 4 transport protocol that is used at the OS networking 
level for this port.
+     *
+     * @return the transport protocol
+     */
+    TransportProtocol getTransportProtocol();
+
+    /**
+     * Get the currently configured application protocol(s) that this port 
supports.
+     * <p>
+     *   Note that this is not always the same as the application protocols 
that could be supported. For example, if this port could support http/1.1 or h2 
(HTTP 2),
+     *   but is currently configured to require h2, then this method should 
return [h2], not [http1.1, h2].
+     * </p>
+     * <p>
+     *   See {@link ListenPortDefinition#getApplicationProtocols()} for 
guidance on application protocol string values.
+     *   This method should return a subset of application protocol values 
specified by the corresponding PropertyDescriptor {@link ListenPortDefinition}.
+     * </p>
+     *
+     * @return the application protocol(s) supported by this listen port, if 
applicable; otherwise an empty list.

Review Comment:
   Very minor, but recommend removing the parentheses since the plural implies 
one or more.
   ```suggestion
        * @return the application protocols supported by this listen port, if 
applicable; otherwise an empty list.
   ```



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

Reply via email to