Merge "Bug-2842:If an install snapshot is in progress, Follower should return immedia...
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / RegisterChangeListenerReply.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.messages;
10
11 import akka.actor.ActorPath;
12 import akka.actor.ActorSystem;
13 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
14
15 public class RegisterChangeListenerReply implements SerializableMessage{
16   public static final Class<ListenerRegistrationMessages.RegisterChangeListenerReply> SERIALIZABLE_CLASS =
17           ListenerRegistrationMessages.RegisterChangeListenerReply.class;
18   private final ActorPath listenerRegistrationPath;
19
20   public RegisterChangeListenerReply(final ActorPath listenerRegistrationPath) {
21     this.listenerRegistrationPath = listenerRegistrationPath;
22   }
23
24   public ActorPath getListenerRegistrationPath() {
25     return listenerRegistrationPath;
26   }
27
28   @Override
29   public ListenerRegistrationMessages.RegisterChangeListenerReply toSerializable() {
30     return ListenerRegistrationMessages.RegisterChangeListenerReply.newBuilder()
31             .setListenerRegistrationPath(listenerRegistrationPath.toString()).build();
32   }
33
34   public static RegisterChangeListenerReply fromSerializable(final ActorSystem actorSystem,final Object serializable){
35     ListenerRegistrationMessages.RegisterChangeListenerReply o = (ListenerRegistrationMessages.RegisterChangeListenerReply) serializable;
36     return new RegisterChangeListenerReply(
37         actorSystem.actorFor(o.getListenerRegistrationPath()).path()
38         );
39   }
40 }