| // |
| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| // |
| |
| = DevFaqModulesStartupActions |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| :keywords: Apache NetBeans wiki DevFaqModulesStartupActions |
| :description: Apache NetBeans wiki DevFaqModulesStartupActions |
| :toc: left |
| :toc-title: |
| :syntax: true |
| |
| === How do I run some code when my module starts/loads/unloads? |
| |
| To run some code when your module is loaded, and basically every time the IDE starts and your module is enabled, simply create a subclass of `org.openide.modules.ModuleInstall` and override the `restored()` method. Bear in mind that this is being executing during the time the IDE/platform is starting up. You should limit the work you do here to that which is absolutely necessary. |
| |
| Once the class is created, you must declare it in your module's `manifest.mf` file, like so: |
| |
| [source,java] |
| ---- |
| |
| OpenIDE-Module-Install: org/netbeans/modules/editor/EditorModule.class |
| ---- |
| |
| Likewise, to execute code when the IDE is shutting down, you can override the `close()` method. This method of `ModuleInstall` is called when the IDE is shutting down, contrary to the `closing()` method, which is called to alert the module that the IDE is about to shut down. However, another module may veto the shutdown by returning `false` from the `closing()` method, so the `close()` method is best for performing any cleanup work for your module. |
| |
| You can simply use *File > New File > Module Development | Module Installer* to create the `ModuleInstall` class and its registration in the manifest. |
| |
| <hr/> |
| Applies to: NetBeans 6.5 and later |
| |
| === Apache Migration Information |
| |
| The content in this page was kindly donated by Oracle Corp. to the |
| Apache Software Foundation. |
| |
| This page was exported from link:http://wiki.netbeans.org/DevFaqModulesStartupActions[http://wiki.netbeans.org/DevFaqModulesStartupActions] , |
| that was last modified by NetBeans user Jglick |
| on 2009-12-03T13:43:29Z. |
| |
| |
| *NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed. |