Version 12

    A module is an application that can be plugged into Nukes quite easily, if you know how to do it. This will give you a quick overview of how to do it and a working example (see attached file at the bottom).

     

    Generally, this article (http://www.onjava.com/pub/a/onjava/2003/06/04/nukes.html?page=2&x-maxdepth=0), which is also referenced on some of the other WiKi pages, will give you a pretty good idea. However, it contains some flaws when it comes down to the example presented and I became quite frustrated that nothing seemed to work when I tried to work with the example...

     

    So, read the article (since I will not repeat what is said there) and then come back here to get a working example.

     

    Module source

    Here is the code of working module (pretty much following the article on onjava.com). The name of the file would be FSInfoModule.java:

    package edu.unika.fswiwi.fsinfo.module;
    
    import org.jboss.nukes.html.Page;
    import org.jboss.nukes.module.ModuleSupport;
    
    //classes extending ModuleSupport MUST be PUBLIC!!
    public class FSInfoModule extends ModuleSupport{
         
         public FSInfoModule(){
              super("FSInfoModule");
         }
         
         /**
          * This method is called with the following url:
          * http://localhost:8080/Nukes/index.html?module=FSInfoModule
          */
         public void main(Page page)
         {
             page.print("<div align=\"center\">");
             page.print("Welcome to the template module");
             page.print("</div>");
    
             // print a form that ask for a name
             page.print("<table align=\"center\">");
    
             // call Nukes main entry point
             page.print("<form action=\"index.html\" method=\"GET\">");
    
             // with module = FSInfoModule
             page.print("<input type=\"hidden\" name=\"module\" value=\"FSInfoModule\"/>");
    
             // and op = action
             page.print("<input type=\"hidden\" name=\"op\" value=\"action\"/>");
    
             // name = XXX
             page.print("<tr><td>Type your name: </td><td><input type=\"text\" name=\"name\" value=\"\"/></td></tr>");
             page.print("<tr><td colspan=\"2\"><input type=\"submit\"/></td></tr>");
             page.print("</form>");
             page.print("</table>");
             page.print("</div>");
         }
    
         
         /** 
          * This method is called with the following url: 
          * http://localhost:8080/Nukes/index.html?module=FSInfoModule&op=action 
          */ 
         public void action(Page page) 
         { 
             // get the parameter 
             String name = page.getParameter("name"); 
    
             // if no name has been provided, just render the main page again 
             if (name == null || name.length() == 0) 
             { 
                main(page); 
                return; 
             } 
    
             page.print("<div align=\"center\">"); 
             page.print("Welcome to the template module " + name); 
             if ( getApi().userLoggedIn() ) 
             { 
                page.print("you are logged in"); 
             } 
             page.print("</div>"); 
         }
    }
    

    jboss-service.xml

    Here is the corresponding jboss-service.xml (the xml declaration has to be the very first thing in the xml-file, not even white space is allowed before the declaration!):

    <?xml version="1.0" encoding="UTF-8" ?> 
      <mbean code="org.jboss.nukes.addons.modules.fsinfo.FSInfoModule"
       name="nukes.modules:name=FSInfoModule" xmbean-dd=""
       xmbean-code="org.jboss.nukes.component.NukesMBean">
           <depends>nukes.modules:name=core</depends> 
           <xmbean>
           <attribute name="DisplayName">FS-Info</attribute> 
           <attribute name="Description">FSWIWI::WIMA</attribute> 
           <attribute name="Configuration">
                <module>
                     <operation name="FSInfoModule" display-name="FS-Info"
                             description="Fachschaft WiWi" image="" hint="" ></operation> 
                </module>
           </attribute>
           </xmbean>
      </mbean>
    

    How to put the files together and deploy them?

    You put your files (including MANIFEST files, which can be automatically created by the JDK's jar.exe (in the bin folder of the JDK) or various IDEs, see article on onjava.com) in a .sar file (Service ARchive), which is a simple ZIP file, renamed to .sar. Inside the sar you put your manifest-file and the jboss-service.xml into a directory called META-INF and package your actual classes into a .jar file (again using jar.exe) and put it in the root folder of the sar. An example can be found in the attached file below.

     

    The .sar file itself has then to be deployed into the appropriate directory:

    (jboss_home)\server\(server_instance)\nukes (e.g. C:\program files\jboss\server\default\nukes). Nukes/JBoss automatically recognizes the new file and deploys it.

     

    Hopefully this saves you some time. Please feel free to make additions/modifications to this page to enhance it! It really does help people