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.persistence.UntypedPersistentActor;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public abstract class AbstractUntypedPersistentActor extends UntypedPersistentActor {
17 protected final Logger LOG = LoggerFactory.getLogger(getClass());
19 protected AbstractUntypedPersistentActor() {
20 LOG.trace("Actor created {}", getSelf());
21 getContext().system().actorSelection("user/termination-monitor").tell(new Monitor(getSelf()), getSelf());
25 public final void onReceiveCommand(Object message) throws Exception {
26 final String messageType = message.getClass().getSimpleName();
27 LOG.trace("Received message {}", messageType);
29 handleCommand(message);
31 LOG.trace("Done handling message {}", messageType);
35 public final void onReceiveRecover(Object message) throws Exception {
36 final String messageType = message.getClass().getSimpleName();
37 LOG.trace("Received message {}", messageType);
38 handleRecover(message);
39 LOG.trace("Done handling message {}", messageType);
42 protected abstract void handleRecover(Object message) throws Exception;
44 protected abstract void handleCommand(Object message) throws Exception;
46 protected void ignoreMessage(Object message) {
47 LOG.debug("Unhandled message {} ", message);
50 protected void unknownMessage(Object message) throws Exception {
51 LOG.debug("Received unhandled message {}", message);