diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/build.gradle.kts b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/build.gradle.kts new file mode 100644 index 00000000000..c2d10c5970b --- /dev/null +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Fraunhofer Institute for Software and Systems Engineering - initial API and implementation + * + */ + +plugins { + `java-library` +} + +dependencies { + api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-spi")) + api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-transform")) + api(project(":data-protocols:dsp:dsp-http-core")) + api(project(":data-protocols:dsp:dsp-http-spi")) + api(project(":extensions:common:json-ld")) + api(project(":spi:control-plane:contract-spi")) + + api(libs.jakartaJson) +} \ No newline at end of file diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java new file mode 100644 index 00000000000..0255aa931ca --- /dev/null +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Fraunhofer Institute for Software and Systems Engineering - initial API and implementation + * + */ + +package org.eclipse.edc.protocol.dsp.negotiation.dispatcher; + +import org.eclipse.edc.jsonld.transformer.JsonLdTransformerRegistry; +import org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate.ContractAgreementMessageDelegate; +import org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate.ContractAgreementVerificationMessageDelegate; +import org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate.ContractNegotiationEventMessageDelegate; +import org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate.ContractOfferRequestDelegate; +import org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate.ContractRejectionHttpDelegate; +import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpRemoteMessageDispatcher; +import org.eclipse.edc.runtime.metamodel.annotation.Extension; +import org.eclipse.edc.runtime.metamodel.annotation.Inject; +import org.eclipse.edc.spi.system.ServiceExtension; +import org.eclipse.edc.spi.system.ServiceExtensionContext; +import org.eclipse.edc.spi.types.TypeManager; + +import static org.eclipse.edc.jsonld.JsonLdExtension.TYPE_MANAGER_CONTEXT_JSON_LD; + +@Extension(value = DspNegotiationHttpDispatcherExtension.NAME) +public class DspNegotiationHttpDispatcherExtension implements ServiceExtension { + + public static final String NAME = "Dataspace Protocol Negotiation HTTP Dispatcher Extension"; + + @Inject + private DspHttpRemoteMessageDispatcher messageDispatcher; + @Inject + private TypeManager typeManager; + @Inject + private JsonLdTransformerRegistry transformerRegistry; + + @Override + public String name() { + return NAME; + } + + @Override + public void initialize(ServiceExtensionContext context) { + var objectMapper = typeManager.getMapper(TYPE_MANAGER_CONTEXT_JSON_LD); + + messageDispatcher.registerDelegate(new ContractAgreementMessageDelegate(objectMapper, transformerRegistry)); + messageDispatcher.registerDelegate(new ContractAgreementVerificationMessageDelegate(objectMapper, transformerRegistry)); + messageDispatcher.registerDelegate(new ContractNegotiationEventMessageDelegate(objectMapper, transformerRegistry)); + messageDispatcher.registerDelegate(new ContractOfferRequestDelegate(objectMapper, transformerRegistry)); + messageDispatcher.registerDelegate(new ContractRejectionHttpDelegate(objectMapper, transformerRegistry)); + } +} diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension new file mode 100644 index 00000000000..e0121021b66 --- /dev/null +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension @@ -0,0 +1,15 @@ +# +# Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Contributors: +# Fraunhofer Institute for Software and Systems Engineering - Initial API and Implementation +# +# + +org.eclipse.edc.protocol.dsp.negotiation.dispatcher.DspNegotiationHttpDispatcherExtension \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 94b051f92d3..8035dc32005 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -68,6 +68,7 @@ include(":data-protocols:dsp:dsp-catalog:dsp-catalog-http-dispatcher") include(":data-protocols:dsp:dsp-catalog:dsp-catalog-spi") include(":data-protocols:dsp:dsp-catalog:dsp-catalog-transform") include(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-transform") +include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-http-dispatcher") include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-spi") include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-transform") include(":data-protocols:dsp:dsp-http-core")