diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle new file mode 100644 index 0000000000..4a82353e6e --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle @@ -0,0 +1,25 @@ +/* + * 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. + */ + +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-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties new file mode 100644 index 0000000000..07476be28a --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties @@ -0,0 +1,18 @@ +# 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. +# + +pluginType=protocol +pluginName=eventmeshmessage \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java similarity index 76% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolAdaptor.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java index 4b8eeefa23..378114715c 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -15,31 +15,32 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage; +package org.apache.eventmesh.protocol.meshmessage; import io.cloudevents.CloudEvent; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.ProtocolTransportObject; import org.apache.eventmesh.common.command.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; -import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageBatchProtocolResolver; -import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageBatchV2ProtocolResolver; -import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageRequestProtocolResolver; -import org.apache.eventmesh.protocol.eventmeshmessage.resolver.tcp.TcpMessageProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchV2ProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageRequestProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.tcp.TcpMessageProtocolResolver; import java.nio.charset.StandardCharsets; import java.util.List; -public class EventMeshMessageProtocolAdaptor implements ProtocolAdaptor { +public class MeshMessageProtocolAdaptor + implements ProtocolAdaptor { @Override - public CloudEvent toCloudEvent(T protocol) throws ProtocolHandleException { + public CloudEvent toCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { if (protocol instanceof Package) { Header header = ((Package) protocol).getHeader(); Object body = ((Package) protocol).getBody(); @@ -78,16 +79,18 @@ private CloudEvent deserializeHttpProtocol(String requestCode, org.apache.eventm } @Override - public List toBatchCloudEvent(T protocol) throws ProtocolHandleException { + public List toBatchCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { return null; } @Override - public Object fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { + public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); if (StringUtils.equals("http", protocolDesc)) { - return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8); + // todo: return command, set cloudEvent.getData() to content? + return null; +// return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8); } else if (StringUtils.equals("tcp", protocolDesc)) { return TcpMessageProtocolResolver.buildEventMeshMessage(cloudEvent); } else { @@ -97,6 +100,6 @@ public Object fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleExcepti @Override public String getProtocolType() { - return EventMeshMessageProtocolConstant.PROTOCOL_NAME; + return MeshMessageProtocolConstant.PROTOCOL_NAME; } } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolConstant.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java similarity index 89% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolConstant.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java index f1c744fe24..0a667f63f0 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/EventMeshMessageProtocolConstant.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage; +package org.apache.eventmesh.protocol.meshmessage; -public enum EventMeshMessageProtocolConstant { +public enum MeshMessageProtocolConstant { ; public static final String PROTOCOL_NAME = "eventmeshmessage"; } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java similarity index 94% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchProtocolResolver.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java index 9c8203837c..cd8f8179e7 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http; +package org.apache.eventmesh.protocol.meshmessage.resolver.http; import io.cloudevents.CloudEvent; import org.apache.eventmesh.common.protocol.http.body.Body; diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java similarity index 96% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java index adc1e7e0b9..6e2ad28140 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java @@ -15,13 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http; +package org.apache.eventmesh.protocol.meshmessage.resolver.http; import io.cloudevents.CloudEvent; import io.cloudevents.SpecVersion; import io.cloudevents.core.builder.CloudEventBuilder; -import io.cloudevents.core.v03.CloudEventV03; -import io.cloudevents.core.v1.CloudEventV1; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; @@ -29,8 +27,6 @@ import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; import org.apache.eventmesh.common.protocol.http.header.Header; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; -import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; import java.nio.charset.StandardCharsets; diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageRequestProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java similarity index 97% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageRequestProtocolResolver.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java index 40e2e9f5cb..9abbdaf7ce 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/http/SendMessageRequestProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java @@ -15,13 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http; +package org.apache.eventmesh.protocol.meshmessage.resolver.http; import io.cloudevents.CloudEvent; import io.cloudevents.SpecVersion; import io.cloudevents.core.builder.CloudEventBuilder; -import io.cloudevents.core.v03.CloudEventV03; -import io.cloudevents.core.v1.CloudEventV1; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; @@ -30,7 +28,6 @@ import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; import org.apache.eventmesh.common.protocol.http.header.Header; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; -import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; import java.nio.charset.StandardCharsets; diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/tcp/TcpMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java similarity index 94% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/tcp/TcpMessageProtocolResolver.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java index 38faf38718..623575941b 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/java/org/apache/eventmesh/protocol/eventmeshmessage/resolver/tcp/TcpMessageProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.protocol.eventmeshmessage.resolver.tcp; +package org.apache.eventmesh.protocol.meshmessage.resolver.tcp; import io.cloudevents.CloudEvent; import io.cloudevents.SpecVersion; @@ -26,7 +26,7 @@ import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; -import org.apache.eventmesh.protocol.eventmeshmessage.EventMeshMessageProtocolConstant; +import org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolConstant; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -50,7 +50,7 @@ public static CloudEvent buildEvent(Header header, Object body) throws ProtocolH protocolType, protocolVersion, protocolDesc)); } - if (!StringUtils.equals(EventMeshMessageProtocolConstant.PROTOCOL_NAME, protocolType)) { + if (!StringUtils.equals(MeshMessageProtocolConstant.PROTOCOL_NAME, protocolType)) { throw new ProtocolHandleException(String.format("Unsupported protocolType: %s", protocolType)); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor similarity index 89% rename from eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor index 9be39ede56..45ffc15eac 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-eventmeshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF.eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -eventmeshmessage=org.apache.eventmesh.protocol.eventmeshmessage.EventMeshMessageProtocolAdaptor \ No newline at end of file +eventmeshmessage=org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolAdaptor \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 787313b998..0606b2e0d6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -37,5 +37,5 @@ 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' -include 'eventmesh-protocol-plugin:eventmesh-protocol-eventmeshmessage' +include 'eventmesh-protocol-plugin:eventmesh-protocol-meshmessage'