Migrate to UntypedAbstractActor
[controller.git] / opendaylight / md-sal / sal-akka-raft-example / 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 package org.opendaylight.controller.cluster.example;
9
10 import akka.actor.ActorRef;
11 import akka.actor.Props;
12 import akka.actor.UntypedAbstractActor;
13 import org.opendaylight.controller.cluster.example.messages.KeyValue;
14 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 public class ClientActor extends UntypedAbstractActor {
19     private static final Logger LOG = LoggerFactory.getLogger(ClientActor.class);
20
21     private final ActorRef target;
22
23     public ClientActor(final ActorRef target) {
24         this.target = target;
25     }
26
27     public static Props props(final ActorRef target) {
28         return Props.create(ClientActor.class, target);
29     }
30
31     @Override
32     public void onReceive(final Object message) {
33         if (message instanceof KeyValue) {
34             target.tell(message, getSelf());
35         } else if (message instanceof KeyValueSaved) {
36             LOG.info("KeyValue saved");
37         }
38     }
39 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.