<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Bhavani Shankar&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/" />
<modified>2008-04-14T07:49:07Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/bhavanishankar/313</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, bhavanishankar</copyright>
<entry>
<title>Using SailFin as Instant Messaging (IM/Chat) server</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2008/04/using_sailfin_a.html" />
<modified>2008-04-14T07:49:07Z</modified>
<issued>2008-04-14T07:48:56Z</issued>
<id>tag:weblogs.java.net,2008:/blog/bhavanishankar/313.9527</id>
<created>2008-04-14T07:48:56Z</created>
<summary type="text/plain">It is very easy to use SailFin server as an Instant Messaging server (IM server). All that you need is to write a SipServlet and deploy it in SailFin server.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<PRE LANG="en" CLASS="screen" STYLE="margin-left: 0.5in; margin-right: 0.5in">

It is very easy to use SailFin server as an Instant Messaging server (IM server). 
For that, I wrote a IM/Chat server application which is nothing but a <a href="http://en.wikipedia.org/wiki/SIMPLE">SIMPLE</a> SipServlet 
running on top of SailFin.

Here is how you can deploy and use my application :

    * Download, install and start SailFin - <a href="http://sailfin.dev.java.net">http://sailfin.dev.java.net</a>
    * Download the application (IMServer.war) from <a href="http://weblogs.java.net/blog/bhavanishankar/archive/IMServer.war">here</a> 
    * Deploy the application using 'asadmin deploy IMServer.war'
    * Go through the <a href="http://weblogs.java.net/blog/bhavanishankar/archive/sailfin-for-im.htm">flash demo</a> and see how to use the application.
    * Needless to mention, you need to have a SIP aware IM client (I used X-Lite).

The flash demo is worth thousand lines of description.

The complete source code of my application is available <a href="http://weblogs.java.net/blog/bhavanishankar/archive/IMServer.zip">here</a>. 
For viewing and modifying the source code, you need to have <a href="http://download.netbeans.org/netbeans/6.0/final/">NetBeans 6.0</a> 
and latest version of <a href="https://sailfin.dev.java.net/servlets/ProjectDocumentList?folderID=8167&expandFolder=8167&folderID=0">SIP Application Development plug-in</a>

<b>Highlights of the code:</b>

Here are the main code snippets of the IMServer SipServlet with some basic 
description. However the complete source code is available for <a href="http://weblogs.java.net/blog/bhavanishankar/archive/IMServer.zip">download</a>. I have used 
the very familiar names in SIP world i.e., 'bob' & 'alice' for explaining the code snippets.

<b><i>Sending and receiving PRESENCE information to/from buddies:</b></i>

When 'bob' adds 'alice' to his Friend's list, 'bob' will send a SUBSCRIBE request to SailFin 
server requesting to send NOTIFICATIONS for any status change of 'alice'.

When 'bob' sends a SUBSCRIBE request, doSubscribe method is called. As part of 
doSubscribe, we also send a SUBSCRIBE request to 'bob' so that SailFin gets notified of 
any status change of 'bob'.

Here is the code for doSubscribe:

<DIV style="background-color: rgb(204, 204, 204);">
    /**
     * This method is called when the Person adds a FRIEND to his
     * friend's list, Also, this method is called for every FRIEND in
     * Person's friend's list when the softphone starts up.
     */
    @Override
    protected void doSubscribe(SipServletRequest request)
            throws ServletException, IOException {

        String friendID = ((SipURI) request.getRequestURI()).getUser();

        System.out.println(className + " :: doSubscribe " +
                "for friend : " + friendID + ", incoming request = \n\n" +
                request + "\n");
        /**
         * Add FRIEND to the Person's friend's list. Also, store the SipSession
         * of this request, so that we can send the NOTIFY using this SipSession.
         */
        Person person = findPerson(request);

        if (person != null &&
                !person.getId().equals(friendID)) {

            person.addFriendID(friendID);

            person.setSubscriptionSession(friendID, request.getSession());
        }

        /**
         * Send 200 OK.
         */
        SipServletResponse resp =
                request.createResponse(SipServletResponse.SC_OK);
        resp.send();

        /**
         * SUBSCRIBE for the presence information of this user.
         */
        subscribeForPresenceEvents(request);

        /**
         * If the friend is currently online, send his presence information
         * to this person.
         */
        sendPresenceInformation(PersonDB.findPersonById(friendID), person);
       
    }

    /**
     * Send the SUBSCRIBE request to sourceAddress of SipServletRequest.
     */
    private void subscribeForPresenceEvents(SipServletRequest request) {
        SipURI sourceAddress = getSourceAddress(request);
        try {
            SipServletRequest sReq = sf.createRequest(
                    sf.createApplicationSession(),
                    "SUBSCRIBE",
                    request.getRequestURI(),
                    sourceAddress);
            sReq.addHeader("Event", "presence");
            sReq.addHeader("Expires", "3600");
            System.out.println(className + " :: subscribeForPresenceEvents, " +
                    "outgoing SUBSCRIBE request = \n\n" + sReq + "\n");
            sReq.send();
        } catch (Exception ex) {
            System.out.println("Unable to send SUBSCRIBE request to " +
                    sourceAddress);
            ex.printStackTrace();
        }
    }

</DIV>

For the SUBSCRIBE request we sent to 'bob' in doSubscribe method, we also receive 
NOTIFICATIONS from 'bob' whenever he changes his status.

Following is the method which handles the NOTIFICATIONS received from 'bob'. As part 
of this method, we send bob's status to all his friends who are currently online.

<DIV style="background-color: rgb(204, 204, 204);">
   /**
     * This method is called when someone sends the presence information.
     */
    @Override
    protected void doNotify(SipServletRequest request)
            throws ServletException, IOException {

        System.out.println(className + " :: " +
                "doNotify, incoming request = \n\n" + request + "\n");

        /**
         * Retrieve the presence information from request and store
         * it in Person object.
         */
        Person person = storePresenceInformation(request);

        /**
         * Send 200 OK.
         */
        SipServletResponse resp =
                request.createResponse(SipServletResponse.SC_OK);
        resp.send();

        /**
         * Notify the presence information to all friends
         * who are currently online.
         */
        sendPresenceInformationToAllFriends(person);
    }

</DIV>


<b><i>Sending and receiving InstantMessage to/from buddies:</b></i>

Below is the code snippet which is invoked when 'bob' sends an InstantMessage to 
'alice'. This method takes care of forwarding that message to the current IP address of 
'alice'.

<DIV style="background-color: rgb(204, 204, 204);">
   /**
     * This method is called when someone types some message in his/her
     * Chat window. We need to direct that message to the present location
     * of the destination.
     */
    @Override
    protected void doMessage(SipServletRequest request)
            throws ServletException, IOException {

        System.out.println(className + " :: " +
                "doMessage, incoming request = \n\n" + request + "\n");

        String to = ((SipURI)request.getRequestURI()).getUser();
        Person p = PersonDB.findPersonById(to);

        if (p != null && p.getStatus() == Person.Status.ONLINE) {

            System.out.println("personID = " + p.getId() +
                    ", proxying request to presentLocationURI = " +
                    p.getPresentLocationURI());

            Proxy proxy = request.getProxy();
            proxy.proxyTo(sf.createURI(p.getPresentLocationURI()));

            /**
             * Send 200 OK
             */
            SipServletResponse resp =
                    request.createResponse(SipServletResponse.SC_OK);
            resp.send();

        } else {
            /**
             * Send 404 NOT_FOUND
             */
            SipServletResponse resp =
                    request.createResponse(SipServletResponse.SC_NOT_FOUND);
            resp.send();
        }
    }

</DIV>

</PRE>
]]>

</content>
</entry>
<entry>
<title>SailFin : SIP and JavaEE convergence demo</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2007/12/sailfin_sip_and_1.html" />
<modified>2007-12-04T06:14:32Z</modified>
<issued>2007-12-04T05:32:23Z</issued>
<id>tag:weblogs.java.net,2007:/blog/bhavanishankar/313.8754</id>
<created>2007-12-04T05:32:23Z</created>
<summary type="text/plain">Using the converged container, the SIP component and the JavaEE components (eg., MDB) can share the resources, and the SIP functionality can be used inside the MDB.

The flash demo embedded in this blog illustrates how the SailFin converged container is used for SIP and MDB convergence.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[Using the converged container, the SIP component and the JavaEE components (eg., MDB) can share the resources, and the SIP functionality can be used inside the MDB.
<br/><br/>
The flash demo embedded in this blog illustrates how the <a href="http://sailfin.dev.java.net">SailFin</a> converged container is used for SIP and MDB convergence.
<br/><br/>
This is what the sample application is all about : The customer can apply for a credit card online. After applying for the credit card, the customer is supposed to receive a phone call (on his SIP phone) from the bank executive. During the conversation, the bank executive will be able to access the details submitted by the customer. The sample is written in a way that, if there is only one bank executive, the simultaneous applications submitted by the different customers will be queued in the JMS Queue (<a href="http://en.wikipedia.org/wiki/Sun_Java_System_Message_Queue">SJSMQ</a>) and processed one by one.
<br/><br/>
The sample has two web interfaces, one for the customer to apply for the credit card online, and another for the bank executive to access the customer details during the phone conversation.
<br/><br/>
In terms of the implementation, there is a Java EE application (EAR file) containing the Web component, Message Driven Bean, and a SIP component. The web component serves as the front end for Customer and Bank executive. SIP component serves as a B2B User Agent. The MDB sequentially processes the customer requests placed in the JMS Queue (<a href="http://en.wikipedia.org/wiki/Sun_Java_System_Message_Queue">SJSMQ</a>) and initiates a phone call between the customer and bank executive.
<br/><br/>
The sample does not demonstrate the convergence between the SIP and HTTP, instead it demonstrates the convergence between SIP and EJB.
<br/><br/>
Though this sample has not been tried with the cluster topology, it is possible for the MDB running in <em>instanceA</em> to access the SipApplicationSession (& its child sessions) created by the JSP running in <em>instanceB</em>. This is possible using the high availability feature (implemented using in-memory session replication)  provided by the SailFin server.
<br/><br/>
The <a href="http://weblogs.java.net/blog/bhavanishankar/archive/onlinebank-demo.htm">Flash demo</a> shows the steps of developing this application and running it.

The source code of the sample is available in <a href="https://sailfin.dev.java.net/source/browse/sailfin">SailFin CVS</a> repository (sailfin/samples/OnlineBank).
]]>

