Quantcast

[openide-dev] How to start code in module upon NetBeans launch?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[openide-dev] How to start code in module upon NetBeans launch?

Charles Hymes
Hi All!
My modules (ahem) work, but I'd like to start a service running in the background when NetBeans starts.
I tried the following in layers.mf

<filesystem>
    <folder name="Services">
            <file name="com-hymerfania-MyBackgroundServiceImpl.instance">
                <attr name="instanceOf" stringvalue="com.hymerfania.MyBackgroundService"/>                
            </file><!-- FormServices -->
    </folder><!-- Services Folder-->          
</filesystem>

But the constructor is never called. I tried AutoLoad and Eager in the project settings, but still no launch. I know the module
"*loads*", because I can see it in the module list.

How can this be done?

Also, where is the best place to put service startup code? Is it save to put stuff in constructors? I know this is frowned upon in
Actions.....

Thanks!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[openide-dev] Re: How to start code in module upon NetBeans launch?

wconroy
You can extend org.openide.modules.ModuleInstall and override the
restored method.  in your manifest file for your plugin, you would then
add the line.

OpenIDE-Module-Install: com/whatever/MyModuleInstall.class


Charles Hymes wrote:

> Hi All!
> My modules (ahem) work, but I'd like to start a service running in the background when NetBeans starts.
> I tried the following in layers.mf
>
> <filesystem>
>     <folder name="Services">
>             <file name="com-hymerfania-MyBackgroundServiceImpl.instance">
>                 <attr name="instanceOf" stringvalue="com.hymerfania.MyBackgroundService"/>                
>             </file><!-- FormServices -->
>     </folder><!-- Services Folder-->          
> </filesystem>
>
> But the constructor is never called. I tried AutoLoad and Eager in the project settings, but still no launch. I know the module
> "*loads*", because I can see it in the module list.
>
> How can this be done?
>
> Also, where is the best place to put service startup code? Is it save to put stuff in constructors? I know this is frowned upon in
> Actions.....
>
> Thanks!
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [openide-dev] How to start code in module upon NetBeans launch?

Ayub Khan
In reply to this post by Charles Hymes
Hi Charles,

This may work for you

1) Add folowing line to module manifest.mf file
OpenIDE-Module-Install: com/hymerfania/MyModuleInstall .class

2)
MyModuleInstall.java
==========================================
package com.hymerfania;

import org.openide.modules.*;

public class MyModuleInstall extends ModuleInstall
{
    /**
     *
     *
     */
    public void installed()
    {
        restored();
    }

    /**
     *
     *
     */
    public void restored()
    {
        //run background process here
    }
}

Thanks
Ayub

Charles Hymes wrote:

>Hi All!
>My modules (ahem) work, but I'd like to start a service running in the background when NetBeans starts.
>I tried the following in layers.mf
>
><filesystem>
>    <folder name="Services">
>            <file name="com-hymerfania-MyBackgroundServiceImpl.instance">
>                <attr name="instanceOf" stringvalue="com.hymerfania.MyBackgroundService"/>                
>            </file><!-- FormServices -->
>    </folder><!-- Services Folder-->          
></filesystem>
>
>But the constructor is never called. I tried AutoLoad and Eager in the project settings, but still no launch. I know the module
>"*loads*", because I can see it in the module list.
>
>How can this be done?
>
>Also, where is the best place to put service startup code? Is it save to put stuff in constructors? I know this is frowned upon in
>Actions.....
>
>Thanks!
>
>  
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [openide-dev] Re: How to start code in module upon NetBeans launch?

listbox
In reply to this post by wconroy
Thanks!
That worked.
Doesn't seem the best way to do this though.
Hmmm. Time for a feature/ape-change request.

Charlweed
 

-----Original Message-----
From: Bo Conroy [mailto:[hidden email]]
Sent: Tuesday, July 26, 2005 12:22 PM
To: [hidden email]
Subject: [openide-dev] Re: How to start code in module upon NetBeans launch?

You can extend org.openide.modules.ModuleInstall and override the
restored method.  in your manifest file for your plugin, you would then
add the line.

OpenIDE-Module-Install: com/whatever/MyModuleInstall.class


Charles Hymes wrote:

> Hi All!
> My modules (ahem) work, but I'd like to start a service running in the background when NetBeans starts.
> I tried the following in layers.mf
>
> <filesystem>
>     <folder name="Services">
>             <file name="com-hymerfania-MyBackgroundServiceImpl.instance">
>                 <attr name="instanceOf" stringvalue="com.hymerfania.MyBackgroundService"/>                
>             </file><!-- FormServices -->
>     </folder><!-- Services Folder-->          
> </filesystem>
>
> But the constructor is never called. I tried AutoLoad and Eager in the project settings, but still no launch. I know the module
> "*loads*", because I can see it in the module list.
>
> How can this be done?
>
> Also, where is the best place to put service startup code? Is it save to put stuff in constructors? I know this is frowned upon in
> Actions.....
>
> Thanks!
>
>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[openide-dev] Re: How to start code in module upon NetBeans launch?

Jesse Glick
From: Bo Conroy [mailto:[hidden email]]
> You can extend org.openide.modules.ModuleInstall and override the
> restored method.  in your manifest file for your plugin, you would
> then add the line.
>
> OpenIDE-Module-Install: com/whatever/MyModuleInstall.class

listbox wrote:
> Thanks! That worked. Doesn't seem the best way to do this though.

It's the *only* way to do it, and always has been.

-J.

--
[hidden email]   x22801   netbeans.org   ant.apache.org

Loading...