Merge "Resolve Bug:707 - ConfigPusher should wait for netconf-impl to register JMX...
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / NetconfServerSessionListenerFactory.java
1 /*
2  * Copyright (c) 2013 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.netconf.impl;
10
11 import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
12 import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
13 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
14 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
15 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
16 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
17 import org.opendaylight.protocol.framework.SessionListenerFactory;
18
19 import static org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider.NetconfOperationProviderUtil.getNetconfSessionIdForReporting;
20
21 public class NetconfServerSessionListenerFactory implements SessionListenerFactory<NetconfServerSessionListener> {
22
23     private final NetconfOperationProvider netconfOperationProvider;
24
25     private final DefaultCommitNotificationProducer commitNotifier;
26
27     private final SessionIdProvider idProvider;
28
29     private final SessionMonitoringService monitor;
30
31     public NetconfServerSessionListenerFactory(NetconfOperationProvider netconfOperationProvider,
32                                                DefaultCommitNotificationProducer commitNotifier,
33                                                SessionIdProvider idProvider, SessionMonitoringService monitor) {
34         this.netconfOperationProvider = netconfOperationProvider;
35         this.commitNotifier = commitNotifier;
36         this.idProvider = idProvider;
37         this.monitor = monitor;
38     }
39
40     @Override
41     public NetconfServerSessionListener getSessionListener() {
42         NetconfOperationServiceSnapshot netconfOperationServiceSnapshot = netconfOperationProvider.getSnapshot(
43                 getNetconfSessionIdForReporting(idProvider.getCurrentSessionId()));
44
45         CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationServiceSnapshot);
46
47         NetconfOperationRouter operationRouter = NetconfOperationRouterImpl.createOperationRouter(
48                 netconfOperationServiceSnapshot, capabilityProvider,
49                 commitNotifier);
50
51         return new NetconfServerSessionListener(operationRouter, monitor);
52     }
53 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.