</content>
</entry>
<entry>
<title>GlassFish : Sun Java EE Engine (pka Java EE Service Engine) article</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2007/06/glassfish_sun_j.html" />
<modified>2007-06-19T04:24:55Z</modified>
<issued>2007-06-19T04:21:13Z</issued>
<id>tag:weblogs.java.net,2007:/blog/bhavanishankar/313.7675</id>
<created>2007-06-19T04:21:13Z</created>
<summary type="text/plain">An article which covers most of the aspects of Sun Java EE Engine is published at http://java.sun.com/developer/technicalArticles/J2EE/sunjavaee_engine. The article is a good reading for the GlassFish &amp; JBI users. The new features of the Sun Java EE Engine, available as part of GlassFish V2, have been explained in detail in the article.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[An article which covers most of the aspects of <i>Sun Java EE Engine</i> is published <a href="http://java.sun.com/developer/technicalArticles/J2EE/sunjavaee_engine">here</a>.

<p>The article is a good reading for the GlassFish & JBI users. The new features of the Sun Java EE Engine, available as part of GlassFish V2, have been explained in detail in the article. </p>


]]>

</content>
</entry>
<entry>
<title>GlassFish : Java EE Service Engine is now called sun-javaee-engine</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2007/06/glassfish_java_1.html" />
<modified>2007-06-03T06:39:06Z</modified>
<issued>2007-06-03T06:36:54Z</issued>
<id>tag:weblogs.java.net,2007:/blog/bhavanishankar/313.7552</id>
<created>2007-06-03T06:36:54Z</created>
<summary type="text/plain">Recently, the component name of the Java EE service engine is changed from &quot;JavaEEServiceEngine&quot; to &quot;sun-javaee-engine&quot;. It is very easy for the end users to migrate their applications to the new name. All that is required is to open your existing JBI project in NetBeans, build and deploy.....</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE>GlassFish : Java EE Service Engine is now called sun-javaee-engine</TITLE>
	<META NAME="GENERATOR" CONTENT="StarOffice 8  (Linux)">
	<META NAME="AUTHOR" CONTENT="B S">
	<META NAME="CREATED" CONTENT="20070603;11051000">
	<META NAME="CHANGEDBY" CONTENT="B S">
	<META NAME="CHANGED" CONTENT="20070603;11081300">
	<!-- header END -->
	<!-- leftside BEGIN -->
	<!-- leftside END -->
	<!-- content BEGIN -->
	<STYLE>
	<!--
		PRE.screen { background: #eeeeee; border: 1px solid #bbbbbb; padding: 0.1in; color: #000000; font-family: monospace }
	-->
	</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P STYLE="margin-left: 0.5in; margin-right: 0.5in; margin-bottom: 0in; border: none; padding: 0in">
<BR>
</P>
<P STYLE="margin-left: 0.5in; margin-right: 0.5in"><SPAN LANG="en"><FONT SIZE=2><FONT FACE="sans-serif">Recently,
the component name of the Java EE service engine is changed from
&quot;JavaEEServiceEngine&quot; to &quot;sun-javaee-engine&quot;. It
is very easy for the end users to migrate their applications to the
new name. All that is required is to open your existing JBI project
in NetBeans, build and deploy.<BR><BR>These are the detailed
steps:<BR><BR>1. Go to
<A HREF="http://www.netbeans.org/community/releases/60/index.html">http://www.netbeans.org/community/releases/60/index.html</A><BR>2.
Click &quot;Download Preview&quot;<BR>3. Select your platform and
download &quot;Full&quot; version.<BR>4. Open your JBI project with
this new NetBeans, do a &quot;Clean and Build Project&quot; and
&quot;Deploy Project&quot;.<BR><BR>If you have Non-NetBeans projects,
then the following program can be used to migrate your projects to
the new name. You just need to compile it and run it. You can also
modify this utility to server your
purpose.<BR><BR><BR><B>JBICompNameChangeUtil.java</B></FONT></FONT></SPAN></P>
<PRE LANG="en" CLASS="screen" STYLE="margin-left: 0.5in; margin-right: 0.5in">import java.io.BufferedReader;
<SPAN LANG="en">import java.io.BufferedWriter;</SPAN>
<SPAN LANG="en">import java.io.File;</SPAN>
<SPAN LANG="en">import java.io.FileFilter;</SPAN>
<SPAN LANG="en">import java.io.FileNotFoundException;</SPAN>
<SPAN LANG="en">import java.io.FileReader;</SPAN>
<SPAN LANG="en">import java.io.FileWriter;</SPAN>
<SPAN LANG="en">import java.io.IOException;</SPAN>
<SPAN LANG="en">import java.util.ArrayList;</SPAN>
<SPAN LANG="en">import java.util.Iterator;</SPAN>
<SPAN LANG="en">import java.util.List;</SPAN>
<SPAN LANG="en">public class JBICompNameChangeUtil {</SPAN>
    
    <SPAN LANG="en">private void printUsage() {</SPAN>
        <SPAN LANG="en">System.err.println(&quot;Usage: java JBICompNameChangeUtil &quot; +</SPAN>
                <SPAN LANG="en">&quot;&lt;root-directory-for-all-projects&gt;&quot;);</SPAN>
        <SPAN LANG="en">System.err.println(&quot;For example: java JBICompNameChangeUtil&quot; +</SPAN>
                <SPAN LANG="en">&quot; /space/projects/jbi&quot;);</SPAN>
    <SPAN LANG="en">}</SPAN>
    
    <SPAN LANG="en">private void changeName(String... args) {</SPAN>
        <SPAN LANG="en">if(args.length != 1) {</SPAN>
            <SPAN LANG="en">printUsage();</SPAN>
            <SPAN LANG="en">System.exit(1);</SPAN>
        <SPAN LANG="en">}</SPAN>
        
        <SPAN LANG="en">File root = new File(args[0]);</SPAN>
        <SPAN LANG="en">if(!root.exists() || !root.isDirectory()) {</SPAN>
            <SPAN LANG="en">printUsage();</SPAN>
            <SPAN LANG="en">System.exit(1);</SPAN>
        <SPAN LANG="en">}</SPAN>
        <SPAN LANG="en">List fileList = new ArrayList();</SPAN>
        <SPAN LANG="en">getAllImpactedFiles(root, fileList);</SPAN>
        <SPAN LANG="en">for(Iterator i = fileList.iterator(); i.hasNext();) {</SPAN>
            <SPAN LANG="en">File file = (File)i.next();</SPAN>
            <SPAN LANG="en">try {</SPAN>
                <SPAN LANG="en">updateFile(file);</SPAN>
            <SPAN LANG="en">} catch(FileNotFoundException ex) {</SPAN>
                <SPAN LANG="en">ex.printStackTrace();</SPAN>
            <SPAN LANG="en">} catch(IOException ex) {</SPAN>
                <SPAN LANG="en">ex.printStackTrace();</SPAN>
            <SPAN LANG="en">}</SPAN>
        <SPAN LANG="en">}</SPAN>
    <SPAN LANG="en">}</SPAN>
    
    <SPAN LANG="en">private void getAllImpactedFiles(File root, List fileList) {</SPAN>
        <SPAN LANG="en">FileFilter myFileFilter = new FileFilter() {</SPAN>
            <SPAN LANG="en">public boolean accept(File file) {</SPAN>
                <SPAN LANG="en">if(file.isDirectory()) {</SPAN>
                    <SPAN LANG="en">return true;</SPAN>
                <SPAN LANG="en">} else {</SPAN>
                    <SPAN LANG="en">String fileName = file.getName();</SPAN>
                    <SPAN LANG="en">return fileName.equals(&quot;jbi.xml&quot;);</SPAN>
                <SPAN LANG="en">}</SPAN>
            <SPAN LANG="en">}</SPAN>
        <SPAN LANG="en">};</SPAN>
        <SPAN LANG="en">File files[] = root.listFiles(myFileFilter);</SPAN>
        <SPAN LANG="en">File arr[] = files;</SPAN>
        <SPAN LANG="en">int len = arr.length;</SPAN>
        <SPAN LANG="en">for(int i = 0; i &lt; len; i++) {</SPAN>
            <SPAN LANG="en">File file = arr[i];</SPAN>
            <SPAN LANG="en">if(file.isDirectory())</SPAN>
                <SPAN LANG="en">getAllImpactedFiles(file, fileList);</SPAN>
            <SPAN LANG="en">else</SPAN>
                <SPAN LANG="en">fileList.add(file);</SPAN>
        <SPAN LANG="en">}</SPAN>
    <SPAN LANG="en">}</SPAN>
    
    <SPAN LANG="en">private void updateFile(File file)</SPAN>
            <SPAN LANG="en">throws FileNotFoundException, IOException {</SPAN>
        <SPAN LANG="en">System.out.println((new StringBuilder()).append(&quot;Updating &quot;).</SPAN>
                <SPAN LANG="en">append(file.getPath()).append(&quot;...&quot;).toString());</SPAN>
        <SPAN LANG="en">String fileName = file.getName();</SPAN>
        <SPAN LANG="en">BufferedReader reader = new BufferedReader(new FileReader(file));</SPAN>
        <SPAN LANG="en">File tempFile = File.createTempFile(fileName, &quot;tmp&quot;);</SPAN>
        <SPAN LANG="en">BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));</SPAN>
        <SPAN LANG="en">String line;</SPAN>
        <SPAN LANG="en">if(fileName.equals(&quot;jbi.xml&quot;)) {</SPAN>
            <SPAN LANG="en">while((line = reader.readLine()) != null) {</SPAN>
                <SPAN LANG="en">line = updateSEName(line);</SPAN>
                <SPAN LANG="en">writer.write((new StringBuilder()).append(line).</SPAN>
                        <SPAN LANG="en">append(LINE_SEPARATOR).toString());</SPAN>
            <SPAN LANG="en">}</SPAN>
        <SPAN LANG="en">}</SPAN>
        <SPAN LANG="en">writer.close();</SPAN>
        <SPAN LANG="en">reader = new BufferedReader(new FileReader(tempFile));</SPAN>
        <SPAN LANG="en">writer = new BufferedWriter(new FileWriter(file));</SPAN>
        <SPAN LANG="en">while((line = reader.readLine()) != null)</SPAN>
            <SPAN LANG="en">writer.write((new StringBuilder()).append(line).</SPAN>
                    <SPAN LANG="en">append(LINE_SEPARATOR).toString());</SPAN>
        <SPAN LANG="en">reader.close();</SPAN>
        <SPAN LANG="en">writer.close();</SPAN>
        <SPAN LANG="en">tempFile.delete();</SPAN>
    <SPAN LANG="en">}</SPAN>
    
    <SPAN LANG="en">private String updateSEName(String line) {</SPAN>
        <SPAN LANG="en">if(line.indexOf(&quot;JavaEEServiceEngine&quot;) != -1)</SPAN>
            <SPAN LANG="en">line = line.replace(&quot;JavaEEServiceEngine&quot;, &quot;sun-javaee-engine&quot;);</SPAN>
        <SPAN LANG="en">return line;</SPAN>
    <SPAN LANG="en">}</SPAN>
    
    <SPAN LANG="en">private static final String LINE_SEPARATOR = </SPAN>
            <SPAN LANG="en">System.getProperty(&quot;line.separator&quot;);</SPAN>
    
    <SPAN LANG="en">public static void main(String args[]) {</SPAN>
        <SPAN LANG="en">JBICompNameChangeUtil instance = </SPAN>
                <SPAN LANG="en">new JBICompNameChangeUtil();</SPAN>
        <SPAN LANG="en">instance.changeName(args);</SPAN>
    <SPAN LANG="en">}</SPAN>
    
