d3fe40686a55de26491a444f9ac1257496ec6477
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / Rfc8040RestConfWiring.java
1 /*
2  * Copyright (c) 2019 Red Hat, 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 package org.opendaylight.restconf.nb.rfc8040;
9
10 import javax.inject.Inject;
11 import javax.inject.Singleton;
12 import org.apache.aries.blueprint.annotation.service.Reference;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
15 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
16 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
17 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
18 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
19 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
20 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.JSONRestconfServiceRfc8040Impl;
21 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
22 import org.opendaylight.restconf.nb.rfc8040.web.WebInitializer;
23
24 /**
25  * Standalone wiring for RESTCONF.
26  *
27  * <p>This wiring alone is not sufficient; there are a few other singletons which
28  * need to be bound as well, incl. {@link RestconfApplication},
29  * {@link JSONRestconfServiceRfc8040Impl} &amp; {@link WebInitializer}; see the
30  * Rfc8040RestConfWiringTest for how to do this e.g. for Guice (this class can
31  * be used with another DI framework but needs the equivalent).
32  *
33  * @author Michael Vorburger.ch
34  */
35 @Singleton
36 public class Rfc8040RestConfWiring {
37
38     private final ServicesWrapper servicesWrapper;
39
40     @Inject
41     public Rfc8040RestConfWiring(
42             SchemaContextHandler schemaCtxHandler,
43             DOMMountPointServiceHandler domMountPointServiceHandler, TransactionChainHandler transactionChainHandler,
44             DOMDataBrokerHandler domDataBrokerHandler, RpcServiceHandler rpcServiceHandler,
45             NotificationServiceHandler notificationServiceHandler, @Reference DOMSchemaService domSchemaService) {
46         servicesWrapper = ServicesWrapper.newInstance(schemaCtxHandler, domMountPointServiceHandler,
47                 transactionChainHandler, domDataBrokerHandler, rpcServiceHandler, notificationServiceHandler,
48                 domSchemaService);
49     }
50
51     public ServicesWrapper getServicesWrapper() {
52         return servicesWrapper;
53     }
54 }