<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Techo</title>
	<atom:link href="http://khaledkhan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://khaledkhan.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 05 Mar 2009 10:17:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='khaledkhan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/fffd8dc740b7bf165aef47947dfa41f8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Techo</title>
		<link>http://khaledkhan.wordpress.com</link>
	</image>
			<item>
		<title>Getting Started with JBoss Drools</title>
		<link>http://khaledkhan.wordpress.com/2009/03/05/getting-started-with-jboss-drools/</link>
		<comments>http://khaledkhan.wordpress.com/2009/03/05/getting-started-with-jboss-drools/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 10:02:09 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=44</guid>
		<description><![CDATA[1. Download Drools  installations.
2. If you are using Eclipse the best way is to download the drools plugins for eclipse, which would create a new project type in the Eclipse enviorment.
3.Create a new Java project and add the jars from the drools directory to the project.
4.Create a new rules file with .drl file extension, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=44&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>1. Download <a href="http://www.jboss.org/drools/downloads.html">Drools </a> installations.</p>
<p>2. If you are using Eclipse the best way is to download the drools plugins for eclipse, which would create a new project type in the Eclipse enviorment.</p>
<p>3.Create a new Java project and add the jars from the drools directory to the project.</p>
<p>4.Create a new rules file with .drl file extension, having the following contents</p>
<p><strong>Sample.drl</strong></p>
<p>package com.sample</p>
<p>import com.sample.DroolsTest.Message;</p>
<p>rule &#8220;Hello World&#8221;<br />
when<br />
m : Message( status == Message.HELLO, message : message )<br />
then<br />
System.out.println( message );<br />
m.setMessage( &#8220;Goodbye cruel world&#8221; );<br />
m.setStatus( Message.GOODBYE );<br />
System.out.println( &#8220;Testing message again&#8221; );<br />
update( m );<br />
end</p>
<p>rule &#8220;GoodBye&#8221;<br />
no-loop true<br />
when<br />
m : Message( status == Message.GOODBYE, message : message )<br />
then<br />
System.out.println( message );<br />
m.setMessage( message );</p>
<p>end</p>
<p>5. Next we write the Rule Loader and Sample application</p>
<p><strong>DroolsTest.java</strong></p>
<p>package com.sample;</p>
<p>import java.io.InputStreamReader;<br />
import java.io.Reader;</p>
<p>import org.drools.RuleBase;<br />
import org.drools.RuleBaseFactory;<br />
import org.drools.WorkingMemory;<br />
import org.drools.compiler.PackageBuilder;<br />
import org.drools.rule.Package;<br />
import org.drools.spi.Activation;<br />
import org.drools.spi.AgendaFilter;</p>
<p>/**<br />
* This is a sample file to launch a rule package from a rule source file.<br />
*/<br />
public class DroolsTest {</p>
<p>public static final void main(String[] args) {<br />
try {<br />
//Loading the Rules<br />
RuleBase ruleBase = readRule();<br />
WorkingMemory workingMemory = ruleBase.newStatefulSession();<br />
Message message = new Message();<br />
message.setMessage(  &#8220;Hello World&#8221; );<br />
message.setStatus( Message.HELLO );<br />
workingMemory.insert( message );</p>
<p>//To run all the rules please un-comment the following line<br />
//            workingMemory.fireAllRules();</p>
<p>//To run a specific rule<br />
AgendaFilter filter = new AgendaFilter()<br />
{<br />
public boolean accept(Activation activation)<br />
{<br />
if (activation.getRule().getName().equals(&#8220;Hello World&#8221;))<br />
{<br />
return true;<br />
}</p>
<p>return false;<br />
}<br />
};<br />
workingMemory.fireAllRules(filter);</p>
<p>} catch (Throwable t) {<br />
t.printStackTrace();<br />
}<br />
}</p>
<p>/**<br />
* Please note that this is the &#8220;low level&#8221; rule assembly API.<br />
*/<br />
private static RuleBase readRule() throws Exception {<br />
//read in the source<br />
Reader source = new InputStreamReader( DroolsTest.class.getResourceAsStream( &#8220;/Sample.drl&#8221; ) );</p>
<p>//optionally read in the DSL (if you are using it).<br />
//Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( &#8220;/mylang.dsl&#8221; ) );</p>
<p>//Use package builder to build up a rule package.<br />
//An alternative lower level class called &#8220;DrlParser&#8221; can also be used&#8230;</p>
<p>PackageBuilder builder = new PackageBuilder();</p>
<p>//this wil parse and compile in one step<br />
//NOTE: There are 2 methods here, the one argument one is for normal DRL.<br />
builder.addPackageFromDrl( source );</p>
<p>//Use the following instead of above if you are using a DSL:<br />
//builder.addPackageFromDrl( source, dsl );</p>
<p>//get the compiled package (which is serializable)<br />
Package pkg = builder.getPackage();</p>
<p>//add the package to a rulebase (deploy the rule package).<br />
RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br />
ruleBase.addPackage( pkg );<br />
return ruleBase;<br />
}</p>
<p>public static class Message {<br />
public static final int HELLO = 0;<br />
public static final int GOODBYE = 1;</p>
<p>private String message;</p>
<p>private int status;</p>
<p>public String getMessage() {<br />
return this.message;<br />
}</p>
<p>public void setMessage(String message) {<br />
this.message = message;<br />
}</p>
<p>public int getStatus() {<br />
return this.status;<br />
}</p>
<p>public void setStatus( int status ) {<br />
this.status = status;<br />
}<br />
}</p>
<p>}</p>
<p>In my case I am running &#8220;Hello World&#8221; Rule. Hope everything would work accordingly, for you also.</p>
<p>I would try to embed Drools with Spring, which I am trying to integrate with one of our projects on GWT.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=44&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2009/03/05/getting-started-with-jboss-drools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Killing the Oracle DBMS_JOB</title>
		<link>http://khaledkhan.wordpress.com/2008/12/15/killing-the-oracle-dbms_job/</link>
		<comments>http://khaledkhan.wordpress.com/2008/12/15/killing-the-oracle-dbms_job/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 13:00:44 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=41</guid>
		<description><![CDATA[Lets first go through a few different methods of viewing the information about job queues.
Viewing scheduled dbms_jobs
When looking at what jobs have been scheduled, there is really only one view that you need to go to. The dba_jobs view contains all of the information you need, to see what has been scheduled, when they were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=41&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Lets first go through a few different methods of viewing the information about job queues.<br />
Viewing scheduled dbms_jobs</p>
<p>When looking at what jobs have been scheduled, there is really only one view that you need to go to. The dba_jobs view contains all of the information you need, to see what has been scheduled, when they were last run, and if they are currently running. Use the following simple script to take a look. Bear with me on the sub-select, I will build on this query as we go on in the presentation.</p>
<p><strong><span style="text-decoration:underline;">scheduled_dbms_jobs.sql</span></p>
<p>set linesize 250<br />
col log_user for a10<br />
col job for 9999999 head &#8216;Job&#8217;<br />
col broken for a1 head &#8216;B&#8217;<br />
col failures for 99 head &#8220;fail&#8221;<br />
col last_date for a18 head &#8216;Last|Date&#8217;<br />
col this_date for a18 head &#8216;This|Date&#8217;<br />
col next_date for a18 head &#8216;Next|Date&#8217;<br />
col interval for 9999.000 head &#8216;Run|Interval&#8217;<br />
col what for a60</p>
<p>select j.log_user,<br />
j.job,<br />
j.broken,<br />
j.failures,<br />
j.last_date||&#8217;:'||j.last_sec last_date,<br />
j.this_date||&#8217;:'||j.this_sec this_date,<br />
j.next_date||&#8217;:'||j.next_sec next_date,<br />
j.next_date &#8211; j.last_date interval,<br />
j.what<br />
from (select dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,<br />
dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,<br />
dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT<br />
from dba_jobs dj) j;</p>
<p><strong><span style="text-decoration:underline;">What Jobs are Actually Running</span></p>
<p>A simple join to the dba_jobs_running view will give us a good handle on the scheduled jobs that are actually running at this time. This is done by a simple join through the job number. The new column of interest returned here is the sid which is the identifier of the process that is currently executing the job.</p>
<p><strong><span style="text-decoration:underline;">running_jobs.sql</span></p>
<p>set linesize 250<br />
col sid for 9999 head &#8216;Session|ID&#8217;<br />
col log_user for a10<br />
col job for 9999999 head &#8216;Job&#8217;<br />
col broken for a1 head &#8216;B&#8217;<br />
col failures for 99 head &#8220;fail&#8221;<br />
col last_date for a18 head &#8216;Last|Date&#8217;<br />
col this_date for a18 head &#8216;This|Date&#8217;<br />
col next_date for a18 head &#8216;Next|Date&#8217;<br />
col interval for 9999.000 head &#8216;Run|Interval&#8217;<br />
col what for a60<br />
select j.sid,<br />
j.log_user,<br />
j.job,<br />
j.broken,<br />
j.failures,<br />
j.last_date||&#8217;:'||j.last_sec last_date,<br />
j.this_date||&#8217;:'||j.this_sec this_date,<br />
j.next_date||&#8217;:'||j.next_sec next_date,<br />
j.next_date &#8211; j.last_date interval,<br />
j.what<br />
from (select djr.SID,<br />
dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,<br />
dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,<br />
dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT<br />
from dba_jobs dj, dba_jobs_running djr<br />
where dj.job = djr.job ) j;</p>
<p><strong><span style="text-decoration:underline;">What Sessions are Running the Jobs</span></p>
<p>Now that we have determined which jobs are currently running, we need to find which Oracle session and operating system process is accessing them. This is done through first joining v$process to v$session by way of paddr and addr which is the address of the processs that owns the sessions, and then joining the results back to the jobs running through the sid value. The new columns returned in our query are spid which is the operating system process identifier and serial# which is the session serial number.</p>
<p><strong><span style="text-decoration:underline;">session_jobs.sql</span></p>
<p>set linesize 250<br />
col sid for 9999 head &#8216;Session|ID&#8217;<br />
col spid head &#8216;O/S|Process|ID&#8217;<br />
col serial# for 9999999 head &#8216;Session|Serial#&#8217;<br />
col log_user for a10<br />
col job for 9999999 head &#8216;Job&#8217;<br />
col broken for a1 head &#8216;B&#8217;<br />
col failures for 99 head &#8220;fail&#8221;<br />
col last_date for a18 head &#8216;Last|Date&#8217;<br />
col this_date for a18 head &#8216;This|Date&#8217;<br />
col next_date for a18 head &#8216;Next|Date&#8217;<br />
col interval for 9999.000 head &#8216;Run|Interval&#8217;<br />
col what for a60<br />
select j.sid,<br />
s.spid,<br />
s.serial#,<br />
j.log_user,<br />
j.job,<br />
j.broken,<br />
j.failures,<br />
j.last_date||&#8217;:'||j.last_sec last_date,<br />
j.this_date||&#8217;:'||j.this_sec this_date,<br />
j.next_date||&#8217;:'||j.next_sec next_date,<br />
j.next_date &#8211; j.last_date interval,<br />
j.what<br />
from (select djr.SID,<br />
dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,<br />
dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,<br />
dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT<br />
from dba_jobs dj, dba_jobs_running djr<br />
where dj.job = djr.job ) j,<br />
(select p.spid, s.sid, s.serial#<br />
from v$process p, v$session s<br />
where p.addr = s.paddr ) s<br />
where j.sid = s.sid;</p>
<p>Now that we have a good handle on how we can look at the jobs and the key columns involved, let&#8217;s go through the steps needed to bring down a job. The following is a 5 to 11 step process that should solve all of your problems.</p>
<p><strong><span style="text-decoration:underline;">Bringing Down a DBMS_JOB</span></strong></p>
<p>1. Find the Job You Want to Bring Down<br />
In order to do anything you first need to find the job that is giving you a headache. Go ahead and run the running_jobs.sql. This will give you the prime information, job, sid, serial#, and spid, for the following actions in bringing down the job.</p>
<p>2. Mark the DBMS_JOB as Broken<br />
Use the following command for the job that you have to deal with.</p>
<p>SQL&gt; EXEC DBMS_JOB.BROKEN(job#,TRUE);</p>
<p>All this command does is mark the job so that if we get it to stop, it won&#8217;t start again. Let&#8217;s make one thing perfectly clear, after executing this command the job is still running.</p>
<p>As a side note, if you are trying to shut down a database with jobs that run throughout the day, they may hinder your attempts to bring down the database cleanly. This is a wonderful command to make sure no jobs are executing during the shutdown process. Just be aware that you will need to mark the jobs as unbroken when the database comes back up, more on that later.<br />
3. Kill the Oracle Session</p>
<p>Since the job is still running and it isn&#8217;t going to end soon, you will need to kill the Oracle session that is executing the job. Use the following command for to kill the job.</p>
<p>ALTER SYSTEM KILL SESSION &#8217;sid,serial#&#8217;;</p>
<p>4. Kill the O/S Process</p>
<p>More often than not the previous step will still leave the job attached to the database and still running. When this happens you will need to go out to the operating system level and get rid of the process that has spawned from the running job. In order to do this you must login to the database box and issue the following command, depending on the type of operating system you have.</p>
<p>For Windows, at the DOS Prompt: orakill sid spid</p>
<p>For UNIX at the command line&gt; kill &#8216;9 spid</p>
<p>The orakill is an Oracle command, while kill is a Unix command.<br />
5. Check if the Job is Still Running</p>
<p>Re-run the session_jobs.sql script to see if you have gotten rid of the job. If you have there is no reason to go further. Usually steps 1 through 4 will be sufficient to get rid of a job but when the job is running wild you will have to continue with steps 6 through 11 which describes a process for bouncing the job queue process.</p>
<p>6. Determine the Current Number of Job Queue Processes</p>
<p>SQL&gt; col value for a10<br />
SQL&gt; select name,value from v$parameter where name = &#8216;job_queue_processes&#8217;;</p>
<p>7. Alter the Job Queue to Zero</p>
<p>SQL&gt; ALTER SYSTEM SET job_queue_processes = 0;</p>
<p>This will bring down the entire job queue processes.</p>
<p>8. Validate that No Processes are Using the Job Queue<br />
Re-run the session_jobs.sql script to see if any jobs are still running. Since we have given a hard stop to the job queue and issued the kill commands, you can now wait until no more jobs are running. After all the jobs have quit running, you can do whatever maintenance or tuning you need to do before proceeding.</p>
<p>9. Mark the DBMS_JOB as Not Broken<br />
You can now reset the broken job to not broken so they can run again. Just issue the command.</p>
<p>SQL&gt;EXEC DBMS_JOB.BROKEN(job#,FALSE):</p>
<p>10. Alter the Job Queue to Original Value<br />
Set the job queue to its&#8217; original value so that the jobs can run again.</p>
<p>ALTER SYSTEM SET job_queue_processes = original_value;</p>
<p>11. Validate that DBMS_JOB Is Running<br />
To make sure everything is back to normal, re-run the above scripts to validate that jobs are scheduled, not broken, and are executing with the next and last dates columns changing.</strong></strong></strong></strong></strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=41&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/12/15/killing-the-oracle-dbms_job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>creating desktop shortcut (windows) with izPack</title>
		<link>http://khaledkhan.wordpress.com/2008/10/19/creating-desktop-shortcut-windows-with-izpack/</link>
		<comments>http://khaledkhan.wordpress.com/2008/10/19/creating-desktop-shortcut-windows-with-izpack/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 11:34:45 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[GUI]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=39</guid>
		<description><![CDATA[create a .vbs file containing the following text, you can name it myshortcut.vbs


Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortcut(DesktopPath &#38; "\MyApp.lnk")
link.Arguments = "Arg1 Arg2 Arg3"
link.Description = "A Tooltip"
link.HotKey = "CTRL+ALT+SHIFT+F"
link.IconLocation = "$INSTALL_PATH\images\MyApp.ico"
link.TargetPath = "$INSTALL_PATH\MyApp.jar"
link.WindowStyle = 1
link.WorkingDirectory = "$INSTALL_PATH"
link.Save

add the following pack information in the install.xml file


&#60;pack name="MyApp - Core" required="yes"&#62;
  &#60;description&#62;&#60;/description&#62;
  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=39&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#000000;">create a .vbs file containing the following text, you can name it myshortcut.vbs<br />
</span></p>
<p><span style="color:#000000;"><span class="Apple-style-span" style="border-collapse:separate;color:#444444;font-family:0;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:20px;orphans:2;text-indent:0;text-transform:none;white-space:nowrap;widows:2;word-spacing:2px;"></p>
<pre style="margin:0;padding:0;"><tt>Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortcut(DesktopPath &amp; "\MyApp.lnk")
link.Arguments = "Arg1 Arg2 Arg3"
link.Description = "A Tooltip"
link.HotKey = "CTRL+ALT+SHIFT+F"
link.IconLocation = "$INSTALL_PATH\images\MyApp.ico"
link.TargetPath = "$INSTALL_PATH\MyApp.jar"
link.WindowStyle = 1
link.WorkingDirectory = "$INSTALL_PATH"
link.Save

add the following pack information in the install.xml file

</tt><span class="Apple-style-span" style="border-collapse:separate;color:#444444;font-family:0;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:20px;orphans:2;text-indent:0;text-transform:none;white-space:nowrap;widows:2;word-spacing:2px;">
<pre style="margin:0;padding:0;"><tt><strong><span style="margin:0;padding:0;">&lt;pack</span></strong> <span style="margin:0;padding:0;">name</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"MyApp - Core"</span> <span style="margin:0;padding:0;">required</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"yes"</span><strong><span style="margin:0;padding:0;">&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;description&gt;&lt;/description&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;fileset</span></strong> <span style="margin:0;padding:0;">dir</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"dist"</span> <span style="margin:0;padding:0;">targetdir</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"$INSTALL_PATH"</span><strong><span style="margin:0;padding:0;">&gt;</span></strong>
    <strong><span style="margin:0;padding:0;">&lt;include</span></strong> <span style="margin:0;padding:0;">name</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"mkshortcut.vbs"</span><strong><span style="margin:0;padding:0;">/&gt;</span></strong>
    <strong><span style="margin:0;padding:0;">&lt;include</span></strong> <span style="margin:0;padding:0;">name</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"MyApp.jar"</span><strong><span style="margin:0;padding:0;">/&gt;</span></strong>
    <strong><span style="margin:0;padding:0;">&lt;include</span></strong> <span style="margin:0;padding:0;">name</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"MyApp.ico"</span><strong><span style="margin:0;padding:0;">/&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;/fileset&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;parsable</span></strong> <span style="margin:0;padding:0;">targetfile</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"$INSTALL_PATH/mkshortcut.vbs"</span><strong><span style="margin:0;padding:0;">/&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;executable</span></strong> <span style="margin:0;padding:0;">os</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"windows"</span> <span style="margin:0;padding:0;">keep</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"true"</span> <span style="margin:0;padding:0;">failure</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"warn"</span> <span style="margin:0;padding:0;">stage</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"postinstall"</span>
    <span style="margin:0;padding:0;">targetfile</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"wscript.exe"</span><strong><span style="margin:0;padding:0;">&gt;</span></strong>
    <strong><span style="margin:0;padding:0;">&lt;args&gt;</span></strong>
      <strong><span style="margin:0;padding:0;">&lt;arg</span></strong> <span style="margin:0;padding:0;">value</span><span style="margin:0;padding:0;">=</span><span style="margin:0;padding:0;">"$INSTALL_PATH/mkshortcut.vbs"</span><strong><span style="margin:0;padding:0;">/&gt;</span></strong>
    <strong><span style="margin:0;padding:0;">&lt;/args&gt;</span></strong>
  <strong><span style="margin:0;padding:0;">&lt;/executable&gt;</span></strong>
<strong><span style="margin:0;padding:0;">&lt;/pack&gt;</span></strong></tt></pre>
<p></span><br />
This would create a shortcut on the desktop which would be a shortcut to a jar file, most probably<br />
you shall create a shortcut to a .bat file to run the application.</pre>
<p></span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=39&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/10/19/creating-desktop-shortcut-windows-with-izpack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Typical IT Project</title>
		<link>http://khaledkhan.wordpress.com/2008/10/07/typical-it-project/</link>
		<comments>http://khaledkhan.wordpress.com/2008/10/07/typical-it-project/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 11:02:59 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[System Design]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=27</guid>
		<description><![CDATA[       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=27&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div class="wp-caption alignnone" style="width: 810px"><a href="http://777-team.org/tmp/project.jpg"><img title="Typical IT Project" src="http://777-team.org/tmp/project.jpg" alt="Typical IT Project" width="800" height="600" /></a><p class="wp-caption-text">Typical IT Project</p></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=27&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/10/07/typical-it-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>

		<media:content url="http://777-team.org/tmp/project.jpg" medium="image">
			<media:title type="html">Typical IT Project</media:title>
		</media:content>
	</item>
		<item>
		<title>Development Good Practices</title>
		<link>http://khaledkhan.wordpress.com/2008/10/07/development-good-practices/</link>
		<comments>http://khaledkhan.wordpress.com/2008/10/07/development-good-practices/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 10:57:49 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[System Design]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=22</guid>
		<description><![CDATA[There are some general practices one may follow while writing software
1. Start with the end in mind.
In General it is also a good habit, but while development a developer must always know what is required.
2. resume oriented development takes you no where
3. Use a single point of control, like debuging, logging, application controllers, view generators [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=22&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are some general practices one may follow while writing software</p>
<p>1. Start with the end in mind.</p>
<p>In General it is also a good habit, but while development a developer must always know what is required.</p>
<p>2. resume oriented development takes you no where</p>
<p>3. Use a single point of control, like debuging, logging, application controllers, view generators etc, Its always easy to manage one piece of crap than managing a bundle.</p>
<p>4. code, code, code shall not be your strategy. do more test driven development.</p>
<p>5. Involve everyone who will be influenced by the end result from the beginning.</p>
<p>6. Interface does makes allot of diffrence, and sometimes it the only diffrence.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=22&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/10/07/development-good-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Sequence ID Generator (Derby)</title>
		<link>http://khaledkhan.wordpress.com/2008/10/07/sequence-id-generator-derby/</link>
		<comments>http://khaledkhan.wordpress.com/2008/10/07/sequence-id-generator-derby/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 10:48:11 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=18</guid>
		<description><![CDATA[I often face problem with databases where there are no sequences in the database, obvious solution is to use a table to keep the counts of the sequences by selecting the current sequence number and than updating the count. Hibernate also provides a solution which is as follows
For Example I will use a MessageStatus class [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=18&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I often face problem with databases where there are no sequences in the database, obvious solution is to use a table to keep the counts of the sequences by selecting the current sequence number and than updating the count. Hibernate also provides a solution which is as follows</p>
<p>For Example I will use a MessageStatus class which contains id which need to be incremented with every insert</p>
<p>import java.util.Date;</p>
<p>import javax.persistence.Column;<br />
import javax.persistence.Entity;<br />
import javax.persistence.GeneratedValue;<br />
import javax.persistence.GenerationType;<br />
import javax.persistence.Id;<br />
import javax.persistence.SequenceGenerator;<br />
import javax.persistence.Table;<br />
import org.hibernate.annotations.Parameter;<br />
import org.hibernate.annotations.Type;</p>
<p>@Entity<br />
@Table(name=&#8221;MESSAGESTATUS&#8221;,schema=&#8221;INTEGRATION&#8221;)<br />
public class MessageStatus {<br />
private long id;<br />
public MessageStatus()<br />
{<br />
super();<br />
}</p>
<p>@Column(name=&#8221;ID&#8221;)<br />
@GeneratedValue(generator=&#8221;status&#8221;)<br />
@GenericGenerator(name=&#8221;status&#8221;,strategy=&#8221;MessageStatusIdentifierGenerator&#8221;,<br />
parameters={@Parameter(name=&#8221;name&#8221;,value=&#8221;MESSAGESTATUSID_GEN&#8221;),@Parameter(name=&#8221;table&#8221;,value=&#8221;SEQUENCE&#8221;),<br />
@Parameter(name=&#8221;schema&#8221;,value=&#8221;MOIINTEGRATION&#8221;),@Parameter(name=&#8221;pkColumnName&#8221;,value=&#8221;SEQ_NAME&#8221;),<br />
@Parameter(name=&#8221;valueColumnName&#8221;,value=&#8221;SEQ_COUNT&#8221;),@Parameter(name=&#8221;pkColumnValue&#8221;,value=&#8221;SEQ_MESSAGE&#8221;),<br />
@Parameter(name=&#8221;initialValue&#8221;,value=&#8221;1&#8243;),@Parameter(name=&#8221;allocationSize&#8221;,value=&#8221;1&#8243;)})<br />
@Column(name=&#8221;ID&#8221;)<br />
public long getId()<br />
{<br />
return id;<br />
}</p>
<p>public void setId(long id)<br />
{<br />
this.id = id;<br />
}</p>
<p>}<br />
import java.io.Serializable;<br />
import java.sql.Connection;<br />
import java.sql.PreparedStatement;<br />
import java.sql.ResultSet;<br />
import java.sql.SQLException;<br />
import java.sql.Statement;<br />
import java.util.Properties;</p>
<p>import org.hibernate.HibernateException;<br />
import org.hibernate.MappingException;<br />
import org.hibernate.dialect.Dialect;<br />
import org.hibernate.engine.SessionImplementor;<br />
import org.hibernate.id.Configurable;<br />
import org.hibernate.id.IdentifierGenerator;<br />
import org.hibernate.id.IdentifierGeneratorFactory;<br />
import org.hibernate.type.Type;</p>
<p>import com.datel.fawriintegration.common.messaging.model.message.api.MessageStatus;</p>
<p>public class MessageStatusIdentifierGenerator implements IdentifierGenerator, Configurable<br />
{</p>
<p>private IdentifierGenerator identifierGenerator;</p>
<p>private Type identifierType;</p>
<p>private String tableName;<br />
private String sequenceName;</p>
<p>private String schema;</p>
<p>private String pkColumnName;</p>
<p>private String valueColumnName;</p>
<p>private String pkColumnValue;</p>
<p>private int initialValue;</p>
<p>private int allocationSize;</p>
<p>private String selectString;</p>
<p>private String updateString;</p>
<p>public Serializable generate(SessionImplementor session, Object entity) throws HibernateException<br />
{<br />
Connection conn = null;<br />
PreparedStatement ps = null;<br />
ResultSet rs = null;<br />
Statement st = null;<br />
if (entity instanceof MessageStatus)<br />
{</p>
<p>MessageStatus es = (MessageStatus) entity;<br />
if (es.getId() == 0)<br />
{<br />
if (identifierGenerator != null)<br />
{<br />
return identifierGenerator.generate(session, entity);<br />
} else<br />
{<br />
conn = session.connection();<br />
try<br />
{<br />
boolean autoCommit = conn.getAutoCommit();<br />
conn.setAutoCommit(true);<br />
ps = conn.prepareStatement(selectString);<br />
rs = ps.executeQuery();<br />
Long sequenceNumber = null;<br />
if (rs.next())<br />
{<br />
sequenceNumber = rs.getLong(valueColumnName);<br />
Long nextNumber = sequenceNumber + allocationSize;<br />
String tempUpdateString = updateString + nextNumber + &#8221; where &#8221; + pkColumnName + &#8221; = &#8216;&#8221;<br />
+ pkColumnValue + &#8220;&#8216;&#8221;;<br />
st = conn.createStatement();<br />
st.executeUpdate(tempUpdateString);<br />
// session.executeUpdate(updateString, null);<br />
} else<br />
{<br />
throw new HibernateException(&#8220;The database returned no generated identity value&#8221;);<br />
}<br />
conn.setAutoCommit(autoCommit);<br />
st.close();<br />
rs.close();<br />
ps.close();<br />
conn.close();<br />
return sequenceNumber;<br />
} catch (SQLException e)<br />
{<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
try<br />
{<br />
if (st != null)<br />
{<br />
st.close();<br />
}<br />
if (rs != null)<br />
{<br />
rs.close();<br />
}<br />
if (ps != null)<br />
{<br />
ps.close();<br />
}<br />
if (conn != null)<br />
{<br />
conn.close();<br />
}<br />
} catch (Exception ex)<br />
{<br />
ex.printStackTrace();<br />
}</p>
<p>}<br />
}<br />
} else<br />
{<br />
return es.getId();<br />
}<br />
}<br />
return null;<br />
}</p>
<p>public void configure(Type type, Properties params, Dialect d) throws MappingException<br />
{<br />
this.identifierType = type;<br />
if (d.supportsSequences())<br />
{<br />
sequenceName = params.getProperty(&#8220;sequencename&#8221;);<br />
identifierGenerator = IdentifierGeneratorFactory.create(&#8220;sequence&#8221;, type, params, d);<br />
} else<br />
{<br />
tableName = params.getProperty(&#8220;table&#8221;);<br />
schema = params.getProperty(&#8220;schema&#8221;);<br />
pkColumnName = params.getProperty(&#8220;pkColumnName&#8221;);<br />
valueColumnName = params.getProperty(&#8220;valueColumnName&#8221;);<br />
pkColumnValue = params.getProperty(&#8220;pkColumnValue&#8221;);<br />
initialValue = Integer.parseInt(params.getProperty(&#8220;initialValue&#8221;));<br />
allocationSize = Integer.parseInt(params.getProperty(&#8220;allocationSize&#8221;));<br />
selectString = &#8220;SELECT &#8221; + valueColumnName + &#8221; from &#8221; + schema + &#8220;.&#8221; + tableName + &#8221; where &#8221; + pkColumnName<br />
+ &#8221; = &#8216;&#8221; + pkColumnValue + &#8220;&#8216;&#8221;;<br />
selectString = d.transformSelectString(selectString);<br />
updateString = &#8220;UPDATE &#8221; + schema + &#8220;.&#8221; + tableName + &#8221; SET &#8221; + valueColumnName + &#8221; = &#8220;;<br />
}<br />
}<br />
}<br />
Sorry for providing no comments, I guess the codes a self explanatory <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=18&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/10/07/sequence-id-generator-derby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make task monitor work</title>
		<link>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/</link>
		<comments>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 10:26:08 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=10</guid>
		<description><![CDATA[This is indeed somewhat tricky to find it out&#8230; I have understood at 
least some basics, and will try to explain it.
These animations are controlled by a background task. Background tasks 
should be used when time consuming tasks are made, which should not 
&#8220;freeze&#8221; the apllication. So a background task runs in the background, 
and is firing messages every [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=10&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is indeed somewhat tricky to find it out&#8230; I have understood at <br />
least some basics, and will try to explain it.</p>
<p>These animations are controlled by a background task. Background tasks <br />
should be used when time consuming tasks are made, which should not <br />
&#8220;freeze&#8221; the apllication. So a background task runs in the background, <br />
and is firing messages every now and then, while the main programming <br />
is still running and reacting. You can observe the task messages via a <br />
taskmonitor and than e.g. make changes to GUI components, like in this <br />
case the animated label (circling icon).</p>
<p>First of all, here is how a task is started. One way to do this is via <br />
actions (right click on a component and choose &#8220;set action&#8221;). Then you <br />
could start a task like this:</p>
<p>@Action<br />
public Task myTask() {<br />
return new <br />
ThisIsMyTask <br />
(org <br />
.jdesktop.application.Application.getInstance(yourappsnamehere.class));<br />
}</p>
<p>The above sample shows how to start a task via an action, e.g. <br />
pressing a button. But you can also start a task manually, out of your <br />
application, without user interaction. I recently asked this question <br />
in this list and got following perfectly working answer:</p>
<p>Task mT = myTask();<br />
ApplicationContext appC = Application.getInstance().getContext();<br />
TaskMonitor tM = appC.getTaskMonitor();<br />
TaskService tS = appC.getTaskService();<br />
tS.execute(mT);<br />
tM.setForegroundTask(mT);</p>
<p>This starts the task manually, by referring to the method shown in the <br />
first sample above. So, you have to have this method anyway, as far as <br />
I understood, but not necessarily declared as &#8220;action&#8221;.</p>
<p>Now, the Task class itself looks like the following:</p>
<p>private class ThisIsMyTask extends <br />
org.jdesktop.application.Task&lt;Object, Void&gt; {<br />
ThisIsMyTask(org.jdesktop.application.Application app) {<br />
super(app);</p>
<p>}</p>
<p>Furthermore, this class has some overidden methods. The most important <br />
one ist &#8220;doInBackground()&#8221;. This method contains the time consuming <br />
source code, which runs in the background, while the &#8220;main <br />
application&#8221; can still do other things (even waiting, e.g.).</p>
<p>@Override protected Object doInBackground() throws <br />
IOException {<br />
// your heavy code here<br />
return null;<br />
}</p>
<p>Two more useful methods are &#8220;succeeded&#8221; and &#8220;finished&#8221;. succeeded is <br />
called, when the task has been successfully completed. Finished is <br />
called afterwards &#8211; but it is also called, when the task is &#8220;finished&#8221; <br />
by a cancel action for instance.</p>
<p>@Override protected void succeeded(Object result) {<br />
// what should happen if task was successfully completed?<br />
// insert here<br />
}</p>
<p>@Override<br />
protected void finished()<br />
{<br />
// when the task is finished, enter your code here. this method is <br />
even called, when<br />
// a task was cancelled &#8211; if I understood right<br />
super.finished();<br />
}</p>
<p>Now, these are the tasks basics. Now to the animated cycling icon.</p>
<p>First of all, you have to store the single icons from the animations <br />
in an array. this is what you find in the samples from NetBeans:</p>
<p>// initiate animated busy-icons, which are animated when the <br />
thread is running<br />
int busyAnimationRate = <br />
resourceMap.getInteger(&#8220;StatusBar.busyAnimationRate&#8221;);<br />
for (int i = 0; i &lt; busyIcons.length; i++) {<br />
busyIcons[i] = resourceMap.getIcon(&#8220;StatusBar.busyIcons[" <br />
+ i + "]&#8220;);<br />
}</p>
<p>Than you have to create a timer, which will start the animation once <br />
this timer is started. By creating this timer, it is not automatically <br />
running, just initiated&#8230;</p>
<p>// and create a busy-icon-timer<br />
busyIconTimer = new Timer(busyAnimationRate, new <br />
ActionListener() {<br />
@Override<br />
public void actionPerformed(ActionEvent e) {<br />
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;<br />
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);<br />
}<br />
});</p>
<p>The following lines just set the icon to the statusAnimationLabel (the <br />
one which show the cycling icon respectively a light grey one if <br />
nothing happens)</p>
<p>// initiate the idle icon and make it visible<br />
idleIcon = resourceMap.getIcon(&#8220;StatusBar.idleIcon&#8221;);<br />
statusAnimationLabel.setIcon(idleIcon);<br />
progressBar.setVisible(false);</p>
<p>Now you have to create a task monitor, which observes the task. If I <br />
understood correctly, it is observing the current foreground task, so <br />
it might get in conflict with several background tasks at the same <br />
time &#8211; BUT I&#8217;M NOT SURE WITH THIS!</p>
<p>// connecting action tasks to status bar via TaskMonitor<br />
TaskMonitor taskMonitor = new <br />
TaskMonitor <br />
(org <br />
.jdesktop <br />
.application.Application.getInstance(yourapp.class).getContext());</p>
<p>taskMonitor.addPropertyChangeListener(new <br />
java.beans.PropertyChangeListener() {<br />
@Override<br />
public void propertyChange(java.beans.PropertyChangeEvent <br />
evt) {<br />
String propertyName = evt.getPropertyName();</p>
<p>And now come the events or messages which are fired by the background <br />
tasks. Here you decide, *what* should be done in such a case.</p>
<p>If I understood correctly, the &#8220;start&#8221; message is automatically fired <br />
by the task. So everything here will be done automatically when the <br />
background thread starts. In this case, the timer of the cycling icon <br />
is started, i.e. the icon is animated, and the progressbar is made <br />
visible (but not animated! there is no timer for the progressbar, it <br />
is just made visible; we come back to this later)</p>
<p>// when a background thread starts, start the busy <br />
icon animation<br />
if (&#8220;started&#8221;.equals(propertyName)) {<br />
if (!busyIconTimer.isRunning()) {<br />
statusAnimationLabel.setIcon(busyIcons[0]);<br />
busyIconIndex = 0;<br />
busyIconTimer.start();<br />
}<br />
// and make the progressbar visible<br />
progressBar.setVisible(true);<br />
progressBar.setIndeterminate(true);</p>
<p>On the opposite, when the task is done, the &#8220;done&#8221; message is <br />
automatically fired. Accordingly, here the cycling icon timer is <br />
stopped and the progressbar is hidden</p>
<p>// when the thread finished working, stop animation, <br />
set idle icon<br />
// and hide the progress bar<br />
} else if (&#8220;done&#8221;.equals(propertyName)) {<br />
busyIconTimer.stop();<br />
statusAnimationLabel.setIcon(idleIcon);<br />
progressBar.setVisible(false);<br />
progressBar.setValue(0);</p>
<p>Now here comes a message which can be fired by your application, that <br />
means you can let this event happen. for instance, you can tell the <br />
task monitor out of your background task(!) that it is proceeding, <br />
i.e. firing a &#8220;progress&#8221; message. when the task monitor gets this <br />
message from your background task, you can insert your code here what <br />
should be done. typically, the progressbar is animated.</p>
<p>// if a progress was indicated during the thread <br />
using the<br />
// &#8220;setProgress(value,min,max)&#8221; method, we can change <br />
the state<br />
// of the progress bar here.<br />
} else if (&#8220;progress&#8221;.equals(propertyName)) {<br />
int value = (Integer)(evt.getNewValue());<br />
progressBar.setVisible(true);<br />
progressBar.setIndeterminate(false);<br />
progressBar.setValue(value);<br />
}<br />
}<br />
});<br />
}<br />
}</p>
<p>As you see, we have to important components here: statusAnimationLabel <br />
and progressBar. I don&#8217;t use the statusMessageLabel, so it&#8217;s missing <br />
here.</p>
<p>Now, once the background task is started (see very above), the icon is <br />
automatically animated, because we have started a timer which is <br />
responsible for the animation. but: the progressbar is only &#8220;animated&#8221; <br />
when we fire a progress event, which does not occur automatically - <br />
unlike &#8220;start&#8221; and &#8220;done&#8221; events/messages.</p>
<p>The &#8220;progress&#8221; event/message for the taskmonitor is simply fired when <br />
invoking the &#8220;setProgress&#8221; method!</p>
<p>This is what you could put in your doInBackground-Method in your task. <br />
Here&#8217;s an example for loading a file and animating the progressbar <br />
which show the process of the amount of loaded bytes:</p>
<p>// length of file<br />
final long l = filepath.length();<br />
// length of file in kilobytes<br />
final long kbl = l / 1024;<br />
// counter for progbar<br />
long counter = 0;</p>
<p>fr = new FileReader(filepath);<br />
buffer = new StringBuffer(&#8220;&#8221;);</p>
<p>for (int c; (c=fr.read()) != -1;) {<br />
// append the bytes to the buffer<br />
buffer.append((char)c);<br />
// increase the counter for the progress <br />
bar<br />
counter++;<br />
// this method fires the &#8220;progress&#8221; event/message for the task <br />
monitor<br />
setProgress(counter/1024,0,kbl);</p>
<p>that&#8217;s it. all your time consuming stuff should be put into the <br />
doInBackground method. If you like, you can animate a progress bar, if <br />
you don&#8217;t do this, you just have the cycling icon.</p>
<p>Now, since the initialization of the animated icons and progressbar <br />
needs known GUI components, usually all the init stuff is included in <br />
that class that contains also the components (statusMessageLabel, <br />
progressBar). But since I&#8217;m writing a desktop application which uses <br />
several forms with background tasks, I simply created an &#8220;task monitor <br />
initialisation class&#8221;. Whenever I have a form which needs background <br />
tasks, I simply pass the JLabel (statusAnimationLabel) and <br />
JProgressBar (progressbar) as parameters to the constructor:</p>
<p>CInitStatusBar isb = new <br />
CInitStatusBar( statusAnimationLabel, progressBar );</p>
<p>Now I only need to write my Task Class and start the task via an <br />
action or manually. But I don&#8217;t need to have the init stuff also <br />
included.</p>
<p>Here&#8217;s the complete class with the &#8220;externalised&#8221; taskmonitor-init:</p>
<p>public class CInitStatusBar {</p>
<p>private final Timer busyIconTimer;<br />
private final Icon idleIcon;<br />
private final Icon[] busyIcons = new Icon[15];<br />
private int busyIconIndex = 0;</p>
<p>org.jdesktop.application.ResourceMap resourceMap = <br />
org <br />
.jdesktop <br />
.application <br />
.Application <br />
.getInstance <br />
(zettelkasten <br />
.ZettelkastenApp <br />
.class).getContext().getResourceMap(ZettelkastenView.class);</p>
<p>/**<br />
* Initiates the status bar for background tasks.<br />
* Catches messages from the doInBackground task<br />
* and changes the progressbar state, the busy icon animation<br />
* and &#8211; if necessary &#8211; the status message.<br />
*/<br />
CInitStatusBar( final javax.swing.JLabel statusAnimationLabel,<br />
final javax.swing.JProgressBar progressBar ) {<br />
/**<br />
* This is pre-defined code taken from the NetBeans IDE<br />
* Initiates some basic things for background tasks, like<br />
* associating a statusbar and busy-icon to a background thread<br />
*/</p>
<p>// initiate animated busy-icons, which are animated when the <br />
thread is running<br />
int busyAnimationRate = <br />
resourceMap.getInteger(&#8220;StatusBar.busyAnimationRate&#8221;);<br />
for (int i = 0; i &lt; busyIcons.length; i++) {<br />
busyIcons[i] = resourceMap.getIcon(&#8220;StatusBar.busyIcons[" <br />
+ i + "]&#8220;);<br />
}<br />
// and create a busy-icon-timer<br />
busyIconTimer = new Timer(busyAnimationRate, new <br />
ActionListener() {<br />
@Override<br />
public void actionPerformed(ActionEvent e) {<br />
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;<br />
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);<br />
}<br />
});</p>
<p>// initiate the idle icon and make it visible<br />
idleIcon = resourceMap.getIcon(&#8220;StatusBar.idleIcon&#8221;);<br />
statusAnimationLabel.setIcon(idleIcon);<br />
progressBar.setVisible(false);</p>
<p>// connecting action tasks to status bar via TaskMonitor<br />
TaskMonitor taskMonitor = new <br />
TaskMonitor <br />
(org <br />
.jdesktop <br />
.application <br />
.Application <br />
.getInstance(zettelkasten.ZettelkastenApp.class).getContext());</p>
<p>taskMonitor.addPropertyChangeListener(new <br />
java.beans.PropertyChangeListener() {<br />
@Override<br />
public void propertyChange(java.beans.PropertyChangeEvent <br />
evt) {<br />
String propertyName = evt.getPropertyName();<br />
// when a background thread starts, start the busy <br />
icon animation<br />
if (&#8220;started&#8221;.equals(propertyName)) {<br />
if (!busyIconTimer.isRunning()) {<br />
statusAnimationLabel.setIcon(busyIcons[0]);<br />
busyIconIndex = 0;<br />
busyIconTimer.start();<br />
}<br />
// and make the progressbar visible<br />
progressBar.setVisible(true);<br />
progressBar.setIndeterminate(true);<br />
// when the thread finished working, stop animation, <br />
set idle icon<br />
// and hide the progress bar<br />
} else if (&#8220;done&#8221;.equals(propertyName)) {<br />
busyIconTimer.stop();<br />
statusAnimationLabel.setIcon(idleIcon);<br />
progressBar.setVisible(false);<br />
progressBar.setValue(0);<br />
// if a progress was indicated during the thread <br />
using the<br />
// &#8220;setProgress(value,min,max)&#8221; method, we can change <br />
the state<br />
// of the progress bar here.<br />
} else if (&#8220;progress&#8221;.equals(propertyName)) {<br />
int value = (Integer)(evt.getNewValue());<br />
progressBar.setVisible(true);<br />
progressBar.setIndeterminate(false);<br />
progressBar.setValue(value);<br />
}<br />
}<br />
});<br />
}<br />
}</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=10&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Toys</title>
		<link>http://khaledkhan.wordpress.com/2008/07/14/toys/</link>
		<comments>http://khaledkhan.wordpress.com/2008/07/14/toys/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 07:15:43 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Toys]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=7</guid>
		<description><![CDATA[we all love toys when we are young, well guess what we still love toys when we grow up, its just that the &#8220;form&#8221; of toys changes like FaceBook, twitter, wordpress or wiki or digg or you name it. But as far as I remember there was one problem with toys and that&#8217;s called &#8220;Getting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=7&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>we all love toys when we are young, well guess what we still love toys when we grow up, its just that the &#8220;form&#8221; of toys changes like FaceBook, twitter, wordpress or wiki or digg or you name it. But as far as I remember there was one problem with toys and that&#8217;s called &#8220;Getting Bored&#8221;. sure all these sites and technologies are great and they make us connected to our friends and family, but what I think is that we will get bored by them sooner or later. That&#8217;s where innovation comes into play, keep giving the customer what they want, whenever they want and where ever they want it <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/khaledkhan.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/khaledkhan.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=7&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/07/14/toys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>About the theme!!</title>
		<link>http://khaledkhan.wordpress.com/2008/06/15/about-the-theme/</link>
		<comments>http://khaledkhan.wordpress.com/2008/06/15/about-the-theme/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 07:46:36 +0000</pubDate>
		<dc:creator>khaledkhan</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[DI]]></category>
		<category><![CDATA[Spring J2EE]]></category>

		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=3</guid>
		<description><![CDATA[The theme which I have used for my blogs is called “Almost Spring” which by the way reflect my appreciation for Spring Framework (sorry, I couldn’t find a theme named almost Seam). Spring really rocks when it comes to AOP and DI. But I became its fan when we (Imran Sarwar) plugged Spring resources in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=3&subd=khaledkhan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal">The theme which I have used for my blogs is called “Almost Spring” which by the way reflect my appreciation for Spring Framework (sorry, I couldn’t find a theme named almost Seam). Spring really rocks when it comes to AOP and DI. But I became its fan when we (Imran Sarwar) plugged Spring resources in our desktop applications. I really fell in love with the “Plugability” of Spring based projects. I now understand the real difference between EJB and Springs.</p>
<p class="MsoNormal"><span> </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/khaledkhan.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/khaledkhan.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khaledkhan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khaledkhan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khaledkhan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khaledkhan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khaledkhan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khaledkhan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khaledkhan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khaledkhan.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khaledkhan.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khaledkhan.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khaledkhan.wordpress.com&blog=2414603&post=3&subd=khaledkhan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://khaledkhan.wordpress.com/2008/06/15/about-the-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd216ad5b76fbc42f053d6c6a1f849b2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">khaledkhan</media:title>
		</media:content>
	</item>
	</channel>
</rss>