You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2021/10/28 03:29:02 UTC
[incubator-eventmesh] branch develop updated: [WIP][ISSUE #482]Add
protocol adaptor plugin (#572)
This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/develop by this push:
new 25c2515 [WIP][ISSUE #482]Add protocol adaptor plugin (#572)
25c2515 is described below
commit 25c251566d21e0ad72b6a70a8e7d5c8b5aae484b
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Thu Oct 28 11:28:55 2021 +0800
[WIP][ISSUE #482]Add protocol adaptor plugin (#572)
* Add protocol adaptor plugin
* ProtocolAdaptor deal with Package
* Remove java doc check
---
.../eventmesh-connector-rocketmq/build.gradle | 7 ---
.../eventmesh-protocol-api/build.gradle | 29 ++++------
.../eventmesh/protocol/api/ProtocolAdaptor.java | 61 ++++++++++++++++++++++
.../protocol/api/ProtocolPluginFactory.java | 55 +++++++++++++++++++
.../api/exception/ProtocolHandleException.java | 23 ++++----
.../eventmesh-protocol-cloudevents/build.gradle | 27 +++-------
.../cloudevents/CloudEventsProtocolAdaptor.java | 33 +++++++-----
.../cloudevents/CloudEventsProtocolConstant.java | 23 ++------
...g.apache.eventmesh.protocol.api.ProtocolAdaptor | 16 ++++++
.../CloudEventsProtocolAdaptorTest.java | 34 ++++++------
.../eventmesh-protocol-openmessage/build.gradle | 29 +++-------
.../openmessage/OpenMessageProtocolAdaptor.java | 36 ++++++++-----
.../openmessage/OpenMessageProtocolConstant.java | 21 ++------
...g.apache.eventmesh.protocol.api.ProtocolAdaptor | 16 ++++++
.../OpenMessageProtocolAdaptorTest.java | 35 ++++++-------
eventmesh-runtime/build.gradle | 6 ++-
.../eventmesh/spi/EventMeshExtensionType.java | 1 +
settings.gradle | 4 ++
style/checkStyle.xml | 10 +---
19 files changed, 271 insertions(+), 195 deletions(-)
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
index 52f4c31..eb722cc 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
@@ -15,13 +15,6 @@
* limitations under the License.
*/
-//apply plugin: 'java'
-////apply plugin: "maven"
-//apply plugin: "eclipse"
-//apply plugin: "idea"
-//
-//sourceCompatibility = 1.8
-
configurations {
implementation.exclude group: 'ch.qos.logback', module: 'logback-classic'
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle
similarity index 61%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle
index 786ae72..c251936 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle
@@ -15,26 +15,15 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+dependencies {
+ implementation project(":eventmesh-spi")
+ implementation project(":eventmesh-common")
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
-
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
+ implementation "io.cloudevents:cloudevents-core"
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+ testImplementation project(":eventmesh-spi")
+ testImplementation project(":eventmesh-common")
-}
+ testImplementation "io.cloudevents:cloudevents-core"
+ testImplementation "junit:junit"
+}
\ No newline at end of file
diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java
new file mode 100644
index 0000000..77ca725
--- /dev/null
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java
@@ -0,0 +1,61 @@
+/*
+ * 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.eventmesh.protocol.api;
+
+import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;
+import org.apache.eventmesh.spi.EventMeshExtensionType;
+import org.apache.eventmesh.spi.EventMeshSPI;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.v1.CloudEventV1;
+
+/**
+ * Protocol transformer SPI interface, all protocol plugin should implementation.
+ *
+ * <p>All protocol stored in EventMesh is {@link CloudEvent}.
+ *
+ * @since 1.3.0
+ */
+@EventMeshSPI(isSingleton = true, eventMeshExtensionType = EventMeshExtensionType.PROTOCOL)
+public interface ProtocolAdaptor {
+
+ /**
+ * transform protocol to {@link CloudEvent}.
+ *
+ * @param protocol input protocol
+ * @return cloud event
+ */
+ CloudEventV1 toCloudEventV1(Package protocol) throws ProtocolHandleException;
+
+
+ /**
+ * Transform {@link CloudEvent} to target protocol.
+ *
+ * @param cloudEvent clout event
+ * @return target protocol
+ */
+ Package fromCloudEventV1(CloudEventV1 cloudEvent) throws ProtocolHandleException;
+
+ /**
+ * Get protocol type.
+ *
+ * @return protocol type, protocol type should not be null
+ */
+ String getProtocolType();
+
+}
diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java
new file mode 100644
index 0000000..f9208ee
--- /dev/null
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.eventmesh.protocol.api;
+
+import org.apache.eventmesh.spi.EventMeshExtensionFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A factory to get Protocol plugin instance.
+ *
+ * @since 1.3.0
+ */
+public enum ProtocolPluginFactory {
+ ;
+
+ private static final Map<String, ProtocolAdaptor> PROTOCOL_ADAPTOR_MAP =
+ new ConcurrentHashMap<>(16);
+
+ /**
+ * Get protocol adaptor by name.
+ *
+ * @param protocolType protocol type
+ * @return protocol adaptor
+ * @throws IllegalArgumentException if protocol not found
+ */
+ public static ProtocolAdaptor getProtocolAdaptor(String protocolType) {
+ ProtocolAdaptor protocolAdaptor = PROTOCOL_ADAPTOR_MAP.computeIfAbsent(
+ protocolType,
+ (type) -> EventMeshExtensionFactory.getExtension(ProtocolAdaptor.class, type)
+ );
+ if (protocolAdaptor == null) {
+ throw new IllegalArgumentException(
+ String.format("Cannot find the Protocol adaptor: %s", protocolType)
+ );
+ }
+ return protocolAdaptor;
+ }
+}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/exception/ProtocolHandleException.java
similarity index 62%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/exception/ProtocolHandleException.java
index 786ae72..27f823a 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/exception/ProtocolHandleException.java
@@ -15,26 +15,21 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.api.exception;
/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
+ * Protocol Handle exception, will be thrown in protocol handling.
+ *
+ * @since 1.3.0
*/
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
-
- private final String extensionTypeName;
+public class ProtocolHandleException extends Exception {
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
+ public ProtocolHandleException(String message) {
+ super(message);
}
- public String getExtensionTypeName() {
- return extensionTypeName;
+ public ProtocolHandleException(String message, Throwable cause) {
+ super(message, cause);
}
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle
similarity index 61%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle
index 786ae72..4a82353 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle
@@ -15,26 +15,11 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
-
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
-
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
-
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+dependencies {
+ compileOnly project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+ implementation "io.cloudevents:cloudevents-core"
+ testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+ testImplementation "io.cloudevents:cloudevents-core"
+ testImplementation "junit:junit"
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java
similarity index 56%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java
index 786ae72..0466896 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java
@@ -15,26 +15,31 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.cloudevents;
+
+import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
+
+import io.cloudevents.core.v1.CloudEventV1;
/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
+ * CloudEvents protocol adaptor, used to transform CloudEvents message to CloudEvents message.
+ *
+ * @since 1.3.0
*/
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
+public class CloudEventsProtocolAdaptor implements ProtocolAdaptor {
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
+ @Override
+ public CloudEventV1 toCloudEventV1(Package cloudEvent) {
+ return null;
}
- public String getExtensionTypeName() {
- return extensionTypeName;
+ @Override
+ public Package fromCloudEventV1(CloudEventV1 cloudEvent) {
+ return null;
}
+ @Override
+ public String getProtocolType() {
+ return CloudEventsProtocolConstant.PROTOCOL_NAME;
+ }
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolConstant.java
similarity index 61%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolConstant.java
index 786ae72..7c26920 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolConstant.java
@@ -15,26 +15,9 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.cloudevents;
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
+public enum CloudEventsProtocolConstant {
;
-
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
-
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
-
+ public static final String PROTOCOL_NAME = "cloudevents";
}
diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor
new file mode 100644
index 0000000..7892308
--- /dev/null
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor
@@ -0,0 +1,16 @@
+# 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.
+
+cloudevents=org.apache.eventmesh.protocol.cloudevents.CloudEventsProtocolAdaptor
\ No newline at end of file
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java
similarity index 53%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java
index 786ae72..7cbb9ab 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java
@@ -15,26 +15,24 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.cloudevents;
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
+import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
+import org.apache.eventmesh.protocol.api.ProtocolPluginFactory;
- private final String extensionTypeName;
+import org.junit.Assert;
+import org.junit.Test;
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
+public class CloudEventsProtocolAdaptorTest {
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+ @Test
+ public void loadPlugin() {
+ ProtocolAdaptor protocolAdaptor =
+ ProtocolPluginFactory.getProtocolAdaptor(CloudEventsProtocolConstant.PROTOCOL_NAME);
-}
+ Assert.assertNotNull(protocolAdaptor);
+ Assert.assertEquals(
+ CloudEventsProtocolConstant.PROTOCOL_NAME, protocolAdaptor.getProtocolType());
+ Assert.assertEquals(CloudEventsProtocolAdaptor.class, protocolAdaptor.getClass());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle
similarity index 61%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle
index 786ae72..27c8997 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle
@@ -15,26 +15,13 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
-
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
-
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
-
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+dependencies {
+ compileOnly project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+ implementation "io.cloudevents:cloudevents-core"
+ implementation "io.openmessaging:openmessaging-api"
+ testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+ testImplementation "io.cloudevents:cloudevents-core"
+ testImplementation "io.openmessaging:openmessaging-api"
+ testImplementation "junit:junit"
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java
similarity index 53%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java
index 786ae72..cea3d79 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java
@@ -15,26 +15,34 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.openmessage;
+
+import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.v1.CloudEventV1;
+import io.openmessaging.api.Message;
/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
+ * OpenMessage protocol adaptor, used to transform protocol between
+ * {@link CloudEvent} with {@link Message}.
+ *
+ * @since 1.3.0
*/
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
+public class OpenMessageProtocolAdaptor implements ProtocolAdaptor {
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
+ @Override
+ public CloudEventV1 toCloudEventV1(Package message) {
+ return null;
}
- public String getExtensionTypeName() {
- return extensionTypeName;
+ @Override
+ public Package fromCloudEventV1(CloudEventV1 cloudEvent) {
+ return null;
}
+ @Override
+ public String getProtocolType() {
+ return OpenMessageProtocolConstant.PROTOCOL_NAME;
+ }
}
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolConstant.java
similarity index 61%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolConstant.java
index 786ae72..9073add 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolConstant.java
@@ -15,26 +15,11 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.openmessage;
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
+public enum OpenMessageProtocolConstant {
;
- private final String extensionTypeName;
-
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
-
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+ public static final String PROTOCOL_NAME = "openmessage";
}
diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor
new file mode 100644
index 0000000..f29201a
--- /dev/null
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor
@@ -0,0 +1,16 @@
+# 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.
+
+openmessage=org.apache.eventmesh.protocol.openmessage.OpenMessageProtocolAdaptor
\ No newline at end of file
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java
similarity index 53%
copy from eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
copy to eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java
index 786ae72..60c2eb6 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java
@@ -15,26 +15,25 @@
* limitations under the License.
*/
-package org.apache.eventmesh.spi;
+package org.apache.eventmesh.protocol.openmessage;
-/**
- * An Extension can be defined by extensionTypeName and extensionInstanceName
- */
-public enum EventMeshExtensionType {
- UNKNOWN("unknown"),
- CONNECTOR("connector"),
- REGISTRY("registry"),
- SECURITY("security"),
- ;
+import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
+import org.apache.eventmesh.protocol.api.ProtocolPluginFactory;
- private final String extensionTypeName;
+import org.junit.Assert;
+import org.junit.Test;
- EventMeshExtensionType(String extensionTypeName) {
- this.extensionTypeName = extensionTypeName;
- }
+public class OpenMessageProtocolAdaptorTest {
- public String getExtensionTypeName() {
- return extensionTypeName;
- }
+ @Test
+ public void loadPlugin() {
+ ProtocolAdaptor protocolAdaptor =
+ ProtocolPluginFactory.getProtocolAdaptor(OpenMessageProtocolConstant.PROTOCOL_NAME);
-}
+ Assert.assertNotNull(protocolAdaptor);
+ Assert.assertEquals(
+ OpenMessageProtocolConstant.PROTOCOL_NAME, protocolAdaptor.getProtocolType()
+ );
+ Assert.assertEquals(OpenMessageProtocolAdaptor.class, protocolAdaptor.getClass());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle
index 2a58e49..ebf4980 100644
--- a/eventmesh-runtime/build.gradle
+++ b/eventmesh-runtime/build.gradle
@@ -23,7 +23,7 @@ dependencies {
implementation 'io.prometheus:simpleclient'
implementation 'io.prometheus:simpleclient_httpserver'
implementation 'io.cloudevents:cloudevents-core'
-
+
implementation "org.apache.httpcomponents:httpclient"
implementation 'io.netty:netty-all'
@@ -36,6 +36,8 @@ dependencies {
implementation project(":eventmesh-registry-plugin:eventmesh-registry-api")
implementation project(":eventmesh-registry-plugin:eventmesh-registry-namesrv")
+ implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+
testImplementation project(":eventmesh-common")
testImplementation project(":eventmesh-spi")
testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
@@ -45,6 +47,8 @@ dependencies {
testImplementation project(":eventmesh-registry-plugin:eventmesh-registry-api")
testImplementation project(":eventmesh-registry-plugin:eventmesh-registry-namesrv")
+ testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
+
testImplementation "org.apache.httpcomponents:httpclient"
testImplementation "io.netty:netty-all"
diff --git a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java b/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
index 786ae72..cbe9f3e 100644
--- a/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
+++ b/eventmesh-spi/src/main/java/org/apache/eventmesh/spi/EventMeshExtensionType.java
@@ -25,6 +25,7 @@ public enum EventMeshExtensionType {
CONNECTOR("connector"),
REGISTRY("registry"),
SECURITY("security"),
+ PROTOCOL("protocol"),
;
private final String extensionTypeName;
diff --git a/settings.gradle b/settings.gradle
index e28efc9..a87e068 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -33,4 +33,8 @@ include 'eventmesh-registry-plugin:eventmesh-registry-namesrv'
include 'eventmesh-admin'
include 'eventmesh-schema-registry'
include 'eventmesh-schema-registry:eventmesh-schema-registry-server'
+include 'eventmesh-protocol-plugin'
+include 'eventmesh-protocol-plugin:eventmesh-protocol-api'
+include 'eventmesh-protocol-plugin:eventmesh-protocol-openmessage'
+include 'eventmesh-protocol-plugin:eventmesh-protocol-cloudevents'
diff --git a/style/checkStyle.xml b/style/checkStyle.xml
index 8c0a35d..9e86d55 100644
--- a/style/checkStyle.xml
+++ b/style/checkStyle.xml
@@ -336,18 +336,10 @@
<property name="allowedAnnotations" value="Override, Test"/>
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
</module>
- <module name="MissingJavadocMethod">
- <property name="scope" value="public"/>
- <property name="minLineCount" value="2"/>
- <property name="allowedAnnotations" value="Override, Test"/>
- <property name="tokens" value="METHOD_DEF,
- COMPACT_CTOR_DEF"/>
- </module>
<module name="MissingJavadocType">
<property name="scope" value="protected"/>
<property name="tokens"
- value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
- RECORD_DEF, ANNOTATION_DEF"/>
+ value="INTERFACE_DEF"/>
<property name="excludeScope" value="nothing"/>
</module>
<module name="MethodName">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org