Convert bierman02 from web.xml to programmtic web API
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / rest / impl / RestconfApplication.java
index 882ac2e9163dd2f9f77fdf00aecba9b62b79f90c..54a81d6b9871f4cf7925865b932837fe0013ecd0 100644 (file)
@@ -16,10 +16,19 @@ import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYinBodyWri
 import org.opendaylight.netconf.md.sal.rest.schema.SchemaRetrievalServiceImpl;
 import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
 
 public class RestconfApplication extends Application {
+    private final ControllerContext controllerContext;
+    private final BrokerFacade brokerFacade;
+    private final StatisticsRestconfServiceWrapper statsServiceWrapper;
+
+    public RestconfApplication(ControllerContext controllerContext, BrokerFacade brokerFacade,
+            StatisticsRestconfServiceWrapper statsServiceWrapper) {
+        this.controllerContext = controllerContext;
+        this.brokerFacade = brokerFacade;
+        this.statsServiceWrapper = statsServiceWrapper;
+    }
 
     @Override
     public Set<Class<?>> getClasses() {
@@ -36,16 +45,11 @@ public class RestconfApplication extends Application {
     @Override
     public Set<Object> getSingletons() {
         final Set<Object> singletons = new HashSet<>();
-        final ControllerContext controllerContext = ControllerContext.getInstance();
-        final BrokerFacade brokerFacade = BrokerFacade.getInstance();
-        final RestconfImpl restconfImpl = RestconfImpl.getInstance();
         final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext);
-        restconfImpl.setBroker(brokerFacade);
-        restconfImpl.setControllerContext(controllerContext);
         singletons.add(controllerContext);
         singletons.add(brokerFacade);
         singletons.add(schemaRetrieval);
-        singletons.add(new RestconfCompositeWrapper(StatisticsRestconfServiceWrapper.getInstance(), schemaRetrieval));
+        singletons.add(new RestconfCompositeWrapper(statsServiceWrapper, schemaRetrieval));
         singletons.add(new RestconfDocumentedExceptionMapper(controllerContext));
         singletons.add(new XmlNormalizedNodeBodyReader(controllerContext));
         singletons.add(new JsonNormalizedNodeBodyReader(controllerContext));