<SPAN LANG="en">}</SPAN></PRE>
</BODY>
</HTML>]]>

</content>
</entry>
<entry>
<title>Self Managing the JBI runtime in GlassFish</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2007/05/self_managing_t.html" />
<modified>2007-05-22T11:51:23Z</modified>
<issued>2007-05-22T11:49:34Z</issued>
<id>tag:weblogs.java.net,2007:/blog/bhavanishankar/313.7474</id>
<created>2007-05-22T11:49:34Z</created>
<summary type="text/plain">You can self manage the JBI runtime using the Self Management module of GlassFish application server.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>
<dc:subject>Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<html>
<head>
<title>Self Manage JBI</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="print" href="print.css">
<style type="text/css" media="screen">
@import url("css/layout.css");
@import url("css/content.css");
@import url("css/docbook.css");
</style>
<style type="text/css">
li p {
display: inline;
}

div.table table {
width: 95%;
background-color: #DCDCDC;
color: #000000;
border-spacing: 0;
}

div.table table th {
border: 1px solid #A9A9A9;
background-color: #A9A9A9;
color: #000000;
}

div.table table td {
border: 1px solid #A9A9A9;
background-color: #DCDCDC;
color: #000000;
padding: 0.5em;
margin-bottom: 0.5em;
margin-top: 2px;

}

div.note table, div.tip table, div.important table, div.caution table, div.warning table {
width: 95%;
border: 2px solid #B0C4DE;
background-color: #F0F8FF;
color: #000000;
/* padding inside table area */
padding: 0.5em;
margin-bottom: 0.5em;
margin-top: 0.5em;
}

.qandaset table {
border-collapse: collapse;
}
.qandaset {
}
.qandaset tr.question {
}
.qandaset tr.question td {
font-weight: bold;
padding: 1em 1em 0;
}
.qandaset tr.answer td {
padding: 0.25em 1em 1.5em;
}
.qandaset tr.question td, .qandaset tr.answer td {
}

hr {
border: 0;
border-bottom: 1px solid #ccc;
}

h1, h2, h3, h4 {
font-family: luxi sans,sans-serif;
color: #990000;
font-weight: bold;
}
h1 {
font-size: 1.75em;
}

h2 {
font-size: 1.25em;
}

h3 {
font-size: 1.1em;
}

code.screen, pre.screen {
font-family: monospace;
font-size: 1em;
display: block;
padding: 10px;
border: 1px solid #bbb;
background-color: #eee;
color: #000;
overflow: auto;
border-radius: 2.5px;
-moz-border-radius: 2.5px;
margin: 0.5em 2em;
}

div.example {
padding: 10px;
border: 1px solid #bbb;
margin: 0.5em 2em;
}

.procedure ol li {
margin-bottom: 0.5em;
}
.procedure ol li li {
/* prevent inheritance */
margin-bottom: 0em;
}

