-
Notifications
You must be signed in to change notification settings - Fork 2
/
PluginContextListener.java
47 lines (37 loc) · 1.76 KB
/
PluginContextListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package io.hawt.examples.sampleplugin;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import io.hawt.web.plugin.HawtioPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PluginContextListener implements ServletContextListener {
private static final Logger LOG = LoggerFactory.getLogger(PluginContextListener.class);
private HawtioPlugin plugin = null;
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
/*
* These are the parameters required to load a remote Hawtio plugin (a.k.a. Module Federation remote module):
*
* - scope: The name of the container defined at Webpack ModuleFederationPlugin. See also: sample-plugin/craco.config.js
* - module: The path exposed from Webpack ModuleFederationPlugin. See also: sample-plugin/craco.config.js
* - url: The URL of the remote entry for the plugin, e.g. "http://localhost:8081". (optional)
*/
plugin = new HawtioPlugin()
.scope("samplePlugin")
.module("./plugin")
.url("/sample-plugin");
/*
* By default, Hawtio expects "plugin" as the name of the Hawtio plugin entry function.
* If you want to use the name other than the default one, specify the name using HawtioPlugin#pluginEntry()
* as follows. See also: sample-plugin/src/sample-plugin/index.ts
*/
//plugin.pluginEntry("registerMyPlugin");
plugin.init();
LOG.info("Initialised plugin: {}", plugin.getScope());
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
plugin.destroy();
LOG.info("Destroyed plugin: {}", plugin.getScope());
}
}