-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additionally, change existing RootActorStarter to be RootChildActorStarter and add new RootActorStarter for starting additional root actors outside BaseRootActor Signed-off-by: David Schwilk <david.schwilk@bosch.io>
- Loading branch information
1 parent
62cbbd9
commit 2e2676a
Showing
18 changed files
with
157 additions
and
153 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
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
35 changes: 35 additions & 0 deletions
35
base/service/src/main/java/org/eclipse/ditto/base/service/NoOpRootChildActorStarter.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,35 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.base.service; | ||
|
||
import akka.actor.ActorContext; | ||
import akka.actor.ActorSystem; | ||
|
||
/** | ||
* Root actor child starter that does purposefully nothing. | ||
*/ | ||
public final class NoOpRootChildActorStarter implements RootChildActorStarter { | ||
|
||
/** | ||
* @param actorSystem the actor system in which to load the extension. | ||
*/ | ||
public NoOpRootChildActorStarter(final ActorSystem actorSystem) { | ||
//No-Op because extensions need a constructor accepting an actorSystem | ||
} | ||
|
||
@Override | ||
public void execute(final ActorContext actorContext) { | ||
// Do nothing. | ||
} | ||
|
||
} |
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
base/service/src/main/java/org/eclipse/ditto/base/service/RootChildActorStarter.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) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.base.service; | ||
|
||
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.ditto.internal.utils.akka.AkkaClassLoader; | ||
import org.eclipse.ditto.internal.utils.config.DefaultScopedConfig; | ||
|
||
import akka.actor.ActorContext; | ||
import akka.actor.ActorSystem; | ||
|
||
/** | ||
* Extension to start custom child actors in root actor. | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
public interface RootChildActorStarter extends DittoExtensionPoint { | ||
|
||
static final String CONFIG_PATH = "root-child-actor-starter"; | ||
|
||
/** | ||
* Execute custom custom code. | ||
* | ||
* @param actorContext the context of the {@code RootActor}. | ||
*/ | ||
void execute(ActorContext actorContext); | ||
|
||
/** | ||
* Loads the implementation of {@code RootChildActorStarter} which is configured for the | ||
* {@code ActorSystem}. | ||
* | ||
* @param actorSystem the actorSystem in which the {@code RootChildActorStarter} should be loaded. | ||
* @return the {@code RootChildActorStarter} implementation. | ||
* @throws NullPointerException if {@code actorSystem} is {@code null}. | ||
*/ | ||
static RootChildActorStarter get(final ActorSystem actorSystem) { | ||
checkNotNull(actorSystem, "actorSystem"); | ||
final DefaultScopedConfig dittoScoped = DefaultScopedConfig.dittoScoped(actorSystem.settings().config()); | ||
final var implementation = dittoScoped.getString(CONFIG_PATH); | ||
|
||
return AkkaClassLoader.instantiate(actorSystem, RootChildActorStarter.class, | ||
implementation, | ||
List.of(ActorSystem.class), | ||
List.of(actorSystem)); | ||
} | ||
} |
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
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
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
Oops, something went wrong.