Merge "Fixed for bug 1197"
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / ActorSystemFactory.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.remote.rpc;
10
11 import akka.actor.ActorSystem;
12 import akka.actor.Props;
13 import com.google.common.base.Function;
14 import com.typesafe.config.ConfigFactory;
15
16 import javax.annotation.Nullable;
17
18 public class ActorSystemFactory {
19     private static final ActorSystem actorSystem = (new Function<Void, ActorSystem>(){
20
21         @Nullable @Override public ActorSystem apply(@Nullable Void aVoid) {
22                 ActorSystem system =
23                     ActorSystem.create("opendaylight-rpc", ConfigFactory
24                         .load().getConfig("odl-cluster"));
25                 system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
26                 return system;
27         }
28     }).apply(null);
29
30     public static final ActorSystem getInstance(){
31         return actorSystem;
32     }
33 }