You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2023/01/11 14:47:11 UTC
[plc4x] 03/04: feat(plc4j/api): Introduced a new PlcConnectionManager interface, which just contains the getConnection variants in preparation of building a drop-in replacement plc-connection cache.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/cdutz/connection-cache-and-scraper-ng
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit b01d1fbebf5bac1ae126263b491b98368a2ce0ec
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Jan 11 15:46:22 2023 +0100
feat(plc4j/api): Introduced a new PlcConnectionManager interface, which just contains the getConnection variants in preparation of building a drop-in replacement plc-connection cache.
---
.../org/apache/plc4x/java/PlcDriverManager.java | 3 +-
.../plc4x/java/api/PlcConnectionManager.java | 45 ++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/PlcDriverManager.java b/plc4j/api/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
index 1514b4c080..5c25b61d0d 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java;
import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.java.api.PlcConnectionManager;
import org.apache.plc4x.java.api.authentication.PlcAuthentication;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.PlcDriver;
@@ -32,7 +33,7 @@ import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
-public class PlcDriverManager {
+public class PlcDriverManager implements PlcConnectionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(PlcDriverManager.class);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnectionManager.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnectionManager.java
new file mode 100644
index 0000000000..98511ad75a
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnectionManager.java
@@ -0,0 +1,45 @@
+/*
+ * 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
+ *
+ * https://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.plc4x.java.api;
+
+import org.apache.plc4x.java.api.authentication.PlcAuthentication;
+import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+
+public interface PlcConnectionManager {
+
+ /**
+ * Connects to a PLC using the given plc connection string.
+ *
+ * @param url plc connection string.
+ * @return PlcConnection object.
+ * @throws PlcConnectionException an exception if the connection attempt failed.
+ */
+ PlcConnection getConnection(String url) throws PlcConnectionException;
+
+ /**
+ * Connects to a PLC using the given plc connection string using given authentication credentials.
+ *
+ * @param url plc connection string.
+ * @param authentication authentication credentials.
+ * @return PlcConnection object.
+ * @throws PlcConnectionException an exception if the connection attempt failed.
+ */
+ PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException;
+
+}