|
| 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