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.common.actor;
11 import akka.actor.UntypedActor;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public abstract class AbstractUntypedActor extends UntypedActor {
16 protected final Logger LOG = LoggerFactory.getLogger(getClass());
18 public AbstractUntypedActor() {
19 if(LOG.isDebugEnabled()) {
20 LOG.debug("Actor created {}", getSelf());
24 actorSelection("user/termination-monitor").
25 tell(new Monitor(getSelf()), getSelf());
29 @Override public void onReceive(Object message) throws Exception {
30 final String messageType = message.getClass().getSimpleName();
31 if(LOG.isDebugEnabled()) {
32 // LOG.debug("Received message {}", messageType);
34 handleReceive(message);
35 if(LOG.isDebugEnabled()) {
36 // LOG.debug("Done handling message {}", messageType);
40 protected abstract void handleReceive(Object message) throws Exception;
42 protected void ignoreMessage(Object message) {
43 LOG.debug("Unhandled message {} ", message);
46 protected void unknownMessage(Object message) throws Exception {
47 if(LOG.isDebugEnabled()) {
48 LOG.debug("Received unhandled message {}", message);