2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.client;
10 import akka.actor.ActorSystem;
11 import akka.persistence.SnapshotSelectionCriteria;
12 import com.google.common.base.Preconditions;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
16 * The initial context for an actor.
18 * @author Robert Varga
20 final class InitialClientActorContext extends AbstractClientActorContext {
21 private final AbstractClientActor actor;
23 InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
24 super(actor.self(), persistenceId);
25 this.actor = Preconditions.checkNotNull(actor);
28 void saveSnapshot(final ClientIdentifier snapshot) {
29 actor.saveSnapshot(snapshot);
32 void deleteSnapshots(final SnapshotSelectionCriteria criteria) {
33 actor.deleteSnapshots(criteria);
36 ClientActorBehavior<?> createBehavior(final ClientIdentifier clientId) {
37 final ActorSystem system = actor.getContext().system();
38 final ClientActorContext context = new ClientActorContext(self(), system.scheduler(), system.dispatcher(),
39 persistenceId(), clientId, actor.getClientActorConfig());
41 return actor.initialBehavior(context);