<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaBeat &#187; Eclipse</title>
	<atom:link href="http://www.javabeat.net/category/tools-ides/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Sun, 16 Jun 2013 11:17:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Error starting modern compiler in Ant and Eclipse</title>
		<link>http://www.javabeat.net/2011/04/error-starting-modern-compiler-in-ant-and-eclipse/</link>
		<comments>http://www.javabeat.net/2011/04/error-starting-modern-compiler-in-ant-and-eclipse/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 13:43:38 +0000</pubDate>
		<dc:creator>JavaBeat</dc:creator>
				<category><![CDATA[ANT]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=293</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Eclipse and ANT Build Tool Error You would have come across this compiler error (error starting modern compiler) in many times during the developement. This error occirs when the actual Java runtime loaded by the environment and another tool is pointing to the differenet Java run time. This tips explains with example if this error [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><h1>Eclipse and ANT Build Tool Error</h1>
<p>You would have come across this compiler error (<b>error starting modern compiler</b>) in many times during the developement. This error occirs when the actual Java runtime loaded by the environment and another tool is pointing to the differenet Java run time. This tips explains with example if this error occirs when you are trying to run the <b>Ant build tool</b> inside eclipse. The following are the screenshots which explains where you need to check and change it.</p>
<p><img src="images/2011/04/ant/ant-build.jpg" /></p>
<p><img src="images/2011/04/ant/ant-build-1.jpg" width="670" /></p>
<p><img src="images/2011/04/ant/ant-build-2.jpg" width="670" /></p>
<p><font color="red">Here the jre selection must be the same as your eclipse is used for running the application. If its is different, you will get <b>error starting modern compiler</b></font></p>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Ftools-ides%2Feclipse%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/tools-ides/eclipse/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/tools-ides/eclipse/feed/" data-count="vertical" data-text="Eclipse" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/04/error-starting-modern-compiler-in-ant-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 3.0 Applications with BlazeDS in Eclipse</title>
		<link>http://www.javabeat.net/2009/02/flex-3-0-applications-with-blazeds-in-eclipse/</link>
		<comments>http://www.javabeat.net/2009/02/flex-3-0-applications-with-blazeds-in-eclipse/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 15:46:50 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex 3.0]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=411</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Introduction BlazeDS is the server-based Java remoting and web messaging technology. BlazeDS enables Adobe Flex and Adobe AIR applications developers to easily connect to back-end distributed data and push data in real-time. BlazeDS makes use of AMF3 protocol which is similar to SOAP, but AMF3 protocol is a binary protocol and so is much faster [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Introduction</h2>
<p><strong>BlazeDS</strong> is the server-based Java remoting and web messaging technology. <strong>BlazeDS</strong> enables <strong>Adobe Flex</strong> and <strong>Adobe AIR</strong> applications developers to easily connect to back-end distributed data and push data in real-time. <strong>BlazeDS</strong> makes use of <em>AMF3 protocol</em> which is similar to SOAP, but <em>AMF3 protocol</em> is a binary protocol and so is much faster than SOAP. <strong>BlazeDS</strong>, enables Flex applications make remote procedure calls to the Java server. BlazeDS Simplifies integration with existing Java code.</p>
<p>In this article we will see how to develop <strong>Flex RIA</strong> and integrate with Java server side using <strong>BlazeDS &#8211; Remote Object Service</strong>.</p>
<h2>Software used in BlazeDS &#8211; Remote Object Service</h2>
<ul>
<li>Adobe Flex Builder 3.0.2 Professional Eclipse Plug-in(<a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email" target="_blank">http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email</a>)</li>
<li>BlazeDS 3.x (<a href="http://opensource.adobe.com/wiki/display/blazeds/Downloads" target="_blank">http://opensource.adobe.com/wiki/display/blazeds/Downloads</a>)</li>
<li>JDK version 5.0/6.0</li>
</ul>
<p>List of topics covered in this article:</p>
<ul>
<li><em>BlazeDS Overview</em></li>
<li><em>Features of BlazeDS</em></li>
<li><em>Creating a Flex project ith BlaxeDS in Eclipse</em></li>
<li><em>Lanching server view in Flex Development Perspective</em></li>
<li><em>Creating RPC Service</em></li>
<li><em>Configuring Remote Object Service</em></li>
<li><em>Creating the Client application MXML file</em></li>
<li><em>Running the Flex Web application</em></li>
<li><em>Download Flex Application Source Code</em></li>
</ul>
<h2>BlazeDS Overview</h2>
<p><strong>BlazeDS</strong> consists of two parts a Clint side application and a Server side application.</p>
<p>BlazeDS client side application is typically an <strong>Adobe Flex</strong> applicaton or an <strong>Adobe Air</strong> Application. Client side application use Flex components to communicate with the <strong>BlazeDS server</strong>, including the</p>
<ul>
<li>RemoteObject,</li>
<li>HTTPService,</li>
<li>WebService,</li>
<li>Producer, and</li>
<li>Consumer components.</li>
</ul>
<p>In this article we will see only about RemoteObject component. Other components are not in the scope of this article.</p>
<p><strong>BlazeDS</strong> Server side application is a server-side J2EE web application that runs on a J2EE application server. Below figure shows the client server intraction architecture of <strong>BlazeDS</strong>.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2009/02/1.png"><img class="aligncenter size-medium wp-image-937" title="1" src="http://www.javabeat.net/wp-content/uploads/2009/02/1-300x183.png" alt="" width="300" height="183" /></a></p>
<h2>Features of BlazeDS</h2>
<p>The following bullet points lists the features of BlazeDS.</p>
<ul>
<li>RPC Services</li>
<li>Messaging Service</li>
<li>Proxy Service</li>
<li>Service Adapters</li>
</ul>
<p>In this RPC and Messaging services form the core features of BlazeDS.</p>
<p>RPC Service includes HTTP GET or POST(HTTPService), SOAP(Web Service), or Java Object(Remote Object Service).</p>
<p>For services like HTTP and Web Service you can use only Flex SDK and work. But for Remote Object Service you need to use BlazeDS.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2009/02/flex-3-0-applications-with-blazeds-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editing eclipse classpath file</title>
		<link>http://www.javabeat.net/2008/07/editing-eclipse-classpath-file/</link>
		<comments>http://www.javabeat.net/2008/07/editing-eclipse-classpath-file/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 10:40:33 +0000</pubDate>
		<dc:creator>JavaBeat</dc:creator>
				<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=151</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>While creating a project in Eclipse, by default it creates a .classpath file in the project directory. That file will be usedfor storing file names and other dependent files needed in the classpath to compile and execute the project successfully. Normally this file will be updated automatically when ever you update the project libraries here [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>While creating a project in Eclipse, by default it creates a .classpath file in the project directory. That file will be usedfor storing file names and other dependent files needed in the classpath to compile and execute the project successfully. Normally this file will be updated automatically when ever you update the project libraries here :
</p>
<p>
<img src="images/2008/07/eclipse1.jpg" width="500"><br />
<a href="articleImageOpen('images/2008/07/eclipse1.jpg');">Show Full Image</a>
</p>
<p>
The following are the few sample values used in the classpath setting :</p>
<pre lang="LANGUAGE" line="1">
src - setting source folders path<br />
lib - setting jar files path<br />
output - setting path for generating class files from the source files.<br />
The following is sample .classpath file</p>
<p>The following is sample .classpath file</p>
<p><?xml version="1.0" encoding="UTF-8"?><br /><classpath></p>
<p><classpathentry kind="src" path="src/java"/></p>
<p><classpathentry kind="lib" path="lib/log4j.jar"/></p>
<p><classpathentry combineaccessrules="false" kind="src" path="/Project"/></p>
<p><classpathentry kind="output" path="WebRoot/WEB-INF/classes"/></p>
<p></classpath></p></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/07/editing-eclipse-classpath-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating Webservice using JBoss and Eclipse Europa</title>
		<link>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/</link>
		<comments>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 11:39:44 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[Eclipse Europa]]></category>
		<category><![CDATA[Webservice]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=110</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>This article will introduce you to JBoss Webservice(JAX-WS). Here you will be knowing how to use the annotations and create a web service to deploy in JBoss. Since JBoss comes with JAX-WS jars inbuilt, we will not be adding any jars in addition for this article. This article will also give you a example code [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><span style="font-size: 13px;">This article will introduce you to </span><strong style="font-size: 13px;"><em>JBoss Webservice</em></strong><strong style="font-size: 13px;"><em>(JAX-WS)</em></strong><span style="font-size: 13px;">. Here you will be knowing how to use the </span><strong style="font-size: 13px;"><em>annotations</em></strong><span style="font-size: 13px;"> and create a web service to deploy in JBoss. Since JBoss comes with </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;"> jars inbuilt, we will not be adding any jars in addition for this article. This article will also give you a example code and walk you through the code. This will also explain creation of </span><strong style="font-size: 13px;"><em>dynamic web project</em></strong><span style="font-size: 13px;"> (not elaborated) and </span><strong style="font-size: 13px;"><em>configuration of JBoss server</em></strong><span style="font-size: 13px;"> to it.</span></p>
<p>You can also get <strong><em>JBossws</em></strong> download separately and create a webservice and deploy it in your preferred application server. Since we are using JBoss for this article we will not be covering this information here.</p>
<h2>Software Used in <strong><em>Configuring JBossws</em></strong></h2>
<ul>
<li><strong><em>JBoss Application Server 4.0.5.GA</em></strong>.</li>
<li><strong><em>Eclipse Europa</em></strong> (WTP all in one pack)</li>
<li><strong><em>JDK 1.5.x</em></strong></li>
</ul>
<h2>Pre-Requirements to Learn JBossWs and follow this article.</h2>
<ul>
<li>Should have <strong><em>Java</em></strong> knowledge.</li>
<li>Should know how to use <strong><em>Eclipse</em></strong>. (Creating web projects in Eclipse)</li>
<li>Should have basic knowledge of <strong><em>webservice</em></strong>.</li>
</ul>
<h2>Where to get the JBossWs from?</h2>
<p>You can download the software from the following URL:</p>
<ul>
<li><strong><em>JBoss Application Server 4.0.5.GA</em></strong>. == <a href="http://labs.jboss.com/" target="_blank">http://labs.jboss.com/</a></li>
<li><strong><em>Eclipse Europa</em></strong> (WTP all in one pack)== <a href="http://eclipse.org" target="_blank">http://eclipse.org</a></li>
<li><strong><em>JDK 1.5.x</em></strong> == <a href="http://java.sun.com" target="_blank">http://java.sun.com</a></li>
</ul>
<h2>Defining JBoss server in Eclipse</h2>
<p>First thing what you have to do is to <strong><em>define JBoss server in Eclipse</em></strong>. The steps below will explain how to define JBoss server in Eclipse.</p>
<ul>
<li>Step 1 : Open <strong><em>Eclipse WTP all in one pack</em></strong> in a new work space.</li>
<li>Step 2 : Change the perspective to <strong><em>J2EE Perspective</em></strong> if it is not currently in J2EE Perspective.</li>
<li>Step 3 : Once the Perspective is changed to <strong><em>J2EE</em></strong>, you can see a tab called <strong><em>Servers</em></strong> in the bottom right panel along with Problems, Tasks, Properties.</li>
<li>Step 4 : If the Servers tab is not found. Go to Eclipse <strong><em>menu : Windows &gt; Show view</em></strong> and click on Servers, so that Server tab will be displayed.</li>
<li>Step 5 : Go to Servers tab window and right click the mouse. You will get a pop up menu called &#8220;New&#8221;.</li>
<li>Step 6 : Clicking on the New menu you will get one more pop up called <strong><em>&#8220;Server&#8221;</em></strong>. Click on it.</li>
<li>Step 7 : Now you will get <strong><em>Define New Server Wizard</em></strong>.</li>
<li>Step 8 : In the wizard there are options to define many servers. One among them is <strong><em>JBoss</em></strong>. Click on JBoss and Expand the tree.</li>
<li>Step 9 : Select <strong><em>JBoss v 4.0</em></strong> and click next.</li>
<li>Step 10 : Now give the <strong><em>JDK</em></strong> directory and <strong><em>JBoss home</em></strong> directory. Click Next.</li>
<li>Step 11 : Now the wizard will show you the default Address, port, etc., Leave it as it is and click on Next.</li>
<li>Step 12 : Click on finish.</li>
<li>Step 13 : Now you can see the <strong><em>JBoss server</em></strong> listed in the Servers window and the status is Stopped.</li>
<li>Step 14 : JBoss server is now defined in Eclipse now and its ready to use from with in <strong><em>Eclipse IDE</em></strong>.</li>
</ul>
<h2>Creating a Dynamic Web Application Project</h2>
<p>Now it is time to <strong><em>create a web application</em></strong> in order to <strong><em>Expose a method as a Web service</em></strong>.</p>
<p>Create a <strong><em>Dynamic Web Application Project in eclipse</em></strong> by selecting the <strong><em>JBoss server</em></strong> what we have defined in the Eclipse IDE as the default server for the project. (We assume that who ever is reading this article knows how to create a dynamic web application in Eclipse, So that part is not detailed out here).</p>
<p>Once the <strong><em>JBoss server</em></strong> is selected as the server for the web applications. <strong><em>All the libraries existing in JBoss will be selected and used by eclipse in the Build Path</em></strong>. So no need to add any extra jar files for our work.</p>
<p>Now we will start with a <strong><em>Java code</em></strong>:</p>
<p>This is a simple <strong><em>Java code</em></strong> and does not have any thing to do with <strong><em>Webservices</em></strong>.</p>
<h3>JBossWs Code sample without annotations: (TestWs.java)</h3>
<p>Our Java code will have a single method called &#8220;greet&#8221;. Its functionality will be just to accept a string and return the same prefixed with &#8220;Hello&#8221;.</p>
<pre class="brush: java; title: ; notranslate">package com.test.dhanago;

public class TestWs
{
   /**
    * This method will accept a string and prefix with Hello.
    *
    * @param name
    * @return
    */
   public String greet( String name )
   {
      return &quot;Hello&quot; + name;
   }
}</pre>
<p>We will add <strong><em>annotations</em></strong> to the above code and modify the code like below:</p>
<h3>JBossWs Code sample with annotations: (TestWs.java)</h3>
<pre class="brush: java; title: ; notranslate">package com.test.dhanago;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 * This is a webservice class exposing a method called greet which takes a
 * input parameter and greets the parameter with hello.
 *
 * @author dhanago
 */

/*
 * @WebService indicates that this is webservice interface and the name
 * indicates the webservice name.
 */
@WebService(name = &quot;TestWs&quot;)
/*
 * @SOAPBinding indicates binding information of soap messages. Here we have
 * document-literal style of webservice and the parameter style is wrapped.
 */
@SOAPBinding
   (
         style = SOAPBinding.Style.DOCUMENT,
         use = SOAPBinding.Use.LITERAL,
         parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    )
public class TestWs
{
   /**
    * This method takes a input parameter and appends &quot;Hello&quot; to it and
    * returns the same.
    *
    * @param name
    * @return
    */
   @WebMethod
   public String greet( @WebParam(name = &quot;name&quot;)
   String name )
   {
      return &quot;Hello&quot; + name;
   }

}</pre>
<h3>JBossWs annotations Walk Through</h3>
<pre class="brush: java; title: ; notranslate">@WebService(name = &quot;TestWs&quot;)</pre>
<p>Here, <strong><em>@WebService </em></strong>Indicates that this is a webservice class. <strong><em>name = &#8220;TestWs&#8221; </em></strong>Indicates the webservice name.</p>
<pre class="brush: java; title: ; notranslate">@SOAPBinding
   (
         style = SOAPBinding.Style.DOCUMENT,
         use = SOAPBinding.Use.LITERAL,
         parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    )</pre>
<p>Here, <strong><em>@SOAPBinding </em></strong>Indicates binding information of <strong><em>soap messages</em></strong>. The properties below them indicates the <strong><em>style of web service</em></strong>, Here it is <strong><em>document-literal style</em></strong>. And <strong><em>parameter style is Wrapped</em></strong>.</p>
<p>Here, <strong><em>@WebMethod </em></strong>Indicates this is a method <strong><em>exposed as web service</em></strong>. <strong><em>@WebParam </em></strong>Indicates the <strong><em>parameter name to be used in soap message</em></strong>.</p>
<h2>JBossWs Deployment Descriptor</h2>
<p>Once the code is ready and compiled. You have modify the web.xml file located in WEB-INF folder.</p>
<p>Modify the <strong><em>web.xml</em></strong> file like below. (web.xml)</p>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
    xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    id=&quot;WebApp_ID&quot; version=&quot;2.5&quot;&gt;
    &lt;display-name&gt;TestWS&lt;/display-name&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;TestWs&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.test.dhanago.TestWs&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;TestWs&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/TestWs&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;session-config&gt;
        &lt;session-timeout&gt;30&lt;/session-timeout&gt;
    &lt;/session-config&gt;
    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<h2><strong><em>Deploying the JBoss web service application</em></strong></h2>
<p>Once this is done, its time to build and deploy the application in <strong><em>JBoss Application server</em></strong>.<br />
Once every thing is compiled with out any errors. And if you have enabled the <strong><em>Auto build unctionality of the Eclipse IDE</em></strong>, You have already done with building the application. If the auto build functionality of eclipse is not enabled, then right click on the project and build the project using build option.</p>
<p>Go to Servers window and right click on the <strong><em>JBoss server</em></strong> listed over there and select Run.<br />
Wait for server to start. Once it starts, right click on the server listing. You can find a option called <strong><em>&#8220;Add and Remove Project&#8221;</em></strong>. Click on the option. You will get a wizard where you can select your projects to move to right and <strong><em>configure with server</em></strong>. Once you moved your project. Click on finish.</p>
<p>Once it is done, you can find that the project is again build and moved to server default deployment folder automatically.</p>
<p>Console will display you like below.</p>
<pre class="brush: java; title: ; notranslate">Buildfile: D:\ec2\eclipse\plugins\org.eclipse.jst.server.generic.jboss_1.5.102.v20070608\buildfiles\jboss323.xml
deploy.j2ee.web:
      [jar] Building jar: D:\validation\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\Tws.war
     [move] Moving 1 file to D:\MyBoss\jboss-4.0.5.GA_ws121\server\default\deploy
BUILD SUCCESSFUL
Total time: 10 seconds</pre>
<p>The dynamic web application i created is with the name &#8220;Tws&#8221;. So the build has created Tws.war and moved it to the default deploy folder of the JBoss server.</p>
<p>To make sure web service is started once it is deployed in the JBoss console you can find the log like below.</p>
<pre class="brush: java; title: ; notranslate">13:57:52,306 INFO  [ServiceEndpointManager] WebService started: http://:8080/Tws/TestWs</pre>
<p>To view the WSDL follow the link http://&lt;machine name&gt;:8080/Tws/TestWs?wsdl</p>
<p>To see the list of webservices deployed in your JBoss Application server follow the link <a href="http://localhost:8080/jbossws">http://localhost:8080/jbossws</a>. This browser console will have link to see your deployed webservices and their <strong><em>WSDL</em></strong> files.</p>
<h3>JBossWs Browser Console.</h3>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/10/1.jpg"><img class="aligncenter size-medium wp-image-889" title="1" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/10/1-300x178.jpg" width="300" height="178" /></a>Clicking on <strong><em>View a list of deployed services</em></strong> will list you the deployed web services. In our case we will get the following screen where we can see the registered service endpoints.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/10/2.jpg"><img class="aligncenter size-medium wp-image-890" title="2" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/10/2-300x190.jpg" width="300" height="190" /></a>Here in this screen you can see the <strong><em>ServiceEndpointAddress</em></strong> link which will take you to the <strong><em>WSDL</em></strong> file.</p>
<p>You can also find the <strong><em>WSDL</em></strong> file in the following path:<br />
&lt;jboss_path&gt;\server\default\data\wsdl\&lt;project_name&gt;.war\&lt;filename&gt;.wsdl</p>
<p>You can generate the <strong><em>client stubs</em></strong> using this file and access the web service. Creating the client stubs to access the web service is out of scope of this article.</p>
<h2>The WSDL file generated using JBossWs is shown below:</h2>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;definitions name=&quot;TestWsService&quot; targetNamespace=&quot;http://dhanago.test.com/&quot; xmlns:tns=&quot;http://dhanago.test.com/&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;&gt;
  &lt;types&gt;
    &lt;xs:schema targetNamespace=&quot;http://dhanago.test.com/&quot; version=&quot;1.0&quot; xmlns:tns=&quot;http://dhanago.test.com/&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
   &lt;xs:element name=&quot;greet&quot; type=&quot;tns:greet&quot;/&gt;
   &lt;xs:element name=&quot;greetResponse&quot; type=&quot;tns:greetResponse&quot;/&gt;
   &lt;xs:complexType name=&quot;greet&quot;&gt;
    &lt;xs:sequence&gt;
     &lt;xs:element minOccurs=&quot;0&quot; name=&quot;name&quot; type=&quot;xs:string&quot;/&gt;
    &lt;/xs:sequence&gt;
   &lt;/xs:complexType&gt;
   &lt;xs:complexType name=&quot;greetResponse&quot;&gt;
    &lt;xs:sequence&gt;
     &lt;xs:element minOccurs=&quot;0&quot; name=&quot;return&quot; type=&quot;xs:string&quot;/&gt;
    &lt;/xs:sequence&gt;
   &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  &lt;/types&gt;
  &lt;message name=&quot;TestWs_greet&quot;&gt;
    &lt;part name=&quot;greet&quot; element=&quot;tns:greet&quot;/&gt;
  &lt;/message&gt;
  &lt;message name=&quot;TestWs_greetResponse&quot;&gt;
    &lt;part name=&quot;greetResponse&quot; element=&quot;tns:greetResponse&quot;/&gt;
  &lt;/message&gt;
  &lt;portType name=&quot;TestWs&quot;&gt;
    &lt;operation name=&quot;greet&quot; parameterOrder=&quot;greet&quot;&gt;
      &lt;input message=&quot;tns:TestWs_greet&quot;/&gt;
      &lt;output message=&quot;tns:TestWs_greetResponse&quot;/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
  &lt;binding name=&quot;TestWsBinding&quot; type=&quot;tns:TestWs&quot;&gt;
    &lt;soap:binding style=&quot;document&quot; transport=&quot;http://schemas.xmlsoap.org/soap/http&quot;/&gt;
    &lt;operation name=&quot;greet&quot;&gt;
      &lt;soap:operation soapAction=&quot;&quot;/&gt;
      &lt;input&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/input&gt;
      &lt;output&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/output&gt;
    &lt;/operation&gt;
  &lt;/binding&gt;
  &lt;service name=&quot;TestWsService&quot;&gt;
    &lt;port name=&quot;TestWsPort&quot; binding=&quot;tns:TestWsBinding&quot;&gt;
      &lt;soap:address location=&quot;http://EC3-NOR-124251:8080/Tws/TestWs&quot;/&gt;
    &lt;/port&gt;
  &lt;/service&gt;
&lt;/definitions&gt;
</pre>
<h2>Summary</h2>
<p>This article is just a quick start to start with for developers who want to quickly proceed with <strong><em>JBoss web services</em></strong>. It is up to the developers interest to leverage on this and proceed further. This is not the only procedure to expose a web service in JBoss. There might be lot of ways to do that and this is one of the way. So don&#8217;t stop here and continue Exploring.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to write Eclipse Plugin?</title>
		<link>http://www.javabeat.net/2007/07/introduction-to-eclipse-plugin-architecture/</link>
		<comments>http://www.javabeat.net/2007/07/introduction-to-eclipse-plugin-architecture/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 01:57:33 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Tools & IDEs]]></category>
		<category><![CDATA[Eclipse Plugin]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=68</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>This article will guide you in creating Eclipse Plugins using the Eclipse Plugin Development Environment (PDE). Because the Plugin Development Architecture is vast, this article will only provide brief information about the various components that fits into the PDE. It starts off in creating a Simple Plugin and they will try to explain the various [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><span style="font-size: 13px;">This article will guide you in creating </span><em style="font-size: 13px;"><strong>Eclipse Plugins</strong></em><span style="font-size: 13px;"> using the Eclipse </span><em style="font-size: 13px;"><strong>Plugin Development Environment (PDE)</strong></em><span style="font-size: 13px;">. Because the Plugin Development Architecture is vast, this article will only provide brief information about the various components that fits into the PDE. It starts off in creating a Simple Plugin and they will try to explain the various pieces involved in the Plugin Development. More specifically this article will show how to create a </span><em style="font-size: 13px;"><strong>View based Plugin</strong></em><span style="font-size: 13px;">, an </span><em style="font-size: 13px;"><strong>Action based Plugin</strong></em><span style="font-size: 13px;"> and a </span><em style="font-size: 13px;"><strong>Preference-based Plugin</strong></em><span style="font-size: 13px;">.</span></p>
<h2>1. Creating Views and Categories</h2>
<p align="justify"><em><strong>Views</strong></em> occupy majority of the portion in any IDE and in Eclipse they generally falls into some <em><strong>Category</strong></em>. For example, there are Views like <em><strong>&#8216;Declaration&#8217;</strong></em>, <em><strong>&#8216;Hierarchy&#8217;</strong></em>, <em><strong>&#8216;Package Explorer&#8217;</strong></em>, and <em><strong>&#8216;JavaDoc&#8217;</strong></em> that falls under a category called <em><strong>&#8216;Java&#8217;</strong></em>. This can be seen by going to Window&#8211;&gt;Show View&#8211;&gt;Other. When you go there you can see a list of Categories like <em><strong>&#8216;General&#8217;</strong></em>, <em><strong>&#8216;Ant&#8217;</strong></em>, <em><strong>&#8216;Cheat Sheats&#8217;</strong></em>, <em><strong>&#8216;CVS&#8217;</strong></em>, <em><strong>&#8216;Debug&#8217;</strong></em>, <em><strong>&#8216;Help&#8217;</strong></em>, <em><strong>&#8216;Java&#8217;</strong></em> and so on. These are called <em><strong>View Categories</strong></em>. Once after expanding a particular Category you can see a group of Views under that Category. So Category, in general, acts as a Container for holding logically similar type of Views.</p>
<h3>1.1) Creating a View within a Category</h3>
<p align="justify">Let us see how to create one such <em><strong>Custom Category</strong></em> having some Views defined within it. Let us name the category as <em><strong>&#8216;Organization&#8217;</strong></em> having various Views like <em><strong>&#8216;Employee&#8217;</strong></em> and <em><strong>&#8216;Department&#8217;</strong></em>.</p>
<p align="justify">Follow the steps to create a new <em><strong>Plugin Project</strong></em> in Eclipse representing User-defined Views.</p>
<ol>
<li>Choose File&#8211;&gt;New&#8211;&gt;Project, expand the Plug-in Development Folder and then choose <em><strong>&#8216;Plug-in Project&#8217;</strong></em> and click Next.</li>
<li>For Project Name, give net.javabeat.eclipse.plugins.organization and click Next.</li>
<li>Then comes the <em><strong>&#8216;New Plug-in Project&#8217;</strong></em> Page where you can configure the various properties of the plug-in that you are going to create. Ensure that the following values are filled in the respective columns for the &#8216;Plug-in Properties&#8217;.</li>
</ol>
<ul>
<li>Plug-in ID: net.javabeat.eclipse.plugins.organization</li>
<li>Plugin Version: 1.0.0</li>
<li>Plug-in Name: Organization Plug-in</li>
<li>Plug-in Provider: javabeat.net</li>
<li>Classpath: organization.jar</li>
<li>In the Plug-in Options panel, rename the Activator class to net.javabeat.eclipse.plugins.organizations.OrganizationActivator. Leave the remaining defaults and click Next.</li>
<li>Choose the Template &#8216;Plug-in with a View&#8217; in the Available Templates and click &#8216;Next&#8217;.</li>
<li>Ensure that the following values are given in the respective Text Fields in the Main View Settings.
<ul>
<li>Java Package Name: net.javabeat.eclipse.plugins.countries.views</li>
<li>View Class Name: OrganizationView</li>
<li>View Name: Employee</li>
<li>View Category ID: net.javabeat.eclipse.plugins.organization</li>
<li>View Category Name: Organization</li>
</ul>
</li>
<li>Un-check the &#8216;Add the view to the resource perspective&#8217; check-box and click Next.</li>
<li>Click Next and un-check all the View Features. For this simple View, we don&#8217;t necessarily need all these features.</li>
<li>When you click the Finish Button, Eclipse will prompt you to switch to &#8216;Plug-in Development Perspective&#8217;. Check &#8216;Remember my decision&#8217; check-box and press yes.</li>
</ul>
<p align="justify">Browse to <code>OrganizationView.java</code> which is available under <code>'net.javabeat.eclipse.plugins.organization.views'</code> package and search for the method <code>'getElements(Object)'</code> in the <code>'ViewContentProvider'</code> class. This is the method that will called to return the objects for decorating the View in consideration. By default, this method returns a String Array containing &#8216;One&#8217;, &#8216;Two&#8217; and &#8216;Three&#8217;. Modify the String Array such that it is returning something like return new String[] {&#8220;Harry&#8221;, &#8220;David&#8221;};</p>
<p align="justify">To make the names more meaningful, double click the <code>plugin.xml</code> file and choose the plugin.xml tab in the active Editor. There you can see the View definition for the Employee. Replace the value of the attribute &#8216;id&#8217; with <code>'net.javabeat.eclipse.plugins.organization.views.EmployeeView'</code>.</p>
<p align="justify">To run the Organization Plugin Application that you have just developed, right-click the Project, Go to Run As and then choose Eclipse Application. Eclipse will now create a <em><strong>Default Work-Bench</strong></em> pointing to <em><strong>&#8216;runtime-EclipseApplication&#8217;</strong></em> directory which is created in the same level as the current work-area directory. In the new Eclipse Workbench, Go to Window Menu, and then choose Show View&#8211;&gt;Other where you can find a Category by name <em><strong>&#8216;Organization&#8217;</strong></em>. Expand it to see the View called <em><strong>&#8216;Employee&#8217;</strong></em> that we just created before. Click the view to see the View get attached with the existing list of Views.</p>
<h3>1.2) Creating Multiple Views</h3>
<p align="justify">In this section, let us expand the above example by providing support to create <em><strong>Multiple Views</strong></em>. Let us create another View called <em><strong>&#8216;Department&#8217;</strong></em> within the <em><strong>Organization</strong></em> Category. To do this, carry out the following steps.</p>
<ol>
<li>Double-click the plugin.xml and to bring the editor in front. You can see a series of tabs attached to this editor. Click on the plugin.xml tab.</li>
<li>To add another View called &#8216;Department&#8217; under the &#8216;Organization&#8217; Category, simply copy the view definition (given below) and paste it below the exiting View Definition, i.e Employee View, in the Xml file.</li>
</ol>
<p>Now the plugin.xml file will look like this, <strong>plugin.xml</strong></p>
<p align="justify">Note that the name of the New View is <em><strong>&#8216;Department&#8217;</strong></em> and the corresponding <em><strong>View Id</strong></em> is <code>'net.javabeat.eclipse.plugins.countries.views.DepartmentView'</code>, though the class name for this view is still pointing to <code>'net.javabeat.eclipse.plugins.organization.views.OrganizationView'</code>. Since we are re-using the same class for both the Employee View as well as the Department View, make the following changes in the <code>OrganizationView.java</code> file so that Employee View and Department View looks different in terms of appearance. Navigate to the <code>getElements(Object)</code> method found in the inner class <code>ViewContentProvider</code> and add the following code.</p>
<pre class="brush: java; title: ; notranslate">public Object[] getElements(Object parent) {

    if (parent instanceof IViewSite){
        IViewSite view = (IViewSite)parent;
        String viewId = view.getId();

        if (viewId.equals(EMPLOYEE_VIEW_ID)){
            return new String[]{&quot;Harry&quot;, &quot;David&quot;};
        }else if (viewId.equals(DEPARTMENT_VIEW_ID)){
            return new String[]{&quot;Admin&quot;, &quot;Travel&quot;};
        }
    }
    return null;
}</pre>
<p align="justify">Don&#8217;t forget to declare the variables <code>EMPLOYEE_VIEW_ID</code> and <code>DEPARTMENT_VIEW_ID</code> which are pointing to their respective <em><strong>View Identifiers</strong></em> as being configured in the <code>plugin.xml</code> file.</p>
<pre class="brush: java; title: ; notranslate">private static final String EMPLOYEE_VIEW_ID =
 &quot;net.javabeat.eclipse.plugins.organization.views.EmployeeView&quot;;

private static final String DEPARTMENT_VIEW_ID =
 &quot;net.javabeat.eclipse.plugins.organization.views.DepartmentView&quot;;</pre>
<p align="justify">Run the Application, then you will something like the one in the following figure.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/07/1.png"><img class="aligncenter size-medium wp-image-858" title="1" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/07/1-227x300.png" width="227" height="300" /></a><em>Employee and Department Views</em></p>
<h2>2) What we have done so far?</h2>
<p align="justify">In the previous section, we developed a Simple View Plugin within a Category. Now, let us briefly see the Various Classes and Configuration Files that are involved in the Developmental Process.</p>
<h3>2.1) Plugins</h3>
<p align="justify">Most of the things we see in Eclipse Environment are <em><strong>Plugins</strong></em> and they form the core Components in Eclipse Environment. A <em><strong>Plugin</strong></em> is represented by <code>org.eclipse.core.runtime.Plugin</code> class. Since Eclipse Plugins started to conform with OSGI Model (starting from 3.0), all Plugins implemented by the <code>org.osgi.framework.BundleActivator</code> interface which provides the <em><strong>Life Cycle Methods</strong></em> like starting and stopping a bundle in the form of <code>start()</code> and <code>stop()</code> methods. The most common variations of the Plugin interface are the <em><strong>User Interface Plugin</strong></em>, <em><strong>Resources Plugin</strong></em> and the <em><strong>Variables Plugin</strong></em>. Customized Views, Dialogs and Preferences Page creation in a Project will mandates the need to the the <em><strong>UI Plugin</strong></em> (represented by <code>org.eclipse.ui.plugin.AbstractUIPlugin</code>). The <em><strong>Resources Plugin</strong></em> (<code>org.eclipse.core.resources.ResourcesPlugin</code>) is used to load and unload any type of Resources being referred in an Application. The <em><strong>Variables Plugin</strong></em> maintains a list of Varaibles like Environment Variables, Path Variables and any User-defined Variables within the Environment.</p>
<h3>2.2) Activators</h3>
<p align="justify">Simply put, this <em><strong>Activator</strong></em> will be the class that will be loaded initially and if you look into the hierarchy of the Activator class (<code>net.javabeat.eclipse.plugins.organization.OrganizationActivator</code>), it extends the <code>AbstractUIPlugin</code>, which tells the Eclipse Run-time that this Plugin is someway related to the <em><strong>Eclipse Platform UI</strong></em>. Note that the method <code>getDefault()</code> will be called by the Eclipse run-time to return the Plugin instance. Since it&#8217;s of no meaning to maintain more than one instance of the Plugin class, the Activator class is maintained as a <em><strong>Singleton Class</strong></em> by having a shared static variable of type OrganizationActivator.</p>
<p><strong>OrganizationActivator.java</strong></p>
<pre class="brush: java; title: ; notranslate">package net.javabeat.eclipse.plugins.organization;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
* The activator class controls the plug-in life cycle
*/
public class OrganizationActivator extends AbstractUIPlugin {

    // The plug-in ID
    public static final String PLUGIN_ID =
	    &quot;net.javabeat.eclipse.plugins.organization&quot;;

    // The shared instance
    private static OrganizationActivator plugin;

    /**
    * The constructor
    */
    public OrganizationActivator() {
        plugin = this;
    }

    /*
    * (non-Javadoc)
    * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(
	* org.osgi.framework.BundleContext)
    */
    public void start(BundleContext context) throws Exception {
        super.start(context);
    }

    /*
    * (non-Javadoc)
    * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(
	* org.osgi.framework.BundleContext)
    */
    public void stop(BundleContext context) throws Exception {
        plugin = null;
        super.stop(context);
    }

    /**
    * Returns the shared instance
    *
    * @return the shared instance
    */
    public static OrganizationActivator getDefault() {
        return plugin;
    }

    /**
    * Returns an image descriptor for the image file at the given
    * plug-in relative path
    *
    * @param path the path
    * @return the image descriptor
    */
    public static ImageDescriptor getImageDescriptor(String path) {
        return imageDescriptorFromPlugin(PLUGIN_ID, path);
    }
}</pre>
<h3>2.3) Views</h3>
<p align="justify"><em><strong>Views</strong></em> in Eclipse are represented by <code>'org.eclipse.ui.part.ViewPart'</code> class which can be sub-classed to create a <em><strong>Customized View</strong></em> along with View Contents. Views tightly integrate with <em><strong>Content Providers</strong></em> and <em><strong>Label Providers</strong></em>. A content Provider which is represented by <code>org.eclipse.jface.viewers.IContentProvider</code> provides the <em><strong>Model Information</strong></em> directly to the View. On the other hand, <em><strong>Label Providers</strong></em> (<code>org.eclipse.jface.viewers.IBaseLabelProvider</code>) associates elements in the View either with Text or Images. For example, a Label Provider may associate a Custom Icon along with a Directory object.</p>
<p align="justify">Views are related with <em><strong>Label Providers</strong></em> and <em><strong>Content Providers</strong></em> with the help of <code>setContentProvider()</code> and <code>setLabelProvider()</code> methods. Since we want a return different model values for Employee and Department Views, we have overridden the <code>getElements()</code> method in Content Provider class to return different set of data.</p>
<h3>2.4) Plugin Configuration File</h3>
<p align="justify">Let us analyze the contents of <code>plugin.xml</code> file in this section. All <em><strong>Eclipse Plugins</strong></em> supports the notion of <em><strong>Extension</strong></em> and <em><strong>Extension Points</strong></em>. For example, a vendor who creates a plugin will architect the Plugin in such a way that other Plugins can extend this plugin to add its own additional behaviors. So, <em><strong>Extension Points</strong></em> acts as a mediator between the Existing Plugin and the new Plugin which wants to add new functionalities. Eclipse already comes with a bunch of Extension Points so that we can directly depend on them instead of writing everything from the scratch.</p>
<p align="justify">The root element in the <code>plugin.xml</code> in the <em><strong>&#8216;plugin&#8217;</strong></em> element that represents a Plugin. In our case, since we are going to create a new View, we have the corresponding <em><strong>&#8216;extension&#8217;</strong></em> tag with the <em><strong>&#8216;point&#8217;</strong></em> attribute pointing to <code>'org.eclipse.ui.views'</code>.</p>
<p><strong>plugin.xml</strong></p>
<p align="justify">Other than Views, there are so many Extension Points that comes along with Eclipse, to name a few, <em><strong>Perspective Extensions</strong></em> for decorating Custom Perspectives (<code>org.eclipse.ui.perspectiveExtensions</code>), <em><strong>User defined Pop-up Menus</strong></em> (<code>org.eclipse.ui.popupMenus</code>), for creating <em><strong>Preference Pages</strong></em> (<code>org.eclispe.ui.preferencePages</code>), for creating <em><strong>Menus and Toolbar</strong></em> (<code>org.eclipse.ui.actionSets</code>).</p>
<p align="justify">Then comes the <em><strong>&#8216;category&#8217;</strong></em> element which acts as a container for holding multiple Views. The <em><strong>&#8216;name&#8217;</strong></em> attribute acts as a label and the <em><strong>&#8216;identifier&#8217;</strong></em> attribute, which is <code>'net.javabeat.eclipse.plugins.organization'</code>, is uniquely used to identify the Organization category.</p>
<p align="justify">Views can be created by defining a <em><strong>&#8216;view&#8217;</strong></em> element. The relationship between the View and a Category is maintained by the <em><strong>&#8216;category&#8217;</strong></em> attribute. Since we want both the &#8216;Employee&#8217; and the &#8216;Department&#8217; Views to be a part of the &#8216;Organization&#8217; category we<br />
have pointed out the &#8216;category&#8217; attribute to <code>'net.javabeat.eclipse.plugins.organization'</code>. Following is the definition for &#8216;Employee&#8217; and &#8216;Department&#8217; Views.</p>
<h2>3) Creating Menus and Toolbars</h2>
<p align="justify">In this section, let us put our effort in creating <em><strong>Customized Menus and Toolbars</strong></em> using the Eclipse PDE. For this, let us create a Menu called &#8216;MS Office&#8217; which has menu items namely &#8216;MS Word&#8217;, &#8216;MS Excel&#8217; and &#8216;MS Access&#8217;. Users can click any of these menu items to launch the corresponding Application. Without waiting, let us jump directly to start the coding.</p>
<p align="justify">Follow the steps to create the new Plugin.</p>
<ol>
<ol>
<li>Choose File&#8211;&gt;New&#8211;&gt;Project, expand the Plug-in Development Folder, choose the Plug-in Project and Click Next.</li>
</ol>
</ol>
<ul>
<li>Give &#8216;net.javabeat.eclipse.plugins.msofficelauncher&#8217; for the project name and click Next.</li>
</ul>
<ul>
<li>Check for the following values in the Plug-in Properties Panel which is in the</li>
</ul>
<ul>
<ul>
<li>Plug-in Content Dialog</li>
</ul>
</ul>
<ul>
<li>Plug-in ID: net.javabeat.eclipse.plugins.msofficelauncher</li>
</ul>
<ul>
<li>Plug-in Version: 1.0.0</li>
</ul>
<ul>
<li>Plug-in Name: MsOfficelauncher Plug-in</li>
</ul>
<ul>
<li>Plug-in Provider: javabeat.net</li>
</ul>
<ul>
<li>Classpath: msofficelauncher.jar</li>
</ul>
<ul>
<li>Give the Activator class name as &#8216;net.javabeat.eclipse.plugins.msofficelauncher.MsOfficeLauncher&#8217; and Click Next.</li>
</ul>
<ul>
<li>Choose &#8216;Hello World&#8217; in the &#8216;Available Templates&#8217; Panel and Click Next.</li>
</ul>
<ul>
<li>Name the Action class name as &#8216;MsOfficeAction&#8217; and press the Finish Button.</li>
</ul>
<p>Now we want to create a Menu called &#8216;MS Office&#8217; which has &#8216;MS Word&#8217;, &#8216;MS Excel&#8217; and &#8216;MS Access&#8217; as the menu items. To achieve this, do the following steps.</p>
<ol>
<ol>
<li>Double-click the MANIFEST.MF file which is the META-INF directory to bring up the Editor.</li>
</ol>
</ol>
<ul>
<li>The editor has a number of tabs arranged in the bottom like &#8216;Overview&#8217;, Dependencies&#8217;, … &#8216;build.properties&#8217;. Click the &#8216;Extensions&#8217; tab where you can see 3 panels namely &#8216;All Extensions&#8217; (in the left), &#8216;Extension Details&#8217; (in the right) and &#8216;Body Text&#8217; in the bottom.</li>
</ul>
<ul>
<li>In the &#8216;All Extension&#8217; Panel, you can see an expandable item by name &#8216;org.eclipse.ui.actionSets&#8217;. Expand this to bring the &#8216;Sample Action Set (actionSet)&#8217; item and expand it further to see the &#8216;Sample Menu&#8217;.</li>
</ul>
<ul>
<li>Select the &#8216;Sample Action Set(actionSet)&#8217; item, in the &#8216;Extension Element Details&#8217; panel (right-side), you can see the corresponding properties for the item. Change to label property to &#8216;MS Office Action Set&#8217; and leave the other default settings.</li>
</ul>
<ul>
<li>Click on the &#8216;Sample Menu (menu)&#8217; item and change the value of the properties &#8216;id&#8217; and &#8216;label&#8217; to &#8216;MsOfficeMenu&#8217; and &#8216;MS &amp;Office&#8217;.</li>
</ul>
<ul>
<li>Select the sampleGroup (separator) item which is under &#8216;MS Office (menu)&#8217; item and change its name to &#8216;MsOfficeGroup&#8217;.</li>
</ul>
<ul>
<li>Delete the existing &#8216;Sample Action (action)&#8217; by pressing the Delete key and add a new Action by the following steps. a). Right-click on the &#8216;MS Office Action Set (actionSet)&#8217; and then choose New&#8211;&gt;Action. It will add a new Action with some default values. Edit the default values with the one that is given below.</li>
</ul>
<ul>
<ul>
<li>id: net.javabeat.eclipse.plugins.msofficelauncher.msWord</li>
</ul>
</ul>
<ul>
<li>label: MS &amp;Word</li>
</ul>
<ul>
<li>menubarPath: MsOfficeMenu/MsOfficeGroup</li>
</ul>
<ul>
<li>toolbarPath: MsOfficeGroup</li>
</ul>
<ul>
<li>icon: icons/sample.gif</li>
</ul>
<ul>
<li>tooltip: Microsoft Word Application</li>
</ul>
<ul>
<li>class: net.javabeat.eclipse.plugins.msofficelauncher.actions.MsOfficeAction</li>
</ul>
<ul>
<ul>
<li>Add another action by right-clicking the &#8216;MS Office Action Set (actionSet)&#8217;, choosing New&#8211;&gt;Action with the following properties.</li>
</ul>
</ul>
<ul>
<ul>
<li>id: net.javabeat.eclipse.plugins.msofficelauncher.msExcel</li>
</ul>
</ul>
<ul>
<li>label: MS &amp;Excel</li>
</ul>
<ul>
<li>menubarPath: MsOfficeMenu/MsOfficeGroup</li>
</ul>
<ul>
<li>toolbarPath: MsOfficeGroup</li>
</ul>
<ul>
<li>icon: icons/sample.gif</li>
</ul>
<ul>
<li>tooltip: Microsoft Excel Application</li>
</ul>
<ul>
<li>class: net.javabeat.eclipse.plugins.msofficelauncher.actions.MsOfficeAction</li>
</ul>
<ul>
<ul>
<li>And one more for &#8216;MS Access&#8217; with the following properties.</li>
</ul>
</ul>
<ul>
<ul>
<li>id: net.javabeat.eclipse.plugins.msofficelauncher.msAccess</li>
</ul>
</ul>
<ul>
<li>label: MS &amp;Access</li>
</ul>
<ul>
<li>menubarPath: MsOfficeMenu/MsOfficeGroup</li>
</ul>
<ul>
<li>toolbarPath: MsOfficeGroup</li>
</ul>
<ul>
<li>icon: icons/sample.gif</li>
</ul>
<ul>
<li>tooltip: Microsoft Access Application</li>
</ul>
<ul>
<li>class: net.javabeat.eclipse.plugins.msofficelauncher.actions.MsOfficeAction</li>
</ul>
<p align="justify">Now, go to the <code>MsOfficeAction.java</code> file which is inside the &#8216;net.javabeat.eclipse.plugins.msofficelauncher.actions&#8217; package and do the following code changes. The changes are in relation with handling <em><strong>Appropriate Events</strong></em> (click of MS Word Item, or MS Excel Item or MS Access Item) and then taking the corresponding <em><strong>Actions</strong></em> (Opening the Application). Jump to MsOfficeAction.run(IAction) method and make the changes as specified below.</p>
<pre class="brush: java; title: ; notranslate">public void run(IAction action) {

    String id = action.getId();
    String actionItem = &quot;&quot;;
    if (id.equals(MSWORD_ACTION)){
        actionItem = &quot;winword.exe&quot;;
    }else if (id.equals(MSEXCEL_ACTION)){
        actionItem = &quot;excel.exe&quot;;
    }else if (id.equals(MSACCESS_ACTION)){
        actionItem = &quot;msaccess.exe&quot;;
    }

    String fullPath = officeInstallationPath + java.io.File.separator + actionItem;
    ProcessBuilder processBuider = new ProcessBuilder(new String[]{fullPath});
    try{
        processBuider.start();
    }catch (java.io.IOException exception){
        exception.printStackTrace();
    }
}</pre>
<p align="justify">In the above code, we check for the Item that raised the Event with the help of the <em><strong>Action Id</strong></em>, and then constructs the path of the executable file accordingly. Then we launch the Application by using the Java <code>ProcessBuilder</code> class. For completeness, following is the declaration of the various objects that points to the various Action Identifiers.</p>
<pre class="brush: java; title: ; notranslate">private static final String MSWORD_ACTION =
    &quot;net.javabeat.eclipse.plugins.msofficelauncher.msWord&quot;;

