import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.restconf.common.wrapper.services.Draft16ServicesWrapperImpl;
+import org.opendaylight.restconf.common.wrapper.services.ServicesWrapperImpl;
import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.handlers.RpcServiceHandler;
import org.slf4j.LoggerFactory;
/**
- * Provider for restconf draft16.
+ * Provider for restconf draft17.
*
*/
public class RestConnectorProvider implements Provider, RestConnector, AutoCloseable {
private ListenerRegistration<SchemaContextListener> listenerRegistration;
private static TransactionChainHandler transactionChainHandler;
private static DOMDataBroker dataBroker;
+ private static DOMMountPointServiceHandler mountPointServiceHandler;
@Override
public void onSessionInitiated(final ProviderSession session) {
final SchemaService schemaService = Preconditions.checkNotNull(session.getService(SchemaService.class));
- final Draft16ServicesWrapperImpl wrapperServices = Draft16ServicesWrapperImpl.getInstance();
+ final ServicesWrapperImpl wrapperServices = ServicesWrapperImpl.getInstance();
final SchemaContextHandler schemaCtxHandler = new SchemaContextHandler();
this.listenerRegistration = schemaService.registerSchemaContextListener(schemaCtxHandler);
- final DOMMountPointServiceHandler domMountPointServiceHandler = new DOMMountPointServiceHandler(
+ RestConnectorProvider.mountPointServiceHandler = new DOMMountPointServiceHandler(
session.getService(DOMMountPointService.class));
RestConnectorProvider.dataBroker = session.getService(DOMDataBroker.class);
final DOMRpcService rpcService = session.getService(DOMRpcService.class);
final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
- wrapperServices.setHandlers(schemaCtxHandler, domMountPointServiceHandler,
+ wrapperServices.setHandlers(schemaCtxHandler, RestConnectorProvider.mountPointServiceHandler,
RestConnectorProvider.transactionChainHandler, brokerHandler, rpcServiceHandler);
}
);
}
+ /**
+ * Get current {@link DOMMountPointService} from {@link DOMMountPointServiceHandler}.
+ * @return {@link DOMMountPointService}
+ */
+ public static DOMMountPointService getMountPointService() {
+ return RestConnectorProvider.mountPointServiceHandler.get();
+ }
+
@Override
public Collection<ProviderFunctionality> getProviderFunctionality() {
return Collections.emptySet();
}
// close transaction chain
- if (RestConnectorProvider.transactionChainHandler != null) {
- RestConnectorProvider.transactionChainHandler.get().close();
+ if ((transactionChainHandler != null) && (transactionChainHandler.get() != null)) {
+ transactionChainHandler.get().close();
}
}
}