-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2890] Update the new portal version before sending notifications
Rework the PortalEventProcessor and IPortalEventHandler so that: * handlers only compute the response (which makes them simpler); * the PortalEventProcessor handles the response by always updating/saving the new portal version (if there is one) before emiting notifications. This ensures that "downstream" representations like the Representations view see the correct, updated version of the Portal when the notification triggers their own refresh. This also centralizes the technical details about handling reactive streams correctly (instead of counting on each and every handler to e.g. always publish exactly one payload in all their code paths), and allows for "middleware" handlers like the example CountingHandler to be written once and apply to all handlers. Bug: #2890 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
- Loading branch information
Showing
15 changed files
with
249 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...rg/eclipse/sirius/components/collaborative/portals/PortalEventProcessorConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.portals; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.sirius.components.collaborative.portals.api.IPortalEventHandler; | ||
import org.eclipse.sirius.components.collaborative.portals.services.ICollaborativePortalMessageService; | ||
import org.eclipse.sirius.components.portals.Portal; | ||
|
||
/** | ||
* Bundles Portal-specific input arguments for {@link PortalEventProcessor}. | ||
* | ||
* @author pcdavid | ||
*/ | ||
public record PortalEventProcessorConfiguration(List<IPortalEventHandler> portalEventHandlers, Portal portal, ICollaborativePortalMessageService messageService) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...src/main/java/org/eclipse/sirius/components/collaborative/portals/api/PortalResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.portals.api; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.portals.Portal; | ||
|
||
/** | ||
* Encapsulates the response from a portal event handler. | ||
* | ||
* @author pcdavid | ||
*/ | ||
public class PortalResponse { | ||
private IPayload payload; | ||
|
||
private Optional<Portal> nextPortal = Optional.empty(); | ||
|
||
private List<ChangeDescription> changeDescriptions = new ArrayList<>(); | ||
|
||
public Optional<Portal> getNextPortal() { | ||
return this.nextPortal; | ||
} | ||
|
||
public void setNextPortal(Portal nextPortal) { | ||
this.nextPortal = Optional.ofNullable(nextPortal); | ||
} | ||
|
||
public void addChangeDescription(ChangeDescription changeDescription) { | ||
this.changeDescriptions.add(Objects.requireNonNull(changeDescription)); | ||
} | ||
|
||
public List<ChangeDescription> getChangeDescriptions() { | ||
return this.changeDescriptions; | ||
} | ||
|
||
public void setPayload(IPayload payload) { | ||
this.payload = Objects.requireNonNull(payload); | ||
} | ||
|
||
public IPayload getPayload() { | ||
return this.payload; | ||
} | ||
} |
Oops, something went wrong.