modules/ballerina-core/src/main/java/org/ballerinalang/services/dispatchers/http/HTTPServicesRegistry.java
/**
     * Register a service into the map.
     * @param service requested service to register.
     */
Register a service into the map.
@param service requested service to register.
Register a service into the map . @param service requested service to register .
public void registerService(Service service) {
        if (serviceExists(service)) {
            logger.debug("Service already exists.");
            return;
        }
        String listenerInterface = Constants.DEFAULT_INTERFACE;
        String basePath = service.getSymbolName().getName();
        for (Annotation annotation : service.getAnnotations()) {
            if (annotation.getName().equals(Constants.ANNOTATION_NAME_SOURCE)) {
                String sourceInterfaceVal = annotation
                        .getValueOfElementPair(new SymbolName(Constants.ANNOTATION_SOURCE_KEY_INTERFACE));
                if (sourceInterfaceVal != null) {   
                    listenerInterface = sourceInterfaceVal;
                }
            } else if (annotation.getName().equals(
                    Constants.PROTOCOL_HTTP + ":" + Constants.ANNOTATION_NAME_BASE_PATH)) {
                basePath = annotation.getValue();
            }
        }
        if (!basePath.startsWith(Constants.DEFAULT_BASE_PATH)) {
            basePath = Constants.DEFAULT_BASE_PATH.concat(basePath);
        }
        Map<String, Service> servicesOnInterface = servicesMap.get(listenerInterface);
        if (servicesOnInterface == null) {
            servicesOnInterface = new HashMap<>();
            servicesMap.put(listenerInterface, servicesOnInterface);
            ServerConnector connector = BallerinaConnectorManager.getInstance().getServerConnector(listenerInterface);
            if (connector == null) {
                throw new BallerinaException(
                        "ServerConnector interface not registered for : " + listenerInterface);
            }
            BallerinaConnectorManager.getInstance().addStartupDelayedServerConnector(connector,
                                                                                     Collections.emptyMap());
        }
        if (servicesOnInterface.containsKey(basePath)) {
            throw new BallerinaException(
                    "service with base path :" + basePath + " already exists in listener : " + listenerInterface);
        }
        servicesOnInterface.put(basePath, service);
        logger.info("Service deployed : " +
                         (service.getSymbolName().getPkgPath() != null ?
                                 service.getSymbolName().getPkgPath() + ":" : "") +
                         service.getSymbolName().getName() +
                         " with context " +  basePath);
    }
public void registerService ( Service service ) { if ( serviceExists ( service ) ) { logger . debug ( "Service already exists." ) ; return ; } String listenerInterface = Constants . DEFAULT_INTERFACE ; String basePath = service . getSymbolName ( ) . getName ( ) ; for ( Annotation annotation : service . getAnnotations ( ) ) { if ( annotation . getName ( ) . equals ( Constants . ANNOTATION_NAME_SOURCE ) ) { String sourceInterfaceVal = annotation . getValueOfElementPair ( new SymbolName ( Constants . ANNOTATION_SOURCE_KEY_INTERFACE ) ) ; if ( sourceInterfaceVal != null ) { listenerInterface = sourceInterfaceVal ; } } else if ( annotation . getName ( ) . equals ( Constants . PROTOCOL_HTTP + ":" + Constants . ANNOTATION_NAME_BASE_PATH ) ) { basePath = annotation . getValue ( ) ; } } if ( ! basePath . startsWith ( Constants . DEFAULT_BASE_PATH ) ) { basePath = Constants . DEFAULT_BASE_PATH . concat ( basePath ) ; } Map < String , Service > servicesOnInterface = servicesMap . get ( listenerInterface ) ; if ( servicesOnInterface == null ) { servicesOnInterface = new HashMap < > ( ) ; servicesMap . put ( listenerInterface , servicesOnInterface ) ; ServerConnector connector = BallerinaConnectorManager . getInstance ( ) . getServerConnector ( listenerInterface ) ; if ( connector == null ) { throw new BallerinaException ( "ServerConnector interface not registered for : " + listenerInterface ) ; } BallerinaConnectorManager . getInstance ( ) . addStartupDelayedServerConnector ( connector , Collections . emptyMap ( ) ) ; } if ( servicesOnInterface . containsKey ( basePath ) ) { throw new BallerinaException ( "service with base path :" + basePath + " already exists in listener : " + listenerInterface ) ; } servicesOnInterface . put ( basePath , service ) ; logger . info ( "Service deployed : " + ( service . getSymbolName ( ) . getPkgPath ( ) != null ? service . getSymbolName ( ) . getPkgPath ( ) + ":" : "" ) + service . getSymbolName ( ) . getName ( ) + " with context " + basePath ) ; }
Register a service into the map.
Register a service into the map .
//TODO: Filter non-http protocols // Assumption : this is always sequential, no two simultaneous calls can get here // Delay the startup until all services are deployed