<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Days</title>
	<atom:link href="http://sudanlive.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sudanlive.wordpress.com</link>
	<description>Streets crossed in my life</description>
	<lastBuildDate>Wed, 23 Mar 2011 05:16:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sudanlive.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>My Days</title>
		<link>http://sudanlive.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sudanlive.wordpress.com/osd.xml" title="My Days" />
	<atom:link rel='hub' href='http://sudanlive.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Data handler for converting Http/post to BO in Websphere Integration Developer</title>
		<link>http://sudanlive.wordpress.com/2010/12/15/data-handler-for-converting-httppost-to-bo-in-websphere-integration-developer-2/</link>
		<comments>http://sudanlive.wordpress.com/2010/12/15/data-handler-for-converting-httppost-to-bo-in-websphere-integration-developer-2/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 12:05:10 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/2010/12/15/data-handler-for-converting-httppost-to-bo-in-websphere-integration-developer-2/</guid>
		<description><![CDATA[In this data handler we need to convert a Http/post parameters into a BO. This data handler can be used at any place wherever you need the Data Transformation Configuration. 1. Create a class say HttpPostToBoDataHandler implementing interface DataHandler. 2. When you implement this interface, by default you will get all the methods that needs [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=84&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this data handler we need to convert a Http/post parameters into a BO. This data handler can be used at any place wherever you need the Data Transformation Configuration.<br />
1.	Create a class say HttpPostToBoDataHandler implementing interface DataHandler.<br />
2.	When you implement this interface, by default you will get all the methods that needs to be implemented.<br />
3.	The interested method names we need look into are<br />
transform<br />
transformInto<br />
setBindingContext<br />
4.	transform and transformInto methods would be called depending on the input and output data formats<br />
5.	setBindingContext method sets the initial properties for the transformation</p>
<p>HttpPostToBoDataHandler.java</p>
<p>/*<br />
* Author: Sudarsan Manickam<br />
* Description: This Data handler is for converting a HTTP/POST parameter message into a BO message and send it to the SCA component<br />
* Date: 20th September 2010<br />
*<br />
*/</p>
<p>import java.io.ByteArrayOutputStream;<br />
import java.io.IOException;<br />
import java.io.InputStream;<br />
import java.io.Reader;<br />
import java.io.UnsupportedEncodingException;<br />
import java.net.URLDecoder;<br />
import java.util.List;<br />
import java.util.Map;</p>
<p>import javax.xml.namespace.QName;</p>
<p>import com.ibm.websphere.bo.BOFactory;<br />
import com.ibm.websphere.sca.ServiceManager;<br />
import com.ibm.ws.bo.bomodel.util.BOPropertyImpl;</p>
<p>import commonj.connector.runtime.BindingContext;<br />
import commonj.connector.runtime.DataHandler;<br />
import commonj.connector.runtime.DataHandlerException;<br />
import commonj.sdo.DataObject;</p>
<p>@SuppressWarnings(&#8220;serial&#8221;)<br />
public class HttpPostToBoDataHandler implements DataHandler{ private ServiceManager serviceManager;<br />
private BOFactory boFactory;<br />
private String encoding;<br />
private String exclusionList;<br />
private boolean caseSensitive;<br />
private String targetNamespace;<br />
private String localName;<br />
private char listSeparator;</p>
<p>public HttpPostToBoDataHandler()<br />
{<br />
serviceManager = ServiceManager.INSTANCE;<br />
boFactory = (BOFactory)serviceManager.locateService<br />
(&#8220;com/ibm/websphere/bo/BOFactory&#8221;);</p>
<p>encoding = &#8220;UTF-8&#8243;;<br />
}</p>
<p>public Object transform(Object source, Class target, Object options) throws DataHandlerException<br />
{<br />
//This transforms our source message into the target message System.out.println(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;transform&#8221;, &#8220;Start of transformation&#8221;);</p>
<p>if ((source == null) || (target == null)){<br />
return null;<br />
}<br />
// native data format to DataObject transformations<br />
if (target == String.class) {<br />
if (source instanceof InputStream)<br />
{<br />
System.out.println(&#8220;HttpPostToBoDataHandler&#8221;,<br />
&#8220;transform&#8221;, &#8220;source and target is String and InputStream respectively&#8221;); // Transform InputStream to DataObject<br />
InputStream inputstream = (InputStream)source;</p>
<p>byte[] bytes = readBytes(inputstream);<br />
try<br />
{<br />
if (bytes.length &gt; 0)<br />
{<br />
System.out.println<br />
(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;transform&#8221;, &#8220;Parsing input parameters&#8221;); String parms = new String(bytes, 0,<br />
bytes.length, encoding);<br />
System.out.println<br />
(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;transform&#8221;, &#8220;Parameters: &#8221; + parms);</p>
<p>return createBusinessObject(parms);<br />
}<br />
}<br />
catch (UnsupportedEncodingException e) {<br />
System.out.println(&#8220;HttpPostToBoDataHandler &#8211; transform&#8221;, e);</p>
<p>}<br />
}<br />
else if (source instanceof Reader) {<br />
// Transform Reader to DataObject<br />
// we dont have to implement this for our<br />
requirement<br />
}<br />
else {<br />
// Transform Object to DataObject<br />
// we dont have to implement this for our<br />
requirement<br />
}<br />
}</p>
<p>if (target == DataObject.class) {<br />
if (source instanceof InputStream)<br />
{<br />
System.out.println(&#8220;HttpPostToBoDataHandler&#8221;,<br />
&#8220;transform&#8221;, &#8220;source and target is InputStream and DataObject respectively&#8221;);<br />
// Transform InputStream to DataObject<br />
InputStream inputstream = (InputStream)source;</p>
<p>byte[] bytes = readBytes(inputstream);<br />
try<br />
{<br />
if (bytes.length &gt; 0)<br />
{<br />
System.out.println<br />
(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;transform&#8221;, &#8220;Parsing input parameters&#8221;); String parms = new String(bytes, 0,<br />
bytes.length, encoding);<br />
System.out.println<br />
(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;transform&#8221;, &#8220;Parameters: &#8221; + parms);</p>
<p>return createBusinessObject(parms);<br />
}<br />
}<br />
catch (UnsupportedEncodingException e) {<br />
System.out.println(&#8220;HttpPostToBoDataHandler &#8211; transform&#8221;, e);<br />
}<br />
}<br />
else if (source instanceof Reader) {<br />
// Transform Reader to DataObject<br />
// we dont need to implement this for our<br />
requirement<br />
}<br />
else {<br />
// Transform Object to DataObject<br />
// we dont need to implement this for our<br />
requirement<br />
}<br />
}</p>
<p>// DataObject to native data format transformations if (source instanceof DataObject) {<br />
if (target == InputStream.class) {<br />
System.out.println(&#8220;HttpPostToBoDataHandler&#8221;,<br />
&#8220;transform&#8221;, &#8220;source and target is DataObject and InputStream respectively&#8221;);<br />
// Transform DataObject to InputStream<br />
// we dont need to implement this for our<br />
requirement<br />
}<br />
else {<br />
// Transform DataObject to Object<br />
// we dont need to implement this for our<br />
requirement<br />
}<br />
}<br />
throw new DataHandlerException(&#8220;Transformation not<br />
supported&#8221;);<br />
}</p>
<p>private DataObject createBusinessObject(String s) throws<br />
DataHandlerException<br />
{<br />
System.out.println(&#8220;HttpPostToBoDataHandler&#8221;, &#8220;createBusinessObject&#8221;, &#8220;Creating a business object from string &#8220;+targetNamespace+&#8221; localName &#8220;+localName);<br />
DataObject dataobject = boFactory.create(targetNamespace, localName); if(dataobject == null)<br />
dataobject = boFactory.createByElement(targetNamespace, localName);</p>
<p>//Populating the business object with parameters from the string //Split the incoming parameters into individual tokens<br />
String[] parms = s.trim().split(&#8220;&amp;&#8221;);</p>
<p>for (int i=0; i &lt; parms.length; i ++)<br />
{<br />
//Find next parameter name<br />
String parmName = parms[i].substring(0, parms[i].indexOf(&#8220;=&#8221;)); if (parms[i].indexOf(parmName) != -1)<br />
{<br />
String updatedName = includeParameter(dataobject,<br />
parmName);<br />
if (updatedName != null)<br />
{<br />
try<br />
{<br />
//If parameter needs to be included then<br />
String value = parms[i].substring(parms<br />
[i].indexOf(&#8220;=&#8221;) + 1);<br />
value = URLDecoder.decode(value, encoding);<br />
dataobject.setString(updatedName, value);<br />
} catch (UnsupportedEncodingException e) {<br />
System.out.println<br />
(&#8220;HttpPostToBoDataHandler &#8211; transform&#8221;, e);<br />
}</p>
<p>}<br />
}<br />
}<br />
return dataobject;<br />
}</p>
<p>private String includeParameter(DataObject object , String name) {<br />
//Find if we need to exclude some of the strings (in the given example we need to exclude parameters with the names &#8216;operation&#8217; and &#8216;user&#8217;)<br />
String[] excludedParms = exclusionList.split(String.valueOf (listSeparator));</p>
<p>//Check if the parameter is in the exclusion list<br />
boolean exclude = false;<br />
for (int j=0; j &lt; excludedParms.length; j++)<br />
{<br />
if ((caseSensitive &amp;&amp; name.equals(excludedParms[j])) ||<br />
(!caseSensitive &amp;&amp; name.equalsIgnoreCase<br />
(excludedParms[j])))<br />
{<br />
return null;<br />
}<br />
}</p>
<p>//If the parameter does not need to get excluded then return the name to be set on the BO<br />
if (caseSensitive &amp;&amp; object.getInstanceProperty(name) !=<br />
null)<br />
return name;<br />
else if (!caseSensitive)<br />
{<br />
List props = object.getInstanceProperties();<br />
for (int n=0; n</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=84&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/12/15/data-handler-for-converting-httppost-to-bo-in-websphere-integration-developer-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>PeopleSoft stuffs</title>
		<link>http://sudanlive.wordpress.com/2010/07/07/peoplesoft-stuffs/</link>
		<comments>http://sudanlive.wordpress.com/2010/07/07/peoplesoft-stuffs/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 11:19:33 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=70</guid>
		<description><![CDATA[when we try to invoke PeS CI from a plain Java, sometimes we see an error like psft.pt8.joa.JOAException: Distributed Object Manager: User ID=H_MGR1_EID Query=%2 (1,16) User ID=H_MGR1_EID is specific to the sample CI that i used for testing, so ignore that. If you see any exception similar like this, then the reason would be because [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=70&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>when we try to invoke PeS CI from a plain Java, sometimes we see an error like</p>
<p>psft.pt8.joa.JOAException: Distributed Object Manager: User ID=H_MGR1_EID Query=%2 (1,16)</p>
<p>User ID=H_MGR1_EID is specific to the sample CI that i used for testing, so ignore that. If you see any exception similar like this, then the reason would be because of the CI remote object is not properly instantiated at PeS end.</p>
<p>Hence try executing the get method of the CI like oHMdaGeitCrrUpdCi.get() which will instantiate the CI object in the PeS.</p>
<p>Hope this would help in your debugging.</p>
<p>Thanks,</p>
<p>Sudan</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=70&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/07/07/peoplesoft-stuffs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Refresh</title>
		<link>http://sudanlive.wordpress.com/2010/06/29/java-refresh/</link>
		<comments>http://sudanlive.wordpress.com/2010/06/29/java-refresh/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 17:53:26 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=60</guid>
		<description><![CDATA[I am creating this post because most of the java savvy forget the basics in Java and unfortunately at the time of interview they are shooted with basic questions. This post would just have a simple one liner kind of stuff of Java which would be a refresh. Please note this is not for beginners [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=60&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am creating this post because most of the java savvy forget the basics in Java and unfortunately at the time of interview they are shooted with basic questions. This post would just have a simple one liner kind of stuff of Java which would be a refresh.</p>
<p>Please note this is not for beginners in Java</p>
<ol>
<li>Java Identifiers can be of any length.</li>
<li>A java file can have many classes inside it. If it has a public class then the name of it should match the file name.</li>
<li>A java file can have only one public class and can have more than one public class.</li>
<li>A class with default access can be seen only by classes  within the same package.</li>
<li>A class with public access can be seen by all classes  from all packages.</li>
<li>An abstract class can have both  abstract and non abstract methods.</li>
<li>The first concrete class to extend an abstract class  must implement all of its abstract methods.</li>
<li>Interfaces are contracts for what a class can do, but they  say nothing about the way in which the class must do it.</li>
<li>An interface can have only abstract methods, no concrete  methods allowed.</li>
<li>Interfaces can have constants, which are always implicitly  public, static, and final.</li>
<li>A legal non abstract implementing class has the following properties:
<ol>
<li>It must not declare any new checked exceptions for an  implementation method.</li>
<li>It must not declare any checked exceptions that are broader  than the exceptions declared in the interface method.</li>
<li>It may declare runtime exceptions on any interface method  implementation regardless of the interface declaration.</li>
</ol>
</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=60&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/06/29/java-refresh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>Immutable objects</title>
		<link>http://sudanlive.wordpress.com/2010/06/29/immutable-objects/</link>
		<comments>http://sudanlive.wordpress.com/2010/06/29/immutable-objects/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 11:13:36 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=65</guid>
		<description><![CDATA[Immutable objects have a very compelling list of positive qualities. Without question, they are among the simplest and most robust kinds of classes you can possibly build. When you create immutable classes, entire categories of problems simply disappear. Make a class immutable by following these guidelines : ensure the class cannot be overridden &#8211; make [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=65&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Immutable objects have a very compelling list of  positive qualities. Without question, they are among the simplest and most robust kinds of  classes you can possibly build. When you create immutable classes, entire categories of problems simply  disappear.</p>
<p>Make a class immutable by following these guidelines :</p>
<ul>
<li>ensure the class cannot be overridden &#8211; make the class <tt>final</tt>,  or use static factories and keep constructors private</li>
<li>make fields <tt>private</tt> and <tt>final</tt></li>
<li>force callers to construct an object completely in a single step,  instead of using a no-argument constructor combined with subsequent calls to <tt>setXXX</tt> methods (that is, <a href="http://www.javapractices.com/topic/Topic84.cjp">avoid the Java  Beans convention</a>)</li>
<li>do not provide any methods which can change the state of the object  in any way &#8211; not just <tt>setXXX</tt> methods, but any method which can  change state</li>
<li>if the class has any mutable object fields, then they must be  <a href="http://www.javapractices.com/topic/TopicAction.do?Id=15">defensively  copied</a> when passed between the class and its caller</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=65&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/06/29/immutable-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>Interesting Java stuffs</title>
		<link>http://sudanlive.wordpress.com/2010/06/02/interesting-java-stuffs/</link>
		<comments>http://sudanlive.wordpress.com/2010/06/02/interesting-java-stuffs/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 08:13:48 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=48</guid>
		<description><![CDATA[You can&#8217;t declare a constructor in an interface. For example you can&#8217;t do public interface Hello { public Hello(){}; } Most of them time when we work with Currencies, there might be a necessity of doing arithmetic operations. So, we use double as a data type for storing the decimal values. eg: double f = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=48&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ul>
<li>You can&#8217;t declare a constructor in an interface. For example you can&#8217;t do</li>
</ul>
<p>public interface Hello {</p>
<p>public Hello(){};</p>
<p>}</p>
<p><span style="color:#00ccff;"><br />
</span></p>
<ul>
<li>Most of them time when we work with Currencies, there might be a necessity of doing arithmetic operations. So, we use double as a data type for storing the decimal values.</li>
</ul>
<p>eg:</p>
<p>double f = 0.05;</p>
<p>double f1 = 0.35;</p>
<p>System.out.println(f+f1);</p>
<p>output:</p>
<p>0.39999999999999997</p>
<p>So, the above output gives lots of problems. This is because of the 64 bit precision of Double. To solve this use the below code</p>
<p>double f = 0.05;</p>
<p>double f1 = 0.35;</p>
<p>NumberFormat nf = NumberFormat.getInstance();</p>
<p>nf.setMaximumFractionDigits(2);</p>
<p>System.out.println(nf.format(f+f1));</p>
<p>Output:</p>
<p>0.4</p>
<ul>
<li>A singleton is an class that can be instantiated once, and only once.         This is a fairly unique property, but useful in a wide range of  object         designs. Creating an implementation of the singleton pattern is  fairly         straightforward &#8211; simple block off access to all constructors,  provide a         static method for getting an instance of the singleton, and  prevent         cloning.</li>
</ul>
<p>public class SingletonObject<br />
{</p>
<p>//It is declared private, just to ensure that no one outside this class calls this constructor. Which also means no one outside this class can instantiate this class<br />
private SingletonObject()<br />
{<br />
// no code req&#8217;d<br />
}</p>
<p>//It is made static, so that the caller can call this method without instantiating this class. It is synchronized to avoid the multiple calls by thread at the same time.<br />
public static synchronized SingletonObject getSingletonObject()<br />
{<br />
if (ref == null)<br />
// it&#8217;s ok, we can call this constructor<br />
ref = new SingletonObject();<br />
return ref;<br />
}</p>
<p>//This is just to override the Object clone or any other super class that this singleton class might extend.<br />
public Object clone()<br />
throws CloneNotSupportedException<br />
{<br />
throw new CloneNotSupportedException();<br />
// that&#8217;ll teach &#8216;em<br />
}</p>
<p>private static SingletonObject ref;<br />
}</p>
<p><strong>what is Factory methods?</strong></p>
<p>Factory methods are static methods that return an instance of the native class.</p>
<p>public class ComplexNumber {</p>
<p>/**<br />
* Static factory method returns an object of this class.<br />
*/<br />
public static ComplexNumber valueOf(float aReal, float aImaginary) {<br />
return new ComplexNumber(aReal, aImaginary);<br />
}</p>
<p>/**<br />
* Caller cannot see this private constructor.<br />
*<br />
* The only way to build a ComplexNumber is by calling the static<br />
* factory method.<br />
*/<br />
private ComplexNumber (float aReal, float aImaginary) {<br />
fReal = aReal;<br />
fImaginary = aImaginary;<br />
}</p>
<p>private float fReal;<br />
private float fImaginary;</p>
<p>//..elided<br />
}</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=48&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/06/02/interesting-java-stuffs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>Date Format in dd-mmm-yyyy in Java</title>
		<link>http://sudanlive.wordpress.com/2010/04/05/date-format-in-dd-mmm-yyyy-in-java/</link>
		<comments>http://sudanlive.wordpress.com/2010/04/05/date-format-in-dd-mmm-yyyy-in-java/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 12:05:57 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=45</guid>
		<description><![CDATA[Today i am going to blog on how to format a date to dd-mmm-yyyy for example &#8220;30-Aug-1985&#8243;. This might be available in many other blogs, but still for a kind of reference i am writing it here. The below code will describe how to do it. DateFormat df = new SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss.S&#8221;); Date dobDate; try [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=45&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today i am going to blog on how to format a date to dd-mmm-yyyy for example &#8220;30-Aug-1985&#8243;. This might be available in many other blogs, but still for a kind of reference i am writing it here.</p>
<p>The below code will describe how to do it.</p>
<p>DateFormat df = new SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss.S&#8221;);<br />
Date dobDate;<br />
try {<br />
dobDate = df.parse(&#8220;1985-08-30 00:00:00.0&#8243;);<br />
if (dobDate != null){<br />
DateFormat dobFormat = new java.text.SimpleDateFormat(&#8220;dd-MMM-yyyy&#8221;);</p>
<p>//Please note that in above format &#8220;MMM&#8221; is in caps. This is to print the month in alphabets<br />
System.out.println(dobFormat.format(dobDate));<br />
}<br />
} catch (ParseException e) {<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
}</p>
<p>Thanks,</p>
<p>-Sudan</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=45&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/04/05/date-format-in-dd-mmm-yyyy-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>finding the recent workspace path in eclipse</title>
		<link>http://sudanlive.wordpress.com/2010/03/04/finding-the-recent-workspace-path-in-eclipse/</link>
		<comments>http://sudanlive.wordpress.com/2010/03/04/finding-the-recent-workspace-path-in-eclipse/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 06:36:17 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=40</guid>
		<description><![CDATA[Hi All, Today when i was working on my eclipse for some reason suddenly it got crashed and it didnt opened. I was working on lots of my POC projects in it. Now i forgot all of the projects and different workspace path. I tried searching the eclipse extract folder to find my workspace path. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=40&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All,</p>
<p>Today when i was working on my eclipse for some reason suddenly it got crashed and it didnt opened. I was working on lots of my POC projects in it. Now i forgot all of the projects and different workspace path. I tried searching the eclipse extract folder to find my workspace path. Finally after a big search i got the file where this is stored.</p>
<p>I thought i would share the file name where this data would be stored in the eclipse.</p>
<p>File name: <span style="color:#003366;"><strong>eclipse\configuration\.settings\org.eclipse.ui.ide.prefs</strong></span></p>
<p>The data in this file would be something like below(for me)</p>
<p>#Mon Mar 01 15:34:44 IST 2010<br />
RECENT_WORKSPACES_PROTOCOL=3<br />
MAX_RECENT_WORKSPACES=5<br />
SHOW_WORKSPACE_SELECTION_DIALOG=true<br />
eclipse.preferences.version=1<br />
<span style="color:#000080;"><strong>RECENT_WORKSPACES=D\:\\OpenBPEL\nD\:\\MDAServerTest\nD\:\\MDA\\automations\\eclipse_workspace\nD\:\\SMSFinal\nD\:\\SMS1</strong></span></p>
<p>Guess this would help.</p>
<p>-Sudan</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=40&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/03/04/finding-the-recent-workspace-path-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>Invoking PeS through plain Java</title>
		<link>http://sudanlive.wordpress.com/2010/03/01/invoking-pes-through-plain-java/</link>
		<comments>http://sudanlive.wordpress.com/2010/03/01/invoking-pes-through-plain-java/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 10:06:18 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Websphere Process Server]]></category>
		<category><![CDATA[adapters]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=34</guid>
		<description><![CDATA[Hi All, Today I would like to explain the POC that I was trying last week. Generally for connecting to PeS we have three ways as below File Layout Web Services Application Messaging Component Interface File Layout: This is used to connect to PeS when we need file based polling integration. Generally the type of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=34&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All,</p>
<p>Today I would like to explain the POC that I was trying last week. Generally for connecting to PeS we have three ways as below</p>
<ol>
<li>File Layout</li>
<li>Web Services Application Messaging</li>
<li>Component Interface</li>
</ol>
<p><strong>File Layout:</strong></p>
<p>This is used to connect to PeS when we need file based polling integration. Generally the type of file used would be xml or csv&#8217;s. This method is still very popularly used in many applications.</p>
<p><strong>Web Services Application Messaging:</strong></p>
<p>This is a plain Web Service communication. Messaging architecture for both synchronous and guaranteed delivery asynchronous integration into and out of the Integration Broker</p>
<p><strong>Component Interface:</strong></p>
<p>This is Object-oriented, request/reply, component architecture that encapsulates PeopleSoft data and communicates.</p>
<p>I am interested in using Component Interface for PeS connectivity. Generally in market lots of adapters are available for doing this. The leaders are Oracle and IBM, they provide adapters for connecting to PeS. So, the developer doesnt have to code or worry about the PeS connectivity, they just need to send the data and get back the data they need. This makes life simple for developers</p>
<p>I have used IBM adapter in Websphere process server for PeopleSoft. The advantage i could see using is just easy development. But is it worth paying huge money for just getting this advantage. Why cant we develop our own component in process server which does this functionality.</p>
<p>The other advantage that adapter give is that we can discover the CI available in the PeS and just use the operation we want. All these things can be done using a good UI wizard. When we go for our own java implementations, we have to open each CI and create a java template for each.</p>
<p>We will go step by step tutorial for doing this.</p>
<p>PSJOA.jar -&gt; This is the interface jar file which would help Java to interact with PeopleSoft through a component interface. It will be available in %PS_HOME%\class directory.</p>
<p>Create a record with a single field and put this on a page. Create a component and move it to a component interface. The component interface should have the following methods :- Cancel, Create, Find, Get and Save.</p>
<p>Now, open the component interface. Click on Build -&gt; PeopleSoft APIs. This process would validate all the component interface and you will get some errors in this process. You can just skip the errors and continue the process. Select the &#8220;java&#8221; class option and specify the target location where the java files needs to be placed. For any component interface, PeopleSoft create four files like for CI name JobData, it would create</p>
<p>IJobDataCI.java</p>
<p>IJobDataCICollection.java</p>
<p>JobDataCI.java</p>
<p>JobDataCICollection.java</p>
<p>So, after compiling this, pack all the class files into a jar file, say PSFTCI.jar. So, now we have two jar&#8217;s PSJOA.jar and PSFTCI.jar</p>
<p>The next step is to create a java template. Open the component Interface, right click and click on generate a Java template. So, this would be saving your java template for that CI in some temp folder. Generally the Java template name would be the CI name itself, say JobDataCI.java</p>
<p>Now if we open the java template, we can see a code like</p>
<p>&#8220;oSession.connect(1, strAppServerPath, strOperatorID, strPassword, null)&#8221;</p>
<p>Here we can give the server name, username and password for the PeS we are trying to connect. This would take the default port. If we need to modify this port number to some specific value and have all these data coming from properties fil, we need to follow the below steps.</p>
<ol>
<li>change the above code to &#8220;oSession.connect(1, strAppServerPath, strOperatorID, strPassword, null)&#8221;</li>
<li>create a property file pstools.properties in the java project with the following key names</li>
</ol>
<p>server_port=&lt;server_port&gt;<br />
server_name=&lt;server_name&gt;<br />
logon_id=&lt;logon_id&gt;<br />
logon_password=&lt;logon_password&gt;</p>
<p>That&#8217;s it, we are done. Just need to use the setter and getter methods in the java template to select or update the date in PeS.</p>
<p>This finishes the tutorial for connecting to PeS through java.</p>
<p>-Sudan</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=34&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2010/03/01/invoking-pes-through-plain-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
		<item>
		<title>How to check what are the HTTP and HTTPS port in WPS from logs and Admin console</title>
		<link>http://sudanlive.wordpress.com/2009/11/21/how-to-check-what-are-the-http-and-https-port-in-wps-from-logs/</link>
		<comments>http://sudanlive.wordpress.com/2009/11/21/how-to-check-what-are-the-http-and-https-port-in-wps-from-logs/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 03:31:10 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[Websphere Process Server]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=13</guid>
		<description><![CDATA[Hi, There would be some case, where we dont have access to the admin console, but have only access to the logs. In this case how can we find the HTTP and HTTPS port for default and admin. To find the ports using Admin Console: start the server, go to Servers-&#62;Application servers &#62; server1 &#62; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=13&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>There would be some case, where we dont have access to the admin console, but have only access to the logs. In this case how can we find the HTTP and HTTPS port for default and admin.</p>
<p><strong>To find the ports using Admin Console:</strong></p>
<p>start the server, go to<strong> </strong>Servers-&gt;Application servers &gt;  server1 &gt;                         Ports, scroll down to see the screenshot below</p>
<p><a href="http://sudanlive.files.wordpress.com/2009/11/ports3.jpg"><img class="alignnone size-medium wp-image-24" title="ports" src="http://sudanlive.files.wordpress.com/2009/11/ports3.jpg?w=300&#038;h=118" alt="" width="300" height="118" /></a></p>
<p>WC admin host: HTTP port for admin console</p>
<p>WC admin host secure: HTTPS port for admin console</p>
<p>WC defaulthost: HTTP port for default host</p>
<p>WC defaulthost secure: HTTPS port for default host</p>
<p><strong>To find the ports using the System out logs</strong>:</p>
<p>Search for the below sentence in the logs</p>
<p>&#8220;Web Module WebSphere Admin File Transfer Application has been bound to admin_host&#8221; -  [*:HTTP,*:HTTPS]. This is for the admin HTTP and HTTPS ports</p>
<p>&#8220;Web Module Default Web Application has been bound to default_host&#8221; &#8211; [*:HTTP,*:80,*:HTTPS]. This is for the default HTTP and HTTPS ports</p>
<p>-<em><strong><span style="color:#3366ff;">Sudan</span></strong></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=13&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2009/11/21/how-to-check-what-are-the-http-and-https-port-in-wps-from-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>

		<media:content url="http://sudanlive.files.wordpress.com/2009/11/ports3.jpg?w=300" medium="image">
			<media:title type="html">ports</media:title>
		</media:content>
	</item>
		<item>
		<title>File Upload using JSP</title>
		<link>http://sudanlive.wordpress.com/2009/06/01/file-upload-using-jsp/</link>
		<comments>http://sudanlive.wordpress.com/2009/06/01/file-upload-using-jsp/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 08:07:54 +0000</pubDate>
		<dc:creator>sudan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[file upload]]></category>

		<guid isPermaLink="false">http://sudanlive.wordpress.com/?p=8</guid>
		<description><![CDATA[Today i am going to explain about a interesting problem, that i faced during the course of my project development. I was trying to do a file upload using jsp from a client to  server. For this when i searched the net, i got many code, at last i managed to edit one such code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=8&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today i am going to explain about a interesting problem, that i faced during the course of my project development.</p>
<p>I was trying to do a file upload using jsp from a client to  server. For this when i searched the net, i got many code, at last i managed to edit one such code and customized it to my requirement. Here is the below code snippet of the form, which is used to upload a file.</p>
<p>File Name:<strong> <span style="color:#ff9900;">FileUploadForm.jsp</span></strong></p>
<p>&lt;FORM ENCTYPE=&#8221;multipart/form-data&#8221; METHOD=&#8221;post&#8221; name=&#8221;main&#8221; action=&#8221;FileUploadAction.jsp&#8221;&gt;<br />
&lt;br&gt;<br />
&lt;tr&gt;<br />
&lt;td align=&#8221;right&#8221;&gt;&lt;b&gt;Choose the file To Upload:&lt;/b&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;INPUT NAME=&#8221;F1&#8243; TYPE=&#8221;file&#8221;&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />
&lt;td&gt;<br />
&lt;INPUT TYPE=&#8221;button&#8221; VALUE=&#8221;Upload&#8221; onclick=uploadFile()&gt;<br />
&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/FORM&gt;</p>
<p>Below scriplet is the code of other file which does the file upload action to the server</p>
<p>File Name: <span style="color:#ff9900;"><strong>FileUploadAction.jsp</strong></span><br />
&lt;%<br />
//to get the content type information from JSP Request Header<br />
String contentType = request.getContentType();<br />
//here we are checking the content type is not equal to Null and as well as the passed data from mulitpart/form-data is greater than or equal to 0<br />
if ((contentType != null) &amp;&amp; (contentType.indexOf(&#8220;multipart/form-data&#8221;) &gt;= 0)) {<br />
DataInputStream in = new DataInputStream(request.getInputStream());<br />
//we are taking the length of Content type data<br />
int formDataLength = request.getContentLength();<br />
byte dataBytes[] = new byte[formDataLength];<br />
int byteRead = 0;<br />
int totalBytesRead = 0;<br />
//this loop converting the uploaded file into byte code<br />
while (totalBytesRead &lt; formDataLength) {<br />
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);<br />
totalBytesRead += byteRead;<br />
}<span style="color:#ff9900;"><br />
</span> <span style="color:#3366ff;"><strong><span style="color:#ff9900;">S</span><span style="color:#ff9900;">tring file = new String(dataBytes);</span></strong></span><br />
//for saving the file name<br />
String saveFile = file.substring(file.indexOf(&#8220;filename=\&#8221;") + 10);<br />
saveFile = saveFile.substring(0, saveFile.indexOf(&#8220;\n&#8221;));<br />
saveFile = saveFile.substring(saveFile.lastIndexOf(&#8220;\\&#8221;) + 1,saveFile.indexOf(&#8220;\&#8221;"));</p>
<p>String timestamp = new SimpleDateFormat(&#8220;yyyy.MM.dd.HH.mm.ss.S.&#8221;).format(new Date());<br />
saveFile = userId+timestamp+saveFile;<br />
int lastIndex = contentType.lastIndexOf(&#8220;=&#8221;);<br />
String boundary = contentType.substring(lastIndex + 1,contentType.length());<br />
int pos;<br />
//extracting the index of file<br />
pos = file.indexOf(&#8220;filename=\&#8221;");<br />
pos = file.indexOf(&#8220;\n&#8221;, pos) + 1;<br />
pos = file.indexOf(&#8220;\n&#8221;, pos) + 1;<br />
pos = file.indexOf(&#8220;\n&#8221;, pos) + 1;</p>
<p>int boundaryLocation = file.indexOf(boundary, pos) &#8211; 4;<br />
int startPos = ((file.substring(0, pos)).getBytes()).length;<br />
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;</p>
<p>// creating a new file with the same name and writing the content in new file<br />
String fileName = request.getRealPath(&#8220;&#8221;)+&#8221;\\excelFiles\\&#8221;+saveFile;<br />
FileOutputStream fileOut = new FileOutputStream(fileName);<br />
fileOut.write(dataBytes, startPos, (endPos &#8211; startPos));<br />
fileOut.flush();<br />
fileOut.close();</p>
<p>%&gt;</p>
<p>But there is a serious problem in the above code, it works fine in the windows, whereas in linux machines this code fails. When i went through the everyline of the code, the line of code which gives different output in linux is,</p>
<p><span style="color:#3366ff;"><strong><span style="color:#ff9900;">S</span><span style="color:#ff9900;">tring file = new String(dataBytes);</span></strong></span><br />
The above line is used to convert the file data in bytes to String. The reason we are doing is to find the boundary location of the file, now lets dont go deep in to this, this is more about file parsing formats. You can read the <a title="Form-based File Upload in HTML" href="http://www.ietf.org/rfc/rfc1867.txt" target="_blank">RFC </a>which explains about the formats and parsing the file data from a HTML. But the strange that i could see in the above line is for the same file uploaded the String variable file length varies in windows server and linux server. I am not able to imaging the reason behind this.</p>
<p>After a long fight with the code and searching in the internet, i happen to see the apache commons api&#8217;s. This api is really cool and interesting. It does all the things that is required for parsing and reduces our load. FileUploadForm.jsp can be used the same. But i changes the code of FileUploadAction.jsp. Below is the code</p>
<p>File Name: <span style="color:#ff9900;"><strong>FileUploadAction.jsp </strong></span></p>
<p>&lt;%@ page import=&#8221;java.text.SimpleDateFormat&#8221; %&gt;<br />
&lt;%@ page import=&#8221;org.apache.commons.fileupload.FileItem&#8221; %&gt;<br />
&lt;%@ page import=&#8221;org.apache.commons.fileupload.FileUploadException&#8221; %&gt;<br />
&lt;%@ page import=&#8221;org.apache.commons.fileupload.disk.DiskFileItemFactory&#8221; %&gt;<br />
&lt;%@ page import=&#8221;org.apache.commons.fileupload.servlet.ServletFileUpload&#8221; %&gt;</p>
<p>&lt;%@ page import=&#8221;java.io.*&#8221; %&gt;<br />
&lt;%@ page import=&#8221;java.util.*&#8221; %&gt;<br />
&lt;%</p>
<p>if (ServletFileUpload.isMultipartContent(request)){<br />
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());<br />
List fileItemsList = null;<br />
try {<br />
fileItemsList = servletFileUpload.parseRequest(request);<br />
} catch (FileUploadException e) {<br />
System.err.println(&#8220;inside uploadUpdateACtion while parsing Exception is ["+e.getMessage()+"]&#8220;);<br />
}</p>
<p>Iterator i = fileItemsList.iterator();<br />
//String comment = ((FileItem)i.next()).getString();<br />
FileItem fi = (FileItem)i.next();<br />
// filename on the client<br />
String fileName = fi.getName();</p>
<p>fileName = fileName.substring(fileName.lastIndexOf(&#8220;\\&#8221;)+1);</p>
<p>String timestamp = new SimpleDateFormat(&#8220;yyyy.MM.dd.HH.mm.ss.S.&#8221;).format(new Date());<br />
String saveFile = userId+timestamp+fileName;<br />
// write the file<br />
try {<br />
fi.write(new File(request.getRealPath(&#8220;&#8221;)+&#8221;/excelFiles&#8221;, saveFile));<br />
} catch (Exception e) {<br />
System.err.println(&#8220;inside uploadUpdateACtion while writing the uploded file Exception is ["+e.getMessage()+"]&#8220;);<br />
}</p>
<p>%&gt;</p>
<p>For the above code to work we need two jars to be included in the classpath <span style="color:#ff9900;">commons-fileupload-1.2.1.jar</span> and <span style="color:#ff9900;">commons-io-1.4.jar. <span style="color:#000000;">Both the jars are available in the apache site. This code will work for all environments and platforms. It has lot of features to be explored by me.</span></span><br />
Thanks for reading, Have a great day !!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
<p>-Sudan</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sudanlive.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sudanlive.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sudanlive.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sudanlive.wordpress.com&amp;blog=7486277&amp;post=8&amp;subd=sudanlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sudanlive.wordpress.com/2009/06/01/file-upload-using-jsp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/979c14fc3d998fd0edd05a782f5e0804?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sudan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
