2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.example;
11 import akka.actor.ActorRef;
12 import akka.actor.Props;
13 import akka.actor.UntypedActor;
14 import akka.event.Logging;
15 import akka.event.LoggingAdapter;
16 import akka.japi.Creator;
17 import org.opendaylight.controller.cluster.example.messages.KeyValue;
18 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
20 public class ClientActor extends UntypedActor {
21 protected final LoggingAdapter LOG =
22 Logging.getLogger(getContext().system(), this);
24 private final ActorRef target;
26 public ClientActor(ActorRef target){
30 public static Props props(final ActorRef target){
31 return Props.create(new Creator<ClientActor>(){
33 @Override public ClientActor create() throws Exception {
34 return new ClientActor(target);
39 @Override public void onReceive(Object message) throws Exception {
40 if(message instanceof KeyValue) {
41 target.tell(message, getSelf());
42 } else if(message instanceof KeyValueSaved){
43 LOG.info("KeyValue saved");