Merge "Fail on validation of checkstyle set to true"
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / example / ClientActor.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.example;
10
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 org.opendaylight.controller.cluster.example.messages.KeyValue;
17 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
18
19 public class ClientActor extends UntypedActor {
20     protected final LoggingAdapter LOG =
21         Logging.getLogger(getContext().system(), this);
22
23     private final ActorRef target;
24
25     public ClientActor(ActorRef target){
26         this.target = target;
27     }
28
29     public static Props props(final ActorRef target) {
30         return Props.create(ClientActor.class, target);
31     }
32
33     @Override public void onReceive(Object message) throws Exception {
34         if(message instanceof KeyValue) {
35             target.tell(message, getSelf());
36         } else if(message instanceof KeyValueSaved){
37             LOG.info("KeyValue saved");
38         }
39     }
40 }