Merge "Fix for Bug 2727 - Upgrade Akka from 2.3.4 to 2.3.9"
[controller.git] / opendaylight / netconf / mdsal-netconf-connector / src / main / java / org / opendaylight / controller / netconf / mdsal / connector / MdsalNetconfOperationServiceFactory.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.mdsal.connector;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
13 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
14 import org.opendaylight.controller.sal.core.api.model.SchemaService;
15
16 public class MdsalNetconfOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
17
18     private final DOMDataBroker dataBroker;
19     private final CurrentSchemaContext currentSchemaContext;
20
21     public MdsalNetconfOperationServiceFactory(final SchemaService schemaService, final DOMDataBroker domDataBroker) {
22         this.currentSchemaContext = new CurrentSchemaContext(Preconditions.checkNotNull(schemaService));
23         this.dataBroker = Preconditions.checkNotNull(domDataBroker);
24     }
25
26     @Override
27     public MdsalNetconfOperationService createService(final String netconfSessionIdForReporting) {
28         return new MdsalNetconfOperationService(currentSchemaContext, netconfSessionIdForReporting, dataBroker);
29     }
30
31     @Override
32     public void close() throws Exception {
33         currentSchemaContext.close();
34     }
35 }