Merge "BUG-190 Simplify reconnect logic in protocol-framework."
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractUntypedActor.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.datastore;
10
11 import akka.actor.UntypedActor;
12 import akka.event.Logging;
13 import akka.event.LoggingAdapter;
14 import org.opendaylight.controller.cluster.datastore.messages.Monitor;
15
16 public abstract class AbstractUntypedActor extends UntypedActor {
17     protected final LoggingAdapter LOG =
18         Logging.getLogger(getContext().system(), this);
19
20
21     public AbstractUntypedActor(){
22         LOG.debug("Actor created {}", getSelf());
23         getContext().
24             system().
25             actorSelection("user/termination-monitor").
26             tell(new Monitor(getSelf()), getSelf());
27     }
28
29     @Override public void onReceive(Object message) throws Exception {
30         LOG.debug("Received message {}", message.getClass().getSimpleName());
31         handleReceive(message);
32         LOG.debug("Done handling message {}", message.getClass().getSimpleName());
33     }
34
35     protected abstract void handleReceive(Object message) throws Exception;
36 }