private static final String MSEXCEL_ACTION =
    &quot;net.javabeat.eclipse.plugins.msofficelauncher.msExcel&quot;;

private static final String MSACCESS_ACTION =
    &quot;net.javabeat.eclipse.plugins.msofficelauncher.msAccess&quot;;

private static final String officeInstallationPath =
    &quot;C:\\Program Files\\Microsoft Office\\OFFICE11&quot;;</pre>
<p align="justify">Note that the variable <code>'officeInstallationPath'</code> must point to the installation directory of MS Office Distribution in your machine. To run the Application, right-click the project and choose Run As&#8211;&gt;Eclipse Application. A new Eclipse Workbench will launch, where you can see a menu by name &#8216;MS office&#8217; which is adjacent to the &#8216;Project&#8217; Menu. Click the menu will bring the menu Items &#8216;MS Access&#8217;, &#8216;MS Word&#8217; and &#8216;MS Excel&#8217;. Also note the arrangement of the Toolbar buttons having appropriate Tool tips as being configured in the <code>plugin.xml</code> file. Clicking the menu items (or through the Tool Bar) will launch the Appropriate Application in a separate process space.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/07/2.png"><img class="aligncenter size-medium wp-image-860" title="2" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/07/2-262x300.png" width="262" height="300" /></a><em>MSOffice Menu with various Menu Items</em></p>
<h2>4) Creating Preferences</h2>
<p align="justify">The final section of this article will show you how to create <em><strong>Preferences Page</strong></em> in Eclipse. Preferences usually store Application related or Client related data and it can be accessed through Window&#8211;&gt;Preferences. You can see a number of Preference Items like &#8216;General&#8217;, &#8216;Ant&#8217;, &#8230; , &#8216;Team&#8217; etc. These are technically called as <em><strong>Preference Pages</strong></em> in Eclipse Terminology. Carry out the following steps to create a <em><strong>Custom Preference Page</strong></em> in Eclipse.</p>
<ol>
<li>Click File&#8211;&gt;New&#8211;&gt;Project, choose Plug-in Project from the folder &#8216;Plug-in Development&#8217; folder and click &#8216;Next&#8217;.</li>
<li>Enter the project name as &#8216;net.javabeat.eclipse.plugins.preferences&#8217; and click Next.</li>
<li>Check for the following values in the Plug-in Properties.</li>
</ol>
<ul>
<li>Plug-in ID: net.javabeat.eclipse.plugins.preferences</li>
<li>Plug-in Version: 1.0.0</li>
<li>Plug-in Name: Preferences Plug-in</li>
<li>Plug-in Provider: javabeat.net</li>
<li>Classpath: preferences.jar</li>
<li>Rename the Activator class as &#8216;net.javabeat.eclipse.plugins.preferences.PreferencesActivator&#8217; and click Next.</li>
<li>Choose &#8216;Custom Plug-in wizard&#8217; this time and Click Next.</li>
<li>Deselect all the Available Templates by clicking the &#8216;Deselect All&#8217; button (found in the right side) and then select only the template by name &#8216;Preference Page&#8217; and click Next.</li>
<li>Leave the defaults for the Java Package name, Preference Page Class Name and Preference Page Name and click Finish.</li>
</ul>
<p align="justify">Navigate to &#8216;SamplePreferencePage&#8217; which is in the <code>'net.javabeat.eclipse.plugins.preferences.preferences'</code> package. By default, the Wizard creates a number of <em><strong>Field Editors</strong></em> for the Sample Preference Page, which can be found in <code>SamplePreferencePage.createFieldEditors()</code> method. Simply put, a <em><strong>Preference Page View</strong></em> is nothing but a collection of Field Editors. A <em><strong>Field Editor</strong></em> is used to store the User&#8217;s Preference Data, like the Home Directory for all Eclipse Projects. There are a number of Pre-defined Field Editors in Eclipse like <em><strong>Boolean Field Editor</strong></em>, <em><strong>Integer Field Editor</strong></em>, <em><strong>String Field Editor</strong></em>, <em><strong>File Field Editor</strong></em>, <em><strong>Directory Field Editor</strong></em>, <em><strong>Color Field Editor</strong></em> etc.</p>
<p align="justify">A <em><strong>Field Editor</strong></em> is added to a Preference page by calling the <code>addField()</code> method which is passed a Field Editor Object. Consider the following Code which by default got generated by the PDE.</p>
<pre class="brush: java; title: ; notranslate">public void createFieldEditors() {

    addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
        &quot;&amp;Directory preference:&quot;, getFieldEditorParent()));

    addField(new BooleanFieldEditor(
        PreferenceConstants.P_BOOLEAN, &quot;&amp;An example of a boolean preference&quot;,
            getFieldEditorParent()));

    addField(new RadioGroupFieldEditor(PreferenceConstants.P_CHOICE,
        &quot;An example of a multiple-choice preference&quot;, 1,
            new String[][] {
			{&quot;&amp;Choice 1&quot;, &quot;choice1&quot; },
			{&quot;C&amp;hoice 2&quot;, &quot;choice2&quot; }}, getFieldEditorParent()));

    addField(new StringFieldEditor(PreferenceConstants.P_STRING,
	    &quot;A &amp;text preference:&quot;, getFieldEditorParent()));
}</pre>
<p align="justify">A <em><strong>Directory Field Editor</strong></em> as represented by <code>org.eclipse.jface.preference.DirectoryFieldEditor</code> is used to input the Directory name from the User by showing the <em><strong>Browse Directory Dialog</strong></em>. All Field Editor Components generally accept a Unique name along with a Label name. Other than that, they will also accept Editor specific values for construction. By default a Label containing the text, a Text-Field to hold the name of the Directory is created in this case. The next is the <em><strong>Boolean Field Editor</strong></em> that is used to turn-on or turn-off a property. The View for a Boolean Field Editor is shown in the form of a Check-box. Next is the <em><strong>Radio Group Field Editor</strong></em> which presents multiple choices in the form of Radio Buttons. Finally, the <em><strong>String Field Editor</strong></em> is used to accept String based inputs.</p>
<p align="justify">Run the Application directly without making any code changes to see how Eclipse PDE simplifies the Development Process. Right-click the project, choose RunAs&#8211;&gt;Eclipse Application to see the new Work-bench. Go to Window&#8211;&gt;Preferences to see the &#8216;Sample Preferences&#8217; listed in alphabetical order. To make things interesting, add the following additional Field Editors in the <code>createFieldEditors()</code> method to get a feel over Field Editors.</p>
<pre class="brush: java; title: ; notranslate">public void createFieldEditors(){

    ...

    addField(new ColorFieldEditor(
	    &quot;Color&quot;, &quot;Choose your favourite Color&quot;, getFieldEditorParent()));

    addField(new FontFieldEditor(
	    &quot;Font&quot;, &quot;Select a Font&quot;, &quot;Eclipse&quot;, getFieldEditorParent()));

    addField(new PathEditor(
	    &quot;Path&quot;, &quot;Directory Paths&quot;, &quot;Choose a Folder&quot;, getFieldEditorParent()));

    addField(new ScaleFieldEditor(
	    &quot;Scale&quot;, &quot;Adjust the Slider&quot;, getFieldEditorParent(), 10, 100, 5, 20));
}</pre>
<p align="justify">Build the Application and then run the Project as Eclipse Application to see additional Field Editors being populated in the Sample Preferences Page.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/07/3.png"><img class="aligncenter size-medium wp-image-857" title="3" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/07/3-225x300.png" width="225" height="300" /></a><em>Custom Preference Page</em></p>
<h2>5) Conclusion</h2>
<p align="justify">This article guided you how to create <em><strong>Custom Plugins</strong></em> with ease using the <em><strong>Eclipse PDE</strong></em>. Starting with the Creation of <em><strong>View Plugin</strong></em>, it then went on explaining the concepts related to Plugins like <em><strong>Extensions</strong></em>, <em><strong>Extension Points</strong></em>. Then a deeper look over the various Java files along with the Concepts of <em><strong>Views/Activators</strong></em> and then the <em><strong>Plugin Configuration File</strong></em> is made. Continuing that, creation of <em><strong>ActionSet based Plugins</strong></em> and <em><strong>Preference based Plugins</strong></em> are also given healthier discussion.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/07/introduction-to-eclipse-plugin-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