.itemizedlist ul li {
margin-bottom: 0.5em;
}
.itemizedlist ul li li {
/* prevent inheritance */
margin-bottom: 0em;
}
</style>
<script src="offsite.js" type="text/javascript"></script>
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
</head>
<body onload="OffSite();">
<!-- header END --><!-- leftside BEGIN --><!-- leftside END --><!-- content BEGIN -->
<div style="border: 0pt none ; margin-left: 0.5in; margin-right: 0.5in;"><br>
</div>
<div id="fedora-content">
<div class="article" lang="en">
<div class="titlepage">
<div>
<div>
<div class="legalnotice">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><font
size="-1"><span style="font-family: verdana;">It is possible to self
manage the JBI runtime using the self management module of the
GlassFish application server. I am showing one such example here.<br>
<br>
In this example, we </span></font><font face="sans-serif" size="-1">have
a timer service registered with the self management module which checks
whether all the required components for the deployed JBI service
assemblies are UP or
not. Corrective action : <br>
<br>
&nbsp;&nbsp;&nbsp; (1) Try to bring up the components required by the
running JBI service assemblies.<br>
&nbsp;&nbsp;&nbsp; (2) If (1) fails, log the error in server.log. (The
example can be enhanced to send an email to administrator).<br>
<br>
Here is the MBean code which receives the notification from the self
management module, does the necessary checks and takes the corrective
action.<br>
<br>
<span style="font-weight: bold;">SelfManageJBIComps.java</span> :<br>
<br>
</font>
<pre class="screen"><code class="prompt"></code>package com.sun.samples.appserver;<br><br>import java.util.ArrayList;<br>import javax.management.MBeanServer;<br>import javax.management.MBeanServerFactory;<br>import javax.management.Notification;<br>import javax.management.ObjectName;<br><br>/**<br> *<br> * @author Bhavanishankar &lt;bshankar@sun.com&gt;<br> *<br> */<br><br>public class SelfManageJBIComps<br> implements SelfManageJBICompsMBean, SelfManageJBICompsConstants {<br> <br> public synchronized void handleNotification(<br> Notification notification,<br> Object obj) {<br><br> StringBuffer debugMessage = new StringBuffer<br> ("\n\nSelfManageJBIComps :: \n");<br> <br> System.out.println("SelfManageJBIComps.handleNotification : " +<br> notification.getClass().getName());<br> <br> /**<br> * Allow the JBI framework to initialize itself properly.<br> */<br> if(firstInvocation) {<br> firstInvocation = false;<br> return;<br> }<br> <br> /**<br> * Step 1. Get the connection to the MBean server.<br> */<br> initMBeanConnection();<br> <br> /**<br> * Step 2. Get the list of deployed service assemblies.<br> */<br> Object ret = invokeMBean(<br> getDeploymentServiceMBeanName(),<br> "getDeployedServiceAssemblies",<br> new Object[]{},<br> new String[]{});<br> <br> if(ret == null) {<br> return;<br> }<br> String[] serviceAssemblies = (String[]) ret;<br> <br> /**<br> * Step 3. For each service assembly which is in "Started" <br> * state, if the required component's state is not started <br> * then start the component.<br> */<br> <br> for(String sa : serviceAssemblies) {<br> debugMessage.append("\n\tProcessing ServiceAssembly " +<br> sa + "...");<br> /**<br> * Step 3.1. Get the state of the service assembly.<br> */<br> ret = invokeMBean(<br> getDeploymentServiceMBeanName(),<br> "getState",<br> new Object[] {sa},<br> new String[] {"java.lang.String"});<br> if(ret == null) {<br> continue;<br> }<br> String saState = (String)ret;<br> <br> debugMessage.append("\n\tState of the ServiceAssembly is " +<br> saState);<br> <br> /**<br> * Step 3.2 If the state is "Started" then<br> * get the list of Components for this service assembly.<br> */<br> if(!"Started".equalsIgnoreCase(saState)) {<br> continue;<br> }<br> <br> ret = invokeMBean(<br> getDeploymentServiceMBeanName(),<br> "getComponentsForDeployedServiceAssembly",<br> new Object[] {sa},<br> new String[] {"java.lang.String"});<br> if(ret == null) {<br> continue;<br> }<br> String[] jbiComps = (String[])ret;<br> <br> for(String jbiComp : jbiComps) {<br> debugMessage.append("\n\n\t JBIComponent used " +<br> "by " + sa + " is " + jbiComp);<br> <br> ret = invokeMBean(<br> getAdminServiceMBeanName(),<br> "getComponentByName",<br> new Object[]{jbiComp},<br> new String[]{"java.lang.String"});<br> if(ret == null) {<br> continue;<br> }<br> ObjectName compName = (ObjectName)ret;<br> <br> ret = invokeMBean(<br> compName,<br> "getCurrentState",<br> new Object[]{},<br> new String[]{});<br> <br> if(ret == null) {<br> continue;<br> }<br> <br> String componentState = (String) ret;<br> debugMessage.append("\n\t State of the " + jbiComp +<br> " is " + componentState);<br> <br> if(!"started".equalsIgnoreCase(componentState)) {<br> debugMessage.append("\n\t Starting " + <br> jbiComp + "...");<br> ret = invokeMBean(<br> compName,<br> "start",<br> new Object[] {},<br> new String[] {});<br> debugMessage.append("\n\t Successfully started " +<br> jbiComp);<br> }<br> }<br> }<br> System.out.println(debugMessage.toString());<br> }<br> <br> private static MBeanServer mBeanServer;<br> private static boolean firstInvocation = true;<br> <br> /**<br> * Get the connection to the MBean server.<br> */<br> private synchronized void initMBeanConnection() {<br> if(mBeanServer == null) {<br> ArrayList&lt;MBeanServer&gt; mBeanServers =<br> MBeanServerFactory.findMBeanServer(null);<br> if(!mBeanServers.isEmpty()) {<br> mBeanServer = mBeanServers.get(0);<br> }<br> if(mBeanServer == null) {<br> System.err.println("Unable " +<br> "to obtain connection to MBean server");<br> }<br> }<br> }<br> <br> private Object invokeMBean(<br> ObjectName mBeanName,<br> String methodName,<br> Object[] params,<br> String[] signatures) {<br> Object output = null;<br> try {<br> output = mBeanServer.invoke(mBeanName,<br> methodName, params, signatures);<br> } catch(Exception ex) {<br> ex.printStackTrace();<br> }<br> return output;<br> }<br> <br> private ObjectName getDeploymentServiceMBeanName() {<br> ObjectName objName = null;<br> try {<br> objName = new ObjectName(DEPLOYMENT_SERVICE_MBEAN);<br> } catch(Exception ex) {<br> ex.printStackTrace();<br> }<br> return objName;<br> }<br> <br> private ObjectName getAdminServiceMBeanName() {<br> ObjectName objName = null;<br> try {<br> objName = new ObjectName(ADMIN_SERVICE_MBEAN);<br> } catch(Exception ex) {<br> ex.printStackTrace();<br> }<br> return objName;<br> }<br> <br>}<br><br></pre>
<br>
<font style="font-weight: bold;" face="sans-serif" size="-1">SelfManageJBICompsMBean.java</font>
:<br>
<br>
<font size="-1"><span style="font-family: verdana;"></span></font></div>
<div class="fedora-corner-br">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<pre class="screen"><code class="prompt">package com.sun.samples.appserver;<br><br>import javax.management.NotificationListener;<br><br>/**<br> *<br> * @author Bhavanishankar &lt;bshankar@sun.com&gt;<br> *<br> */<br><br>public interface SelfManageJBICompsMBean <br> extends NotificationListener {<br> <br>}<br></code></pre>
</div>
<div id="fedora-footer">
<div id="fedora-footer">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><font
style="font-weight: bold;" face="sans-serif" size="-1"><br>
SelfManageJBICompsConstants.java</font> :<br>
<br>
<pre class="screen"><code class="prompt">package com.sun.samples.appserver;<br><br>/**<br> *<br> * @author Bhavanishankar &lt;bhankar@sun.com&gt;<br> *<br> */<br>public interface SelfManageJBICompsConstants {<br> <br> /**<br> * Set these values as per the JBI runtime being used.<br> */<br> <br> public String ADMIN_SERVICE_MBEAN =<br> "com.sun.jbi:JbiName=server,ServiceName=AdminService," +<br> "ControlType=AdministrationService,ComponentType=System";<br> <br> public String DEPLOYMENT_SERVICE_MBEAN =<br> "com.sun.jbi:JbiName=server,ServiceName=DeploymentService," +<br> "ControlType=DeploymentService,ComponentType=System";<br> <br>}<br></code></pre>
<font face="sans-serif" size="-1"><br>
</font><font face="sans-serif"><span style="font-weight: bold;">Steps
to setup:</span></font><font face="sans-serif" size="-1"><br>
<br>
&nbsp;&nbsp;&nbsp; 1. Compile the above code and create a JAR file say
SelfManageJBIComps.jar. Copy this JAR file to
&lt;YOUR-GLASSFISH-INSTALLATION&gt;/lib directory.<br>
<br>
&nbsp;&nbsp;&nbsp; 2. Register the above MBean with the MBean server.<br>
<br>
</font>
<pre class="screen"><code class="prompt">asadmin create-mbean --name SelfManageJBIComps com.sun.samples.appserver.SelfManageJBIComps</code></pre>
<font face="sans-serif" size="-1">&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; 3. Create a self management rule and register a
timer service.<br>
<br>
</font>
<pre class="screen"><code class="prompt">asadmin create-management-rule --eventtype timer --eventproperties period=60000 --action SelfManageJBIComps SelfManageJBIComps<br></code></pre>
<br>
<font face="sans-serif"><span style="font-weight: bold;">How to test?</span></font><br>
<font face="sans-serif" size="-1"><br>
&nbsp;&nbsp;&nbsp; Bring down a JBI component which is required by a
running JBI service assembly and wait for a minute.
After a minute you can see that the JBI component is started.<br>
</font></div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- footer END -->
</body>
</html>

]]>

</content>
</entry>
<entry>
<title>ServiceMix on GlassFish - Java EE and JBI integration</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2007/01/servicemix_on_g_1.html" />
<modified>2007-01-05T03:44:59Z</modified>
<issued>2007-01-05T03:44:26Z</issued>
<id>tag:weblogs.java.net,2007:/blog/bhavanishankar/313.6254</id>
<created>2007-01-05T03:44:26Z</created>
<summary type="text/plain">This blog details the experiments I did recently to make ServiceMix run inside GlassFish application server. The other interesting thing about this integration is the ability of the GlassFish application server to allow the in-process communication between ServiceMix and Java EE components (EJBs/Servlets wrapped as webservices) using a readily available JBI component of GlassFish viz., the Java EE Service Engine.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<html>
<head>
<title>ServiceMix on GlassFish - Java EE and JBI integration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="print" href="print.css">
<style type="text/css">
li p {
display: inline;
}

div.table table {
width: 100%;
background-color: #DCDCDC;
color: #000000;
border-spacing: 0;
}

div.table table th {
border: 1px solid #A9A9A9;
background-color: #A9A9A9;
color: #000000;
}

div.table table td {
border: 1px solid #A9A9A9;
background-color: #DCDCDC;
color: #000000;
padding: 0.5em;
margin-bottom: 0.5em;
margin-top: 2px;

}

div.note table, div.tip table, div.important table, div.caution table, div.warning table {
width: 100%;
border: 2px solid #B0C4DE;
background-color: #F0F8FF;
color: #000000;
/* padding inside table area */
padding: 0.5em;
margin-bottom: 0.5em;
margin-top: 0.5em;
}

.qandaset table {
border-collapse: collapse;
}
.qandaset {
}
.qandaset tr.question {
}
.qandaset tr.question td {
font-weight: bold;
padding: 1em 1em 0;
}
.qandaset tr.answer td {
padding: 0.25em 1em 1.5em;
}
.qandaset tr.question td, .qandaset tr.answer td {
}

hr {
border: 0;
border-bottom: 1px solid #ccc;
}

h1, h2, h3, h4 {
font-family: luxi sans,sans-serif;
color: #990000;
font-weight: bold;
}
h1 {
font-size: 1.75em;
}

h2 {
font-size: 1.25em;
}

h3 {
font-size: 1.1em;
}

code.screen, pre.screen {
font-family: monospace;
font-size: 1em;
display: block;
padding: 10px;
border: 1px solid #bbb;
background-color: #eee;
color: #000;
overflow: auto;
border-radius: 2.5px;
-moz-border-radius: 2.5px;
margin: 0.5em 2em;
}

div.example {
padding: 10px;
border: 1px solid #bbb;
margin: 0.5em 2em;
}

.procedure ol li {
margin-bottom: 0.5em;
}
.procedure ol li li {
/* prevent inheritance */
margin-bottom: 0em;
}

