Merge "Take advantage of MultipartTransactionAware"
[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.NetconfOperationServiceFactoryListener;
15 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshot;
16 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
17 import org.opendaylight.protocol.framework.SessionListenerFactory;
18
19 public class NetconfServerSessionListenerFactory implements SessionListenerFactory<NetconfServerSessionListener> {
20
21     private final NetconfOperationServiceFactoryListener factoriesListener;
22
23     private final DefaultCommitNotificationProducer commitNotifier;
24
25     private final SessionIdProvider idProvider;
26
27     private final SessionMonitoringService monitor;
28
29     public NetconfServerSessionListenerFactory(NetconfOperationServiceFactoryListener factoriesListener,
30                                                DefaultCommitNotificationProducer commitNotifier,
31                                                SessionIdProvider idProvider, SessionMonitoringService monitor) {
32         this.factoriesListener = factoriesListener;
33         this.commitNotifier = commitNotifier;
34         this.idProvider = idProvider;
35         this.monitor = monitor;
36     }
37
38     @Override
39     public NetconfServerSessionListener getSessionListener() {
40         NetconfOperationServiceSnapshot netconfOperationServiceSnapshot = factoriesListener.getSnapshot(idProvider
41                 .getCurrentSessionId());
42
43         CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationServiceSnapshot);
44
45         NetconfOperationRouter operationRouter = NetconfOperationRouterImpl.createOperationRouter(
46                 netconfOperationServiceSnapshot, capabilityProvider,
47                 commitNotifier);
48
49         return new NetconfServerSessionListener(operationRouter, monitor);
50     }
51 }