Friday Sep 21, 2007

Write your own update center module

An Update Center module can be an addon module or an archive module. For an archive type module, the addons.\* interfaces need not be implemented. Let's take a closer look at the addon module.

For starters, you can read my earlier blogs on creating and testing UC addon modules...

For addon modules, you need to look at the Configurator and Installer APIs.... Here's the package tree.

There were several recent additions to Update Center including Apache Roller. If you ever wanted to know how we did that, here is the code for roller.

Hope this will get you excited enough and started on your own module! Send me your comments.

Tuesday Jul 10, 2007

Pack200 and compression through ant

If you are interested in compressing your jar file, you can use Pack200 for compression.

You can also do this through ant using the Pack200Task. (Pack200Task.jar is shipped is shipped with glassFish). Here is a code snippet that does this:


<property name="jarpack-task.jar" value="${glassfish_home}/lib/Pack200Task.jar"/>
   <target name="jarpack-tasks" >
       <taskdef name="pack200"
                classname="com.sun.tools.apache.ant.pack200.Pack200Task"
                classpath="${jarpack-task.jar}" />
       <taskdef name="unpack200"
                classname="com.sun.tools.apache.ant.pack200.Unpack200Task"
                classpath="${jarpack-task.jar}" />
   </target>

     <!-- Target to pack the jars using the Pack200 ant optional task -->
   <target name="jar-pack" depends="jarpack-tasks" description="Applying the pack utility on jars">
       <mkdir dir="${pack.jar.dir}/normalized" />
       <pack200 src="${pack.jar.dir}/${pack.jar.name}" destfile="${pack.jar.dir}/normalized/${pack.jar.name}"
                repack="true" stripdebug="false" deflatehint="keep" unknownattribute="pass" keepfileorder="true" />
   </target>

   <target name="jar-unpack" depends="jarpack-tasks">
       <unpack200 src="${pack.jar.dir}/${pack.jar.name}.pack.gz" dest="${pack.jar.dir}/${pack.jar.name}" />
       <delete file="${pack.jar.dir}/${pack.jar.name}.pack.gz" />
   </target>

     <target name="pack-all">
       <antcall target="jar-pack">
           <param name="pack.jar.dir" value="${build}" />
           <param name="pack.jar.name" value="roller_configurator_${uc_version}.jar" />
       </antcall>
   </target>

In case you are running into Out Of Memory, (especially on windows), you can try changing your JVM heap size. You can do this using ant's ANT_OPTS as below, and then invoke the ant pack-all target.

set ANT_OPTS=-Xmx512m

In case you are interested in signing your compressed file, then you may need to pack, unpack and then repack your jar. This extra step is needed since Pack200 rearranges the contents of the resultant JAR file. The jarsigner hashes the contents of the class file and stores the hash in an encrypted digest in the manifest. When the unpacker runs on a packed packed, the contents of the classes will be rearranged and thus invalidate the signature. Therefore, the JAR file must be normalized first using pack200 and unpack200, and thereafter signed. Here is how this repackaging can be done:


    <pack200 src="${pack.jar.dir}/${pack.jar.name}" destfile="${pack.jar.dir}/normalized/${pack.jar.name}" 
                 repack="true" stripdebug="false" deflatehint="keep" unknownattribute="pass" keepfileorder="true" /> 
    <unpack200 src="${pack.jar.dir}/normalized/${pack.jar.name}.pack.gz" 
                   dest="${pack.jar.dir}/normalized/a-${pack.jar.name}" /> 
    <pack200 src="${pack.jar.dir}/normalized/${pack.jar.name}" 
                 destfile="${pack.jar.dir}/normalized/${pack.jar.name}.pack.gz" 
                 gzipoutput="true" stripdebug="false" deflatehint="keep" 
                 unknownattribute="pass" keepfileorder="true"/>         
    

Monday Jul 02, 2007

How can I check if my updatecenter module got installed successfully?

How can I check if my updatecenter module got installed successfully?

The module gets unzipped or expanded under GF_V2_HOME/updatecenter/registry/glassfish/packagename.of.your.module

If something went wrong, where can I see it?

In the logs under GF_V2_HOME/updatecenter/logs. GF_V2 FCS will contain some bug fixes that promise better logging capabilites. That would be really nice!

Wednesday Jun 27, 2007

Unconfiguring your update center module

If you want to unconfigure your update center module, one hack to do this would be to edit GF_HOME/domains/domain1/config/domain-registry (domain-registry for your particular domain instance)

Change this property to false

mymodule_configurator_version.configured=false

Then restart your Application server so that unconfigure can explicitly be called.

If you want to reconfigure your module, just set the property to true and restart the application server.

To uninstall,

 asadmin uninstall-addon mymodulename 

Tuesday Jun 19, 2007

Testing your Update Center module

Before you "host" your module on a server for others to download, it would be wise to test it out yourself.

This blog describes how you can test your update center module locally on your GlassFish container through the updatetool client. Hopefully you already know how to create and package your update center module.

Here's what you do to "host" the module on your local running instance of GlassFish. Updatetool is available from GlassFish v2 onwards.

  1. Copy your final module jar to be tested into GF_V2_HOME/domains/domain1/docroot. This enables it to be accessible from http://localhost:8080/module.jar
  2. Copy GF_V2_HOME/updatecenter/registry/glassfish/server.xml to GF_V2_HOME/domains/domain1/docroot. Let's call it update_center.xml. Doing this will enable it to be accessible from http://localhost:8080/update_center.xml.
  3. Edit update_center.xml to have a single entry for the module. Add appropriate values for module codenamebase="my.package" distribution="http://localhost:8080/roller_module.jar". The module type should be "ADDON_INSTALLER".
    Don't worry about getting the exact numbers for downloadsize etc. for now.
  4. Edit GF_v2_HOME/updatecenter/config/config.xml.
    For the catalog name='glassfish' change the url to url='http://localhost:8080/update_center.xml'
  5. Run GF_V2_HOME/updatecenter/bin/updatetool and choose your module.

Trivia: Did you know that a Netbeans module or .nbm extension is just a fancy name for a .jar?

Important contact information: If you are interested in hosting your application on GlassFish Update Center repository, do touch base with the GlassFish Update Center team at: dev@updatecenter.dev.java.net and they'll be happy to work with you.

About

manveen

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today