Red Hat Training

A Red Hat training course is available for Red Hat Virtualization

C.2.4. Red Hat Virtualization 用户界面插件

典型的插件 bootstrap 序列包括以下步骤:

过程 C.1. 插件 Bootstrap Sequence

  1. 为给定插件获取 pluginApi 实例
  2. 获取运行时插件配置对象(可选)
  3. 注册相关的事件处理器功能
  4. 通知 UI 插件基础架构以继续插件初始化
以下代码片段演示了实践中提到的步骤:
// Access plug-in API using 'parent' due to this code being evaluated within the context of an iframe element.
// As 'parent.pluginApi' is subject to Same-Origin Policy, this will only work when WebAdmin HTML page and plug-in
// host page are served from same origin. WebAdmin HTML page and plug-in host page will always be on same origin
// when using UI plug-in infrastructure support to serve plug-in resource files.
var api = parent.pluginApi('MyPlugin');

// Runtime configuration object associated with the plug-in (or an empty object).
var config = api.configObject();

// Register event handler function(s) for later invocation by UI plug-in infrastructure.
api.register({
	    // UiInit event handler function.
		UiInit: function() {
				// Handle UiInit event.
					window.alert('Favorite music band is ' + config.band);
					    }
});

// Notify UI plug-in infrastructure to proceed with plug-in initialization.
api.ready();