Skip to content

Commit 2909047

Browse files
authored
feat: contract negotiation and transfer process task executor (#5617)
1 parent 2fdcc1d commit 2909047

27 files changed

Lines changed: 1803 additions & 120 deletions

File tree

core/common/task-core/src/main/java/org/eclipse/edc/controlplane/tasks/TaskTypes.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
package org.eclipse.edc.controlplane.tasks;
1616

17-
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.AcceptNegotiation;
1817
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.AgreeNegotiation;
1918
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.FinalizeNegotiation;
20-
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.OfferNegotiation;
2119
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.RequestNegotiation;
2220
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.SendAccept;
2321
import org.eclipse.edc.controlplane.contract.spi.negotiation.tasks.SendAgreement;
@@ -47,10 +45,8 @@ public class TaskTypes {
4745
public static final List<Class<?>> TYPES = List.of(
4846
RequestNegotiation.class,
4947
SendRequestNegotiation.class,
50-
AcceptNegotiation.class,
5148
SendAccept.class,
5249
AgreeNegotiation.class,
53-
OfferNegotiation.class,
5450
SendAgreement.class,
5551
SendOffer.class,
5652
SendTerminateNegotiation.class,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
plugins {
16+
`java-library`
17+
}
18+
19+
dependencies {
20+
api(project(":spi:common:task-spi"))
21+
api(project(":spi:common:transaction-spi"))
22+
api(project(":spi:control-plane:contract-spi"))
23+
implementation(libs.opentelemetry.instrumentation.annotations)
24+
testImplementation(project(":core:control-plane:control-plane-contract"))
25+
testImplementation(project(":core:common:lib:state-machine-lib"))
26+
27+
}
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2026 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.controlplane.contract.negotiation.tasks;
16+
17+
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.ContractNegotiationPendingGuard;
18+
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.NegotiationProcessors;
19+
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.observe.ContractNegotiationObservable;
20+
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.store.ContractNegotiationStore;
21+
import org.eclipse.edc.controlplane.contract.negotiation.tasks.executor.ContractNegotiationTaskExecutorImpl;
22+
import org.eclipse.edc.controlplane.contract.negotiation.tasks.listener.ContractNegotiationStateListener;
23+
import org.eclipse.edc.controlplane.contract.spi.negotiation.ContractNegotiationTaskExecutor;
24+
import org.eclipse.edc.controlplane.tasks.TaskService;
25+
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
26+
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
27+
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
28+
import org.eclipse.edc.spi.monitor.Monitor;
29+
import org.eclipse.edc.spi.system.ServiceExtension;
30+
import org.eclipse.edc.spi.system.ServiceExtensionContext;
31+
import org.eclipse.edc.transaction.spi.TransactionContext;
32+
33+
import java.time.Clock;
34+
35+
import static org.eclipse.edc.controlplane.contract.negotiation.tasks.ContractNegotiationTaskExtension.NAME;
36+
37+
@Extension(NAME)
38+
public class ContractNegotiationTaskExtension implements ServiceExtension {
39+
40+
public static final String NAME = "Contract Negotiation Task Extension";
41+
@Inject
42+
private ContractNegotiationStore contractNegotiationStore;
43+
@Inject
44+
private TransactionContext transactionContext;
45+
@Inject
46+
private ContractNegotiationPendingGuard pendingGuard;
47+
@Inject
48+
private Monitor monitor;
49+
@Inject
50+
private TaskService taskService;
51+
@Inject
52+
private NegotiationProcessors negotiationProcessors;
53+
@Inject
54+
private Clock clock;
55+
@Inject
56+
private ContractNegotiationObservable contractNegotiationObservable;
57+
58+
59+
@Override
60+
public void initialize(ServiceExtensionContext context) {
61+
contractNegotiationObservable.registerListener(new ContractNegotiationStateListener(taskService, clock));
62+
}
63+
64+
@Provider
65+
public ContractNegotiationTaskExecutor contractNegotiationTaskExecutor() {
66+
return ContractNegotiationTaskExecutorImpl.Builder.newInstance()
67+
.taskService(taskService)
68+
.negotiationProcessors(negotiationProcessors)
69+
.clock(clock)
70+
.store(contractNegotiationStore)
71+
.transactionContext(transactionContext)
72+
.pendingGuard(pendingGuard)
73+
.monitor(monitor)
74+
.build();
75+
}
76+
}

0 commit comments

Comments
 (0)