| // Copyright 2016 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library modular; |
| |
| // import "lib/story/fidl/link.fidl"; |
| // import "lib/module/fidl/module_context.fidl"; |
| |
| // This service is implemented by an application that is meant to be run under a |
| // ModuleContext in a Story. |
| // |
| // When ModuleContext.StartModuleDeprecated() is invoked, the Module instance is requested |
| // from its application and its dependent services and parameters are passed to |
| // it by Initialize(). |
| // |
| // If a module application implements the |Lifecycle| interface, then invocation |
| // of the Terminate() method on its |Lifecycle| service is a signal that it |
| // should stop. If the module application does not implement the |Lifecycle| |
| // interface, the application instance is simply terminated in order to stop it. |
| // |
| // A module may be stopped for the following reasons: |
| // |
| // (1) StoryController.Stop() is called to stop the whole story. A plausible |
| // occasion for this to happen is that the root module in the story has |
| // signalled that it's Done(), or that the user logs out. |
| // |
| // (2) ModuleController.Stop() is called by the caller that started this |
| // Module. A plausible occasion for this to happen is that the module has |
| // signalled that it's Done(). |
| // |
| // Other connections the Module instance may hold, such as to Link, LinkWatcher, |
| // ModuleController of other Module instances, are closed after |
| // Lifecycle.Terminate() is called. |
| [ServiceName="modular.Module"] // Created by each module component. |
| interface Module { |
| // The arguments to Initialize() are the ModuleContext instance that created |
| // the Module instance and a Link instance provided by the caller of |
| // ModuleContext.StartModuleDeprecated(). |
| // |
| // The default Link instance available from ModuleContext.GetLink() with a |
| // null link name is shared with the calling module and can be used to |
| // exchange data. |
| // |
| // Additionally, this module may provide its services to the calling module by |
| // implementing its |outgoing_services|. |
| // |
| // The ModuleContext instance can be used to start more Module instances, and |
| // to create Link instances to share data with those Module instances. Calling |
| // ModuleContext.Done() signals this module requests to be stopped. |
| // |
| // TODO(vardhan): Move outgoing_services as getter into ModuleContext. |
| 1: Initialize(ModuleContext module_context, |
| request<component.ServiceProvider>? outgoing_services); |
| }; |