.itemizedlist ul li {
margin-bottom: 0.5em;
}
.itemizedlist ul li li {
/* prevent inheritance */
margin-bottom: 0em;
}
</style>
<script src="offsite.js" type="text/javascript"></script>
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
</head>
<body onload="OffSite();">
<!-- header END --><!-- leftside BEGIN --><!-- leftside END --><!-- content BEGIN -->
<div style="border: 0pt none ; margin-left: 0.5in; margin-right: 0.5in;"><br>
</div>
<div id="fedora-content">
<div class="article" lang="en">
<div class="titlepage">
<div>
<div>
<div class="legalnotice">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left">Contents<br>
</th>
</tr>
<tr>
<td align="left" valign="top">
<p><a href="#Introduction">1. Introduction<br>
</a></p>
<p><a href="#Introduction_to_ServiceMix_GlassFish">2. Brief
descripions of ServiceMix, GlassFish and Java EE Service Engine</a></p>
<p><a href="#Installing_ServiceMix_on_GlassFish">3. Installing
ServiceMix on GlassFish</a><br>
</p>
<p><a href="#Installing_Java_EE_Service_Engine_to">4. Installing
Java EE Service Engine to ServiceMix</a></p>
<p><a href="#Accessing_the_EJBs_deployed_on_GlassFish">5.
Accessing
the EJBs deployed on GlassFish from ServiceMix using Java EE Service
Engine</a><br>
</p>
<p><a href="#More_Info">6. More Info.</a><br>
</p>
<p> </p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fedora-corner-br">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><br>
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left"><a name="Introduction"></a>Introduction<br>
</th>
</tr>
<tr>
<td align="left" valign="top"><br>
This blog details the experiments I did recently to make ServiceMix run
inside GlassFish application server.<br>
<br>
The other interesting thing about this integration is the ability of
the GlassFish application server to allow the in-process communication
between ServiceMix and Java EE components (EJBs/Servlets wrapped as
webservices) using a readily available JBI component of GlassFish viz.,
the Java EE Service Engine.<br>
<br>
Details of the versions of the various softwares I used for this
experiment :<br>
<br>
<table style="width: 50%; text-align: left;" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;">GlassFish Application
Server<br>
</td>
<td style="vertical-align: top;"><a
href="http://download.java.net/javaee5/trunk/installer-nightly/Linux/glassfish-installer-v2-b31-nightly-04_jan_2007.jar">v2
b31</a><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">ServiceMix<br>
</td>
<td style="vertical-align: top;"><a
href="http://servicemix.org/site/servicemix-30.html">3.0</a><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">Maven<br>
</td>
<td style="vertical-align: top;"><a
href="http://maven.apache.org/download.html">2.0.4</a><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">JDK<br>
</td>
<td style="vertical-align: top;"><a
href="http://java.sun.com/javase/downloads/index_jdk5.jsp">5.0</a><br>
</td>
</tr>
</tbody>
</table>
<br>
<p> </p>
</td>
</tr>
</tbody>
</table>
</div>
&nbsp;&nbsp;<br>
<div id="fedora-footer">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left"><a name="Introduction_to_ServiceMix_GlassFish"></a>Brief
descriptions of ServiceMix, GlassFish and Java EE Service Engine</th>
</tr>
<tr>
<td align="left" valign="top">
<p><span style="font-weight: bold; font-style: italic;">ServiceMix</span>
is an open source distributed Enterprise Service Bus
(ESB) and SOA toolkit built on the semantics and
APIs of the Java Business Integration (JBI) specification <span
class="nobr"><a href="http://www.jcp.org/en/jsr/detail?id=208">JSR 208</a></span>
and released under the <span class="nobr"><a
href="http://www.apache.org/">Apache</a></span> <span class="nobr"><a
href="http://www.apache.org/licenses/LICENSE-2.0.html">license</a></span>.
More details about the ServiceMix is found at <a
href="http://servicemix.org">http://servicemix.org</a>.<br>
</p>
<p><span style="font-weight: bold; font-style: italic;">GlassFish</span>
is free and open source Java EE 5 application server. It is based on
the source code
for <a href="http://www.sun.com/software/products/appsrvr/index.xml">Sun
Java System Application Server</a> donated by <a
href="http://www.sun.com">Sun Microsystems</a>. More details about the
GlassFish is found at <a href="http://glassfish.dev.java.net">http://glassfish.dev.java.net.</a><br>
</p>
<p><span style="font-weight: bold; font-style: italic;">Java EE
Service Engine</span> acts as a bridge between
GlassFish and JBI environment for web service providers and web service
consumers
deployed in GlassFish. It provides numerous benefits including the
following :<br>
</p>
<ul>
<li>EJBs/Servlets packaged as web services and deployed on
GlassFish
are transparently exposed as service providers in JBI Enviroment <br>
</li>
<li>Java EE Components - EJBs/Servlets can consume services
exposed
in JBI enviroment using the Java EE service engine without being aware
of the underlying binding/protocol such as SOAP, JMS etc exposing the
web service. <br>
</li>
<li>In-process communication between components of application
server
and JBI components to increase request processing speed.</li>
<li>Any component that is plugged into ESB can directly
communicate
with Java EE applications. For example, clients of various bindings
such as SOAP or JMS can communicate with web services developed using
Java EE via JBI because of Java EE Service Engine.</li>
</ul>
The default JBI runtime bundled with GlassFish is OpenESB which is an
open source, world-class enterprise service bus based on JBI
technology. The details of OpenESB is found at <a
href="http://open-esb.dev.java.net">http://open-esb.dev.java.net</a>.<br>
<br>
This article is for those who want to use ServiceMix as their JBI
runtime with GlassFish application server. So the article explains how
to install ServiceMix on
GlassFish and how the ServiceMix can use Java EE
Service Engine to do in-process communication with the Java EE
applications (web services) deployed on GlassFish.<br>
<p> </p>
</td>
</tr>
</tbody>
</table>
</div>
<!-- content END --><!-- footer BEGIN -->
<div id="fedora-footer"><br>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left"><a name="Installing_ServiceMix_on_GlassFish"></a>Installing
ServiceMix on GlassFish</th>
</tr>
<tr>
<td align="left" valign="top">
<p>Download, install and start the latest GlassFish (if you
haven't done already) from <a
href="http://download.java.net/javaee5/trunk/installer-nightly">here</a>.
From now on, I will refer $glassfish_dir to GlassFish installation
directory.<br>
</p>
<p>Download either the source or binary distribution of
ServiceMix from <a href="http://servicemix.org/site/servicemix-30.html">here</a>.
Now we need to create ServiceMix WAR file inorder to install ServiceMix
on GlassFish. From now on, I will refer $servicemix_web_dir to your
servicemix-web directory which will be either <span
style="font-style: italic;">examples/servicemix-web </span>(for
binary distribution) or <span style="font-style: italic;">samples/servicemix-web</span>
(for source distribution).<br>
</p>
<p>Create ServiceMix WAR file :<br>
</p>
<pre class="screen"><code class="prompt">cd $servicemix_web_dir<br><br># Do this workaround in pom.xml :<br>Remove </code><span
style="font-style: italic;">&lt;scope&gt;test&lt;/scope&gt;</span> (line 82)<br><code
class="prompt">(Ref : <a
href="http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/samples/servicemix-web/pom.xml?r1=448366&amp;r2=449600&amp;pathrev=449600&amp;diff_format=h">Mailing List Archive</a> )<br><br></code># Change servicemix-http configuration to accept dynamic SU deployments.<br>In <code
class="prompt">$servicemix_web_dir</code>/src/webapp/WEB-INF/applicationContext.xml, change <br> &lt;http:component&gt;....&lt;/http:component&gt; to <br> &lt;bean class="org.apache.servicemix.http.HttpComponent" /&gt;<br>(Ref : <a
href="http://mail-archives.apache.org/mod_mbox/geronimo-servicemix-users/200610.mbox/%3C6656951.post@talk.nabble.com%3E">Mailing List Archive</a> )<br><br><code
class="prompt"># creates target/servicemix-web-3.0-incubating.war<br>mvn install -Dmaven.test.skip=true</code><br><br># Rename the WAR file as servicemix-web.war for simplicity.<br>mv target/servicemix-web-3.0-incubating.war target/servicemix-web.war<br></pre>
<p>Deploy ServiceMix WAR file to GlassFish :<br>
</p>
<code class="prompt"></code>
<pre class="screen"><code class="prompt"></code><code
class="prompt">$glassfish_dir/bin/asadmin deploy --port 4848 $servicemix_web_dir/target/servicemix-web.war</code> </pre>
<br>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fedora-corner-br">&nbsp;<!-- content END --><!-- footer BEGIN -->
</div>
<div id="fedora-footer">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left"><a name="Installing_Java_EE_Service_Engine_to"></a>Installing
Java EE Service Engine to ServiceMix</th>
</tr>
<tr>
<td align="left" valign="top">
<p>The servicemix components (I am refering to servicemix-http
which is what is used in the sample application) do not wrap/unwrap the
WSDL1.1 defined messages as explained in 5.5.1.1.4 of JBI 1.0
specification. This seems like a bug with the servicemix components.
So, to workaround this and make Java EE Service Engine inter-operate
with servicemix components, we need to set <code
style="font-style: italic;" class="prompt">com.sun.enterprise.jbi.se.esbruntime=servicemix</code>
system property.<br>
</p>
<p>Here are the steps :<br>
</p>
<pre class="screen"><code class="prompt"># Add the following JVM option in $glassfish_dir/domains/domain/config/domain.xml and Restart GlassFish<br><br>&lt;jvm-options&gt;-Dcom.sun.enterprise.jbi.se.esbruntime=servicemix&lt;/jvm-options&gt;<br><br># </code>Drop the Java EE Service Engine JAR file and the required shared libraries to autodeploy directory of ServiceMix<br><br><code
class="prompt">cd $glassfish_dir/domains/domain1/applications/j2ee-modules/servicemix-web/deploy<br>cp $glassfish_dir/jbi/sharedlibraries/wsdl/installer/wsdlsl.jar .<br>cp $glassfish_dir/jbi/components/javaeeserviceengine/installer/appserv-jbise.jar .<br><br><br></code></pre>
<br>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fedora-corner-br">&nbsp;</div>
<!-- content END --><!-- footer BEGIN -->
<div id="fedora-footer">
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"> <br>
</td>
<th align="left"><a
name="Accessing_the_EJBs_deployed_on_GlassFish"></a>Accessing the EJBs
deployed on GlassFish from ServiceMix using Java EE Service Engine</th>
</tr>
<tr>
<td align="left" valign="top">
<p>A sample application demonstrates how to access EJB webservice
deployed on GlassFish application server from ServiceMix using Java EE
Service Engine.<br>
</p>
<p>This is the schema of flow of the sample.<br>
</p>
<p><img
src="http://weblogs.java.net/blog/bhavanishankar/archive/example-flow.png"
alt="Flow" style="width: 655px; height: 864px;"><br>
</p>
<p>The source code of this sample is available in GlassFish
workspace
under <span style="font-style: italic;">appserv-tests/devtests/webservice/jbi-serviceengine/sm/bc_consumer_se_provider</span><br>
The sample has all the necessary ant tasks predefined. All that is
needed
is to run $glassfish_dir/bin/asant command.<br>
</p>
<p>Here are the steps to checkout the GlassFish source code and
run the sample :<br>
</p>
<pre class="screen"><code class="prompt"># Checkout GlassFish<br><br></code><code>cvs -d :pserver:guest@cvs.dev.java.net:/cvs checkout glassfish<br><br># Run the sample<br><br></code><code
class="prompt">cd glassfish/</code>appserv-tests/devtests/webservice/jbi-serviceengine/sm/bc_consumer_se_provider<br>$glassfish_dir/bin/asant</pre>
<br>
<p> </p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fedora-corner-bl">&nbsp;<br>
<!-- content END --><!-- footer BEGIN -->
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<table summary="Note: Note" border="0">
<tbody>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><br>
</td>
<th align="left"><a name="More_Info"></a>More Info<br>
</th>
</tr>
<tr>
<td align="left" valign="top"><br>
<table style="width: 100%; text-align: left;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">GlassFish<br>
</td>
<td style="vertical-align: top;"><a
href="http://glassfish.dev.java.net/">http://glassfish.dev.java.net/</a><br>
<a href="http://wiki.java.net/bin/view/Projects/GlassFish">http://wiki.java.net/bin/view/Projects/GlassFish</a><br>
<a href="http://glassfishwiki.org/jbiwiki/">http://glassfishwiki.org/jbiwiki/</a><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">Java EE Service Engine<br>
</td>
<td style="vertical-align: top;"><a
href="https://glassfish.dev.java.net/javaee5/jbi-se/ServiceEngine.html">https://glassfish.dev.java.net/javaee5/jbi-se/ServiceEngine.html</a><br>
<a
href="http://download.java.net/general/open-esb/docs/jbi-components/jee-se.html">http://download.java.net/general/open-esb/docs/jbi-components/jee-se.html</a><br>
<a
href="http://weblogs.java.net/blog/binod/archive/2006/07/java_ee_service_1.html">http://weblogs.java.net/blog/binod/archive/2006/07/java_ee_service_1.html</a></td>
</tr>
<tr>
<td style="vertical-align: top;">ServiceMix<br>
</td>
<td style="vertical-align: top;"><a
href="http://servicemix.org">http://servicemix.org</a><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">OpenESB<br>
</td>
<td style="vertical-align: top;"><a
href="http://open-esb.dev.java.net/">http://open-esb.dev.java.net/</a><br>
</td>
</tr>
</tbody>
</table>
<br>
</td>
</tr>
</tbody>
</table>
</div>
<div class="fedora-corner-br">&nbsp;</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- footer END -->
</body>
</html>

]]>

