<?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; Tools &amp; IDEs</title>
	<atom:link href="http://www.javabeat.net/category/tools-ides/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Wed, 22 May 2013 01:42:58 +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>Creating Simple Web Application Using Apache Maven</title>
		<link>http://www.javabeat.net/2013/02/creating-simple-web-application-using-apache-maven/</link>
		<comments>http://www.javabeat.net/2013/02/creating-simple-web-application-using-apache-maven/#comments</comments>
		<pubDate>Sat, 23 Feb 2013 03:30:26 +0000</pubDate>
		<dc:creator>Manisha Patil</dc:creator>
				<category><![CDATA[Apache Maven]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=5956</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>In the previous post we saw how to create simple Java project using Maven. We will create a simple web application. The goal of this post is to highlight the basic features Maven provides to develop web applications. This post covers the following : Create simple web application using Maven Archetype plugin. Prepare the Tomcat [...]</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><p>In the <a href="http://www.javabeat.net/2013/02/creating-simple-java-project-using-apache-maven/">previous post</a> we saw how to create simple Java project using Maven. We will create a simple web application. The goal of this post is to highlight the basic features Maven provides to develop web applications. This post covers the following :</p>
<ul>
<li>Create simple web application using Maven Archetype plugin.</li>
<li>Prepare the Tomcat Manager application.</li>
<li>Define Tomcat Server in Maven settings.</li>
<li>Point POM to Tomcat Server.</li>
<li>Build and Deploy the web application to Tomcat server.</li>
</ul>
<p>If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on Java topics, please subscribe <a title="Subscribe" href="http://www.javabeat.net/subscribe/" target="_blank">here</a>.</p>
<ul>
<li><a href="http://www.javabeat.net/2010/07/apache-maven-2-0-maven-plugins/">Apache Maven 2.0 – Maven Plugins</a></li>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2013/02/apache-maven.jpg"><img class="aligncenter size-full wp-image-5864" alt="apache maven" src="http://www.javabeat.net/wp-content/uploads/2013/02/apache-maven.jpg" width="300" height="104" /></a></p>
<h2 style="text-align: center;"><span style="text-decoration: underline;"><span style="color: #000080; text-decoration: underline;">Create Simple Web Application using Maven</span></span></h2>
<p>To create a web application we will use maven-archetype-webapp plugin. Run <b>mvn archetype:generate</b> with an <i>artifactId</i> and a <i>groupId</i>. Open command line window, point to the desired directory (here we are creating project under C:\MVNProject project) and execute the following command:</p>
<pre class="brush: java; title: ; notranslate">
C:\MVNProject&gt;mvn archetype:generate -DgroupId=net.javabeat -DartifactId=SampleWebapp
-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
</pre>
<h2>Maven Commands</h2>
<ul>
<ul>
<li><b>mvn</b> : is the Maven command.</li>
<li><b>archetype:generate</b> : is called a Maven goal, analogous to an ANT target. It describes a unit of work to be completed in a build. The purpose of this goal is to quickly create(goal) a project from an archetype(plugin).</li>
<li><b>-Dname=value pairs </b> : (DgroupId, DartifactId, DarchetypeArtifactId, DinteractiveMode) These are the arguments which are passed to the goal.They take the form of -D properties, similar to the system property options which you pass to the Java Virtual Machine via the command line.</li>
</ul>
</ul>
<p><b>The output on executing the above command is: </b></p>
<pre class="brush: java; title: ; notranslate">
C:\MVNProject&gt;mvn archetype:generate -DgroupId=net.javabeat -DartifactId=SampleWebapp
-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
[INFO] Scanning for projects...
Downloading: https://www.javabeat.net/pluginrepo1/org/codehaus/mojo/maven-metadata.xml
Downloading: https://www.javabeat.net/pluginrepo1/org/apache/maven/plugins/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from pluginrepo1
(https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from pluginrepo1
(https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
Downloading: https://www.javabeat.net/pluginrepo1/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml
from pluginrepo1 (https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
Downloading: https://www.javabeat.net/pluginrepo1/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://www.javabeat.net/pluginrepo1/org/codehaus/mojo/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from pluginrepo1
(https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from pluginrepo1
(https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
Downloading: https://www.javabeat.net/pluginrepo1/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml
from pluginrepo1 (https://www.javabeat.net/pluginrepo1/): Error transferring file: Connection reset
[INFO]
[INFO] &gt;&gt;&gt; maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom &gt;&gt;&gt;
[INFO]
[INFO] &lt;&lt;&lt; maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom &lt;&lt;&lt;
[INFO]
[INFO] --- maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-webapp:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: net.javabeat
[INFO] Parameter: packageName, Value: net.javabeat
[INFO] Parameter: package, Value: net.javabeat
[INFO] Parameter: artifactId, Value: SampleWebapp
[INFO] Parameter: basedir, Value: C:\MVNProject
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] project created from Old (1.x) Archetype in dir: C:\MVNProject\SampleWebapp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10:01.500s
[INFO] Finished at: Fri Feb 22 21:32:54 IST 2013
[INFO] Final Memory: 8M/24M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Maven creates the complete web based java application project structure as in the screen below:<br />
<a href="http://www.javabeat.net/wp-content/uploads/2013/02/webapp_struct.bmp"><img class="size-medium wp-image-5960 aligncenter" alt="webapp_struct" src="http://www.javabeat.net/wp-content/uploads/2013/02/webapp_struct.bmp" /></a></p>
<p>We see that a default pom.xml has been created. POM file generated is:</p>
<pre class="brush: java; title: ; notranslate">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;net.javabeat&lt;/groupId&gt;
  &lt;artifactId&gt;SampleWebapp&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;SampleWebapp Maven Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
    &lt;finalName&gt;SampleWebapp&lt;/finalName&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
<p>Here we notice that the <i>packaging</i> element has a value <i>war</i>. A project with a <i>war</i> packaging creates a WAR file in the <i>target</i> directory. Default name of this file is ${artifactId}-${version}.war. Hence our WAR generated would be in target/SampleWebapp-1.0-SNAPSHOT.war. The element <i>finalName</i> customizes the name of the generated WAR.</p>
<p>Maven also created a sample JSP Source file <b>index.jsp</b>:</p>
<pre class="brush: java; title: ; notranslate">
&lt;html&gt;
   &lt;body&gt;
      &lt;h2&gt;Hello World!&lt;/h2&gt;
   &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>Prepare the Tomcat Manager application</h2>
<p>We will deploy our web application to Tomcat server. We first need to ensure that we can access the Tomcat Manager application at: http://localhost:8080/manager/html. Just ensure that the &lt;tomcat&gt;/conf/tomcat-users.xml file has the following defined:(where &lt;tomcat&gt; is the Tomcat installed directory).</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;tomcat-users&gt;
  &lt;role rolename=&quot;manager&quot;/&gt;
  &lt;role rolename=&quot;admin&quot;/&gt;
  &lt;user username=&quot;admin&quot; password=&quot;admin&quot; roles=&quot;admin,manager&quot;/&gt;
&lt;/tomcat-users&gt;
</pre>
<p>To login into Tomcat Manager app we will use:</p>
<pre class="brush: java; title: ; notranslate">

Username=admin
 Password=admin

</pre>
<p>&nbsp;</p>
<h2>Define Tomcat Server in Maven settings</h2>
<p>Edit the Maven settings.xml (e.g:C:\Documents and Settings\Manisha\.m2\settings.xml), add a server <i>myserver</i>. Add the credentials to log into the Tomcat Manager application:</p>
<pre class="brush: java; title: ; notranslate">
&lt;settings&gt;
	&lt;servers&gt;
	 &lt;server&gt;
	   &lt;id&gt;myserver&lt;/id&gt;
	   &lt;username&gt;admin&lt;/username&gt;
	   &lt;password&gt;admin&lt;/password&gt;
	&lt;/server&gt;
	&lt;/servers&gt;
	.......
	.....
</pre>
<h2>Point POM to Tomcat Server</h2>
<p>Edit section in the the pom.xml file (under the directory C:\MVNProject\SampleWebapp\pom.xml) as follows:</p>
<pre class="brush: java; title: ; notranslate">
&lt;build&gt;
    &lt;finalName&gt;SampleWebapp&lt;/finalName&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
         &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                &lt;server&gt;myserver&lt;/server&gt;
                &lt;path&gt;/SampleWebapp&lt;/path&gt;
             &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
</pre>
<p>We have added the Tomcat plugin for Maven. The &lt;configuration&gt; section points to the server we defined in settings.xml (&#8216;myserver&#8217;). Through &lt;finalName&gt; and the &lt;path&gt; we define the web context we want to deploy to. We&#8217;ll be able to access our application at http://localhost:8080/SampleWebapp.</p>
<h2>Build and Deploy the web application to Tomcat server</h2>
<p>Open the command window console, and go to the directory where pom.xml is located (C:\MVNProject\SampleWebapp\pom.xml). Execute the following command:<br />
<b> mvn tomcat:deploy</b><br />
If &#8220;BUILD SUCCESS&#8221; message appears, then access the application at:</p>
<p>http://localhost:8080/SampleWebapp/.</p>
<p>If you want to deploy again, then use the following command:<br />
<b>mvn tomcat:redeploy</b></p>
<h2>Summary</h2>
<ul>
<li><a href="http://www.javabeat.net/2010/07/apache-maven-2-0-maven-plugins/">Apache Maven 2.0 – Maven Plugins</a></li>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p>In this post we did learn how to create a simple webapp using the Maven archetype plugin. We checked the directory structure and the generated source code. We then did learn about how to build and deploy this simple web app in the Tomcat server using Maven command. If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on Java topics, please subscribe <a title="Subscribe" href="http://www.javabeat.net/subscribe/" target="_blank">here</a>.</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%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/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/feed/" data-count="vertical" data-text="Tools &amp; IDEs" 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/2013/02/creating-simple-web-application-using-apache-maven/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quartz Job Scheduler &#8211; Example Code</title>
		<link>http://www.javabeat.net/2013/02/quartz-job-scheduler-example-code/</link>
		<comments>http://www.javabeat.net/2013/02/quartz-job-scheduler-example-code/#comments</comments>
		<pubDate>Thu, 21 Feb 2013 04:37:31 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Quartz Scheduler]]></category>
		<category><![CDATA[Quartz]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=5943</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>In this section we are going to develop a simple Quartz Scheduler application with the help of Quartz framework. That will display &#8220;Hello World Quartz Scheduler :&#60;date &#38; time&#62;&#8221; on the console window after specified time schedule. Before using Scheduler you have to instantiate it. For doing this some users may keep an instance of [...]</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>In this section we are going to develop a simple Quartz Scheduler application with the help of <b>Quartz</b> framework. That will display &#8220;<b><i>Hello World Quartz Scheduler :&lt;date &amp; time&gt;</i></b>&#8221; on the console window after specified time schedule.</p>
<p>Before using Scheduler you have to instantiate it. For doing this some users may keep an instance of a factory serialized in a <b>JNDI</b> store, and some other users may find it just to instantiate and use a factory instance. Firstly create the instance of <b>SchedulerFactory</b> by getting the reference of <i><b>org.Quartz.impl.StdSchedulerFactory </b></i>Class. Invoke the <b>getScheduler</b>() method by this instance to instantiate the <b>Scheduler</b>.</p>
<p><b>Description of code:</b></p>
<p><b>execute():</b> Any software components you want to schedule then you must implement the Job interface and override it execute() method.</p>
<p><b>JobExecutionContext:</b> The <b> JobExecutionContext</b> object that is passed to <b>execute</b>() method provides the job instance with information about its &#8220;run-time&#8221; environment &#8211; a handle to the Scheduler that executed it, a handle to the Trigger that triggered the execution, the job&#8217;s JobDetail object, and a few other items.</p>
<p><b>SchedulerFactory</b>: <b>SchedulerFactory</b> is a interface provides a mechanism for obtaining client-usable handles to <b> Scheduler</b> instances.</p>
<p><b>StdSchedulerFactory():</b> A Class <b>StdSchedulerFactory</b> is a class and it is implementation of <b>SchedulerFactory</b> interface. Here it just using for create an instance of <b>SchedulerFactory</b> instance.</p>
<p><b>Scheduler</b>: Scheduler interface is the main interface (<b>API</b>) to this functionality. It provides some simple operations like scheduling jobs, <b> unscheduling</b><b>jobs</b>, <b>starting</b>/<b>stopping</b>/<b>pausing</b> the scheduler.</p>
<p><b>getScheduler():</b><b>SchedulerFactoy</b> interface having the <b>getScheduler</b>() method that returns an instance of Scheduler.</p>
<p><b>start():</b> This method is used to starts the Scheduler&#8217;s threads that fire Triggers. At the first time when we create the Scheduler it is in &#8220;stand-by&#8221; mode, and will not fire triggers. The scheduler can also be send back into stand-by mode by invoking the <b>standby</b>() method.</p>
<p><b>JobDetail(String name, String group, Class jobclass):</b> The <b>JobDetail</b> object is created at the time the Job is added to scheduler. It contains various property settings like job name, group name and job class name. It can be used to store state information for a given instance of job class.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
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><b>SimpleTrigger(String name, String group, Date startTime, Date endTime, int repeatCount, long repeatInterval):</b> Trigger objects are used to firing the execution of jobs. When you want to schedule the job, instantiate the trigger and set the properties to provide the scheduling.</p>
<p><b>DEFAULT_GROUP:</b> It is a constant, specified that <b> Job</b> and <b> Trigger</b> instances are belongs to which group..</p>
<p><b>REPEAT_INDEFINITELY:</b> It is a constant used to indicate the &#8216;<b>repeat count</b>&#8216; of the trigger is indefinite.</p>
<p><b>scheduleJob(JobDetail jd, SimpleTrigger st):</b> This method is used to add the JobDetail to the Scheduler, and associate the Trigger with it.</p>
<p><b> Here is the code of Job Class:</b></p>
<div align="left">
<table border="0" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td align="left" valign="top" nowrap="nowrap"><code><code><b>import </b>org.quartz.Job;<br />
<b>import </b>org.quartz.JobExecutionContext;<br />
<b>import </b>org.quartz.JobExecutionException;<br />
<b>import </b>java.util.Date;</code></code><b>public class </b>HelloJob <b>implements </b>Job {<b>public </b><b>void </b>execute(JobExecutionContext arg0) <b>throws </b>JobExecutionException{</p>
<p>System.out.println(&#8220;Hello World Quartz Scheduler: &#8221; + <b>new </b>Date());<br />
}<br />
}</td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://web.archive.org/web/20100612062411/http://www.roseindia.net/quartz/HelloJob.java"> </a></p>
<p><b>Here is the code of Scheduler Class:</b></p>
<p><code><b>import </b>java.util.Date;<br />
<b>import </b>org.quartz.JobDetail;<br />
<b>import </b>org.quartz.Scheduler;<br />
<b>import </b>org.quartz.SchedulerFactory;<br />
<b>import </b>org.quartz.SimpleTrigger;<br />
<b>import </b>org.quartz.impl.StdSchedulerFactory;</code></p>
<p><b>public class </b>HelloSchedule {<br />
<b>public </b>HelloSchedule()<b>throws </b>Exception{<br />
SchedulerFactory sf=<b>new </b>StdSchedulerFactory();<br />
Scheduler sched=sf.getScheduler();<br />
sched.start();<br />
JobDetail jd=<b>new </b>JobDetail(&#8220;myjob&#8221;,sched.DEFAULT_GROUP,HelloJob.<b>class</b>);<br />
SimpleTrigger st=<b>new </b>SimpleTrigger(&#8220;mytrigger&#8221;,sched.DEFAULT_GROUP,new Date(),<br />
null,SimpleTrigger.REPEAT_INDEFINITELY,60L*1000L);<br />
sched.scheduleJob(jd, st);<br />
}<br />
<b>public static </b><b>void </b>main(String args[]){<br />
<b>try</b>{<br />
<b>new </b>HelloSchedule();<br />
}<b>catch</b>(Exception e){}<br />
}<br />
}</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/2013/02/quartz-job-scheduler-example-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Simple Java Project Using Apache Maven</title>
		<link>http://www.javabeat.net/2013/02/creating-simple-java-project-using-apache-maven/</link>
		<comments>http://www.javabeat.net/2013/02/creating-simple-java-project-using-apache-maven/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 15:39:35 +0000</pubDate>
		<dc:creator>Manisha Patil</dc:creator>
				<category><![CDATA[Apache Maven]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=5872</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>Maven is a build and project management tool for java based application development. In previous article(&#8220;Apache Maven for Beginners&#8220;), we talked about installing and configuring maven on windows operating system. In this article, we shall see how to create a simple Maven project, check the created directories and build the project. If you have any [...]</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>Maven is a build and project management tool for java based application development. In previous article(&#8220;<a title="Apache Maven for Beginners" href="http://www.javabeat.net/2013/02/apache-maven-for-beginners/">Apache Maven for Beginners</a>&#8220;), we talked about installing and configuring maven on windows operating system. In this article, we shall see how to create a simple Maven project, check the created directories and build the project.</p>
<p>If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on Java topics, please subscribe <a title="subscribe" href="http://www.javabeat.net/subscribe/">here</a>.</p>
<ul>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p>Maven uses archetype plugins to create projects. To create a simple java application, we&#8217;ll use <i>maven-archetype-quickstart</i> plugin from command line. In the example below, We&#8217;ll create a maven based java application project in <strong>C:\MVNProject</strong> folder.</p>
<p>Open the command line window and type the below command, Maven creates a blank java project with all default options.</p>
<pre class="brush: java; title: ; notranslate">
C:\MVNProject&gt;mvn archetype:generate -DgroupId=net.javabeat -DartifactId=
SampleJavaProject -DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
</pre>
<p><i>Note: If you have just installed Maven, and if its your first run, it may take a while, because Maven downloads the most recent artifacts (plugin jars and other files) into your local repository (to your .m2 directory). You may also need to execute the command a couple of times before it succeeds. This is because the remote server may time out before your downloads are complete.</i></p>
<h2><b>Maven commands<br />
</b></h2>
<ul>
<ul>
<li><b>mvn :</b> is the Maven command.</li>
<li><b>archetype:create :</b> is called a Maven goal, analogous to an ANT target. It describes a unit of work to be completed in a build. The purpose of this goal is to quickly <i>create(goal)</i> a project from an <i>archetype(plugin)</i></li>
<li><b>-Dname=value pairs :</b> (DgroupId, DartifactId, DarchetypeArtifactId, DinteractiveMode) These are the arguments which are passed to the goal.They take the form of -D properties, similar to the system property options which you pass to the Java Virtual Machine via the command line.</li>
</ul>
</ul>
<p><b>The output on executing the above command is</b></p>
<pre class="brush: java; title: ; notranslate">
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] &gt;&gt;&gt; maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom &gt;&gt;&gt;
[INFO]
[INFO] &lt;&lt;&lt; maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom &lt;&lt;&lt;
[INFO]
[INFO] --- maven-archetype-plugin:2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: net.javabeat
[INFO] Parameter: packageName, Value: net.javabeat
[INFO] Parameter: package, Value: net.javabeat
[INFO] Parameter: artifactId, Value: SampleJavaProject
[INFO] Parameter: basedir, Value: C:\MVNProject
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] project created from Old (1.x) Archetype in dir: C:\MVNProject\SampleJavaProject
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:03.812s
[INFO] Finished at: Sun Feb 17 08:37:52 IST 2013
[INFO] Final Memory: 8M/24M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Once the project is created, a directory structure is created as shown below. This directory structure adheres to the standard Maven directory layout.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2013/02/dir_struct.bmp"><img class="size-medium wp-image-5883 aligncenter" alt="dir_struct" src="http://www.javabeat.net/wp-content/uploads/2013/02/dir_struct.bmp" /></a><br />
<b>The details of the basic directories is as follows:</b></p>
<ul>
<ul>
<li><b>SampleJavaProject:</b> This directory contains src folder and pom.xml. Maven Archetype plugin creates this directory, value matching the artifactId <i>SampleJavaProject</i></li>
<li><b>src/main/java:</b> This directory contains java code files under the package structure (net/javabeat).</li>
<li><b>src/main/test:</b> This directory contains test java code files under the package structure (net/javabeat).</li>
</ul>
</ul>
<p>We see that a default <strong>pom.xml</strong> has been created. <strong>POM</strong> file generated is:</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre class="brush: java; title: ; notranslate">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;

http://www.w3.org/2001/XMLSchema-instance&quot;

  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0

http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;

  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;net.javabeat&lt;/groupId&gt;
  &lt;artifactId&gt;SampleJavaProject&lt;/artifactId&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;SampleJavaProject&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
&lt;/project&gt;
</pre>
<p>Maven Archetype plugin also created a sample Java Source file(C:\MVNProject\SampleJavaProject\src\main\java\net\javabeat\App.java) and Java Test file(C:\MVNProject\SampleJavaProject\src\test\java\net\javabeat\AppTest.java).</p>
<p><b>App.java</b>, is a single 13-line Java class, with a static main function that prints a simple &#8220;Hello World!&#8221; message.</p>
<pre class="brush: java; title: ; notranslate">
package net.javabeat;

/**
 * Hello world!
 *
 */
public class App
{
    public static void main( String[] args )
    {
        System.out.println( &quot;Hello World!&quot; );
    }
}
</pre>
<p><b>AppTest.java</b></p>
<pre class="brush: java; title: ; notranslate">
package net.javabeat;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test <img src='http://www.javabeat.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> 
     */
    public void testApp()
    {
        assertTrue( true );
    }
}

</pre>
<h2>Build project</h2>
<p>Once the project is created with the Maven Archetype plugin as seen above, we can build and package the application. To do so, run <b>mvn install</b> from the directory that contains the pom.xml(in our case it is C:\MVNProject\SampleJavaProject):</p>
<pre class="brush: java; title: ; notranslate">
C:\MVNProject\SampleJavaProject&gt;mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SampleJavaProject 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ SampleJavaProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVNProject\SampleJavaProject\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ SampleJavaProject ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\MVNProject\SampleJavaProject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ SampleJavaProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVNProject\SampleJavaProject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ SampleJavaProject ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\MVNProject\SampleJavaProject\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.5:test (default-test) @ SampleJavaProject ---
[INFO] Surefire report directory: C:\MVNProject\SampleJavaProject\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running net.javabeat.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.453 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ SampleJavaProject ---
[INFO] Building jar: C:\MVNProject\SampleJavaProject\target\SampleJavaProject-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ SampleJavaProject ---
[INFO] Installing C:\MVNProject\SampleJavaProject\target\SampleJavaProject-1.0-SNAPSHOT.jar to C:\Documents and Settings\Manisha\.m2\repository\net\javabeat\SampleJavaProject\1.0-SNAPSHOT\SampleJavaProject-1.0-SNAPSHOT.jar
[INFO] Installing C:\MVNProject\SampleJavaProject\pom.xml to C:\Documents and Settings\Manisha\.m2\repository\net\javabeat\SampleJavaProject\1.0-SNAPSHOT\SampleJavaProject-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.375s
[INFO] Finished at: Sun Feb 17 12:17:10 IST 2013
[INFO] Final Memory: 11M/27M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Executing the <b>mvn install</b>, we have just created, compiled, tested, packaged and installed the simple java project by Maven. We can also clean the target directories by using the <b>clean</b> command as <b>mvn clean install</b>.</p>
<p>Execute the program from command line as follows:</p>
<pre class="brush: java; title: ; notranslate">
C:\MVNProject\SampleJavaProject\target\classes&gt;java net.javabeat.App
Hello World!
</pre>
<h2>Summary</h2>
<ul>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p>In this article we saw how to create a simple Java project using Maven archetype plugins. We checked the directory structure, the generated source code.We then did learn about how to build this simple Java project using Maven command.In the next article we shall create a web application project using Maven.</p>
<p>If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on Java topics, please subscribe <a title="subscribe" href="http://www.javabeat.net/subscribe/">here</a>.</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/2013/02/creating-simple-java-project-using-apache-maven/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache Maven for Beginners</title>
		<link>http://www.javabeat.net/2013/02/apache-maven-for-beginners/</link>
		<comments>http://www.javabeat.net/2013/02/apache-maven-for-beginners/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 00:48:17 +0000</pubDate>
		<dc:creator>Manisha Patil</dc:creator>
				<category><![CDATA[Apache Maven]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=5838</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>What is Maven? Apache Maven is project management tool which is following the concept of a project object model (POM). Mavan can manage project&#8217;s build and documentation from a central place. Maven 1 actually was started as a sub project of Apache Turbine in 2002 (by Sonatype&#8217;s Jason van Zyl). It was released in July [...]</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>What is Maven?</h2>
<p>Apache Maven is project management tool which is following the concept of a project object model (POM). Mavan can manage project&#8217;s build and documentation from a central place. <span style="text-decoration: underline; color: #000080;"><b>Maven 1</b></span> actually was started as a sub project of Apache Turbine in 2002 (by Sonatype&#8217;s Jason van Zyl). It was released in July 2004 as v1.0. <span style="color: #000080;"><b>Maven 2</b></span> was released in Oct 2005. It was a complete rewrite of the previous project. It was not backward compatible.<br />
<span style="color: #000080;"><b>Maven 3</b></span> was released in October 2010. It is same as Maven 2 but more stable. This article explores the very basic concepts needed for the beginners who want to learn and get started with the Maven. Before the popularity of using Maven, most of the projects used <a href="http://www.javabeat.net/2013/01/tutorial-of-java-programming-with-apache-ant/">Ant Script</a> for the projects build which is used only for the build purpose.</p>
<p>If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on Java topics, please subscribe <a href="http://www.javabeat.net/subscribe/">here</a>.</p>
<ul>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2013/02/apache-maven.jpg"><img class="aligncenter size-full wp-image-5864" alt="apache maven" src="http://www.javabeat.net/wp-content/uploads/2013/02/apache-maven.jpg" width="300" height="104" /></a></p>
<h2>Maven Definition</h2>
<p>Definition of Maven from the Maven site(<a title="http://maven.apache.org/" href="http://maven.apache.org/">http://maven.apache.org/</a>):<br />
<i>&#8220;Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project&#8217;s build, reporting and documentation from a central piece of information. </i></p>
<p>Maven is an open source software engineering platform. The intent of Maven is to make intra-project development highly manageable in the hopes of providing more time for cross-project development. You may say it as sharing of project development knowledge. The core functionality of Maven is automated project building, distribution and website creation.</p>
<h2>Maven features</h2>
<ul>
<li><b>Dependency System:</b> Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies). Maven encourages the use of a central repository of JARs and other dependencies. Maven has a mechanism which helps your project&#8217;s clients to download any required JARs for building your project from a central JAR repository.This allows reuse of JARs across projects for Maven users.This also helps in dealing with backward compatibility issues.</li>
<li><b>Multi-module builds: </b>Able to easily work with multiple projects at the same time</li>
<li><b>Consistent project structure:</b> Consistent structure across all projects means no ramp up time for new developers coming onto a project</li>
<li><b>Consistent build model:</b> Maven is able to build any number of projects into predefined output types such as a JAR, WAR, or distribution based on metadata about the project, without the need to do any scripting in most cases.</li>
<li><b>Plugin oriented:</b> The Maven functionality is implemented in terms of plugins.</li>
<li><b>Project generated sites:</b> Maven generates a website or a PDF file using the same metadata as for the build process.You can include any documentation to this site and the standard report about the state of development of the project.Examples of this information can be seen at the bottom of the left-hand navigation of this site under the &#8220;Project Information&#8221; and &#8220;Project Reports&#8221; sub menus.</li>
</ul>
<h2>Comparison of Maven with Apache ANT:</h2>
<p>Major differences between Maven and ANT are:</p>
<ol>
<li>Maven is description of a project whereas ANT is development of a build script per project.</li>
<li>Maven follows conventions like a common project directory structure whereas ANT needs to be told about the exactly where to find the source and where to put the output.</li>
<li>Maven has invocation of defined goals (targets) whereas in ANT script you have invocation of project specific targets.</li>
<li>Maven has build life cycle, standard project layout where as ANT doesn&#8217;t and it has too complex scripts(You have to define goals and goal dependencies). You have to attach a sequence of tasks to each goal manually.</li>
<li>Maven has reusable plugins, repositories whereas ANT scripts are not reusable.</li>
<li>Maven is declarative.All you have to do is create a pom.xml file and put your source in the default directory. Maven takes care of the rest.ANT is procdeural which means you need to tell it to compile,copy and then compress.</li>
</ol>
<h2>Maven POM</h2>
<p>POM stands for Project Object Model.It describes following data about a project:</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ol>
<li>Metadata: Location of Directories, Developers/Contributors, Dependencies, Repositories</li>
<li>Dependencies (Transitive Dependencies), Inheritance, and Aggregation</li>
<li>Key Elements
<ul>
<li>Project</li>
<li>Model Version</li>
<li>Group ID</li>
<li>Packaging</li>
<li>Artifact ID</li>
<li>Version</li>
<li>Name</li>
<li>URL</li>
<li>Description</li>
<li>Plugins</li>
<li>Profiles (Alternate build configurations)</li>
</ul>
</li>
</ol>
<p>(Note:Transitive Dependencies definition- A dependency that should be included when declaring project itself is a dependency.Example: ProjectA depends on ProjectB. If ProjectC depends on ProjectA then ProjectB is automatically included. Only compile and run time scopes are transitive)</p>
<p><b>POM has four categories</b></p>
<ol>
<li>General project information-this includes project information like name,URL for project,sponsor organization,list of developers,license for the project.</li>
<li>Build settings-This include customization of default Maven build behaviour.</li>
<li>Build environment-This inlcudes profiles that can be used and activated for working in different environments(example development server,production server).</li>
<li>POM relationships-This includes inheritance of POM settings of parent projects.</li>
</ol>
<p><b>Standard Directory Layout</b><br />
<a href="http://www.javabeat.net/wp-content/uploads/2013/02/structure.bmp"><img class="size-medium wp-image-5854 aligncenter" alt="structure" src="http://www.javabeat.net/wp-content/uploads/2013/02/structure.bmp" /></a></p>
<h2>Install Maven</h2>
<ol>
<li>Download the latest Maven from <a title="http://maven.apache.org/download.cgi" href="http://maven.apache.org/download.cgi" target="_blank">http://maven.apache.org/download.cgi</a>.
<ul>
<li>The installed file is:<i>apache-maven-3.0-bin.zip</i></li>
</ul>
<ul>
<li>Extract the archive to the directory you wish to install Maven.We have extracted to the following folder:</li>
</ul>
<ul>
<li><i>C:\tools\apache-maven-3.0</i></li>
</ul>
</li>
<li><b>Test Maven</b><br />
In order to test Maven setup,you need Java installed/configured on your machine.Assuming you have JDK installed at C:\Program Files\Java\jdk1.7.0_11\bin, execute the following commands which sets your System Environment with Java and Maven paths.
<pre class="brush: java; title: ; notranslate">
set MAVEN_HOME=C:\tools\apache-maven-3.0
set MAVEN_OPTS=-Xms256m -Xmx512m
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_11
set path=%path%,%JAVA_HOME%\bin;%MAVEN_HOME%\bin
</pre>
</li>
<li><b>Verify Maven installation</b><br />
Open the command prompt and execute the following command:
<pre class="brush: java; title: ; notranslate">c:\&gt; mvn --version</pre>
<p>This should give the current installed version of Maven.</p>
<pre class="brush: java; title: ; notranslate">
Apache Maven 3.0 (r1004208; 2010-10-04 17:20:56+0530)
Java version: 1.7.0_11
Java home: C:\Program Files\Java\jdk1.7.0_11\jre
Default locale: en_US, platform encoding: Cp1252
OS name: &quot;windows xp&quot; version: &quot;5.1&quot; arch: &quot;x86&quot; Family: &quot;windows&quot;
</pre>
</li>
</ol>
<h2>Basic User specific Maven Configuration</h2>
<p>Now that you have installed Maven, it is a good idea to setup the .m2 directory, where Maven creates its local repository. To create .m2 directory, assuming &#8220;Manisha&#8221; is logged in user, open the command console and execute the following command, to create the .m2 directory.</p>
<pre class="brush: java; title: ; notranslate">
mkdir C:\Documents and Settings\Manisha\.m2
</pre>
<p>The settings.xml file(under the .m2 directory) contains user-specific configuration for authentication, repositories,and other information to customize the behavior of Maven. Sample settings file is:</p>
<pre class="brush: java; title: ; notranslate">
&lt;settings&gt;
&lt;servers&gt;
 &lt;server&gt;
   &lt;id&gt;server1&lt;/id&gt;
   &lt;username&gt;user1&lt;/username&gt;
   &lt;password&gt;password1&lt;/password&gt;
 &lt;/server&gt;
 &lt;server&gt;
    &lt;id&gt;server2&lt;/id&gt;
    &lt;username&gt;user2&lt;/username&gt;
    &lt;password&gt;password2&lt;/password&gt;
 &lt;/server&gt;
&lt;!-- Server settings for repositories Ends --&gt;
 &lt;/servers&gt;

&lt;!-- Mirror settings for repositories Starts --&gt;
&lt;mirrors&gt;
   &lt;mirror&gt;
	&lt;id&gt;mirror1&lt;/id&gt;
	&lt;name&gt;Internal network access to any repository&lt;/name&gt;
	&lt;mirrorOf&gt;repo1&lt;/mirrorOf&gt;
	&lt;url&gt;https://www.javabeat.net/repo1/&lt;/url&gt;
   &lt;/mirror&gt;
&lt;/mirrors&gt;
&lt;!-- Mirror settings for repositories Ends --&gt;
&lt;!-- Profiles settings for repositories Starts --&gt;
&lt;profiles&gt;
   &lt;profile&gt;
     &lt;id&gt;profile1&lt;/id&gt;
	&lt;activation&gt;
	 &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
	&lt;/activation&gt;
	 &lt;repositories&gt;
               &lt;repository&gt;
	         &lt;id&gt;repo1&lt;/id&gt;
	         &lt;url&gt;https://www.javabeat.net/repo1/&lt;/url&gt;
       &lt;/repository&gt;
      &lt;pluginRepositories&gt;
	&lt;pluginRepository&gt;
		&lt;id&gt;pluginrepo1&lt;/id&gt;
		&lt;name&gt;Repos (public/proxied)&lt;/name&gt;
		&lt;url&gt;https://www.javabeat.net/pluginrepo1/&lt;/url&gt;
		&lt;snapshots&gt;
			&lt;enabled&gt;false&lt;/enabled&gt;
		&lt;/snapshots&gt;
		&lt;releases&gt;
			&lt;enabled&gt;true&lt;/enabled&gt;
		&lt;/releases&gt;
	&lt;/pluginRepository&gt;
&lt;/profile&gt;
&lt;/profiles&gt;
&lt;!-- Profiles settings for repositories Ends --&gt;
&lt;/settings&gt;
</pre>
<h2>Summary</h2>
<ul>
<li>Buy: <a href="http://www.flipkart.com/apache-maven-2-effective-implementation/p/itmdyusqwng3phvg?pid=9788184049152&amp;affid=suthukrish" target="_blank">Apache Maven Implementation</a> from flipkart.com</li>
</ul>
<p>In this article we saw basic overview about Apache Maven, its installation and basic configuration.The next article would deal with creating a simple Java project using Maven. I would write the series of tutorials on Apache Maven and how to use Apache Maven in your projects. If you have any questions, please post it in the comments section. If you are interested in receiving the future articles on  Java topics, please subscribe <a href="http://www.javabeat.net/subscribe/">here</a>.</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/2013/02/apache-maven-for-beginners/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HelloWorld with Netbeans 7.2 beta and Scala 2.9</title>
		<link>http://www.javabeat.net/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/</link>
		<comments>http://www.javabeat.net/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/#comments</comments>
		<pubDate>Tue, 05 Jun 2012 00:00:16 +0000</pubDate>
		<dc:creator>Smita</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[netbeans 7.2]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[scala 2.9]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=4117</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>Here is the step by step procedure to set up the scala(2.9) environment with Netbeans(7.2) on a Windows Vista system 1. Install Netbeans 7.2 Beta if not already installed from here. 2. Download the Scala installable from here. Install Scala on your system. 3. Set the environment variable SCALA_HOME pointing it to the Scala installation directory. (On Windows [...]</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>Here is the step by step procedure to set up the <strong>scala(2.9)</strong> environment with Netbeans(7.2) on a Windows Vista system</p>
<p>1. Install <strong>Netbeans 7.2</strong> Beta if not already installed from <a href="http://netbeans.org/community/releases/72/">here</a>.</p>
<p>2. Download the <strong>Scala</strong> installable from <a href="http://www.scala-lang.org/downloads">here</a>. Install <strong>Scala</strong> on your system.</p>
<p>3. Set the environment variable SCALA_HOME pointing it to the <strong>Scala</strong> installation directory. (On Windows Vista, Go to Start Menu -&gt;Right click on Computer -&gt; Select Properties -&gt; From the left menu, Click on Advanced system Settings -&gt; Click on the Environment variables button on the bottom right corner -&gt; Create new System variable named SCALA_HOME pointing to the Scala installation directory).</p>
<p>4. Now we need to install <strong>Scala</strong> plugin for <strong>Netbeans</strong>. Download the plugin <a href="http://plugins.netbeans.org/plugin/38999/nbscala-2-9-x-0-9">here</a> and extract the content into an appropriate folder.</p>
<p>5. Open Netbeans IDE.</p>
<p>6. On the Menu Bar, choose Tools -&gt; Plugin</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Tools_Plugins.jpg"><img class=" wp-image-4193 aligncenter" src="http://www.javabeat.net/wp-content/uploads/2012/06/Tools_Plugins.jpg" alt="" width="423" height="263" /></a></p>
<p>7. Choose Downloaded tab. Click on Add Plugins button. Browse to the folder containing scala plugins. Choose all the *.nbm files and hit the Install button on the bottom left corner.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/AddPlugins_Select1.jpg"><img class="aligncenter  wp-image-4187" src="http://www.javabeat.net/wp-content/uploads/2012/06/AddPlugins_Select1-e1339180670328-1024x506.jpg" alt="Add plugin and select all nbm files" width="423" height="263" /></a></p>
<p>5. You need to hit the Next / Continue button and accept the agreements on all the windows that pop up after that.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPlugins.jpg"><img class="aligncenter  wp-image-4189" src="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPlugins-e1339180828864-1024x508.jpg" alt="Install_SelectedPlugins" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/ContinueUnsigned-e1339179865267.jpg"><img class="aligncenter  wp-image-4201" src="http://www.javabeat.net/wp-content/uploads/2012/06/ContinueUnsigned-e1339179865267-1024x503.jpg" alt="" width="423" height="263" /></a></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
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 style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPluginsCont-e1339180958393.jpg"><img class="aligncenter  wp-image-4190" src="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPluginsCont-e1339180958393-1024x508.jpg" alt="" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/SuccessInstalled.jpg"><img class="aligncenter  wp-image-4192" src="http://www.javabeat.net/wp-content/uploads/2012/06/SuccessInstalled-e1339181197586-1024x506.jpg" alt="" width="423" height="263" /></a></p>
<p>Plugin auto installs everything.</p>
<p>6. Create New Project. You should now be able to see a new category named Scala. Choose Scala Application. Choose your project name / location and click on Finish. An object named Main which prints out &#8220;Hello World&#8221; gets created by default. You can run this file as is by hitting Shift+F6 just to check if the environment is correctly set. HelloWorld should get printed as output.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/NewScalaProject-e1339181343297.jpg"><img class="aligncenter  wp-image-4191" src="http://www.javabeat.net/wp-content/uploads/2012/06/NewScalaProject-e1339181343297-1024x506.jpg" alt="" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/HelloWorld.jpg"><img class="aligncenter  wp-image-4188" src="http://www.javabeat.net/wp-content/uploads/2012/06/HelloWorld-e1339181397675-1024x508.jpg" alt="" width="423" height="263" /></a></p>
<p>Writing a first <strong>Scala</strong> program on <strong>Netbeans 7.2</strong> seemed a breeze. No headache of conf file changes. But <strong>Netbeans 7.2</strong> does seem a lot lot slower than its earlier version 7.0(I have not tried 7.1). Probably because it still is a Beta version.</p>
<p>Following are <span style="text-decoration: underline;"><strong>some gotchas</strong></span> if you are trying to get Scala to work on <strong>Netbeans 7.0</strong> or an earlier version of Scala-</p>
<p>1. After installing the plugin, you should be able to create a new Scala project. In case you are not, check if any of the scala plugins are not activated. Select them and activate them.</p>
<p>2. Error message &#8211; Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.</p>
<p>Solution &#8211; Check if <strong>Scala</strong> has been correctly installed. Append &#8220;-J-Dscala.home=scalahomepath&#8221; property to the end of &#8220;netbeans_default_options&#8221; in NetBeansInstallationPath/etc/netbeans.conf where scalahomepath is the actual path to the Scala installation directory.</p>
<p>Please do let me know how your Scala environment setup with Netbeans went. I will be happy to respond to your questions if any. Please feel free to add your comments below.</p>
<p><em>Adios</em> until the next post !</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/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex 4.x &#8211; Overview</title>
		<link>http://www.javabeat.net/2011/08/flex-4-x-overview/</link>
		<comments>http://www.javabeat.net/2011/08/flex-4-x-overview/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 23:42:58 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2459</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>Type of technology Flex is a highly productive, free open source framework available for building and maintaining web applications which deploy consistently on major browsers, desktops and operating systems. Look and Feel Drag and Drop The support for drag and drop can be added for all Flex components. Flex includes built-in support for drag-and-drop operation [...]</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>Type of technology</h2>
<p>Flex is a highly productive, free open source framework available for building and maintaining web applications which deploy consistently on major browsers, desktops and operating systems.</p>
<h2>Look and Feel</h2>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/1.png"><img class="aligncenter size-medium wp-image-2466" title="1" src="http://www.javabeat.net/wp-content/uploads/2012/04/1-300x173.png" alt="" width="300" height="173" /></a></p>
<h2>Drag and Drop</h2>
<p>The support for drag and drop can be added for all Flex components. Flex includes built-in support for drag-and-drop operation for some controls such as List, Tree and DataGrid, This automates processing required to support drag and drop operation. Drag-and-drop operation has 3 main stages: initiation, dragging, and dropping. A drag-and-drop operation will either copy or move data from drag initiator to drop target. On successful drop, Flex adds the data to drop target and, optionally, deletes it in case of a move from the drag initiator.</p>
<h2>Type of Technology</h2>
<p>Adobe Flex is a collection of technologies based on Adobe Flash platform. Currently Adobe Flex applications are build using Flex 3 SDK. Other technologies used with it are Livecycle Data Services (J2EE application integration). Flex applications are viewed on Adobe Flash Player.</p>
<h2>Application architecture</h2>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/2.png"><img class="aligncenter size-medium wp-image-2464" title="2" src="http://www.javabeat.net/wp-content/uploads/2012/04/2-300x169.png" alt="" width="300" height="169" /></a>Most of the web applications are usually build in MVC architecture in the case of a Flex RIA. The Controller can take form of the Service (or business object) on the application server which reads and updates a Database (the Model).When it receives the requests from the Flex application and itself, represents the Database records to the user.</p>
<h2>Environment</h2>
<p>For render response in terms of web pages, it requires a browser having Adobe Flash plugin installed on the client machine. For deployment purpose Flex 3 SDK is required on the server machine.</p>
<h2>Tools Availability</h2>
<p>Flash Builder 4 is the IDE for developing a Flex application. It has end to end support for building a Flex application, component etc. It has all the components given in palettes to that the designing of front end becomes very easy. However, flex application can be written in any text based tool and executed on machine having Flex 3 SDK.</p>
<h2>Community Support</h2>
<p>Since Flex is a very popular framework for developing RIAs, a huge community support is available. One very popular among them is CFLEX (Community Adobe Flex). This community is dedicated to Adobe Flex.</p>
<h2>Frameworks supported</h2>
<p>In Flex you have several options to choose for back-end server software (ranging from JEE to Dotnet etc). Few examples are -</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<li>
<h5>Flex with Struts:</h5>
</li>
</ul>
<ul>With Flex, you can provide a rich front end to your Struts applications. There are two approaches for integrating Flex with Struts application which are based on 2 different ways a Flex application communicates with remote systems i.e. By using the traditional HTTP request/response mechanism or by using SOAP to invoke methods on remote services. Basically Flex can be taken as part of the View in a distributed MVC framework.</ul>
<ul>
<li>
<h5>Flex with Spring:</h5>
</li>
</ul>
<ul>This integration is done with the help of Flex Data services i.e. BlazeDS. The BlazeDS adds Remoting Service, Message Service, and Proxy Service to the Flex application. Using Remoting Service a Flex application directly invokes methods of Java objects deployed in the application server. Spring beans are Java objects and so can be accessed using the remoting service of BlazeDS. BlazeDS supports the concept of a factory to configure the Spring container for instantiating Spring beans. The role of the factory is simply to provide ready to use instances of components for BlazeDS (instead of letting BlazeDS instantiate these components).</ul>
<ul>
<li>
<h5>Flex with Ruby on Rails:</h5>
</li>
</ul>
<ul>Using this we can do more with very less code. Using Flex we can create the user interface for displaying data. Then we can design this user interface using Flex components for nice look and feel. Then setup the corresponding rails application. Flex can then talk to rails by using the HTTPService to call the different methods in your Rails application.</ul>
<h2>Animation/ Multimedia support</h2>
<p>Flex is developed by Adobe Systems and so is closely related to Flash. Both Flash and Flex Work using ActionScript 3.0, both outputs a SWF format, and both of them use Flash Player to display their content. But Flash is good in animation and Flex by contrast is best at the developing applications and things that are associated with it—charting, handling data, and such. So, Flex can focuses on animations such as transitions that place as menus expand, or items such as image scaling to different sizes and in different states. To add more animation capability we can integrate Flash and Flex in three ways: By using Flash for creating skins and component animations, by adding complex timeline animations, and by adding in Flash multimedia clips that can be controlled in Flex.</p>
<h2>Ease of testing</h2>
<p>Flex Builder comes with debugging tools which helps in unit testing of a Flex application. Breakpoints can be set both in ActionScript as well as in MXML code that allow application execution to pause at a specified code location. Flex 3 comes with an option of profiling the application. The profiler helps in identifying the performance bottlenecks and memory leaks in the application. It tells about Call frequency, Method duration, Call stacks, Number of instances, Object size and Garbage collection. Apart from these many external tools are available for testing flex application like FlexMonkey, FunFx, QuickTestProfessional etc</p>
<h2>Flexibility and Scalability</h2>
<p>Flex application is backend agnostic and can work with any kind of backend server till it sends and receive data in the format/protocol supported by Flex. Scalability of Flex application basically depends upon the underlying application server. The Flex application scales upto the level of support provided by the application server.</p>
<h2>Browsers dependence</h2>
<p>Flex is doesn&#8217;t directly depend on the type of browser but is dependent on the Flash Player web browser plug-in. But as per the statistics 98% of browsers available currently have Flash Player plug-in with version 7-9 installed. So, a Flex-generated code works on each client regardless of browser/platform. So, flex has a limitation in this respect that they are limited by the constraints of Flash Player and cannot display anything outside the boundaries of the player&#8217;s space embedded in the web page.</p>
<h2>Network performance</h2>
<p>The Flex client-side processing model and configuration ability helps in improving the network performance. For example, the network bandwidth and connections can be improved by embedding the product images within the SWF file. The SWF file would increase to 60K (or, a total size of 260K), but the application would require 15 fewer network connections to the server. A second potential improvement is to disable the Flex history management feature if it is not required; this prevents the Flex application from transmitting the history management HTML page, thereby reducing network overhead. (Source: Macromedia White Paper, Flex Performance Brief: A Comparison of Flex and Java Server Pages Applications May 2004)</p>
<h2>Client Performance</h2>
<p>Flex offers the ability to create Rich Internet Applications (RIAs). Misusing this power can result in areas of poor performance. Flex is like any other programming model because certain coding practices can be detrimental to the overall performance of the client. So, depending upon the coding techniques follow are affected at client side:</p>
<ul>
<li>Startup time</li>
<li>Playing complex effects smoothly</li>
<li>Performance of charting components</li>
<li>Streaming of multimedia content</li>
</ul>
<h2>Client Validation Support</h2>
<p>As we know, Flex is best used for good user interface. The data that user enters in user interface control might or might not be appropriate for our application. Adobe Flex applications, uses a validator to ensure that values in the fields of the form meet certain criteria.</p>
<p>Flex includes some set of validators for common types of user input datas, such as zip code, phone numbers, and credit card numbers etc. Validators are created in MXML by using a validator tag such asor. Validators uses following 2 properties to specify the item which needs to be validated:</p>
<ul>
<li>source: This specifies the object which contains the property to be validated .We can set this for an instance of a component or to a data model. You can use data binding syntax in MXML for specifying the value for the source property.</li>
<li>property: A String that specifies the name of the source property that contains value to validate. This property support dot-delimited Strings for specifying nested properties.</li>
</ul>
<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/08/flex-4-x-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What&#8217;s New in Silverlight 5?</title>
		<link>http://www.javabeat.net/2011/07/whats-new-in-silverlight-5/</link>
		<comments>http://www.javabeat.net/2011/07/whats-new-in-silverlight-5/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 23:41:43 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Tools & IDEs]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2450</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 is based on Silverlight 5 in Action , published on June 2011. It is being reproduced here by permission from Manning Publications. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all [...]</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><em>This article is based on <a href="http://www.manning.com/pbrown2/" target="_blank">Silverlight 5 in Action</a> , published on June 2011. It is being reproduced here by permission from <a href="http://www.manning.com" target="_blank">Manning Publications</a>. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all customers will be contacted and upgraded. Visit Manning.com for more information. [ <span style="color: red;"><span style="text-decoration: underline;"><strong>Use promotional code 'java40beat' and get 40% discount on eBooks and pBooks</strong></span> </span>]</em></p>
<h2>Introduction</h2>
<p>Silverlight 3, 4, and 5 have added an amazing number of new capabilities to the platform in all areas, from core capabilities, to device access, to the introduction of both trusted and sandboxed in and out-of-browser client applications. While Silverlight is still a relatively young technology, it has had 5 major releases in the past four years, as described in table 1.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/silverlight-001.jpg"><img class="aligncenter size-medium wp-image-2455" title="silverlight-001" src="http://www.javabeat.net/wp-content/uploads/2012/04/silverlight-001-300x107.jpg" alt="" width="300" height="107" /></a>Table 1 shows just a few of the major enhancements delivered in each version of Silverlight over the last four years. In the remainder of this article, we&#8217;ll look at the features, especially those new to Silverlight 4 and 5, in more detail. The advancements in Silverlight can be loosely grouped into four main areas: business and client applications, media and graphics, user interaction, and text.</p>
<h2>Features for business and client applications</h2>
<p>Though Silverlight 2 could have been used to build rich business applications, it didn&#8217;t have the chops to be a strong contender in that space yet. Three versions later, that story has certainly changed. Many of the features in this article are useful in applications of all sorts; I hate to classify them under the heading of &#8220;business,&#8221; but that&#8217;s the largest consumer of these features.</p>
<p>Validation was one of the biggest new features for business applications. Silverlight didn&#8217;t add just validation but included support for validation through attributes, validation through exceptions, and even asynchronous validation, all of which work with the Silverlight controls. Silverlight even made it possible to completely customize the style of the validation information provided to the end-user.</p>
<p>One technology that builds heavily on the validation stack is WCF RIA Services. A good bit of the validation functionality rolled into the Silverlight runtime actually came from that project. WCF RIA Services provides a way to share validation and logic between the client and the server as well as a framework for validation, data access, and security, shareable between Silverlight and other clients.</p>
<p>WCF RIA Services builds upon the WCF stack, but it&#8217;s not the only enhancement there. The Silverlight networking stack was greatly enhanced to support in-browser and out-of-browser operation, as well as SOAP 1.2 and a number of new protocol enhancements, including WS-Trust. We&#8217;ve also done a lot to optimize networking performance and reduce latency in Silverlight 5. These changes make it easier to use Silverlight behind a firewall where the services often have different requirements than those on the Internet.</p>
<p>Despite the promises of a paperless office, printing is still a staple of business applications everywhere. Printing in Silverlight 4 was optimized for relatively short reports or documents, as well as for the equivalent of print-screen operations. Silverlight 5 adds a new Postscript or true vector printing mode to the existing bitmap approach, making serious printing and print-preview now possible.</p>
<p>Finally, we come to a biggie: out-of-browser sandboxed and trusted applications. Out-of-browser mode was one of the most significant enhancements made to how Silverlight operates. Silverlight 3 introduced the basic out-of-browser mode with a sandbox roughly equivalent to the one in browser. Silverlight 4 opened up whole new classes of applications by adding the trusted application mode with its reduction in prompts, increased file access, and (on Windows) access to IDispatch COM Automation servers. All of these features add up to a platform that&#8217;s more than capable of being the client for our complex business applications.</p>
<p>One of the next major areas of enhancement for Silverlight is media.</p>
<h2>Media and graphics enhancements</h2>
<p>Silverlight was first and best known for its media capabilities. The Silverlight media team didn&#8217;t rest on that, instead pumping out enormous advances in media in each update to Silverlight.</p>
<p>Silverlight 2 included a Media Stream Source API for pushing media through the pipeline. But that API required that the bits be preencoded into one of the formats natively understood at the time. Though useful, this could lead to double-encoding and made transcoding even more difficult.</p>
<p>Silverlight 3 added support for pushing raw video and audio out of custom Media Stream Source implementations. As a result, you can write a managed codec for any type of media or even do something crazy like I did and use it to generate audio and video in real time for an emulator.</p>
<p>Speaking of codecs, one of the new codecs added was H.264 for video. H.264 has emerged as one of the most popular codecs for TV and video for devices. It was a logical choice for an additional native Silverlight format because now content producers can use even more of their content without reencoding. Silverlight 5 expanded on the H.264 support by adding hardware decoding to improve performance, especially on lower-power devices. To appeal to the same audience, Silverlight also continued to improve DRM capabilities, including the addition of offline DRM and seamless switching between DRM media sources.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
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>One common request in the media space was for the ability to play video at double speed. Commonly called Trick Play, this has been added to Silverlight 5. Now you can watch my tutorial videos in 15 minutes instead of half an hour, with automatic pitch correction so I don&#8217;t sound like a chipmunk.</p>
<p>An exciting feature introduced in Silverlight 4 was built-in support for video and audio capture devices or, specifically, webcams and microphones. Though not yet quite at the level that would allow you to create a real-time video chat application, the support does open up a number of new possibilities for application development. Under the covers, Silverlight now has support for all formats of portable network graphics (PNG), something that was only partially supported in previous versions. Silverlight 4 also introduced support for pixel shaders and a set of built-in performance-tuned effects such as drop-shadow and blur.</p>
<p>Easily the most anticipated feature in Silverlight 5, the GPU-accelerated 3D programming interface will enable all sorts of scenarios, from games to data visualization to custom third-party 3D rendering and scene management systems. This system also provides us with the ability to have immediate-mode 2D graphics—another frequent request.</p>
<p>With all of these advancements plus a number of performance optimizations and even additions such as the Silverlight Media Framework, Silverlight continues its leadership in the media space, offering everything you need to build rich media-centric applications.</p>
<p>Sometimes what you want is more than just a media experience; you want an application that can be truly interactive. Silverlight has your back there, too.</p>
<h2>User interaction</h2>
<p>Since Silverlight 2, user interaction has received a number of important enhancements. Two of the most requested features, mouse scroll wheel and right-click mouse support, are now baked into the Silverlight core runtime.</p>
<p>One of the newer and hotter user interaction mechanisms is multitouch. The ability to support multipoint interaction with the user interface, especially in kiosk and handheld/tablet scenarios, is quickly becoming a requirement for many applications. Silverlight now includes core runtime support for multipoint-touch interaction with Silverlight application.</p>
<p>Another user interaction piece missing from Silverlight 2 was the easy ability to show dialogs and pop-up windows (simulated) within your applications. Silverlight now not only has those but also notification toast.</p>
<p>Finally, all the interaction in the world has no value if your user can&#8217;t read the text on the screen. Happily, Silverlight includes plenty of improvements in text as well.</p>
<h2>Text</h2>
<p>By far, the biggest improvement to text since Silverlight 2 is proper ClearType font rendering. Silverlight 2 performed only grayscale rendering, giving text a fuzzy appearance, unless you carefully picked your color schemes. Silverlight 5 has expanded on this to provide even better and faster text rendering, much like we did with WPF 4.</p>
<p>While ClearType may be important for font rendering in general, right-to-left or bidirectional (BiDi) text is something that&#8217;s absolutely essential for the correct rendering of many non-European languages. Silverlight supports not only BiDi text but also input method editors (IMEs) for complex composite characters for many languages, especially Asian and Middle Eastern languages.</p>
<p>Silverlight 5 added enhancements to better improve layout and typography. For example, multicolumn and linked text now enables magazine-like layouts with fluid text flow around other elements. Tracking and leading, always important to the typography-aware (you know, the people who go around wearing shirts that say &#8220;Helvetica&#8221;), was also added.</p>
<p>Finally, one great improvement to text rendering and entry is the inclusion of the rich text box control. This control allows you to display or edit text that includes multiple fonts and styles. The control can even embed other elements that can be interactive when the control is in read-only mode.</p>
<h2>Summary</h2>
<p>Between Silverlight 4 and Silverlight 5, we&#8217;ve seen a huge number of great features and improvements added. Before I joined Microsoft, I heard rumors about people with sleeping bags in their offices and coffee delivered by the gallon. I suspect I now know which team they work for, and I have to say that I&#8217;m &#8220;super&#8221; impressed with the results.</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/2011/07/whats-new-in-silverlight-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Custom Pie Chart Component with Degrafa using Flex</title>
		<link>http://www.javabeat.net/2011/07/creating-a-custom-pie-chart-component-with-degrafa-using-flex/</link>
		<comments>http://www.javabeat.net/2011/07/creating-a-custom-pie-chart-component-with-degrafa-using-flex/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 23:39:52 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2444</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 is based on Flex on Java , published on October 2010. It is being reproduced here by permission from Manning Publications. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all customers [...]</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><em>This article is based on <a href="http://www.manning.com/allmon/" target="_blank">Flex on Java</a> , published on October 2010. It is being reproduced here by permission from <a href="http://www.manning.com" target="_blank">Manning Publications</a>. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all customers will be contacted and upgraded. Visit Manning.com for more information. [ <span style="color: red;"><span style="text-decoration: underline;"><strong>Use promotional code 'java40beat' and get 40% discount on eBooks and pBooks</strong></span> </span>]</em></p>
<p><center></p>
<h2>Creating a Custom Pie Chart Component with Degrafa</h2>
<p></center>Adobe provides data visualization components, but only when you purchase a license for the professional version of the Flash Builder IDE. Because our goal is to do Flex development using only free and open source technologies, we&#8217;ve decided to create our own visualization components—besides, it&#8217;s more fun.</p>
<h2>Drawing in Flex</h2>
<p>Flex and Flash provide powerful drawing libraries that we could leverage to create our custom graph components, but we&#8217;re going to leverage an open source graphics library called Degrafa. Using Degrafa gives us the ability to declaratively build our graphing components rather than having to deal with the complex calculations involved in drawing pie chart slices as illustrated in listing 1, which shows an example ActionScript class specifically for drawing a pie chart slice found at http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html. Notice how much trigonometry is involved in creating something as simple as a pie chart slice from scratch.</p>
<p><strong><span style="color: red;">Listing 1 Example of drawing in ActionScript</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">/*-------------------------------------------------------------
	mc.drawWedge is a method for drawing pie shaped
	wedges. Very useful for creating charts. Special
	thanks to: Robert Penner, Eric Mueller and Michael
	Hurwicz for their contributions.
-------------------------------------------------------------*/
	MovieClip.prototype.drawWedge = function(x, y, startAngle, arc,
	radius, yRadius) {
	==============
		// mc.drawWedge() - by Ric Ewing (ric@formequalsfunction.com) -
		version 1.3 - 6.12.2002
		//
		// x, y = center point of the wedge.
		// startAngle = starting angle in degrees.
		// arc = sweep of the wedge. Negative values draw clockwise.
		// radius = radius of wedge. If [optional] yRadius is defined,
		then radius is the x radius.
		// yRadius = [optional] y radius for wedge.
		// ==============
		// Thanks to: Robert Penner, Eric Mueller and Michael Hurwicz
		for their contributions.
		// ==============
		if (arguments.length&lt;5) {
			return;
		}
		// move to x,y position
		this.moveTo(x, y);
		// if yRadius is undefined, yRadius = radius
		if (yRadius == undefined) {
			yRadius = radius;
		}
		// Init vars
		var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;
		// limit sweep to reasonable numbers
		if (Math.abs(arc)&gt;360) {
			arc = 360;
		}
		// Flash uses 8 segments per circle, to match that, draw in a maximum
		// of 45 degree segments. First calculate how many segments are needed
		// for our arc.
		segs = Math.ceil(Math.abs(arc)/45);
		// Now calculate the sweep of each segment.
		segAngle = arc/segs;
		// The math requires radians rather than degrees. To convert from degrees
		// use the formula (degrees/180)*Math.PI to get radians.
		theta = -(segAngle/180)*Math.PI;
		// convert angle startAngle to radians
		angle = -(startAngle/180)*Math.PI;
		// draw the curve in segments no larger than 45 degrees.
		if (segs&gt;0) {
			// draw a line from the center to the start of the curve
			ax = x+Math.cos(startAngle/180*Math.PI)*radius;
			ay = y+Math.sin(-startAngle/180*Math.PI)*yRadius;
			this.lineTo(ax, ay);
			// Loop for drawing curve segments
			for (var i = 0; i&lt;segs; i++) {
				angle += theta;
				angleMid = angle-(theta/2);
				bx = x+Math.cos(angle)*radius;
				by = y+Math.sin(angle)*yRadius;
				cx = x+Math.cos(angleMid)*(radius/Math.cos(theta/2));
				cy = y+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
				this.curveTo(cx, cy, bx, by);
			}
			// close the wedge by drawing a line to the center
			this.lineTo(x, y);
		}
	};</pre></td></tr></table></div>

<p>Adobe has released the specifications for its declarative graphics library, called FXG. It appears that the Degrafa team has collaborated with the Adobe team to create this specification, but the FXG functionality is only a subset of what is available from the Degrafa library. This may be a library to keep your eye on as it&#8217;s being developed.</p>
<h2>Common Degrafa concepts</h2>
<p>Before diving into developing the component, let&#8217;s familiarize ourselves with some of the terms and concepts that we&#8217;ll see as we work through this example.</p>
<ul>
<li><em>Surface</em>—This is the base component for everything you&#8217;ll do in Degrafa. All other Degrafa components will be composed within a Surface.</li>
<li><em>GeometryGroup</em>—After the Surface, this is the next level of composition. The GeometryGroup tag allows you to group Degrafa components to compose an object.</li>
<li><em>Stroke</em>—Stroke is the object that is used to define the look of an object&#8217;s outline, in terms of color, thickness, and style. Degrafa provides different Stroke objects for your use depending on the style of stroke you want: SolidStroke, Linear-Gradient, and RadialGradient.</li>
<li><em>Fill</em>—Fill refers to the appearance of the bounded area of a graphical component. Degrafa provides the<br />
following fills: SolidFill, LinearGradient, Radial-Gradient, BitmapFill, BlendFill, and ComplexFill.</li>
<li><em>Shapes</em>—Degrafa supports drawing many different shapes out of the box, such as Circle, Ellipse, RegularRectangle, RoundedRectangle, Polygon, and more. For irregular shapes, Degrafa also has an extensive library of auto shapes and enables defining any shape you&#8217;d like by providing a Scalable Vector Graphics (SVG) path.</li>
<li><em>Repeaters</em>—This gives you the ability to repeat a shape any number of times on the surface.</li>
</ul>
<p>Much like other Flex components, the Degrafa components are considered either container components, meaning they will contain other Degrafa components, or graphical elements. Figure 1 shows the relationship of the common components.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/creating-a-custom-pie-chart-001.jpg"><img class="aligncenter size-medium wp-image-2448" title="creating-a-custom-pie-chart-001" src="http://www.javabeat.net/wp-content/uploads/2012/04/creating-a-custom-pie-chart-001-300x222.jpg" alt="" width="300" height="222" /></a>We&#8217;re only going to scratch the surface; to learn more about Degrafa, you can start with the Foundation section of the documentation at http://www.degrafa.org/samples/foundation.html.</p>
<h2>Creating a pie chart for fun and profit</h2>
<p>Now that we have some of the basic concepts, let&#8217;s get on with the task of creating a custom pie chart component. We were inspired by a blog posting by Derrick Grigg titled appropriately enough Degrafa Pie Chart, which can be found at http://www.dgrigg.com/post.cfm/04/15/2008/Degrafa-Pie-Chart. After we decomposed it and removed some of the extra visual effects such as tweening and gradients, it barely resembles what we started with. Figure 2 shows a mock-up of the chart we&#8217;ll be developing in this article.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/creating-a-custom-pie-chart-002.jpg"><img class="aligncenter size-medium wp-image-2447" title="creating-a-custom-pie-chart-002" src="http://www.javabeat.net/wp-content/uploads/2012/04/creating-a-custom-pie-chart-002-300x195.jpg" alt="" width="300" height="195" /></a>For this example you&#8217;ll be developing only a single pie chart component, but some of the concepts illustrated here could potentially be applied to creating any number of charting components.</p>
<p>The component you&#8217;ll develop is a combination of a pie chart and a data grid, which will serve the purpose of a legend for the pie chart. Without this it may be difficult for someone looking at the chart to differentiate between data points on the graph. The pie chart will consist of the pie chart itself and another component for each of the slices that make up the chart. You&#8217;ll also develop a simple custom ItemRenderer for the chart legend to draw a simple box inside one of the cells in the data grid.</p>
<p>You&#8217;ll also be adding a label and a combo box to the GraphView to allow the user to change the data the chart shows. By changing the value of the combo box the user can show how many issues there are by project, type, status, or severity.</p>
<h2>New custom event</h2>
<p>We&#8217;re going to create a new custom event for our pie chart. The reason we&#8217;re creating a new one is that if we ever wanted to put more than one pie chart component into our application, we&#8217;d need to be able to distinguish which component fired the event.</p>
<p><strong><span style="color: red;">Listing 2 PieChartEvent.as</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package org.foj.event {
		import flash.events.Event;
		public class PieChartEvent extends Event{
			public static const DATA_PROVIDER_UPDATED:String =
			&quot;dataProviderUpdated&quot;;
			public var data:*;
			public var id:*;					#1
			public function PieChartEvent(type : String,
				bubbles : Boolean = true,
				cancelable : Boolean = false)
			{
				super(type, bubbles, cancelable);
			}
		}
	}
	#1 id property</pre></td></tr></table></div>

<p>This event differs from the one created previously in the addition of an id property (#1). This is done so that the presenter can decide whether or not it needs to react to the event. With the new event created, you can move on to creating the component itself.</p>
<h2>PieChart component</h2>
<p>First, you&#8217;ll develop the view that contains the pie chart and legend. You&#8217;ll create these view components in a new package, so create a file named PieChart.mxml in the org.foj.components package of your project. The following listing shows the first part of the code for the PieChart view.</p>
<p><strong><span style="color: red;">Listing 3 PieChart.mxml</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
	&lt;s:Group xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
		xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
		xmlns:mx=&quot;library://ns.adobe.com/flex/halo&quot;
		xmlns:degrafa=&quot;http://www.degrafa.com/2007&quot;
		creationComplete=&quot;init()&quot;&gt;								#1
		&lt;s:layout&gt;										#2
			&lt;s:HorizontalLayout/&gt;
		&lt;/s:layout&gt;
		&lt;fx:Script&gt;
			&lt;![CDATA[
				import mx.collections.ICollectionView;
				import org.foj.event.EventDispatcherFactory;
				import org.foj.event.PieChartEvent;
				import org.foj.presenter.PieChartPresenter;
				private var _presenter:PieChartPresenter;				#3
				private var _dataProvider:ICollectionView;				#4
				private function init():void
				{
					_presenter = new PieChartPresente r(this, id);			#5
				}
				public function set dataProvider(dataProvider:ICollectionView):void {	#6
					var refreshEvent:PieChartEvent =
						new PieChartEvent(PieChartEvent.DATA_PROVIDER_UPDATED);
					refreshEvent.id = id;
					refreshEvent.data = dataProvider;
					EventDispatcherFactory.getEventDispatcher().dispatchEvent(refreshEvent);
				}
			]]&gt;
		&lt;/fx:Script&gt;
		...
	&lt;/s:Group&gt;
	#1 CreationComplete handler
	#2 HorizontalLayout
	#3 Define presenter field
	#4 Define data provider field
	#5 Pass component's id to presenter
	#6 Set property for data provider</pre></td></tr></table></div>

<p>You set the creationComplete event (#1) to call the init method. Next, you set the layout of your component to use HorizontalLayout (#2). Then, you declare a couple of private member variables for the data provider and its presenter (#3, #4).</p>
<p>Inside the init method, you bootstrap your presenter (#5). Last, you create a set property (#6) for the data provider where you create an event to notify the presenter that the data provider was updated. Listing 4 shows the rest of your pie chart component.</p>
<p><strong><span style="color: red;">Listing 4 PieChart.mxml (continued)</span></strong></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;s:Group xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
		xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
		xmlns:mx=&quot;library://ns.adobe.com/flex/halo&quot;
		xmlns:degrafa=&quot;http://www.degrafa.com/2007&quot;
		creationComplete=&quot;init()&quot;&gt;
		...
		&lt;/fx:Script&gt;
		&lt;mx:Spacer width=&quot;10&quot;/&gt;								#1
		&lt;degrafa:Surface id=&quot;pieSurface&quot;
			width=&quot;200&quot; height=&quot;200&quot;&gt;						#2
			&lt;degrafa:GeometryGroup id=&quot;pieGroup&quot;&gt;					#3
				&lt;degrafa:filters&gt;
					&lt;mx:DropShadowFilter color=&quot;0x000000&quot;
						alpha=&quot;0.5&quot;/&gt;
				&lt;/degrafa:filters&gt;						#4
			&lt;/degrafa:GeometryGroup&gt;
		&lt;/degrafa:Surface&gt;
		&lt;mx:DataGrid id=&quot;legendDataGrid&quot;&gt;						#5
			&lt;mx:columns&gt;
				&lt;mx:DataGridColumn width=&quot;40&quot;
					sortable=&quot;false&quot;					#6
					itemRenderer=&quot;org.foj.components.PieLegendRenderer&quot;/&gt;
				&lt;mx:DataGridColumn dataField=&quot;label&quot;
					headerText=&quot;Label&quot;/&gt;
				&lt;mx:DataGridColumn dataField=&quot;units&quot;
					headerText=&quot;Units&quot;/&gt;
			&lt;/mx:columns&gt;
		&lt;/mx:DataGrid&gt;
	&lt;/s:Group&gt;
	#1 Spacer to help lay out the component
	#2 Degrafa surface
	#3 Geometry group containing pie chart
	#4 Drop shadow for pie chart
	#5 Legend for pie chart
	#6 Custom ItemRenderer</pre></td></tr></table></div>

<p>First, you added a spacer (#1) to the component to put a bit of padding between your pie chart and its surrounding components. Next you added a Degrafa Surface component (#2) and a GeometryGroup (#3) to hold the rest of the Degrafa components necessary for the pie chart component. The GeometryGroup is the component to which you&#8217;ll add your pie chart slices when you create them. You&#8217;ve also added a Drop-ShadowFilter (#4) to the GeometryGroup to add a bit of visual flair to the pie chart. Last you defined the DataGrid component (#5) for your chart legend, with a custom Item-Renderer (#6) to display the color that corresponds to the data in the chart, which you&#8217;ll create in a bit.</p>
<h2>PieChartSlice</h2>
<p>Now that we&#8217;ve defined the pie chart component, let&#8217;s move on to defining the slices that will make up the pie chart. The pie chart slice is a rather simple component. We probably could have created the pie chart slice programmatically in ActionScript; however, this approach allows us to define sensible defaults declaratively in MXML, adding behavior as well.</p>
<p><strong><span style="color: red;">Listing 5 PieChartSlice.mxml</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
	&lt;degrafa:GeometryGroup xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
		xmlns:degrafa=&quot;http://www.degrafa.com/2007&quot;
		height=&quot;400&quot;
		width=&quot;400&quot;&gt;							#1
		&lt;fx:Script&gt;
			&lt;![CDATA[
				public function refresh():void			#2
				{
					this.graphics.clear();
					this.arc.preDraw();
					this.arc.draw(graphics, null);
				}
			]]&gt;
		&lt;/fx:Script&gt;
		&lt;degrafa:EllipticalArc						#3
			id=&quot;arc&quot;
			width=&quot;200&quot;
			height=&quot;200&quot;
			closureType=&quot;pie&quot;/&gt;
	&lt;/degrafa:GeometryGroup&gt;
	Extends GeometryGroup
	Your pie chart slice
	Adds EllipticalArc</pre></td></tr></table></div>

<p>The pie chart slice will extend from GeometryGroup (#1). Next, you define a refresh method (#2) to abstract behavior away from your presenter. Last you add an EllipticalArc component to the component (#3) and set default values such as its width, height, and most importantly closureType property, which you set to &#8220;pie&#8221;.</p>
<h2>Custom ItemRenderer</h2>
<p>The next component you&#8217;re going to create is the custom ItemRenderer for the pie chart legend. This simple component will draw a colored box in the data grid cell to correspond with the colors of the pie chart.</p>
<p><strong><span style="color: red;">Listing 6 PieLegendRenderer.mxml</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
	&lt;mx:HBox xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
		xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
		xmlns:mx=&quot;library://ns.adobe.com/flex/halo&quot;
		xmlns:degrafa=&quot;http://www.degrafa.com/2007&quot;&gt;					#1
		&lt;mx:Spacer width=&quot;2&quot;/&gt;								#2
		&lt;degrafa:Surface&gt;
			&lt;degrafa:GeometryGroup&gt;
				&lt;degrafa:fill&gt;							#3
					&lt;degrafa:SolidFill id=&quot;fill&quot;&gt;
						&lt;degrafa:color&gt;{data.legend}&quot;&lt;/degrafa:color&gt;	#4
					&lt;/degrafa:SolidFill&gt;
				&lt;/degrafa:fill&gt;
				&lt;degrafa:RegularRectangle					#5
					width=&quot;20&quot;
					height=&quot;20&quot;
					fill=&quot;{fill}&quot;/&gt;
			&lt;/degrafa:GeometryGroup&gt;
		&lt;/degrafa:Surface&gt;
	&lt;/mx:HBox&gt;
	#1 Extends HBox Spacer to help align box
	#2 SolidFill for rectangle
	#3 Color of legend item
	#4 Rectangle</pre></td></tr></table></div>

<p>The ItemRenderer is extending HBox (#1) because all ItemRenderer objects for the DataGrid component must be halo components. Add a Spacer component (#2) to help align the rectangle the way you want it. The SolidFill component (#3) defines the fill color for the RegularRectangle (#5). Now that you&#8217;ve finished creating all the visual components for the pie chart, let&#8217;s move on to creating the Presenter. An implicitly defined variable is available to the ItemRenderer named data, which corresponds to the item in the dataProvider that you&#8217;re rendering. Use this implicit variable to set the color of the Fill object (#4), which is contained in the legend property of the object.</p>
<h2>Presenter for the PieChart</h2>
<p>Now that all the visual components are created for the pie chart, let&#8217;s create the Presenter. The Presenter for the pie chart becomes more involved than any of your previous ones, but it shouldn&#8217;t be hard to follow.</p>
<p><strong><span style="color: red;">Listing 7 PieChartPresenter.as</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package org.foj.presenter {
		import com.degrafa.paint.SolidFill;
	import org.foj.components.PieChart;
	import mx.collections.ArrayCollection;
	import org.foj.components.PieChartSlice;
	import org.foj.event.EventDispatcherFactory;
	import org.foj.event.PieChartEvent;
	import org.foj.model.PieChartModel;
	public class PieChartPresenter {
		private var _view:PieChart;								#1
		private var _model:PieChartModel;
		private var _id:String;
		private var _dataProvider:ArrayCollection;
		public function PieChartPresenter(view:PieChart, id:String) {				#2
			this._view = view;
			this._model = new PieChartModel();
			this._id = id;
			EventDispatcherFactory.getEventDispatcher()
				.addEventListener(PieChartEvent.DATA_PROVIDER_UPDATED,
				refreshData);
			}
			public function set dataProvider(data:ArrayCollection):void {			#3
				_view.legendDataGrid.dataProvider = data;
				this._dataProvider = data;
			}
			public function get dataProvider():ArrayCollection {
				return this._dataProvider;
			}
			private function refreshData(event:PieChartEvent = null):void {			#4
				if (event.id == _id) {
					changeData(event.data);
				}
			}
			private function changeData(data:ArrayCollection):void {
				dataProvider = data;
				createSlices();
			}
			private function createSlices():void {						#5
				while (dataProvider.length &gt; _view.pieGroup.numChildren) {
					_view.pieGroup.addChild(new PieChartSlice());
				}
			setLegendColors();
			redrawSlices();
		}
		private function setLegendColors():void {						#6
			for (var i:int = 0; i &lt; dataProvider.length; i++)
			{
				dataProvider.getItemAt(i).legend = _model.getLegendColorForIndex(i);
			}
		}
		private function redrawSlices():void {							#7
			var currentAngle:Number = 0;
			var totalUnits:Number = _model.getTotalUnits(_dataProvider);
			for (var i:int = 0; i &lt; _view.pieGroup.numChildren; i++) {
				var slice:PieChartSlice = _view.pieGroup.getChildAt(i)
					as PieChartSlice;
				var legendColor:Number = _model.getLegendColorForIndex(i);
				var arc:Number = i &lt; dataProvider.length ?
					_model.getAngleForItem(
				dataProvider[i].units, totalUnits) : 0;
				// workaround for weird display if only one arc and it's 360 degrees
				arc = arc &lt; 360 ? arc : 359.99;						#8
				redrawSlice(slice, currentAngle, arc, legendColor);
				currentAngle += arc;
			}
			_view.pieGroup.draw(null, null);
		}
		private function redrawSlice(slice:PieChartSlice,					#9
			startAngle:Number,
			arc:Number,
			color:Number):void {
			slice.arc.fill = new SolidFill(color, 1);
			slice.arc.startAngle = startAngle;
			slice.arc.arc = arc;
			slice.refresh();
		}
	}
	}
	#1 Private member variables
	#2 Constructor
	#3 Set property for dataProvider
	#4 Event handler
	#5 Create slices method
	#6 Set legend colors on data
	#7 Redraw slices after update
	#8 Workaround
	#9 Redraw slice</pre></td></tr></table></div>

<p>You first define private member variables to hold onto references to the view and the model, the id of the component this Presenter belongs to, and the dataProvider for your pie chart (#1). The constructor (#2) for this Presenter not only takes in a reference to the view, but also is used to bootstrap the id for the view component because there may be multiple pie charts contained in the application. You also define an event listener for the dataProvider being updated in the view component. Next you define a pair of get and set properties (#3) for the dataProvider you leverage to update the dataProvider property of the legend data grid whenever the data-Provider for the pie chart is updated.</p>
<p>You then define the event handler method for the event that is fired whenever the dataProvider for the view is updated (#4). Inside this method you check to see if the id of the component firing the event is the same as the id that created this Presenter.</p>
<p>That way if there are multiple pie chart components, this method can determine whether or not it needs to react.</p>
<p>The createSlices method (#5) checks to see if the data provider has more elements contained in it than there are pie chart slices in your pie chart. If there are more elements in the data provider, it will create more pie chart slices. In the set-LegendColors method (#6) you iterate through the items in the dataProvider and set the legend property of the item to the corresponding color, which you&#8217;ll get from the pie chart model class.</p>
<p>After all of that, refresh your pie chart with a call to the redrawSlices method (#7).</p>
<p>This will iterate over the pie chart slices and update the data values, such as the start angle of the slice and its arc. You iterate over the pie chart slices instead of the data provider because there may be more slices than items in the dataProvider, and this will draw the extra slices with an arc of 0. There is also a little workaround (#8) for when there is only a single slice and its arc is 360, which sets its arc to 359.99 so that it would draw correctly.</p>
<p>After all of the data for the slice is updated, it is passed into the redrawSlice method (#9) to tell the slice to redraw itself.</p>
<h2>Model for the PieChart</h2>
<p>Now you only have one piece of the MVP triad to complete for your pie chart. Even though the pie chart doesn&#8217;t need to call out to any remote services, you&#8217;ve still refactored a couple of methods that could be considered business logic rather than presentation logic and have no need to maintain any kind of state. The following listing shows the code for the pie chart model.</p>
<p><strong><span style="color: red;">Listing 8 PieChartModel.as</span></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package org.foj.model {
		import mx.collections.ICollectionView;
		public class PieChartModel {
			private var colors:Array = [						#1
				0x468966,
				0xFFB03B,
				0xFFF0A5,
				0x999574,
				0x007D9F,
				0x8E2800,
				0x8E28F4,
				0x0528F4,
				0xF42105,
				0x0CF405
			];
			public function getLegendColorForIndex(index:Number):Number {		#2
				return colors[index];
			}
			public function getAngleForItem(units:Number,
				totalUnits:Number):Number {					#3
				return ((((units / totalUnits) * 100) * 360) / 100) ;
			}
			public function getTotalUnits(dataProvider:ICollectionView):Number {	#4
				var total:Number = 0;
				for each(var item:Object in dataProvider) {
					total += item.units;
				}
				return total;
			}
		}
	}
	#1 Array of colors for legend
	#2 Convenience method for getting color
	#3 Calculate angle for item
	#4 Calculate total number of items for pie chart</pre></td></tr></table></div>

<p>An array of 10 different hex values (#1) corresponds to the colors you want the pie chart to use for its data points. This number could easily be increased should the need arise for more data points in your graphs; for this example this number should suffice.</p>
<p>Next, you define a convenience method (#2) for getting the color value for a specific index. The method getAngleForItem (#3) takes care of the calculation for determining the size of the angle for an item based on the total number of items contained within the pie chart and the number of items passed in. The last method you define (#4) in your model iterates through the data set passed in and returns back the total number of items for the pie chart.</p>
<h2>Summary</h2>
<p>In this article, we&#8217;ve introduced the Degrafa framework and created a custom pie chart component. Using Degrafa gives us the ability to declaratively build our graphing components rather than having to deal with complex calculations.</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/2011/07/creating-a-custom-pie-chart-component-with-degrafa-using-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create EJB project in NetBeans 7.0?</title>
		<link>http://www.javabeat.net/2011/06/how-to-create-ejb-project-in-netbeans-7-0/</link>
		<comments>http://www.javabeat.net/2011/06/how-to-create-ejb-project-in-netbeans-7-0/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 23:30:32 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[EJB 3.0]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2399</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>NetBeans IDE 7 CookbookWelcome to the NetBeans Cookbook. NetBeans is a Java Integrated Development Environment, IDE, which enables fast application development with the most adopted frameworks, technologies, and servers. Different than other IDEs, NetBeans comes already pre-packaged with a wide range of functionality out of the box, such as support for different frameworks, servers, databases, [...]</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><center>NetBeans IDE 7 Cookbook</center>Welcome to the NetBeans Cookbook.</p>
<p>NetBeans is a Java Integrated Development Environment, IDE, which enables fast<br />
application development with the most adopted frameworks, technologies, and servers.</p>
<p>Different than other IDEs, <strong>NetBeans</strong> comes already pre-packaged with a wide range of<br />
functionality out of the box, such as support for different frameworks, servers, databases,<br />
and mobile development.</p>
<p>This book does require a minimal knowledge of Java platform, more specifically the<br />
language ifself. But the book might as well be used by either beginners, who are trying to<br />
dip their toes in new technology, or more experienced developers, who are trying to<br />
switch from other IDEs but want to decrease their learning curve of a new environment.<br />
<strong>NetBeans</strong> integrates so many different technologies, many of which are present in this<br />
book, that it is beyond the scope of this book to cover all of them in depth. We provide<br />
the reader with links and information where to go when further knowledge is required.</p>
<h1>What This Book Covers</h1>
<p><em>Chapter 1, NetBeans Head First</em> introduces the developer to the basics of <strong>NetBeans</strong> by<br />
creating basic Java projects and importing Eclipse or Maven projects.</p>
<p><em>Chapter 2, Basic IDE Usage</em> covers the creation of packages, classes, and constructors, as<br />
well as some usability feature.</p>
<p><em>Chapter 3, Designing Desktop GUI Applications</em> goes through the process of creating<br />
a desktop application, then connecting it to a database and even modifying it to look<br />
more professional.</p>
<p><em>Chapter 4, JDBC and NetBeans</em> helps the developer to setup <strong>NetBeans</strong> with the most<br />
common database systems on the market and shows some of the functionality built-in to<br />
<strong>NetBeans</strong> for handling SQL.</p>
<p><em>Chapter 5, Building Web Applications</em> introduces the usage of web frameworks such as<br />
JSF, Struts, and GWT.3</p>
<p><em>Chapter 6, Using JavaFX</em> explains the basic of JavaFX application states and connecting<br />
our JavaFX app to a web service interface.</p>
<p><em>Chapter 7, EJB Application</em> goes through the process of building an <strong>EJB</strong> application<br />
which supports <strong>JPA</strong>, stateless, and stateful beans and sharing a service through a web<br />
service interface.</p>
<p><em>Chapter 8, Mobile Development</em> teaches how to create your own CLDC or CDC<br />
applications with the help of <strong>NetBeans</strong> Visual Mobile Designer.</p>
<p><em>Chapter 9, Java Refactoring lets</em> <strong>NetBeans</strong> refactor your code to extract classes,<br />
interfaces, encapsulate fields, and other options.</p>
<p><em>Chapter 10, Extending the IDE</em> includes handy examples on how to create your own<br />
panels and wizards so you can extend the functionality of the IDE.</p>
<p><em>Chapter 11, Profiling and Testing</em> covers <strong>NetBeans</strong> Profiler, HTTP Monitor, and<br />
integration with tools that analyze code quality and load generator.</p>
<p><em>Chapter 12, Version Control</em> shows how to configure <strong>NetBeans</strong> to be used with the most<br />
common version control systems on the market.</p>
<p><center>EJB Application</center>In this chapter, we will cover:</p>
<ul>
<li>Creating an EJB project</li>
<li>Adding JPA support</li>
<li>Creating Stateless Session Bean</li>
<li>Creating Stateful Session Bean</li>
<li>Sharing a service through Web Service</li>
<li>Creating a Web Service client</li>
</ul>
<h2>Introduction</h2>
<p><strong>Enterprise Java Beans (EJB)</strong> is a framework of server-side components that encapsulates<br />
business logic.</p>
<p>These components adhere to strict specifications on how they should behave. This ensures<br />
that vendors who wish to implement <strong>EJB</strong>-compliant code must follow conventions, protocols,<br />
and classes ensuring portability.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
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>The <strong>EJB</strong> components are then deployed in <strong>EJB</strong> containers, also called <strong>application servers</strong>,<br />
which manage persistence, transactions, and security on behalf of the developer.</p>
<p>If you wish to learn more about <strong>EJB</strong>s, visit http://jcp.org/en/jsr/detail?id=318 or</p>
<p>https://www.packtpub.com/developer-guide-for-ejb3/book.</p>
<p>For our <strong>EJB</strong> application to run, we will need the application servers.</p>
<p>Application servers are responsible for implementing the <strong>EJB</strong> specifications and creating the<br />
perfect environment for our <strong>EJB</strong>s to run in.</p>
<p>Some of the capabilities supported by <strong>EJB</strong> and enforced by Application Servers are:</p>
<ul>
<li>Remote access</li>
<li>Transactions</li>
<li>Security Scalability</li>
</ul>
<p><strong>NetBeans 6.9</strong>, or higher, supports the new Java EE 6 platform, making it the only IDE so far<br />
to bring the full power of <strong>EJB 3.1</strong> to a simple IDE interface for easy development.</p>
<p><strong>NetBeans</strong> makes it easy to develop an <strong>EJB</strong> application and deploy on different Application<br />
Servers without the need to over-configure and mess with different configuration files. It&#8217;s<br />
as easy as a project node right-click.</p>
<h2>Creating EJB project</h2>
<p>In this recipe, we will see how to create an <strong>EJB</strong> project using the wizards provided<br />
by <strong>NetBeans</strong>.</p>
<h3>Getting ready</h3>
<p>It is required to have <strong>NetBeans</strong> with Java EE support installed to continue with this recipe.</p>
<p>If this particular <strong>NetBeans</strong> version is not available in your machine, then you can download it<br />
from http://download.netbeans.org.</p>
<p>There are two application servers in this installation package, Apache Tomcat or GlassFish,<br />
and either one can be chosen , but at least one is necessary.</p>
<p>In this recipe, we will use the GlassFish version that comes together with NetBeans 7.0<br />
installation package.</p>
<h3>How to do it&#8230;</h3>
<ol>
<li>Lets create a new project by either clicking <strong>File</strong> and then <strong>New Project</strong>, or by pressing<br />
<em>Ctrl+Shift+N</em>.</li>
<li>In the <strong>New Project</strong> window, in the categories side, choose <strong>Java Web</strong> and in <strong>Projects<br />
side</strong>, select <strong>WebApplication</strong>, then click <strong>Next</strong>.</li>
<li>In <strong>Name and Location</strong>, under Project Name, enter <strong>EJBApplication</strong>.</li>
<li>Tick the <strong>Use Dedicated Folder for Storing Libraries</strong> option box.</li>
<li>Now either type the folder path or select one by clicking on <strong>browse</strong>.</li>
<li>After choosing the folder, we can proceed by clicking <strong>Next</strong>.</li>
<li>In <strong>Server and Settings</strong>, under <strong>Server</strong>, choose <strong>GlassFish Server 3.1</strong>.</li>
<li>Tick <strong>Enable Contexts and Dependency Injection</strong>.</li>
<li>Leave the other values with their default values and click <strong>Finish</strong>.</li>
</ol>
<p>The new project structure is created.</p>
<h3>How it works&#8230;</h3>
<p><strong>NetBeans</strong> creates a complete file structure for our project.</p>
<p>It automatically configures the compiler and test libraries and creates the GlassFish<br />
deployment descriptor.</p>
<p>The deployment descriptor filename specific for the GlassFish web server is<br />
glassfish-web.xml.</p>
<p><center><img src="images/2011/06/ejb-application/ejb-application-1.jpg" alt="" /></center></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/2011/06/how-to-create-ejb-project-in-netbeans-7-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML5 Multimedia Development Cookbook</title>
		<link>http://www.javabeat.net/2011/06/html5-multimedia-development-cookbook/</link>
		<comments>http://www.javabeat.net/2011/06/html5-multimedia-development-cookbook/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 17:29:03 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Tools & IDEs]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2398</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>HTML5 Multimedia Development Cookbook will show you exactly how to use the latest front-end web technologies like a pro. You&#8217;ll learn how HTML5 is a quantum leap difference from all previous versions and why it matters. Whether you&#8217;re a seasoned pro or a total newbie, this book gives you the roadmap to what&#8217;s next. Starting [...]</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><em><a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> Multimedia Development Cookbook</em> will show you exactly how to use the latest<br />
front-end web technologies like a pro. You&#8217;ll learn how HTML5 is a quantum leap<br />
difference from all previous versions and why it matters. Whether you&#8217;re a seasoned pro<br />
or a total newbie, this book gives you the roadmap to what&#8217;s next.</p>
<p>Starting with an overview of what&#8217;s new in <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a>, we quickly move on to practical<br />
examples. From there, we continue our exploration, all the way to the most cutting-edge<br />
experiments. There&#8217;s much to know about the new <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> specification. This book<br />
examines spec excerpts and relates them to examples currently in use. Woven with a rich<br />
tapestry of theory, practicality, code samples, screenshots, business wisdom, and links to<br />
additional resources, this book will have eager developers coming back to it again and<br />
again. <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> Multimedia Development Cookbook is the essential guide to the latest<br />
front-end web development technologies.</p>
<h1>What This Book Covers</h1>
<p>In Chapter 1, Structuring for Rich Media Applications, we&#8217;ll begin by examining<br />
HTML5&#8242;s state of readiness by analyzing browser support. Then we&#8217;ll lay the groundwork<br />
for how to use HTML5&#8242;s new elements successfully.</p>
<p>Chapter 2, Supporting the Content, makes us rethink the approach the developers used to<br />
create generic containers to house various types of content.</p>
<p>Chapter 3, Styling with CSS, demonstrates how to use CSS3 to support <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a>. We&#8217;ll<br />
also look at styling in modern vs. legacy browsers and what to expect.</p>
<p>Chapter 4, Creating Accessible Experiences, is not a typical regurgitation of Section 508.<br />
Instead, we&#8217;ll employ some of the freshest technologies to support our online experiences.</p>
<p>Chapter 5, Learning to Love Forms, we&#8217;ll closely examine the new <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> input types.<br />
Also included is an analysis of which browsers support each new type.</p>
<p>Chapter 6, Developing Rich Media Applications Using Canvas, is the most forwardthinking<br />
chapter of the entire book. The discussion will center on how to develop for this<br />
new type of interactivity and includes some surprising browser support statistics.</p>
<p>Chapter 7, Interactivity using JavaScript, is jam packed with recipes to extend the new<br />
<a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> audio and video elements. Roll up your sleeves for this one!</p>
<p>Chapter 8, Embracing Audio and Video, we dig into the core HTML audio and video<br />
experiences. We will construct our own player while still supporting accessibility.</p>
<p>Chapter 9, Data Storage, takes a detailed look at a unique aspect of <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> and how to<br />
wield it. Recipes include working with JSON, SQL, and GeoLocation.</p>
<p><center>Supporting the Content</center>In this chapter, we will cover:</p>
<ul>
<li>Structuring a blog article</li>
<li>Highlighting text using the mark element</li>
<li>Using the time element</li>
<li>Specifying the pubdate of an article</li>
<li>Displaying comment blocks using the article element</li>
<li>Adding fonts dynamically with @font-face</li>
<li>Adding drop shadow effect to fonts</li>
<li>Applying gradient effects to fonts</li>
<li>Annotating visual elements using the figure tag</li>
</ul>
<h2>Introduction</h2>
<p><em>&#8220;On the web, a man should not be judged by the color of his skin but by the content<br />
of his content.&#8221; &#8211; Internet meme</em></p>
<p>One of the most significant differences between <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> and all previous versions of HTML<br />
is that before we built generic &lt;div&gt;s and other such generic containers without much<br />
knowledge of what content would go in them. With the advent of <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a>, that comes to an end.<br />
To be correct according to the specification semantically, we need to know what the content<br />
is so we can wrap it with the most appropriate new element tag. While this may mean we<br />
developers have to think differently, a new challenge is exactly why we&#8217;re here. In this chapter<br />
we&#8217;ll look at some examples of how to do just that using several of HTML5&#8242;s new elements.</p>
<p><em>&#8220;In case of confl ict, consider users over authors over implementers over specifiers<br />
over theoretical purity.&#8221; &#8211; Priority of Constituencies</em></p>
<p>Throughout this chapter, we&#8217;ll show you how to use the new &lt;article&gt; element to mark up<br />
both blog posts and comments, add a meaningful publication date to an &lt;article&gt;, use<br />
the new &lt;mark&gt; element to highlight text, and how to note visual elements using the new<br />
&lt;figure&gt; element. We&#8217;ll then turn our attention to some new methods of styling text with<br />
font replacement techniques, as well as adding drop shadows and gradients to our text.</p>
<h2>Structuring a blog article</h2>
<p><em>&#8220;The &lt;article&gt; element represents a self-contained composition in a document,<br />
page, application, or site and that is, in principle, independently distributable or<br />
reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper<br />
article, a blog entry, a user-submitted comment, an interactive widget or gadget,<br />
or any other independent item of content.&#8221; &#8211; WHATWG&#8217;s <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> Draft Standard -</em></p>
<p>http://whatwg.org/html5</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h3>Getting ready</h3>
<p>Blog entries are perfect candidates for the new &lt;article&gt; element, which is designed for<br />
syndicated content.</p>
<p>For this recipe, let&#8217;s start by identifying the major elements of a blog &lt;article&gt;: There&#8217;s<br />
usually a headline in the form of a heading tag, the blog entry itself consisting of several<br />
paragraphs and perhaps one or more images, and some information that usually includes the<br />
author&#8217;s name and other related metadata. Notice this is all self-contained related content.</p>
<h3>How to do it&#8230;</h3>
<p>We&#8217;re going to continue using the new <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> &lt;header&gt; and &lt;footer&gt; elements. The<br />
headline, entry and meta-information should be wrapped in their own unique tags, like &lt;h2&gt;,<br />
multiple &lt;p&gt;s and the new &lt;footer&gt;.</p>
<p>Let&#8217;s start with a foundation very similar to what we used in the last chapter, and add our new<br />
&lt;article&gt; element twice:</p>
<pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Blog Title&lt;/title&gt; &lt;!--[if lt IE 9]&gt;&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt; &lt;/script&gt;[endif]--&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;/head&gt; &lt;body&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<h4>Put your code on a diet?</h4>
<p>Ready for a shocker? Want to have your mind blown? The &lt;html&gt; and &lt;head&gt; and &lt;body&gt;<br />
tags (as well as their closing tags) are now optional in the <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> specification. Sure, you<br />
could leave them in there, and your pages will validate just fine, but why should we? If remove<br />
them from the previous code, we are left with the spartan:</p>
<pre><code> &lt;!DOCTYPE html&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Blog Title&lt;/title&gt; &lt;!--[if lt IE 9]&gt;&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt; &lt;/script&gt;[endif]--&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; </code></pre>
<p>Don&#8217;t believe me? Run that code through the World Wide Web Consortium&#8217;s validator at:<br />
http://validator.w3.org, and you&#8217;ll see it displays correctly in the browser.</p>
<p>Well, not so fast buster. The problem is that removing those elements breaks our code<br />
for screen readers. Uh oh. Strike one. Also, removing the &lt;body&gt; tag breaks our new<br />
HTML5-enabling JavaScript for Internet Explorer. Strike two. And guess what? You can see it<br />
coming, can&#8217;t you? Yes, removing the &lt;html&gt; tag removes the language of the page. There it<br />
is: Strike three.</p>
<p>So let&#8217;s add those elements back in, shall we?</p>
<pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Blog Title&lt;/title&gt; &lt;!--[if lt IE 9]&gt;&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt; &lt;/script&gt;[endif]--&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;/head&gt; &lt;body&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; &lt;article&gt; &lt;header&gt; &lt;h2&gt;Headline&lt;/h2&gt; &lt;/header&gt; &lt;p&gt;First paragraph&lt;/p&gt; &lt;p&gt;Second paragraph&lt;/p&gt; &lt;footer&gt;Meta information.&lt;/footer&gt; &lt;/article&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<p>There, that&#8217;s better.</p>
<h3>How it works&#8230;</h3>
<p>Remember, the new &lt;article&gt; element is a collection of related information intended for<br />
syndication via RSS or another means.</p>
<h3>There&#8217;s more&#8230;</h3>
<p>Richer, more meaningful semantics is perhaps the most significant goal for <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a>. It&#8217;s better<br />
for machines, better for authors, and most importantly, better for our audiences.</p>
<h4>Validation as an aid, not a crutch</h4>
<p>As we saw previously, removing the &lt;html&gt; and &lt;head&gt; and &lt;body&gt; tags render a still valid<br />
page. So that begs the question of how valid validators are. Unlike the XML world, <a href="http://astore.amazon.com/javabeat-20/detail/1849691045" target="_blank">HTML5</a> can<br />
use incorrect syntax and still render just fine.</p>
<p>The author makes every effort to validate his code whenever possible. It&#8217;s not necessary<br />
to be slavish to the validator, but it&#8217;s always a good quality control check. And the closer you<br />
get to valid code, the better chance browsers will display your work in as consistent a manner<br />
as possible.</p>
<h4>Eric Meyer&#8217;s funny</h4>
<p>The author loves how CSS guru Eric Meyer thinks about validators:</p>
<p><center><img src="images/2011/06/html-5-multimedia/html-5-multimedia-1.jpg" alt="" /></center></p>
<h4>Where to find validators</h4>
<p>You can make good use of code validators at:</p>
<ul>
<li>http://validator.nu</li>
<li>http://validator.w3.org</li>
</ul>
<h3>See also</h3>
<p>Kristina Halvorson&#8217;s book &#8220;<em>Content Strategy For The Web</em>&#8221; (http://contentstrategy.<br />
com) was an instant classic from the time of its release. In it, Halvorson, CEO of Minneapolisbased<br />
company Brain Traffic, clearly defines the process of how to create and deliver useful<br />
and usable content for online audiences.</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/2011/06/html5-multimedia-development-cookbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
