模块安装程序是一种 Java 类,用于在启动或装入模块时为运行代码提供挂钩。它还可以在卸载或禁用模块时运行清理代码。
注意:通常,建议您不要使用模块安装程序,因为它会增加启动时间。使用模块安装程序之前,请确保无法使用声明方法来完成要尝试执行的操作。The main declarative way of installing items is to use the org.openide.util.lookup.ServiceProvider
annotation or create an XML layer file that declares information about the items your module is installing. 然后,当需要使用这些项来完成实际操作时,将对其进行实例化。
除了提供模块安装程序类之外,还需要在 MANIFEST 文件中添加一个条目。模块安装程序向导将创建模块安装程序的框架实现,在 MANIFEST 文件中添加该条目,以及在 project.xml 文件(用于提供模块的 meta 数据)中添加一些条目。