/*
 *  Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
package org.wso2.carbon.mss.internal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * MicroservicesRegistry for the MSS component
 */
public class MicroservicesRegistry {

    private static final Logger LOG = LoggerFactory.getLogger(MicroservicesRegistry.class);
    private static MicroservicesRegistry instance = new MicroservicesRegistry();
    private volatile Set<Object> httpServices = new HashSet<>();

    private MicroservicesRegistry() {
    }

    public static MicroservicesRegistry getInstance() {
        return instance;
    }

    public void addHttpService(Object httpHandler) {
        httpServices.add(httpHandler);
        LOG.info("Added HTTP Service: " + httpHandler);
    }

    public void removeHttpService(Object httpService) {
        httpServices.remove(httpService);
    }

    Set<Object> getHttpServices() {
        return Collections.unmodifiableSet(httpServices);
    }
}

@@ -769,16 +769,164 @@
 actory;%0A
+import org.wso2.carbon.mss.internal.router.HttpResourceHandler;%0Aimport org.wso2.carbon.mss.internal.router.Interceptor;%0A%0Aimport java.util.ArrayList;
 %0Aimport 
@@ -974,16 +974,39 @@
 ashSet;%0A
+import java.util.List;%0A
 import j
@@ -1350,16 +1350,222 @@
 Set%3C%3E();
+%0A    private List%3CInterceptor%3E interceptors = new ArrayList%3C%3E();%0A    private HttpResourceHandler httpResourceHandler =%0A            new HttpResourceHandler(Collections.emptyList(), interceptors, null, null);
 %0A%0A    pr
@@ -1779,24 +1779,61 @@
 tpHandler);%0A
+        updateHttpResourceHandler();%0A
         LOG.
@@ -1981,16 +1981,348 @@
 rvice);%0A
+        updateHttpResourceHandler();%0A    %7D%0A%0A    public HttpResourceHandler getHttpResourceHandler() %7B%0A        return httpResourceHandler;%0A    %7D%0A%0A    private void updateHttpResourceHandler() %7B%0A        httpResourceHandler =%0A                new HttpResourceHandler(Collections.unmodifiableSet(httpServices), interceptors, null, null);%0A
     %7D%0A%0A 

Move HttpResourceHandler to MicroservicesRegistry