Merge "Startup archetype: remove 'Impl' from config subsystem Module name."
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / utils / ForwardMessageToBehaviorActor.java
1 /*
2  * Copyright (c) 2015 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.raft.utils;
10
11 import akka.actor.Props;
12 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
13
14 public class ForwardMessageToBehaviorActor extends MessageCollectorActor {
15     private RaftActorBehavior behavior;
16
17     @Override
18     public void onReceive(Object message) throws Exception {
19         if(behavior != null) {
20             behavior.handleMessage(sender(), message);
21         }
22
23         super.onReceive(message);
24     }
25
26     public static Props props() {
27         return Props.create(ForwardMessageToBehaviorActor.class);
28     }
29
30     public void setBehavior(RaftActorBehavior behavior){
31         this.behavior = behavior;
32     }
33 }
34