</content>
</entry>
<entry>
<title>NetBeans plug-in for AVK - Implementation details of the AVK plug-in</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2006/06/netbeans_plugin_2.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-06-06T07:54:55Z</issued>
<id>tag:weblogs.java.net,2006:/blog/bhavanishankar/313.4968</id>
<created>2006-06-06T07:54:55Z</created>
<summary type="text/plain">Provides detailed description of the tasks involved in writing AVK plug-in. This article is intended for the NetBeans plug-in developers.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>NetBeans plug-in for AVK</title>
</head>
<body style="color: windowtext;" alink="#ee0000" link="#0000ee"
 vlink="#551a8b">
<br>
</span><span style=" font-weight: bold;"></span><font
 size="-1"><span style="">My previous blog entry
explained about AVK and how to use AVK from within NetBeans.</span></font><br
 style="">
<br style="">
<font size="-1"><span style="">I thought it is
worthwhile spending some time in writing down the detailed description
of the tasks involved in writing this plug-in. This article is intended
for the NetBeans plug-in developers.</span></font><br
 style="">
<div style="margin-left: 40px;"><br style="">
<font size="-1"><span style=""></span></font></div>
<font size="-1"><big><span
 style=" font-weight: bold;">Implementation
details of AVK plug-in :</span></big><br style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">This is what the AVK plug-in does
internally:</span></font><br style="">
<br style="">
<font size="-1"><span style="">1. Adds "Dynamic
Verification" action to "Verify Project" task.</span></font><br
 style="">
<br style="">
<font size="-1"><span style="">2. When "Dynamic
Verification" action is invoked then the action handler </span></font><br
 style="">
<br style="">
<font size="-1"><span style="">&nbsp;&nbsp;
&nbsp;A. Configures application server to run in AVK mode (by invoking
MBeans deployed on the application server through JMX APIs).</span></font><br
 style="">
<font size="-1"><span style="">&nbsp;&nbsp;
&nbsp;B. Deploys the application (by invoking "run-deploy" ANT task)</span></font><br
 style="">
<font size="-1"><span style="">&nbsp;&nbsp;
&nbsp;C. Lauches the application in the browser if the application has
web component.</span></font><br style="">
<font size="-1"><span style="">&nbsp;&nbsp;
&nbsp;D. Invokes the AVK tool (by creating a seperate process)</span></font><br
 style="">
<font size="-1"><span style="">&nbsp;&nbsp;
&nbsp;E. Launches "AVK Session" window showing the dynamic verification
results.</span></font><br style="">
<br style="">
<font size="-1"><span style="">3. Source code
linking from the swing UI : From the "AVK Session" window - Right click
"Servlet Name" or "Method Name" &gt; "Go To Source" to view the
appropriate source code of your application.</span></font><br
 style="">
<br style="">
</div>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">In the following sections I will be
describing each of the implementation details outlined above. I am
explaining the implementation details in general not being specific to
AVK plug-in.</span></font><br style="">
</div>
<font size="-1"><span style=" font-weight: bold;"><br>
<big>&nbsp;&nbsp;&nbsp; <small>Step 0. Creating a new NetBeans plug-in
project</small></big></span></font><br style="">
<font size="-1"><br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">File &gt; New Project &gt; NetBeans
Plug-in Modules &gt; Module Project (Choose Project name[=AVK plug-in]
and code base name[=avkplugin] and leave the rest at default values).</span></font><br
 style="">
<br style="">
</div>
<font size="-1"><big><span
 style=" font-weight: bold;">&nbsp;&nbsp;&nbsp; <small>Step
1. Adding an
action to the Projects menu</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">Project &gt; Right Click &gt; New &gt;
Action (Select Category=Tools, Menu=Tools, Position=Update Center -
HERE, Classname=MyAction).</span></font><br
 style="">
<br style="">
<font size="-1"><span style="">Open layer.xml and
change </span></font><br style="">
<br style="">
<div
 style="margin-left: 40px; font-family: miscfixed; background-color: rgb(204, 204, 204);"><font
 size="-1">&lt;folder name="Menu"&gt; to &lt;folder name="Projects"&gt;</font><br>
<font size="-1">&lt;folder name="Tools"&gt; to &lt;folder
name="Tools"&gt;</font><br>
</div>
<br style="">
<font size="-1"><span style="">In my case,
layer.xml looks like this:</span></font><br
 style="">
<br style="">
<div
 style="margin-left: 40px; background-color: rgb(204, 204, 204); font-family: miscfixed;"><font
 size="-1">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</font><br>
<font size="-1">&lt;!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD
Filesystem 1.1//EN"
"http://www.netbeans.org/dtds/filesystem-1_1.dtd"&gt;</font><br>
<font size="-1">&lt;filesystem&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; &lt;folder name="Actions"&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;folder
name="Tools"&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;file name="avkplugin-MyAction.instance"/&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/folder&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; &lt;/folder&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; &lt;folder name="Projects"&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;folder
name="Actions"&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;attr
name="org-netbeans-modules-autoupdate-UpdateAction.instance/avkplugin-MyAction.shadow"
boolvalue="true"/&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;file name="avkplugin-MyAction.shadow"&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;attr name="originalFile"
stringvalue="Actions/Tools/avkplugin-MyAction.instance"/&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/file&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/folder&gt;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; &lt;/folder&gt;</font><br>
<font size="-1">&lt;/filesystem&gt;</font><br>
</div>
<br style="">
<br style="">
<font size="-1"><span style="">Change
MyAction.java to inherit from NodeAction instead of from
CallableSystemAction.&nbsp; Implement performAction(...) method. In my
case I simply print 'My action is invoked' message. Here is my
MyAction.java</span></font><br style="">
<br style="">
<div
 style="margin-left: 40px; background-color: rgb(204, 204, 204); font-family: miscfixed;"><font
 size="-1">package avkplugin;</font><br>
