httpserver-service.js 2.08 KB
/*
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2017 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 */

/* globals Promise */
define('screens/player/firmware/httpserver/impl/httpserver-service', [
    'screens/player/firmware/httpserver/httpserver',
    'screens/player/firmware/httpserver/spi/httpserver',
    'screens/player/shared/serviceadmin'
], function(HttpServer, HttpServerSpi, ServiceAdmin) {
    'use strict';

    /**
     * Http Server implementation.
     *
     * @class HttpServerService
     */
    var HttpServerService = function() {
    };

    HttpServerService.prototype = _.assign({}, HttpServer,
        /** @lends HttpServerService.prototype */ {

        activate: function() {
            return new Promise(function(resolve, reject) {
                ServiceAdmin.onServiceHighestRankedStart(HttpServerSpi.serviceName, resolve);
            });
        },

        /**
         * @memberof HttpServerService
         * @inheritdoc
         */
        serve: function(path) {
            return ServiceAdmin.getService(HttpServerSpi.serviceName).serve(path);
        },

        /**
         * @memberof HttpServerService
         * @inheritdoc
         */
        stop: function(path) {
            return ServiceAdmin.getService(HttpServerSpi.serviceName).stop();
        }
    });

    return HttpServerService;
});

/* istanbul ignore next */
require([
    'screens/player/firmware/httpserver/impl/httpserver-service',
    'screens/player/shared/serviceadmin'
], function(HttpServerService, ServiceAdmin) {
    'use strict';
    ServiceAdmin.register(new HttpServerService());
});