Initial code drop of netconf protocol implementation
[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.impl.mapping.CapabilityProvider;
12 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
13 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
14 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshot;
15 import org.opendaylight.protocol.framework.SessionListenerFactory;
16
17 public class NetconfServerSessionListenerFactory implements SessionListenerFactory<NetconfServerSessionListener> {
18
19     private final NetconfOperationServiceFactoryListener factoriesListener;
20
21     private final DefaultCommitNotificationProducer commitNotifier;
22
23     private final SessionIdProvider idProvider;
24
25     public NetconfServerSessionListenerFactory(NetconfOperationServiceFactoryListener factoriesListener,
26             DefaultCommitNotificationProducer commitNotifier, SessionIdProvider idProvider) {
27         this.factoriesListener = factoriesListener;
28         this.commitNotifier = commitNotifier;
29         this.idProvider = idProvider;
30     }
31
32     @Override
33     public NetconfServerSessionListener getSessionListener() {
34         NetconfOperationServiceSnapshot netconfOperationServiceSnapshot = factoriesListener.getSnapshot(idProvider
35                 .getCurrentSessionId());
36
37         CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationServiceSnapshot);
38
39         NetconfOperationRouterImpl operationRouter = new NetconfOperationRouterImpl(netconfOperationServiceSnapshot,
40                 capabilityProvider, commitNotifier);
41
42         return new NetconfServerSessionListener(operationRouter);
43     }
44 }