<br>
<font size="-1">import org.openide.nodes.Node;</font><br>
<font size="-1">import org.openide.nodes.NodeAcceptor;</font><br>
<font size="-1">import org.openide.util.HelpCtx;</font><br>
<font size="-1">import org.openide.util.NbBundle;</font><br>
<font size="-1">import org.openide.util.actions.NodeAction;</font><br>
<br>
<font size="-1">public final class MyAction extends NodeAction {</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public void
performAction(Node[] nodes) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println("My action is invoked...");</font><br>
<font size="-1"></font><font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public String getName() {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
NbBundle.getMessage(MyAction.class, "CTL_MyAction");</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; protected void initialize() {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
super.initialize();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // see
org.openide.util.actions.SystemAction.iconResource() javadoc for more
details</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
putValue("noIconInMenu", Boolean.TRUE);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public HelpCtx getHelpCtx() {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
HelpCtx.DEFAULT_HELP;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; protected boolean asynchronous() {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<br>
<font size="-1">&nbsp;&nbsp;&nbsp; protected boolean enable(Node[]
node) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">}</font><br>
</div>
<br style="">
<font size="-1"><span style="">At this point, my
project uses the following libraries:</span></font><br
 style="">
<br style="">
<div style="margin-left: 40px; background-color: rgb(204, 204, 204);"><font
 style="font-family: miscfixed;" size="-1">Nodes APIs</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">Utilities APIs</font><br
 style="">
</div>
<br style="">
<font size="-1"><span style="">To install the
plug-in : Project &gt; Right Click &gt; Install/Reload in Development
IDE.</span></font><br style="">
<br style="">
<font size="-1"><span style="">After the plug-in
is successfully installed "My Action" action gets added to the Project.
To invoke the action : Project &gt; Right Click &gt; My Action. You
will see "My action is invoked" on the console from where you launched
the IDE.</span></font><br style="">
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 2A:
Invoking MBeans deployed on the application server using JMX APIs:</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">Let us take an example of reading the
deployment directory of a JavaEE application from the domain.xml</span></font><br
 style="">
<br style="">
<div
 style="margin-left: 40px; background-color: rgb(204, 204, 204); font-family: miscfixed;"><font
 size="-1">package avkplugin;</font><br>
<br>
<font size="-1">import java.util.HashMap;</font><br>
<font size="-1">import java.util.Map;</font><br>
<font size="-1">import javax.management.MBeanServerConnection;</font><br>
<font size="-1">import javax.management.ObjectName;</font><br>
<font size="-1">import javax.management.remote.JMXConnector;</font><br>
<font size="-1">import javax.management.remote.JMXConnectorFactory;</font><br>
<font size="-1">import javax.management.remote.JMXServiceURL;</font><br>
<font size="-1">import org.netbeans.api.project.Project;</font><br>
<font size="-1">import
org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;</font><br>
<font size="-1">import
org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;</font><br>
<font size="-1">import org.openide.nodes.Node;</font><br>
<font size="-1">import org.openide.util.HelpCtx;</font><br>
<font size="-1">import org.openide.util.Lookup;</font><br>
<font size="-1">import org.openide.util.NbBundle;</font><br>
<font size="-1">import org.openide.util.actions.NodeAction;</font><br>
<br>
<font size="-1">public final class MyAction extends NodeAction {</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public void performAction(Node[]
nodes) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println("Deployment directory = " +
getDeployDir(getProject(nodes[0])));</font><br>
<font size="-1"></font><font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public Project getProject(Node
projectNode) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lookup
lookup = projectNode.getLookup();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Project
project = (Project)lookup.lookup(Project.class);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
project;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; public String getDeployDir(Project
project) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lookup
projectLookup = project.getLookup();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
J2eeModuleProvider moduleProvider =
(J2eeModuleProvider)projectLookup.lookup(J2eeModuleProvider.class);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
moduleName = moduleProvider.getDeploymentName().toLowerCase();</font><br>
<font size="-1"></font><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String
objectName = "com.sun.appserv:type=j2ee-application,name=" + moduleName
+ ",category=config";</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
InstanceProperties instProps = moduleProvider.getInstanceProperties();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
deployDir = null;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
adminUser = instProps.getProperty("username");</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
adminPassword = instProps.getProperty("password");</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
adminPort = instProps.getProperty("httpportnumber");</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
jmxUrl = "service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi"; //
hardcoded.</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[]
credentials = new String[] { adminUser, adminPassword };</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map env =
new HashMap();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
env.put("jmx.remote.credentials", credentials);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
JMXServiceURL url = new JMXServiceURL(jmxUrl);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
deployDir = (String)mbsc.getAttribute(new ObjectName(objectName),
"location");</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
catch(Exception ex) {</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ex.printStackTrace();</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
deployDir;</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp; }</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;</font><br>
<font size="-1">&nbsp;&nbsp; &nbsp;.....</font><br>
<br>
<font size="-1">}</font><br>
</div>
<br style="">
<font size="-1"><span style="">At this point, my
project uses the following additional libraries:</span></font><br
 style="">
<br style="">
</div>
<div style="background-color: rgb(204, 204, 204); margin-left: 80px;"><font
 style="font-family: miscfixed;" size="-1">J2EE Server Registry</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">Project API</font><br
 style="">
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 2B:
Deploying the application by invoking "run-deploy" ANT task</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">This is how one can invoke any build
target from within an action</span></font><br
 style="">
<br style="">
<div style="margin-left: 40px; background-color: rgb(204, 204, 204);"><font
 style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.apache.tools.ant.module.api.support.ActionUtils;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.spi.project.support.ant.GeneratedFilesHelper;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.openide.filesystems.FileObject;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">public final class
MyAction extends NodeAction {</font><br style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;
public void performAction(Node[] nodes) {</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
runBuildTarget(getProject(nodes[0]), "run-deploy");</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; }</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp; &nbsp;.....</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;
public void runBuildTarget(Project project, String targetName) {</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FileObject buildXML =
project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
try {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ActionUtils.runTarget(buildXML, new String[]{targetName}, new
Properties());</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} catch (Exception ex) {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ex.printStackTrace();</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; }</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp; &nbsp;.....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">}</font><br
 style="">
</div>
<br style="">
<font size="-1"><span style="">Additional
libraries needed for this purpose</span></font><br
 style="">
<br style="">
<div style="background-color: rgb(204, 204, 204); margin-left: 40px;"><font
 style="font-family: miscfixed;" size="-1">File System API</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">Ant</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">Ant-Based Project
Support</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">Execution API</font><br
 style="">
</div>
<br style="">
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 2C:
Launching the application in the browser</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">This is how one can launch the
application in the browser</span></font><br
 style="">
<br style="">
<div style="margin-left: 40px; background-color: rgb(204, 204, 204);"><font
 style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.openide.awt.HtmlBrowser.URLDisplayer;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">public final class
MyAction extends NodeAction {</font><br style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp; &nbsp;.....</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;
public void launchApp(Project project) {</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Lookup projectLookup = project.getLookup();</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
J2eeModuleProvider moduleProvider =
(J2eeModuleProvider)projectLookup.lookup(J2eeModuleProvider.class);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String contextRoot =
moduleProvider.getConfigSupport().getWebContextRoot();</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String httpPort = "8080"; // hardcoded. Correct way of getting it is :
mbsc.getAttribute(new
javax.management.ObjectName("com.sun.appserv:type=http-listener,id=http-listener-1,config=server-config,category=config")
,"port");</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String url = "http://localhost:" + httpPort + "/" + contextRoot;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1"></font><font
 style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
try {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
URLDisplayer.getDefault().showURL(new URL(url));</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} catch (MalformedURLException ex) {</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ex.printStackTrace();</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; }</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; .....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">}</font><br
 style="">
</div>
<br style="">
<br style="">
<font size="-1"><span style="">Additional
libraries needed for this purpose</span></font><br
 style="">
<br style="">
<div style="margin-left: 40px; background-color: rgb(204, 204, 204);"><font
 style="font-family: miscfixed;" size="-1">UI Utilities API</font><br
 style="">
</div>
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 2D:
Invoking a tool by creating a new process</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">This is pretty simple. We can just use
the standard JDK Runtime APIs.</span></font><br
 style="">
<br style="">
<div
 style="margin-left: 40px; background-color: rgb(204, 204, 204); font-family: miscfixed;"><font
 size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
commandString = System.getProperty("java.home") + File.separator +
"bin" + File.separator + "java" + " -classpath " + "&lt;classpath&gt;"
+ " avkplugin.Tool";</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Process p =
Runtime.getRuntime().exec(commandString);</font><br>
<font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p.waitFor();</font><br>
</div>
<br style="">
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 2E:
Lauching a window in the editor pane</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">This can be done using the swing UI
builder capabilities of the NetBeans IDE.</span></font><br
 style="">
</div>
<font size="-1"><br style="">
<big><span style=" font-weight: bold;">&nbsp;&nbsp;&nbsp;
<small>Step 3:
Source code linking</small></span></big><br
 style="">
<br style="">
</font>
<div style="margin-left: 40px;"><font size="-1"><span
 style="">If className, methodName and argument
types are known then we can open the source file and take the
cursor to the exact method. This is how we can achieve that:</span></font><br
 style="">
<br style="">
<div style="margin-left: 40px; background-color: rgb(204, 204, 204);"><font
 style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.jmi.javamodel.Element;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.jmi.javamodel.JavaClass;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.jmi.javamodel.Method;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.jmi.javamodel.Resource;<br>
import org.netbeans.jmi.javamodel.Type;<br
 style="font-family: miscfixed;">
</font><font style="font-family: miscfixed;" size="-1">import
org.netbeans.modules.java.JavaEditor;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.modules.javacore.api.JavaModel;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.netbeans.modules.javacore.internalapi.JavaMetamodel;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.openide.loaders.DataObject;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">import
org.openide.text.PositionBounds;</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">.....</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">public final class
MyAction extends NodeAction {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; .....<br>
<br>
&nbsp;&nbsp;&nbsp; private List getMethodParams(String[] paramTypes) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List methodParams = new
ArrayList();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0;
i&lt;paramTypes.length; i++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String param = paramTypes[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type
type = JavaModel.getDefaultExtent().getType().resolve(param);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
methodParams.add(type);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return methodParams;<br>
&nbsp;&nbsp;&nbsp; }<br>
<br style="font-family: miscfixed;">
</font><font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;
public void openSource(String className, String methodName, String[]
methodParamTypes) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List methodParams =
getMethodParams(methodParamTypes);<br>
</font><font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
JavaClass javaClass =
(JavaClass)JavaModel.getDefaultExtent().getType().resolve(className);<br>
</font><font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FileObject fo = JavaModel.getFileObject(javaClass.getResource());</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
try {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if(methodName != null) {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Resource resource = JavaModel.getResource(fo);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
JavaMetamodel javaMetamodel = JavaMetamodel.getManager();</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Method m = javaClass.getMethod(methodName,methodParams,true);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Element element = resource.getElementByOffset(m.getStartOffset());</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PositionBounds position = javaMetamodel.getElementPosition(element);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
((JavaEditor)
javaMetamodel.getDataObject(element.getResource()).getCookie(JavaEditor.class)).openAt(position.getBegin());</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} else {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DataObject dobj = DataObject.find(fo);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
OpenCookie oc = (OpenCookie)dobj.getCookie(OpenCookie.class);</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
oc.open();</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} catch (Throwable t) {</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
StatusDisplayer.getDefault().setStatusText("Unable to open " +
className);</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
t.printStackTrace();</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font><br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp;&nbsp; }</font><br
 style="font-family: miscfixed;">
<br style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">&nbsp;&nbsp; &nbsp;.....</font><br
 style="font-family: miscfixed;">
<font style="font-family: miscfixed;" size="-1">}</font><br
 style="">
</div>
<br style="">
<font size="-1"><span style="">Additional
libraries needed for this purpose</span></font><br
 style="">
<br style="">
<div
 style="margin-left: 40px; background-color: rgb(204, 204, 204); font-family: miscfixed;"><font
 size="-1">JMI for Java Language Model</font><br>
<font size="-1">Java Language Model Implementation</font><br>
<font size="-1">JMI Reflective API</font><br>
<font size="-1">Text API</font><br>
<font size="-1">Java Source Files</font><br>
<font size="-1">Datasystems API</font><br>
<font size="-1">Window System API</font><br>
<font size="-1">JMI Utilities</font><br>
</div>
<br style="">
<font size="-1"><span style="">Note :&nbsp; Add
&lt;compile-dependency/&gt; for
&lt;code-name-base&gt;org.netbeans.modules.jmiutils&lt;/code-name-base&gt;</span></font><br
 style="">
</div>
<font size="-1"><span style=""></span><br>
<big style=""><big style="font-weight: bold;">Conclusion
:<br>
<br>
</big></big></font>
<div style="margin-left: 40px;"><font size="-1"><big
 style=""><big><small><small>I hope the NetBeans
plug-in developers
find some of the tips and the utility methods described above useful.
Please provide me your comments/feebback.</small></small></big></big></font><br>
</div>
<font size="-1"><br>
<br style="">
</font>
</body>
</html>]]>

</content>
</entry>
<entry>
<title>NetBeans plug-in for AVK : How to use AVK in NetBeans</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bhavanishankar/archive/2006/05/netbeans_plugin_1.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-05-31T07:05:12Z</issued>
<id>tag:weblogs.java.net,2006:/blog/bhavanishankar/313.4937</id>
<created>2006-05-31T07:05:12Z</created>
<summary type="text/plain">Explains how to use AVK in NetBeans with a DEMO.</summary>
<author>
<name>bhavanishankar</name>

<email>bshankar@sun.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bhavanishankar/">
<![CDATA[<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>NetBeans plug-in for AVK : How to use AVK in NetBeans</title>
</head>
<body style="color: windowtext;" alink="#ee0000" link="#0000ee"
vlink="#551a8b">
<span style="font-weight: bold;"><br>
Introduction:</span><font style="" size="-1"><br>
<br>
</font>
<div style="margin-left: 40px; "><font size="-1">In
my recent project I had to develop a
NetBeans plug-in for <a href="http://java.sun.com/j2ee/avk">AVK</a>.
The name of
the plug-in is "Sun Java System Application Verification Kit". This
plug-in is available at the NetBeans Development Update Center. </font><br>
<br>
<font size="-1">This blog is intended
for the NetBeans users who want to use AVK through NetBeans IDE.</font><br>
<br>
<font size="-1">In this blog I brief about the AVK tool and the plug-in
functionalities. <a href="http://weblogs.java.net/blog/bhavanishankar/archive/avk-netbeans-demo.htm">Here is the
flashplayer demo</a> which has the
whole
process installing the plug-in and doing the dynamic verification of a
JavaEE project using this AVK plug-in.</font><br>
</div>
<font style="" size="-1"><br>
</font><span style="font-weight: bold;">AVK Tool:</span><font
style="" size="-1"><br>
<br>
</font>
<div style="margin-left: 40px;"><font size="-1">AVK
tool helps application developers
to test their applications for correct use of Java EE APIs and
portability across Java EE compatible application servers. The tool
determines that an application suite follows the Java EE platform
specification (including all the specifications for the technologies
that are part of the platform) and that it runs on the Application
Server. There are two stages of verification:</font>
<ul>
</ul>
<ul>
<li><font size="-1">Static
verification
: Statically checking the application for the correct usage of
Java EE
specifications. The tool determines that an application suite's
classes,
Java EE annotations, and any deployment descriptors follow the
specification and that the application suite contains no methods that
are proprietary to a particular vendor.</font></li>
<li><font size="-1">Dynamic
verification : Dynamically checking the application for the
correct
usage of Java EE specification by running the application on the Sun
Java System Application Server. The tool profiles the application,
determining the proportion of enterprise bean component methods, web
services methods, and web components that are invoked while the
application runs on the application server.</font></li>
<ul>
</ul>
</ul>
<font size="-1">More details about
the AVK can be found at <a href="http://java.sun.com/j2ee/avk">http://java.sun.com/j2ee/avk</a></font><br>
</div>
<font style="" size="-1"><br>
</font><span style="font-weight: bold;">Plug-in
functionalities:</span><font style="" size="-1"><br>
</font>
<ul style="">
<li><font size="-1"><span style="font-weight: bold;">Static
verification plug-in :</span> This is the plug-in for doing the static
verification of the JavaEE project through NetBeans IDE. Since the
static verifier a subcomponent of the application server itself, the
plug-in for the static verifier is available as part of "Sun Java
System Application Server plug-in". </font></li>
</ul>
<div style="margin-left: 40px; "><font size="-1">To
do static
verification of the JavaEE project - Right click the project &gt;
Select "Verify Project" &gt; Select "Static Verification" from the
dialog box. The static verification results will be displayed in the
output panel.</font><br>
</div>
<ul style="">
<li><font size="-1"><span style="font-weight: bold;">Dynamic
verification plug-in : </span>This
is the plug-in for doing the dynamic verification of the JavaEE project
through NetBeans IDE. This plug-in is called "Sun Java System
Application Verification Kit plug-in". </font></li>
</ul>
<div style="margin-left: 40px;"><font size="-1">To
do dynamic
verification of the JavaEE project :</font><br>
<ol>
<li><font size="-1">In the Projects window, select the project node,
right-click and
choose Verify Project. The Choose Verification dialog box opens.</font></li>
<li><font size="-1">Select the Dynamic Verification radio button and
click OK. The
IDE deploys your project to the application server, starts the
verification process, and brings up 'AVK Session' window in the editor
pane showing the dynamic verification reports. The reports in this
window get automatically updated as you access your application.</font></li>
<li><font size="-1">If your project has a web component then your
application is
launched in the browser. Otherwise, execute a sample manually outside
the IDE.</font></li>
<li><font size="-1">You will notice that the reports are
automatically updated in
'AVK Session' window. Note that 'Right Click' &gt; 'Go To Source' on
any 'Servlet Name' or 'Method Name' will open the appropriate source
code. 'Right Click &gt; 'Show Exception' on any exception of the
unsuccessfully called Servet/EJB will show the exception stack trace on
the output panel.</font></li>
</ol>
<small>Screen shot of the 'AVK Session' window showing the dynamic
verification results for a stateless EJB sample :<br>
<br>
<img alt="avk-blog-1.png" src="http://weblogs.java.net/blog/bhavanishankar/archive/avk-blog-1.png" width="1085" height="800" /><br>
<br>
</small><font size="-1">Note that the
plug-in also supports the J2EE projects running with AppServer 8.x as
runtime. Open "Help &gt; Help Contents" and search "AVK" for more
details.</font><br>
</div>
<font style="" size="-1"><br>
<big><span style="font-weight: bold;"></span></big></font><font
style="" size="-1"><big><big
style="font-weight: bold;">Conclusion
:<br>
<br>
</big></big></font>
<div style="margin-left: 40px;"><font size="-1"><big><big><small><small>In
this blog I
gave a brief introduction to the AVK tool and explained how to use
NetBeans AVK plug-in. I hope NetBeans and AVK users
find this blog useful. Please provide me your comments/feebback.<br>
<br>
Implementation details of the AVK plug-in will be available in my next
blog. That will be intended more towards the NetBeans plug-in
developers.<br>
<br>
<br>
</small></small></big></big></font></div>
<font style="" size="-1"><br>
</font>
<br>
Technorati
Tags: <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/netbeans" rel="tag">netbeans</a>
</body>
</html>]]>

</content>
</entry>

</feed>