Support Wikipedia Follow My Heart: How to create Own “Update Center” for Netbeans / VisualVM Plug-in?

2012年1月6日星期五

How to create Own “Update Center” for Netbeans / VisualVM Plug-in?

What is a “Update Center” and how it works?

The answer is very easy. It is kind of plug-in repository. Plug-in authors will release and save the new plug-in in certain update center, locating in some remote servers. The url of the Update Center (actually, it is the URL of the “updates.xml” file in the root of Update Center folder) can be registered in your software. Then, the next time your software checks the URL, read in the “updates.xml” which descripes what plug-in are available and their version information. If your “Update Center” finds that some your installed plugin has newer version, then you will see a hint note. If you permits updating, then the new plug-in will be downloaded and installed automatically.

VisualVM is a product utilizing the Netbeans Platform, so it is same to build update center for either Netbeans or VisualVM.

What is necessary for a “Update Center”?

It becomes clear that two things are important:

  1. there is an “updates.xml” file locating in the root folder of Update Center
  2. the available .nmb plug-in packages are also located in the Update Center. The location should be accessible by canonical path from the “updates.xml” file.

What is the format and content of such “updates.xml” file?

This question is trivial because acutally it is not designed for human read in my idea. If you insist on it, you can read the following sample from VisualVM Plugin Suites.

Sample Updates.xml

 


How to generate the necessary files automatically?


I suggest using Netbeans IDE to do this, because it already provides function to write “Updates.xml” file and package generated .nbm files. All you need is just to:



  1. Create a Module Suite, and add your plug-in into this suite.

  2. Right click the suite, choose “package as –> nbms” (some posts said the function name is “create nbms”). Or you can use ANT to run the “nbms” target of file “build.xml” of your suite. Then you can see a “update” folder is automaically created under your suite root. All your required files are inside this folder.

Note: sometimes, you may find impossible to create a separate module suite to contain your plug-in because it depends on other modules, which cannot be also copied into the new suite. In this case, maybe you need to add your own plug-in into the same suite, build the suite, and manually change the content of the “updates.xml” (delete useless “module” sections or “module group” sections).


How to publish the generated files as “Update Center” mode?


Since you have got the “update” folder in which all necessary files are generated (“updates.xml”, “*.nbm”,…), you need to put them into some place where is accessible by your software.


Here are some examples.



  1. If you put the folder in “C:\”, then you can open your software, registerr the auto update URL as “file:/C:/update/updates.xml”.

  2. You may also start the Windows IIS service (in windows platform) or any other kind of HTTP Server (like APACHE..), setting up the default website root address to the update folder. Then you may register the URL as “http://localhost/updates.xml”.

Finally, do not forget to notify your software to check available plug-ins if you want to see the changes immediately!

没有评论:

发表评论