<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1262191638215180659</id><updated>2024-09-06T00:24:29.557+05:30</updated><category term="Log4J"/><category term="Java versions and their features"/><category term="Encryption and Decryption"/><category term="log4j PatternLayout"/><category term="Advanced Encryption Standard (AES)"/><category term="Data Encryption Standard (DES)"/><category term="Deploying EJB 2 Stateful Bean on Weblogic"/><category term="EJB"/><category term="EJB 3 Persistence"/><category term="Enhancements in Java SE 6 (Mustang)"/><category term="Factory Method Design Pattern in Java"/><category term="Few Important UML Diagrams"/><category term="Hibernate 3.0"/><category term="J2SE 5.0 (Tiger) Features"/><category term="JAXB"/><category term="JDK-JRE-JVM"/><category term="Java Class Loading"/><category term="Java RMI"/><category term="Java Serialization"/><category term="Object to Xml and Xml to Object Using Java XStream"/><category term="Parsing XML Files in Java"/><category term="Scripting Language Support in Java SE 6 (Mustang)"/><category term="Web Browser Automation using Selenium"/><category term="Working with Data sources"/><title type='text'>Pure Java 4 All</title><subtitle type='html'>purejava4all is a blog dedicated to Java/J2EE developers. We always try to publish some interesting java topics with code examples.&#xa;&#xa;Most examples are simple, easy to understand, and with full source code.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-6825599290363208072</id><published>2014-02-23T11:01:00.003+05:30</published><updated>2014-02-23T11:01:42.301+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Working with Data sources"/><title type='text'>Working with Data sources</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Here in this small example I will show how to&amp;nbsp;look up&amp;nbsp;an&amp;nbsp;&lt;a href=&quot;http://www.oracle.com/index.html&quot; target=&quot;_blank&quot;&gt;Oracle&lt;/a&gt;&amp;nbsp;Data source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;And get the connection to update the tables in a schema.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Let’s consider we have created the data sources in&amp;nbsp;&lt;a href=&quot;http://www.oracle.com/technetwork/middleware/weblogic/overview/index.html&quot; target=&quot;_blank&quot;&gt;Weblogic application server&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Here we have created one Member Data Source with JNDI name “MemberDataSource”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;This data source contains one schema say ods_membership which contains the Table called MEMBERSHIP_FUNCTIONS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Now through java we will do JNDI LOOKUP of the data source, once we look up the data source we will create the connection and finally we will update the mentioned table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;(In similar way we can insert or query the database tables)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;package&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;com.purejava4all.datasource;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;java.sql.Connection;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;java.sql.PreparedStatement;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;java.sql.SQLException;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;java.util.Properties;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;javax.naming.Context;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;javax.naming.InitialContext;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;javax.sql.DataSource;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;UpdateTable {&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;String&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;serviceUrl&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;Properties&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;props&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Connection&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;con&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PreparedStatement&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;stmt&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;setUp(){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Consolas;&quot;&gt;// Host Port information of the Database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;serviceUrl&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;t3://10.20.333.70:9006&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;props&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;Properties();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;props&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.put(Context.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;INITIAL_CONTEXT_FACTORY&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;weblogic.jndi.WLInitialContextFactory&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;props&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.put(Context.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;PROVIDER_URL&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;serviceUrl&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;setUp:serviceUrl::&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;+&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;serviceUrl&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;===setUp Done===&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;main(String ags[]){&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt;setUp&lt;/i&gt;();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Connection con =&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PreparedStatement stmt =&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Consolas;&quot;&gt;// Creating the InitialContext&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Context ctx =&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;InitialContext(&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;props&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;===got the Context===&amp;gt;&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;+ctx);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Consolas;&quot;&gt;// Doing JNDI Look Up of the Data Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource dataSource = (DataSource) ctx.lookup(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;jdbc/MemberDataSource&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;===got the dataSource===&amp;gt;&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;+dataSource);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: #3f7f5f; font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Creating Connection from the Data Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con = dataSource.getConnection();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;===got the con===&amp;gt;&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;+con);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StringBuffer query =&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;StringBuffer();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f; font-family: Consolas;&quot;&gt;// Building the query&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.append(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;update ods_membership.&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;MEMBERSHIP_FUNCTIONS set ACTIVE_STATUS = ‘N’ where MEMBERSHIP_TYPE in (&#39;ROMS&#39;,&#39;BOLS&#39;)&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stmt = con.prepareStatement(query.toString());&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;count&amp;nbsp; = stmt.executeUpdate();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-family: Consolas;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.println(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff; font-family: Consolas;&quot;&gt;&quot;===Update Done===&amp;gt;&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;+count);&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;(SQLException e) {&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;(Exception ex){&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ex.printStackTrace();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con.close();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stmt.close();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: Consolas;&quot;&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;(Exception e){&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/6825599290363208072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2014/02/working-with-data-sources.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6825599290363208072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6825599290363208072'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2014/02/working-with-data-sources.html' title='Working with Data sources'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-3971493740286918738</id><published>2014-02-20T04:16:00.002+05:30</published><updated>2014-02-23T10:16:01.520+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Object to Xml and Xml to Object Using Java XStream"/><title type='text'>Object to Xml and Xml to Object Using Java XStream</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This is very small but very useful code, if you run Junit
test cases then it can very easily provide you java request object from XML
request object. Again we write toString in object to get the object’s property
information at run time, and to write toString we need to print all the
properties. But if we can convert java object to String XML we can have all the
object’s property values and that is very easy to read.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: windowtext; text-decoration: none; text-underline: none;&quot;&gt;&lt;a href=&quot;http://xstream.codehaus.org/&quot; target=&quot;_blank&quot;&gt;Xstream&lt;/a&gt;&lt;/span&gt;&amp;nbsp;provides us API which converts the XML to
object and object to XML again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
For this we have two dependencies &lt;b&gt;jdom-1.1.jar&lt;/b&gt; and &lt;b&gt;xstream-1.3.1.jar&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Below code demonstrate the use of Xstream serialize and
deserialize of an Customer object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box;&quot;&gt;
method getXMLToObject
() converts Xml to Customer object and method getObjectToXML () converts Customer
Object to Xml&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
package com.purejava4all;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import java.io.File;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import org.jdom.Document;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import org.jdom.input.SAXBuilder;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import org.jdom.output.XMLOutputter;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import com.thoughtworks.xstream.XStream;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
import com.thoughtworks.xstream.io.xml.DomDriver;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
public class XtreamUtil {&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
public static void main(String[] args) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
// Here we are reading Customer.xml file and converting that
to Java Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Customer customer = (Customer) getXMLToObject (&quot;C:\\xmlfiles\\Customer.xml&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
System.out.println(&quot;Xml to Customer \n&quot; + customer);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
// Once we have the java object we can use it in anywhere
such as in test cases&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
// Here we are converting the java object again into XML
String format&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
String customerXML = getObjectToXML (customer);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
System.out.println(&quot;Customer to XML String\n&quot; + customerXML);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
public static &lt;t&gt; T getXMLToObject(final String
xmlFilePath) throws Exception {&lt;o:p&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
File file = new File(xmlFilePath);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if
(!file.exists()) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw
new Exception(&quot;File doesn&#39;t exist at &quot; + xmlFilePath);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
SAXBuilder builder = new SAXBuilder();&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
Document doc = builder.build(file);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
String xml = new XMLOutputter().outputString(doc);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
XStream xstream = new XStream(new DomDriver());&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final
Object obj = xstream.fromXML(xml);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
(T) obj;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
public static String getObjectToXML(Object o){&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XStream
xstream = new XStream();&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String xml =
xstream.toXML(o);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return xml;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/3971493740286918738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2014/02/object-to-xml-and-xml-to-object-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3971493740286918738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3971493740286918738'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2014/02/object-to-xml-and-xml-to-object-using.html' title='Object to Xml and Xml to Object Using Java XStream'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-6230308896974132930</id><published>2014-02-16T21:12:00.000+05:30</published><updated>2014-02-23T10:22:15.836+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Web Browser Automation using Selenium"/><title type='text'>Web Browser Automation using Selenium</title><content type='html'>&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;Here I will discuss what is &lt;a href=&quot;http://docs.seleniumhq.org/&quot; target=&quot;_blank&quot;&gt;Selenium&lt;/a&gt;, how Selenium works and will also provide one example to demonstrate how easily we can create automated test cases using Selenium.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;What is &lt;a href=&quot;http://docs.seleniumhq.org/&quot; target=&quot;_blank&quot;&gt;Selenium&lt;/a&gt;?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Selenium automates browsers. That&#39;s it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.
Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;http://docs.seleniumhq.org/docs/03_webdriver.jsp&quot; target=&quot;_blank&quot;&gt;Selenium WebDriver&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The biggest change in Selenium recently has been the inclusion of the WebDriver API. Driving a browser natively as a user would either locally or on a remote machine using the Selenium Server it marks a leap forward in terms of browser automation.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just &quot;WebDriver&quot; or sometimes as Selenium 2.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Selenium 1.0 + WebDriver = Selenium 2.0&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;• WebDriver is designed in a simpler and more concise programming interface along with addressing some limitations in the Selenium-RC API.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;• WebDriver is a compact Object Oriented API when compared to Selenium1.0&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;• It drives the browser much more effectively and over comes the limitations of Selenium 1.x which affected our functional test coverage, like the file upload or download, pop-ups and dialogs barrier&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;• WebDriver overcomes the limitation of Selenium Rc&#39;s Single Host origin policy&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;WebDriver is the name of the key interface against which tests should be written in Java, the implementing classes one should use are listed as below:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;AndroidDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver,InternetExplorerDriver, IPhoneDriver, PhantomJSDriver, RemoteWebDriver, SafariDriver&amp;nbsp;

&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Let’s do some programming now…… This is small but complete example how Selenium works&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;First you need to download the Selenium and WebDriver libraries from www. seleniumhq.org. Here in this example I have used FirefoxDriver but you can use other Drivers for other browsers.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;import org.openqa.selenium.By;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;import org.openqa.selenium.WebDriver;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;import org.openqa.selenium.WebElement;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;public class GoogleAutomation {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;public static void googleSearch(){
   
  System.setProperty(&quot;webdriver.firefox.bin&quot;,&quot;C:\\Users\\Roy\\AppData\\Local\\Mozilla Firefox\\Firefox.exe&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;System.out.println(&quot;Opening WebDriver&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;WebDriver driver = new FirefoxDriver();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;System.out.println(&quot;Opening Google.com&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;// And now use this to visit Google&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;driver.get(&quot;http://www.google.com&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;// Find the text input element by its name&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;WebElement element = driver.findElement(By.name(&quot;q&quot;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;// Enter something to search for&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;element.sendKeys(&quot;Honda Car&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;System.out.println(&quot;Doing Search for Honda Car&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;// Now submit the form. WebDriver will find the form for us from the element&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;element.submit();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;// Now you can see the search results in Google&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;public static void main(String[] args) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp;googleSearch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;I hope now you will be able to write some cool programs to automate Web Browsers using Selenium.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/6230308896974132930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2014/02/web-browser-automation-using-selenium.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6230308896974132930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6230308896974132930'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2014/02/web-browser-automation-using-selenium.html' title='Web Browser Automation using Selenium'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-3623736101849578113</id><published>2012-07-08T09:21:00.007+05:30</published><updated>2014-02-21T09:48:47.630+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAXB"/><title type='text'>JAXB</title><content type='html'>&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 20pt; line-height: 115%;&quot;&gt;JAXB&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 9pt; line-height: 115%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;stands for&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Calibri, sans-serif;&quot;&gt;Java Architecture for XML Binding&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 9pt; line-height: 115%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Calibri, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;JAXB allows Java developers to access and process XML data without having to know XML or XML processing.&amp;nbsp;For example, there&#39;s no need to create or use a SAX parser or write callback methods. It makes use of a&amp;nbsp;&amp;nbsp;given schema of an XML document and automatically generates the required Java classes, corresponding to that schema. Modern trend focuses on XML representation of Data, for ease of exchange in web-service and otherwise. If we have an xml representation of a database, we can use JAXB to create a tree of Java objects&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;and work with them in Java idiom..This is known as XML-Data binding.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;Validation is an important part of any XML document. Unlike&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;HTML, XML tags are user-defined. This is what gives XML its power and utility. But, at the same time, to make it really useful, each such XML document should have a &#39;schema&#39;....Something like Data Definition in SQL. It should be carefully noted that &#39;schema&#39; is a general term. In the earlier days of XML, the only schema that was known and used was&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;DTD (Document-type-definition). Even today, DTD is said to be the most prevalent &#39;schema&#39; in use and best known, among developers.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 115%;&quot;&gt;Using JAXB annotation we do convert Java object to / from XML file&lt;/span&gt;. Converting a Java object into a XML file is called Marshalling and converting XML content into a java object is called Un-marshalling.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 61.05pt; mso-add-space: auto; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;Marshalling – Convert a Java object into a XML file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 61.05pt; mso-add-space: auto; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;Un-marshalling – Convert XML content into a Java Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 61.05pt; mso-add-space: auto; mso-list: l2 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;Technologies used in this article&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 25.05pt; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 12pt;&quot;&gt;1.&lt;span style=&quot;font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;JDK 1.6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 25.05pt; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: 12pt;&quot;&gt;2.&lt;span style=&quot;font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;JAXB 2.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-left: 25.05pt; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;Working with JAXB is easy, just annotate object with JAXB annotation, later use&amp;nbsp;jaxbMarshaller.marshal()&amp;nbsp;or jaxbMarshaller.unmarshal()&amp;nbsp;to do the object / XML conversion.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt; line-height: 15.05pt;&quot;&gt;JAXB Dependency&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;No extra JAXB libraries are required if you are using JDK1.6 or above, because&amp;nbsp;&lt;a href=&quot;http://jaxb.java.net/guide/Which_JAXB_RI_is_included_in_which_JDK_.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #333333; text-decoration: none;&quot;&gt;JAXB is bundled in JDK 1.6&lt;/span&gt;&lt;/a&gt;. For JDK &amp;lt; 1.6 we need to put “&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background-color: white; font-size: 12pt;&quot;&gt;jaxb-api.jar&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;” and “&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background-color: white; font-size: 12pt;&quot;&gt;jaxb-impl.jar&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-size: 12pt;&quot;&gt;” on our project classpath.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt; mso-outline-level: 4;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif; font-size: 12.5pt;&quot;&gt;JAXB Annotation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;For object that needs to convert to / from XML file, it have to annotate with JAXB annotation. The annotation are pretty self-explanatory, you can refer to this&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&lt;a href=&quot;http://jaxb.java.net/tutorial/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #0f3b68;&quot;&gt;JAXB guide&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;for detail explanation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;package&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-family: &#39;Courier New&#39;;&quot;&gt;com.myproj.core&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-family: &#39;Courier New&#39;;&quot;&gt;javax.xml.bind.annotation.XmlAttribute&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-family: &#39;Courier New&#39;;&quot;&gt;javax.xml.bind.annotation.XmlElement&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-family: &#39;Courier New&#39;;&quot;&gt;javax.xml.bind.annotation.XmlRootElement&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;; font-size: large;&quot;&gt;@XmlRootElement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; Customer &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-family: &#39;Courier New&#39;;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; age&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-family: &#39;Courier New&#39;;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; getName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XmlElement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; setName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-family: &#39;Courier New&#39;;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-family: &#39;Courier New&#39;;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; getAge&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; age&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XmlElement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; setAge&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; age&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-family: &#39;Courier New&#39;;&quot;&gt;age&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; age&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; getId&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XmlAttribute&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; setId&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-family: &#39;Courier New&#39;;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-family: &#39;Courier New&#39;;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color: #339933; font-family: &#39;Courier New&#39;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #009900; font-family: &#39;Courier New&#39;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.05pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h4 style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt;&quot;&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif; font-size: 12.5pt;&quot;&gt;Convert Object to XML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15.05pt; margin: 0in 0in 12.5pt;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;JAXB marshalling example, convert customer object into a XML file. The&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px;&quot;&gt;&lt;span style=&quot;background-color: #f7f7f9; border: 1pt solid rgb(225, 225, 232); color: #0f3b68; font-family: Consolas; font-size: 8pt; padding: 1pt;&quot;&gt;jaxbMarshaller.marshal()&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;contains a lot of overloaded methods, find one that suit your output.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: rgba(0, 0, 0, 0.148438); line-height: 15.05pt; margin-bottom: 7.5pt; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;package&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;com.myproj.core&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;java.io.File&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.JAXBContext&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.JAXBException&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.Marshaller&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;public&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;class&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; JAXBExample &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;public&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;static&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; args&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Customer customer &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;new&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; Customer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; customer.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; customer.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;setName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Kamesh&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; customer.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;setAge&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;29&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;b&gt;try&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; file &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;new&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;C:&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000099;&quot;&gt;\\&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: blue;&quot;&gt;file.xml&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JAXBContext jaxbContext &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; JAXBContext.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;Customer.&lt;/span&gt;&lt;b&gt;class&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Marshaller jaxbMarshaller &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; jaxbContext.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;createMarshaller&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;// output pretty printed&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jaxbMarshaller.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;setProperty&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;Marshaller.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;JAXB_FORMATTED_OUTPUT&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;, &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jaxbMarshaller.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;marshal&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;customer, file&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jaxbMarshaller.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;marshal&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;customer, &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;catch&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;JAXBException e&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;printStackTrace&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15.05pt; margin: 0in 0in 12.5pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;em style=&quot;background-color: white; line-height: 15.05pt;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Output&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhXBsy-pMPmLsjI2O8sSJ99fZMzZqS3_iOjOXxB87rsS8zlPwrEW3qKvPrPUkzVkSuGvwk-QJCxlFtcRJZUxaqgQqwkSw44m_6zDJh3tVPR9iCYGcIGL7AxIvlaxPOMhtarreM74Ev8hlz/s1600/jaxb3.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhXBsy-pMPmLsjI2O8sSJ99fZMzZqS3_iOjOXxB87rsS8zlPwrEW3qKvPrPUkzVkSuGvwk-QJCxlFtcRJZUxaqgQqwkSw44m_6zDJh3tVPR9iCYGcIGL7AxIvlaxPOMhtarreM74Ev8hlz/s1600/jaxb3.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;pre style=&quot;background: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: rgba(0, 0, 0, 0.148438); line-height: 15.05pt; margin-bottom: 7.5pt; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;/pre&gt;&lt;h4 style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt;&quot;&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif; font-size: 12.5pt;&quot;&gt;Convert XML to java Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15.05pt; margin: 0in 0in 12.5pt;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;JAXB un-marshalling example, convert a XML file content into a customer object. The&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px;&quot;&gt;&lt;span style=&quot;background-color: #f7f7f9; border: 1pt solid rgb(225, 225, 232); color: #0f3b68; font-family: Consolas; font-size: 8pt; padding: 1pt;&quot;&gt;jaxbMarshaller.unmarshal()&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;contains a lot of overloaded methods, find one that suit yours.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: rgba(0, 0, 0, 0.148438); line-height: 15.05pt; margin-bottom: 7.5pt; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;package&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;com.myproj.core&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;java.io.File&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.JAXBContext&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.JAXBException&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699;&quot;&gt;javax.xml.bind.Unmarshaller&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;public&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;class&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; JAXBExample &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;public&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;static&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; args&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;b&gt;try&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; file &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;new&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;C:&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000099;&quot;&gt;\\&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: blue;&quot;&gt;file.xml&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JAXBContext jaxbContext &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; JAXBContext.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;Customer.&lt;/span&gt;&lt;b&gt;class&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unmarshaller jaxbUnmarshaller &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; jaxbContext.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;createUnmarshaller&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Customer customer &lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;Customer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; jaxbUnmarshaller.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;unmarshal&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;customer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;b&gt;catch&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;JAXBException e&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.&lt;/span&gt;&lt;span style=&quot;color: #006633;&quot;&gt;printStackTrace&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: #333333; font-size: large;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: whitesmoke; line-height: 15.05pt; margin-bottom: 7.5pt; word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15.05pt; margin: 0in 0in 12.5pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;em&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Output&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: rgba(0, 0, 0, 0.148438); line-height: 15.05pt; margin-bottom: 7.5pt; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;Customer &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7a0874;&quot;&gt;[&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #007800;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;=Kamesh, &lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;age&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;29&lt;span style=&quot;color: #333333;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;100&lt;b&gt;&lt;span style=&quot;color: #7a0874;&quot;&gt;]&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h4 style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt;&quot;&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif;&quot;&gt;JAXB Architecture&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOUNIW63pl-e2bJpZWU1UmNMtHyoQm8Z_RZGghg9fxjtCGX7FjtQIQ8kPe2WSH1UMqdkxixXUdxLOSTh7SdB9KbOv7mDcADnpq5GxGq2pSRwCWBMW2c0RfdJJTy1telnnSxDmQmsZtCZOI/s1600/jaxb1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOUNIW63pl-e2bJpZWU1UmNMtHyoQm8Z_RZGghg9fxjtCGX7FjtQIQ8kPe2WSH1UMqdkxixXUdxLOSTh7SdB9KbOv7mDcADnpq5GxGq2pSRwCWBMW2c0RfdJJTy1telnnSxDmQmsZtCZOI/s1600/jaxb1.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;A JAXB implementation consists of the following architectural components:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l3 level1 lfo3; text-indent: -.25in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1691&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Symbol; font-size: 9pt;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Schema compiler&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: Binds a source schema to a set of schema-derived program elements. The binding is described by an XML-based binding language.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l3 level1 lfo3; text-indent: -.25in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1692&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Symbol; font-size: 9pt;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Schema generator&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: Maps a set of existing program elements to a derived schema. The mapping is described by program annotations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l3 level1 lfo3; text-indent: -.25in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1693&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Symbol; font-size: 9pt;&quot;&gt;·&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Binding runtime framework&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: Provides unmarshalling (reading) and marshalling (writing) operations for accessing, manipulating, and validating XML content using either schema-derived or existing program elements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h4 style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;bnazj&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif;&quot;&gt;The JAXB Binding Process&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNtldFFcpDtEhnE2csaPeDQya0BkCo8t3jPspASQON9yeAa2YZoFdHH27IDUe23TufqdY4ELX5gnfS6HRNR1SPzWEBlMTjiioyMif7z3iT8ZEWK8P8lCXPYUTFHhOdYTRI6VFaBwK4LGWE/s1600/jaxb2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNtldFFcpDtEhnE2csaPeDQya0BkCo8t3jPspASQON9yeAa2YZoFdHH27IDUe23TufqdY4ELX5gnfS6HRNR1SPzWEBlMTjiioyMif7z3iT8ZEWK8P8lCXPYUTFHhOdYTRI6VFaBwK4LGWE/s1600/jaxb2.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h4 style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 12.5pt;&quot;&gt;&lt;span style=&quot;color: #0f3b68; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1694&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;The general steps in the JAXB data binding process are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;1.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Generate classes&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: An XML schema is used as input to the JAXB binding compiler to generate JAXB classes based on that schema.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;2.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Compile classes&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: All of the generated classes, source files, and application code must be compiled.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;3.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Unmarshal&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: XML documents written according to the constraints in the source schema are unmarshalled by the JAXB binding framework. Note that JAXB also supports unmarshalling XML data from sources other than files/documents, such as DOM nodes, string buffers, SAX Sources, and so forth.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;4.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Generate content tree&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: The unmarshalling process generates a content tree of data objects instantiated from the generated JAXB classes; this content tree represents the structure and content of the source XML documents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;5.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Validate (optional)&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: The unmarshalling process optionally involves validation of the source XML documents before generating the content tree. Note that if you modify the content tree in Step 6, below, you can also use the JAXB Validate operation to validate the changes before marshalling the content back to an XML document.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;6.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Process content&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: The client application can modify the XML data represented by the Java content tree by means of interfaces generated by the binding compiler.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;7.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Marshal&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;: The processed content tree is marshalled out to one or more XML output documents. The content may be validated before marshalling.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;More about Unmarshalling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1695&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Unmarshalling provides a client application the ability to convert XML data into JAXB-derived Java objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;bnazm&quot;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;More about Marshalling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1696&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Marshalling provides a client application the ability to convert a JAXB-derived Java object tree back into XML data. By default, the&amp;nbsp;Marshaller&amp;nbsp;uses UTF-8 encoding when generating XML data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Client applications are not required to validate the Java content tree before marshalling. There is also no requirement that the Java content tree be valid with respect to its original schema to marshal it back into XML data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 1.9pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;background: white; line-height: 15.05pt; margin-bottom: 12.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;More about Validation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15.05pt; margin: 0in 0in 12.5pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-create.do&quot; name=&quot;indexterm-1697&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Helvetica, sans-serif; font-size: 9pt;&quot;&gt;Validation is the process of verifying that an XML document meets all the constraints expressed in the schema. JAXB 1.0 provided validation at unmarshal time and also enabled on-demand validation on a JAXB content tree. JAXB 2.0 only allows validation at unmarshal and marshal time. A web service processing model is to be lax in reading in data and strict on writing it out. To meet that model, validation was added to marshal time so one could confirm that they did not invalidate the XML document when modifying the document in JAXB form.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/3623736101849578113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2012/07/jaxb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3623736101849578113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3623736101849578113'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2012/07/jaxb.html' title='JAXB'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhXBsy-pMPmLsjI2O8sSJ99fZMzZqS3_iOjOXxB87rsS8zlPwrEW3qKvPrPUkzVkSuGvwk-QJCxlFtcRJZUxaqgQqwkSw44m_6zDJh3tVPR9iCYGcIGL7AxIvlaxPOMhtarreM74Ev8hlz/s72-c/jaxb3.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-3981953767675298522</id><published>2012-02-26T23:11:00.002+05:30</published><updated>2014-02-21T09:49:04.074+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Deploying EJB 2 Stateful Bean on Weblogic"/><title type='text'>Deploying EJB 2 Stateful Bean on Weblogic</title><content type='html'>&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;There are five steps involved in EJB Session bean Development and deploy process.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create the Home Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create the Remote Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create the Session Bean&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Define the resources in Deployment Descriptor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;5.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Deploy on the server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Rules for EJB Home Interface:&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EJB Home must extend&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;EJBHome&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Must have at least one create() Method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The create method should return the Component interface type (Remote interface)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create() method should throw “&lt;strong&gt;CreateException&lt;/strong&gt;,&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;RemoteException&lt;/strong&gt;”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 48.75pt; mso-list: l0 level1 lfo1; tab-stops: list 48.75pt; text-indent: -30.75pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;1.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Create a Home Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;package&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;com.test;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;java.rmi.RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.CreateException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.EJBHome;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;interface&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;CounterHome&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;extends&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBHome {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;Counter create(String name)&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;CreateException, RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Rules for Remote Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remote must extend EJBObject Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Should contains the business methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Every business method should throw RemoteException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 48.75pt; mso-list: l0 level1 lfo1; tab-stops: list 48.75pt; text-indent: -30.75pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;2.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Create a Remote Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;package&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;com.test;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;java.rmi.RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.EJBObject;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;interface&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;Counter&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;extends&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBObject {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;startCounter()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;getCounter()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Rules for SessionBeans&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Every&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;SessionBean&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;should extend SessionBean Interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In case of Stateless session bean there must be only one create method and that should must prefix with “&lt;em&gt;&lt;b&gt;ejb&lt;/b&gt;&lt;/em&gt;&lt;strong&gt;Create&lt;/strong&gt;”. And should be with no-arg approach.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Every bean should save the SessionContext copy in the “&lt;strong&gt;setSessionContext&lt;/strong&gt;” method, as this bean called only once when bean gets created; saving this reference is always useful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Incase of Stateful session bean, do not need to have no-arg create method. And also you can create as many as createMethod.&lt;br /&gt;
e.g &amp;nbsp;ejbCreate(), ejbCreate(String), createCustomerPortfolio(String) etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 48.75pt; mso-list: l0 level1 lfo1; tab-stops: list 48.75pt; text-indent: -30.75pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;3.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Create Stateful session bean&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;package&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;com.test;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;java.io.Serializable;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;java.rmi.RemoteException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.EJBException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.SessionBean;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;javax.ejb.SessionContext;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;class&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;HandleCounter&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;implements&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;SessionBean, Serializable {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;final&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;long&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;em&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;serialVersionUID&lt;/span&gt;&lt;/em&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;= 1L;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;String&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;u&gt;userName&lt;/u&gt;=”&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;SessionContext&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;u&gt;ctx&lt;/u&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;counter=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;ejbActivate()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBException, RemoteException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;System.&lt;em&gt;out&lt;/em&gt;.println(“Inside ejbActivate”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;ejbPassivate()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBException, RemoteException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;System.&lt;em&gt;out&lt;/em&gt;.println(“Inside ejbPassivate”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;ejbRemove()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBException, RemoteException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;System.&lt;em&gt;out&lt;/em&gt;.println(“Inside ejbRemove”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;setSessionContext(SessionContext arg0)&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;EJBException,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;RemoteException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;this&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;.ctx=arg0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;startCounter()&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;RemoteException{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;counter=counter+1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;getCounter()&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;RemoteException{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;return&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;counter;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;ejbCreate(String name)&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;RuntimeException{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;userName=name;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 48.75pt; mso-list: l0 level1 lfo1; tab-stops: list 48.75pt; text-indent: -30.75pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;4.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Deployment Descriptors of EJB Components (ejb-jar.xml)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQiGXpbyOTrcOMhVz0sEqOS7duT2fc5jw690YgiYQyhqZvSwR6aS5eYWkLMIwsv8Hon-xdDilq6dSmsvfU6OrQJ-dLIBZ6-CpicBCwXTgOIeXvoplkPLWwyAWE6cIqzLP2dtCN_O06duv/s1600/ejb-jar.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQiGXpbyOTrcOMhVz0sEqOS7duT2fc5jw690YgiYQyhqZvSwR6aS5eYWkLMIwsv8Hon-xdDilq6dSmsvfU6OrQJ-dLIBZ6-CpicBCwXTgOIeXvoplkPLWwyAWE6cIqzLP2dtCN_O06duv/s1600/ejb-jar.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;color: #555555; font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #555555; font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;ejb-name :&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Give any name for the EJB&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;home:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;EJBHome class FQDN (Fully qualified defined name)&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;remote:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Remote class FQDN (Fully qualified defined name)&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;ejb-class :&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Session bean class FQDN (Fully qualified defined name)&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;session-type:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Stateful or Stateless (in our case Stateful)&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;transaction-type:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;Container | Bean (let container handle this)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;As we are deploying on weblogic , we need weblogic-ejb-jar.xml so that weblogic can treat this as an EJB Component and set the configuration at deploy time(&lt;strong&gt;JNDI&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;name, security related etc).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHVMcWRQQyyNwXI3p8ZYIei3SYuAZcAaR97wqHRcDaxHyYf8hxI_ZcrwDgkVWQfiQood4M2QvTnWzIwxRAdbmyw5dQxy9jou3iiT3cUpuOTJAB9YDtN1htuNb8xGUC4uyV0TpR_ElDbYtA/s1600/weblogic-ejb-jar.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHVMcWRQQyyNwXI3p8ZYIei3SYuAZcAaR97wqHRcDaxHyYf8hxI_ZcrwDgkVWQfiQood4M2QvTnWzIwxRAdbmyw5dQxy9jou3iiT3cUpuOTJAB9YDtN1htuNb8xGUC4uyV0TpR_ElDbYtA/s1600/weblogic-ejb-jar.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;color: #555555; font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #555555; font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;ejb-name:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;make sure to use the same ejb-name defined in ejb-jar.xml&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;jndi-name:&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #003300; font-family: Verdana; font-size: 9pt;&quot;&gt;this is the name of the JNDI given the EJB component.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 48.75pt; mso-list: l0 level1 lfo1; tab-stops: list 48.75pt; text-indent: -30.75pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;5.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Deployment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;To deploy simply extract the jar of the EJB classes and deploy in the admin console of weblogic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;Structure of the EJB Jar:&lt;/span&gt;&lt;/strong&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;———————————————————————————–|&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;com.test&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;META-INF&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;– ejb-jar.xml&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;– weblogic-ejb-jar.xml&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;– manifest&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f4f5f7; background-image: initial; background-origin: initial; color: navy; font-family: Verdana; font-size: 9pt;&quot;&gt;————————————————————————————|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;In case of stateless, keep everything same and change the bean create method to no-arg.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;And change the &lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&lt;session-type&gt;stateless&lt;/session-type&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: maroon; font-family: Verdana; font-size: 9pt;&quot;&gt;Client to test&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;final&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;String&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;JNDI_FACTORY&lt;/em&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;= “weblogic.jndi.WLInitialContextFactory”;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;main(String[] args)&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;throws&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Exception {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;InitialContext ic =&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;getInitialContext&lt;/em&gt;(“t3://localhost:7001″);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;CounterHome home = (CounterHome) PortableRemoteObject.&lt;em&gt;&lt;u&gt;narrow&lt;/u&gt;&lt;/em&gt;(ic&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;.lookup(“&lt;strong&gt;TestStateful&lt;/strong&gt;“), CounterHome.&lt;strong&gt;class&lt;/strong&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;Counter adv = home.create(“&lt;strong&gt;ejbMarathon&lt;/strong&gt;“);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;adv.startCounter();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;adv.startCounter();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;System.&lt;em&gt;out&lt;/em&gt;.println(adv.getCounter());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;InitialContext getInitialContext(String url)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;throws&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;NamingException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;Hashtable&lt;string, string=&quot;&quot;&gt; env =&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;new&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Hashtable&lt;string, string=&quot;&quot;&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/string,&gt;&lt;/string,&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;env.put(Context.&lt;em&gt;INITIAL_CONTEXT_FACTORY&lt;/em&gt;,&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;JNDI_FACTORY&lt;/em&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;env.put(Context.&lt;em&gt;PROVIDER_URL&lt;/em&gt;, url);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;env.put(Context.&lt;em&gt;SECURITY_PRINCIPAL&lt;/em&gt;, “&lt;strong&gt;ejbuser&lt;/strong&gt;“);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;env.put(Context.&lt;em&gt;SECURITY_CREDENTIALS&lt;/em&gt;, “&lt;strong&gt;PASSWORD123&lt;/strong&gt;“);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;env.put(“weblogic.jndi.createIntermediateContexts”, “true”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;return&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;InitialContext(env);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;color: #555555; font-family: Verdana; font-size: 9pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F4F5F7; line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;----------------------------------------- END -----------------------------------------&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/3981953767675298522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2012/02/deploying-ejb-2-stateful-bean-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3981953767675298522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/3981953767675298522'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2012/02/deploying-ejb-2-stateful-bean-on.html' title='Deploying EJB 2 Stateful Bean on Weblogic'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQiGXpbyOTrcOMhVz0sEqOS7duT2fc5jw690YgiYQyhqZvSwR6aS5eYWkLMIwsv8Hon-xdDilq6dSmsvfU6OrQJ-dLIBZ6-CpicBCwXTgOIeXvoplkPLWwyAWE6cIqzLP2dtCN_O06duv/s72-c/ejb-jar.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-6646535060029336526</id><published>2012-01-04T00:35:00.000+05:30</published><updated>2014-02-21T09:49:15.536+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Serialization"/><title type='text'>Java Serialization</title><content type='html'>&lt;div class=&quot;MsoNormal&quot;&gt;Serialization involves saving the current state of an object to a stream, and restoring an equivalent object from that stream. The stream functions as a container for the object. Its contents include a partial representation of the object&#39;s internal structure, including variable types, names, and values. The container may be transient (RAM-based) or persistent (disk-based). A transient container may be used to prepare an object for transmission from one computer to another. A persistent container, such as a file on disk, allows storage of the object after the current session is finished. In both cases the information stored in the container can later be used to construct an equivalent object containing the same data as the original. &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The serialized objects are JVM independent and can be re-serialized by any JVM. In this case the &quot;in memory&quot; java objects state are converted into a byte stream. This type of the file can not be understood by the user. It is a special types of object i.e. reused by the JVM (Java Virtual Machine). This process of serializing an object is also called&amp;nbsp;deflating&amp;nbsp;or&amp;nbsp;marshalling&amp;nbsp;an object. The example code in this article will focus on persistence.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14.0pt;&quot;&gt;Implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14.0pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;For an object to be serialized, it must be an instance of a class that implements either the Serializable or Externalizable interface. Both interfaces only permit the saving of data associated with an object&#39;s variables. They depend on the class definition being available to the Java Virtual Machine at reconstruction time in order to construct the object.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The Serializable interface relies on the Java runtime default mechanism to save an object&#39;s state. Writing an object is done via the writeObject() method in the ObjectOutputStream class (or the ObjectOutput interface). Writing a primitive value may be done through the appropriate write&lt;datatype&gt;() method. Reading the serialized object is accomplished using the readObject() method of the ObjectInputStream class, and primitives may be read using the various read&lt;datatype&gt;() methods.&lt;/datatype&gt;&lt;/datatype&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The Externalizable interface specifies that the implementing class will handle the serialization on its own, instead of relying on the default runtime mechanism. This includes which fields get written (and read), and in what order. The class must define a writeExternal() method to write out the stream, and a corresponding readExternal() method to read the stream. Inside of these methods the class calls ObjectOutputStream writeObject(), ObjectInputStream readObject(), and any necessary write&lt;datatype&gt;() and read&lt;datatype&gt;() methods, for the desired fields.&lt;/datatype&gt;&lt;/datatype&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14.0pt;&quot;&gt;Hiding Data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Sometimes you may wish to prevent certain fields from being stored in the serialized object. The Serializable interface allows the implementing class to specify that some of its fields do not get saved or restored. This is accomplished by placing the keyword transient before the data type in the variable declaration. For example, you may have some data which is confidential and can be re-read from a master file later (as opposed to saving it with the serialized object). Or you decide (wisely) to preserve the privacy of file references by declaring any such variables as transient. Otherwise, all fields automatically get written without any additional effort by the class.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;In addition to those fields declared as transient, static fields are not serialized (written out), and so cannot be deserialized (read back in).&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Another way to use Serializable, and control which fields get written, is to override the writeObject() method of the Serializable interface. Inside of this method, you are responsible for writing out the appropriate fields. If you take this approach, you will want to override readObject() as well, to control the restoration process. This is similar to using Externalizable, except that interface requires writeExternal() and readExternal().&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;For the Externalizable interface, since both writeExternal() and readExternal() must be declared public, this increases the risk that a rogue object could use them to determine the format of the serialized object. For this reason, you should be careful when saving object data with this interface.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14.0pt;&quot;&gt;Versioning&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The ability to save and restore objects leads to an interesting question: what happens when an object has been stored for so long, that upon restoration it finds that its format has been superceded by a new, different version of the class?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The stream reading the serialized representation is responsible for accounting for any differences. The intent is that a newer version of a Java class should be able to interoperate with older representations of the same class, as long as there have not been certain changes in the class structure. The same does not necessarily hold true for an older version of the class, which may not be able to effectively deal with a newer representation.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;So, we need some way to determine at runtime (or more appropriately, deserialization-time) whether we have the necessary backward compatibility.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;In Java 1.1, changes to classes may be specified using a version number. A specific class variable, serialVersionUID (representing the Stream Unique Identifier, or SUID), may be used to specify the earliest version of the class that can be deserialized. The SUID is declared as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; static final long serialVersionUID = 2L;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;This particular declaration and assignment specifies that version 2 is as far back as this class can go. It is not compatible with an object written by version 1 of the class, and it cannot write a version 1 object. If it encounters a version 1 object in a stream (such as when restoring from a file), an InvalidClassException will be thrown.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The SUID is a measure of backward compatibility. The same SUID can be used for multiple representations of a class, as long as newer versions can still read the older versions.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If you do not explicitly assign a SUID, a default value will be assigned when the object gets serialized. This default SUID is a hash, or unique numeric value, which is computed using the class name, interfaces, methods, and fields. The exact algorithm is defined by the S ecure Hash Algorithm (SHA).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;How can you obtain the SUID for a class at runtime to determine compatibility? First, query the Virtual Machine for information about the class represented in the stream, using methods of the class ObjectStreamClass. Here is how we can get the SUID of the current version of the class named MyClass, as known to the Virtual Machine:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;ObjectStreamClass myObject = ObjectStreamClass.lookup(&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Class.forName( &quot;MyClass&quot; ) );&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;long theSUID = myObject.getSerialVersionUID();&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Now when we restore an Externalizable object, we can compare its SUID to the class SUID just obtained. If there is a mismatch, we should take appropriate action. This may involve telling the user that we cannot handle the restoration, or we may have to assign and use some default values.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If we are restoring a Serializable object, the runtime will check the SUID for us when it attempts to read values from the stream. If you override readObject(), you will want to compare the SUIDs there.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;How do you determine what changes between class versions are acceptable? For an earlier version, which may contain fewer fields, trying to read a serialized object from a later version of the same class may cause problems. There is a tendency to add fields to a class as that class evolves, which means that the earlier version does not know about the newer fields. In contrast, since a newer version of a class may look for fields that are not present in the older version, it assigns default values to those fields.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;This can be seen in the example code when we add a new field to the MyVersionObject class, but don&#39;t update the SUID. The new class can still read the older stream representation, even though no values exist in that stream for the new fields. It assigns 0 to the new int, and null to the new String, but doesn&#39;t throw any exceptions. If we then increment the SUID (from 1 to 2) to indicate that we do not consider older class versions compatible with this version, we throw an InvalidClassException when attempting to read a version 1 object from the stream.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14.0pt;&quot;&gt;Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;The following program illustrates how to use object serialization and deserialization. It begins by instantiating an object of class&amp;nbsp;MyClass. This object has three instance variables that are of types&amp;nbsp;String,&amp;nbsp;int, anddouble. This is the information we want to save and restore.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;A&amp;nbsp;FileOutputStream&amp;nbsp;is created that refers to a file named &quot;serial,&quot; and an&amp;nbsp;ObjectOutputStream&amp;nbsp;is created for that file stream. The&amp;nbsp;writeObject()&amp;nbsp;method of&amp;nbsp;ObjectOutputStream&amp;nbsp;is then used to serialize our object. The object output stream is flushed and closed.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;A&amp;nbsp;FileInputStream&amp;nbsp;is then created that refers to the file named &quot;serial,&quot; and an&amp;nbsp;ObjectInputStream&amp;nbsp;is created for that file stream. The&amp;nbsp;readObject()&amp;nbsp;method of&amp;nbsp;ObjectInputStream&amp;nbsp;is then used to deserialize our object. The object input stream is then closed.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Note that&amp;nbsp;MyClass&amp;nbsp;is defined to implement the&amp;nbsp;Serializable&amp;nbsp;interface. If this is not done, aNotSerializableException&amp;nbsp;is thrown. Try experimenting with this program by declaring some of theMyClass&amp;nbsp;instance variables to be&amp;nbsp;transient. That data is then not saved during serialization.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;background: #FAFAFA; color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;SerializationDemo.java&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;background: #FAFAFA; color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;import java.io.*;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;public class SerializationDemo {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;public static void main(String args[]) {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;// Object serialization&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;try {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;MyClass object1 = new MyClass(&quot;Hello&quot;, -7, 2.7e10);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.out.println(&quot;object1: &quot; + object1);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;FileOutputStream fos = new FileOutputStream(&quot;serial&quot;);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;ObjectOutputStream oos = new ObjectOutputStream(fos);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;oos.writeObject(object1);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;oos.flush();&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;oos.close();&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;catch(Exception e) {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.out.println(&quot;Exception during serialization: &quot; + e);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.exit(0);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;// Object deserialization&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;try {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;MyClass object2;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;FileInputStream fis = new FileInputStream(&quot;serial&quot;);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;ObjectInputStream ois = new ObjectInputStream(fis);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;object2 = (MyClass)ois.readObject();&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;ois.close();&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.out.println(&quot;object2: &quot; + object2);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;catch(Exception e) {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.out.println(&quot;Exception during deserialization: &quot; +&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;e);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;System.exit(0);&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;background: #FAFAFA; color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;MyClass.java&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;background: #FAFAFA; color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;class MyClass implements Serializable {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #666666; font-family: &amp;quot;Trebuchet MS&amp;quot;;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;String s;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;int i;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;double d;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;public MyClass(String s, int i, double d) {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;this.s = s;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;this.i = i;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;this.d = d;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;public String toString() {&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;return &quot;s=&quot; + s + &quot;; i=&quot; + i + &quot;; d=&quot; + d;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: #FAFAFA;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;This program demonstrates that the instance variables of&amp;nbsp;object1&amp;nbsp;and&amp;nbsp;object2&amp;nbsp;are&lt;br /&gt;
identical. The output is shown here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;object1: s=Hello; i=-7; d=2.7E10&lt;br /&gt;
object2: s=Hello; i=-7; d=2.7E10&lt;/b&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/6646535060029336526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2012/01/java-serialization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6646535060029336526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/6646535060029336526'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2012/01/java-serialization.html' title='Java Serialization'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-5064433874132142142</id><published>2011-11-21T00:19:00.005+05:30</published><updated>2014-02-21T09:49:25.955+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Parsing XML Files in Java"/><title type='text'>Parsing XML Files in Java</title><content type='html'>&lt;h1 style=&quot;background: white; line-height: 15.0pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: 12pt;&quot;&gt;How to read XML file in Java – (DOM Parser)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;The DOM interface is the easiest XML parser to understand, and use. It parses an entire XML document and loads it into memory, modelling it with Object for easy traversal or manipulation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;DOM Parser is slow and consume a lot of memory if it load a XML document which contains a lot of data. Please consider SAX parser as solution for it, SAX is faster than DOM and use less memory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;DOM Parser Example&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;A DOM XML parser read below XML file and print out each elements one by one.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;File : file.xml&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtzUt9Pp3LQpoN-W7H0eDsqAeqRpiFN_piuSgMCBqEEzP4SVZqrJbTWp_laXJ2CCS28y_GdjNQqFASVt6IW11fUtcqHkin0doHVWTtQ2iu70b02EIcKGh6SDqGvKR0FxOZ5-P15nU3IX1/s1600/xml1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtzUt9Pp3LQpoN-W7H0eDsqAeqRpiFN_piuSgMCBqEEzP4SVZqrJbTWp_laXJ2CCS28y_GdjNQqFASVt6IW11fUtcqHkin0doHVWTtQ2iu70b02EIcKGh6SDqGvKR0FxOZ5-P15nU3IX1/s400/xml1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #009900;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;File : ReadXMLFile.java&lt;/span&gt;&lt;/em&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;– A Java class to read above XML file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;javax.xml.parsers.DocumentBuilderFactory&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;javax.xml.parsers.DocumentBuilder&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.w3c.dom.Document&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.w3c.dom.NodeList&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.w3c.dom.Node&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.w3c.dom.Element&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;java.io.File&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; ReadXMLFile &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; argv&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;[])&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; fXmlFile &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;c:&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000099; font-size: 9pt;&quot;&gt;\\&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;file.xml&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentBuilderFactory dbFactory &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; DocumentBuilderFactory.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentBuilder dBuilder &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; dbFactory.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;newDocumentBuilder&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Document&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; doc &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; dBuilder.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;fXmlFile&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getDocumentElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;normalize&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Root element :&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; doc.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getDocumentElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getNodeName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NodeList nList &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; doc.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;staff&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;-----------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; temp &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; temp &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; nList.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getLength&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; temp&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Node nNode &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; nList.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;item&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;temp&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;nNode.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getNodeType&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; Node.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;ELEMENT_NODE&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Element&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; eElement &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Element&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; nNode&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;First Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; getTagValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;firstname&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, eElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Last Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; getTagValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;lastname&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, eElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Nick Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; getTagValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;nickname&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, eElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Salary : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; getTagValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;salary&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, eElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Exception&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;printStackTrace&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;private&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; getTagValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; sTag, &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Element&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; eElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NodeList nlList &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; eElement.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;sTag&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;item&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getChildNodes&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Node nValue &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Node&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; nlList.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;item&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; nValue.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;getNodeValue&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;Result:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Root element :company&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #660033; font-size: 9pt;&quot;&gt;-----------------------&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;First Name : yong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Last Name : mook kim&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Nick Name : mkyong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Salary : &lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;First Name : low&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Last Name : yin fong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Nick Name : fong fong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Salary : &lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;200000&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1 style=&quot;background: white; line-height: 15.0pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;How to read XML file in Java – (SAX Parser)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10pt;&quot;&gt;SAX parser&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;is work differently than DOM parser, it neither load any XML document into memory nor create any object representation of the XML document. Instead, the SAX parser use callback function (&lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;org.xml.sax.helpers.DefaultHandler&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;) to informs clients of the XML document structure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;Note&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;SAX Parser is faster and uses less memory than DOM parser.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.0pt; margin-bottom: 15.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;See following SAX callback methods :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.0pt; margin-left: 10.5pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 10pt;&quot;&gt;§&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;startDocument()&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;and&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;endDocument()&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;– Method called at the start and end of an XML document.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.0pt; margin-left: 10.5pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 10pt;&quot;&gt;§&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;startElement()&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;and&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;endElement()&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;– Method called at the start and end of a document element.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; line-height: 15.0pt; margin-left: 10.5pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 10pt;&quot;&gt;§&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;characters()&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;– Method called with the text contents in between the start and end tags of an XML document element.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;File : file.xml&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtzUt9Pp3LQpoN-W7H0eDsqAeqRpiFN_piuSgMCBqEEzP4SVZqrJbTWp_laXJ2CCS28y_GdjNQqFASVt6IW11fUtcqHkin0doHVWTtQ2iu70b02EIcKGh6SDqGvKR0FxOZ5-P15nU3IX1/s1600/xml1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtzUt9Pp3LQpoN-W7H0eDsqAeqRpiFN_piuSgMCBqEEzP4SVZqrJbTWp_laXJ2CCS28y_GdjNQqFASVt6IW11fUtcqHkin0doHVWTtQ2iu70b02EIcKGh6SDqGvKR0FxOZ5-P15nU3IX1/s400/xml1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #009900;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;File : ReadXMLFile.java&lt;/span&gt;&lt;/em&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;– A Java class to read above XML file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;javax.xml.parsers.SAXParser&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;javax.xml.parsers.SAXParserFactory&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.xml.sax.Attributes&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.xml.sax.SAXException&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;import&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #006699; font-size: 9pt;&quot;&gt;org.xml.sax.helpers.DefaultHandler&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; ReadXMLFile &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; argv&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;[])&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAXParserFactory factory &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; SAXParserFactory.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAXParser saxParser &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; factory.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;newSAXParser&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DefaultHandler handler &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; DefaultHandler&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; bfname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; blname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; bnname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; bsalary &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; startElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; uri, &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; localName,&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; qName, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Attributes&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; attributes&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;throws&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; SAXException &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Start Element :&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; qName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;qName.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;FIRSTNAME&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bfname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;qName.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;LASTNAME&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;qName.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;NICKNAME&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bnname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;qName.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;SALARY&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bsalary &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; endElement&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; uri, &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; localName,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; qName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;throws&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; SAXException &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;End Element :&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; qName&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; characters&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;char&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; ch&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; start, &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;throws&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; SAXException &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;bfname&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;First Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;ch, start, length&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bfname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;blname&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Last Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;ch, start, length&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;bnname&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Nick Name : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;ch, start, length&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bnname &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;bsalary&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;Salary : &quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;ch, start, length&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bsalary &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; saxParser.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;c:&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000099; font-size: 9pt;&quot;&gt;\\&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;file.xml&quot;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;, handler&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Exception&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; e&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;printStackTrace&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;em&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;Result:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :company&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :staff&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :firstname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;First Name : yong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :firstname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :lastname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Last Name : mook kim&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :lastname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :nickname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Nick Name : mkyong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :nickname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :salary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Salary : &lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :salary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :staff&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :staff&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :firstname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;First Name : low&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :firstname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :lastname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Last Name : yin fong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :lastname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :nickname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Nick Name : fong fong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :nickname&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Start Element :salary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;Salary : &lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;200000&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :salary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :staff&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;End Element :company&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial; font-size: 10pt;&quot;&gt;Warning&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size: 10.5pt;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial;&quot;&gt;This example may encounter exceptions for&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial; font-size: 10pt;&quot;&gt;UTF-8&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7da; background-image: initial; background-origin: initial; font-size: 10.5pt;&quot;&gt;XML file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;if you parse a XML file which contains some special UTF-8 characters, it will prompts “&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;Invalid byte 1 of 1-byte UTF-8 sequence&lt;span class=&quot;apple-style-span&quot;&gt;” exception.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;com.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;sun&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;org&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;apache&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;xerces&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;impl&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;io&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;MalformedByteSequenceException&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Invalid&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; of &lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;-&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066; font-size: 9pt;&quot;&gt;byte&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; UTF&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #cc66cc; font-size: 9pt;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; sequence.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 10.5pt;&quot;&gt;See following xml file which contain a special UTF-8 characters “§”&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTFIOLhGuErELxNYEBVM0_0JGQSbnk8No1GzIofOG39GzKpBv7HLujsQnDtQvEG66u23nvOvOMi58yA5RtWmDgq4VrSmw6CNFDuKC_z7rg0hqrETBBOLKx9NXjJEie5A2rZrP7_LoUNDaN/s1600/xml2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTFIOLhGuErELxNYEBVM0_0JGQSbnk8No1GzIofOG39GzKpBv7HLujsQnDtQvEG66u23nvOvOMi58yA5RtWmDgq4VrSmw6CNFDuKC_z7rg0hqrETBBOLKx9NXjJEie5A2rZrP7_LoUNDaN/s400/xml2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;pre style=&quot;background: #F9F9F9;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px;&quot;&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background: white; line-height: 15.0pt; margin-bottom: 15.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;span style=&quot;font-family: Arial; font-size: 10.5pt;&quot;&gt;To fix it, just override the SAX input source like this :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background: white; float: none; overflow-x: visible; overflow-y: visible; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; file &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;c:&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000099; font-size: 9pt;&quot;&gt;\\&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;file-utf.xml&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;InputStream&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; inputStream&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;FileInputStream&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;Reader&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; reader &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #003399; font-size: 9pt;&quot;&gt;InputStreamReader&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;inputStream,&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;InputSource is &lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt; InputSource&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;is.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;setEncoding&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 9pt;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;saxParser.&lt;/span&gt;&lt;span style=&quot;color: #006633; font-size: 9pt;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;is, handler&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #110000; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: white; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #339933; font-size: 9pt;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/5064433874132142142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/11/parsing-xml-files-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/5064433874132142142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/5064433874132142142'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/11/parsing-xml-files-in-java.html' title='Parsing XML Files in Java'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtzUt9Pp3LQpoN-W7H0eDsqAeqRpiFN_piuSgMCBqEEzP4SVZqrJbTWp_laXJ2CCS28y_GdjNQqFASVt6IW11fUtcqHkin0doHVWTtQ2iu70b02EIcKGh6SDqGvKR0FxOZ5-P15nU3IX1/s72-c/xml1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-7685265059440667369</id><published>2011-08-24T11:15:00.000+05:30</published><updated>2014-02-21T09:49:37.835+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Few Important UML Diagrams"/><title type='text'>Few Important UML Diagrams</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;Normalasian&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The Unified Modeling Language (UML) is a standard&amp;nbsp;language for specifying, visualizing, constructing, and documenting the artifacts of software systems, as well as for business modeling and other non-software systems. The UML represents a collection of best engineering practices that have proven successful in the modeling of large and complex systems. The UML is a very important part of developing objects oriented software and the software development process.&amp;nbsp; The UML uses mostly graphical notations to express the design of software projects.&amp;nbsp; Using the UML helps project teams communicate, explore potential designs, and validate the architectural design of the software.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The Unified Modeling Language (UML) is used to specify, visualize, modify, construct and document the&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;artifacts&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;of an object-oriented software-intensive system under development.&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;UML offers a standard way to visualize a system&#39;s architectural blueprints, including elements such as:&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;activities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;actors&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;business processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;database&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;schemas&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;(logical)&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;components&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;programming language&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;statements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Reusable&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;software components.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 1.2pt; margin-right: 0cm; mso-margin-top-alt: auto; mso-pagination: widow-orphan;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-bottom: 6.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;UML combines techniques from&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;data modeling&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(entity relationship diagrams),&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;business modeling&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(work flows),&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;object modeling, and component modeling. It can be used with all processes, throughout the&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;software development life cycle, and across different implementation technologies.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 6pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; line-height: 24px;&quot;&gt;&lt;h1 style=&quot;font-size: x-large;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;_Toc274140054&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14pt;&quot;&gt;Use-Case D&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14pt;&quot;&gt;iagram&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: maroon;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 14pt; line-height: normal; margin-right: 0cm;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black; font-size: 12pt; font-weight: normal;&quot;&gt;A use case is a set of scenarios that describing an interaction between a user and a system.&amp;nbsp; A use case diagram displays the relationship among actors and use cases.&amp;nbsp;The two main components of a use case diagram are use cases and actors.&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 14pt; line-height: normal; margin-right: 0cm;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black; font-size: 12pt; font-weight: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 14pt; line-height: normal; margin-right: 0cm;&quot;&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id=&quot;_x0000_t75&quot; coordsize=&quot;21600,21600&quot;
 o:spt=&quot;75&quot; o:preferrelative=&quot;t&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; filled=&quot;f&quot;
 stroked=&quot;f&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;/&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;/&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;/&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;/&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;/&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;/&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;/&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;/&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;/&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;/&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;/&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;/&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;/&gt;  &lt;/v:formulas&gt;  &lt;v:path o:extrusionok=&quot;f&quot; gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot;/&gt;  &lt;o:lock v:ext=&quot;edit&quot; aspectratio=&quot;t&quot;/&gt; &lt;/v:shapetype&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; type=&quot;#_x0000_t75&quot; alt=&quot;&quot; style=&#39;width:251.25pt;
 height:96pt&#39;&gt;  &lt;v:imagedata src=&quot;file:///C:\Users\Roy\AppData\Local\Temp\msohtml1\01\clip_image001.jpg&quot;
  o:href=&quot;http://atlas.kennesaw.edu/~dbraun/csis4650/A&amp;amp;D/UML_tutorial/images/actor.jpg&quot;/&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 13.5pt; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkqfe_a-wuQ3MSoMe_jvbCQKa-YYJAvSvpXTzB-BNXOurlmANKHEZ27oBS7YMaY6I_h2OhU-JAXuSM3OybojS3EydX-20MTlk_hUpoTSYd-yR585FoauleqZjdM4eTwQU2Dv7EVBKgHcGe/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkqfe_a-wuQ3MSoMe_jvbCQKa-YYJAvSvpXTzB-BNXOurlmANKHEZ27oBS7YMaY6I_h2OhU-JAXuSM3OybojS3EydX-20MTlk_hUpoTSYd-yR585FoauleqZjdM4eTwQU2Dv7EVBKgHcGe/s320/1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 14pt; line-height: normal; margin-right: 0cm;&quot;&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;An actor is represents a user or another system that will interact with the system you are modeling.&amp;nbsp;A use case is an external view of the system that represents some action the user might perform in order to complete a task.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;Normalasian&quot; style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3 style=&quot;font-size: 14pt; margin-left: 0cm; text-indent: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;When to Use: Use Cases Diagrams&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Use cases are used in almost every project. They are helpful in exposing requirements and planning the project. During the initial stage of a project most use cases should be defined, but as the project continues more might become visible.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black; font-size: 14pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: list 0cm; text-align: justify; text-justify: inter-ideograph;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;st1:place&gt;&lt;st1:placename&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; mso-bidi-font-style: italic;&quot;&gt;Diagram&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; mso-bidi-font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;st1:placetype&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; mso-bidi-font-style: italic;&quot;&gt;Building&lt;/span&gt;&lt;/b&gt;&lt;/st1:placetype&gt;&lt;/st1:place&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; mso-bidi-font-style: italic;&quot;&gt; Blocks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: list 0cm; text-align: justify; text-justify: inter-ideograph;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; mso-bidi-font-style: italic;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l2 level1 lfo1; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Use cases&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-bottom: 6.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;A use case describes a sequence of actions that provide something of measurable value to an actor and is drawn as a horizontal ellipse.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l1 level1 lfo2; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Actors&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-bottom: 6.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;An actor is a person, organization, or external system that plays a role in one or more interactions with the system.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; margin-bottom: 1.2pt; margin-left: 19.2pt; margin-right: 0cm; mso-list: l0 level1 lfo3; mso-margin-top-alt: auto; mso-pagination: widow-orphan; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Wingdings;&quot;&gt;&lt;span&gt;§&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;System boundary boxes (optional)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-bottom: 6.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;A rectangle is drawn around the use cases, called the system boundary box, to indicate the scope of system. Anything within the box represents functionality that is in scope and anything outside the box is not.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; font-size: 19px; line-height: 24px;&quot;&gt;&lt;h1&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; font-size: 19px; line-height: 24px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/h1&gt;How to Draw: Use Cases Diagrams&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 18pt; margin-bottom: 6pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Use cases are a relatively easy UML diagram to draw, but this is a very simplified example.&amp;nbsp; This example is only meant as an introduction to the UML and use cases.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;  &lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Start by listing a sequence of steps a user might take in order to complete an action.&amp;nbsp; For example a user placing an order with a sales company might follow these steps.&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial;&quot;&gt;&lt;span&gt;1.&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Browse catalog and select items.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial;&quot;&gt;&lt;span&gt;2.&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Call sales representative.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial;&quot;&gt;&lt;span&gt;3.&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Supply shipping information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial;&quot;&gt;&lt;span&gt;4.&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Supply payment information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial;&quot;&gt;&lt;span&gt;5.&lt;span style=&quot;font: 7.0pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;Receive conformation number from salesperson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; font-weight: normal; line-height: normal; margin-left: 72pt; margin-right: 36pt; text-indent: -18pt;&quot;&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;These steps would generate this simple use case diagram:&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-weight: normal; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT9c9jWoqdeBK9Q4-mRUB_nag2XZ_uf3BrwmBFYXbPwAjJBVpkL0UwP5IRtbtU03U9MhzVzfrGpevS7Xz2ncEXoDJVXXvsT9cfmDNq53PCiVvry0-ismVARVwNQZbIpUw2suy1qaI5xBEw/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT9c9jWoqdeBK9Q4-mRUB_nag2XZ_uf3BrwmBFYXbPwAjJBVpkL0UwP5IRtbtU03U9MhzVzfrGpevS7Xz2ncEXoDJVXXvsT9cfmDNq53PCiVvry0-ismVARVwNQZbIpUw2suy1qaI5xBEw/s400/2.jpg&quot; width=&quot;356&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial; font-size: 14pt;&quot;&gt;Class Diagram&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial; font-size: 14pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;&quot;&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;software engineering, a&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;class diagram&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;in the&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;Unified Modeling Language&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;(UML) is a type of static structure diagram that describes the structure of a system by showing the system&#39;s&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;classes, their attributes, operations (or methods), and the relationships among the classes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;The class diagram is the main building block in&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;object oriented&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;modeling. It is used both for general&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;conceptual modeling&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;of the systematic of the application, and for detailed modeling translating the models into&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;&quot;&gt;programming code. The classes in a class diagram represent both the main objects and or interactions in the application and the objects to be programmed. In the class diagram these classes are represented with boxes which contain three parts:&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-right: 0cm; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan;&quot;&gt;&lt;span style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;Classes are composed of three things: a name, attributes, and operations.&amp;nbsp; Below is an example of a class.&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-right: 0cm; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan;&quot;&gt;&lt;span style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxiz4YNR3kh2z0RgPln3bYrk98MTLHcReNCtPr8mAx4Qn_79PaicpQ_SMvRLFkcCVSTqyzj2rsL6ov1bFqlNtHydECrYrdrVZfFcHFnaRPcEEB6lhoUEAKLchCqKKe7kpIzhBAYYkKi6xx/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;162&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxiz4YNR3kh2z0RgPln3bYrk98MTLHcReNCtPr8mAx4Qn_79PaicpQ_SMvRLFkcCVSTqyzj2rsL6ov1bFqlNtHydECrYrdrVZfFcHFnaRPcEEB6lhoUEAKLchCqKKe7kpIzhBAYYkKi6xx/s400/1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-right: 0cm; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan;&quot;&gt;&lt;span style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-right: 0cm; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan;&quot;&gt;&lt;span style=&quot;background: white; color: black; font-size: 12.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: SimSun; mso-fareast-language: ZH-CN;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Class diagrams also display relationships such as containment, inheritance, associations and others.&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Below is an example of an associative relationship:&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihUlDiKCNKYZApL3PBSMO_lm4qFZqs6fSChpbQ2KK7uq6YcfymZDUjpsc230Aj4VcObAlhm3CcUZZP6RyWZIl88WbcGMKlqTsQD32GdXHvUXYs31QHpI3G0cKpkyACNgIJc1Vu3cMcvOUy/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihUlDiKCNKYZApL3PBSMO_lm4qFZqs6fSChpbQ2KK7uq6YcfymZDUjpsc230Aj4VcObAlhm3CcUZZP6RyWZIl88WbcGMKlqTsQD32GdXHvUXYs31QHpI3G0cKpkyACNgIJc1Vu3cMcvOUy/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;The association relationship is the most common relationship in a class diagram.&amp;nbsp; The association shows the relationship between instances of classes.&amp;nbsp; For example, the class Order is associated with the class Customer.&amp;nbsp; The multiplicity of the association denotes the number of objects that can participate in then relationship.&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;For example, an Order object can be associated to only one customer, but a customer can be associated to many orders.&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Another common relationship in class diagrams is a generalization.&amp;nbsp; A generalization is used when two classes are similar, but have some differences.&amp;nbsp; Look at the generalization below:&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ-fgeEjoaCFlFFE3hE6BxE_7k3h1FyjqTF8U12AxIPXMcPl56ERTjRrv9d1V44c7LzQDja9CmjDLl6kkQ6MXE7qcQtP6v-F3Ozd_snK-rUNXMMiKhyVYhyGAVqamttFPw2SGZee5UvvrU/s1600/3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;365&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ-fgeEjoaCFlFFE3hE6BxE_7k3h1FyjqTF8U12AxIPXMcPl56ERTjRrv9d1V44c7LzQDja9CmjDLl6kkQ6MXE7qcQtP6v-F3Ozd_snK-rUNXMMiKhyVYhyGAVqamttFPw2SGZee5UvvrU/s400/3.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;In this example the classes Corporate Customer and Personal Customer have some similarities such as name and address, but each class has some of its own attributes and operations.&amp;nbsp; The class Customer is a general form of both the Corporate Customer and Personal Customer classes.&lt;sup&gt; &lt;/sup&gt;This allows the designers to just use the Customer class for modules and do not require in-depth representation of each type of customer.&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;In this example the classes Corporate Customer and Personal Customer have some similarities such as name and address, but each class has some of its own attributes and operations.&amp;nbsp; The class Customer is a general form of both the Corporate Customer and Personal Customer classes. This allows the designers to just use the Customer class for modules and do not require in-depth representation of each type of customer.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;margin-left: 0cm; mso-list: none; text-indent: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;When to Use: Class Diagrams&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Class diagrams are used in nearly all Object Oriented software designs. Use them to describe the Classes of the system and their relationships to each other.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;margin-left: 0cm; mso-list: none; text-indent: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;How to Draw: Class Diagrams&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Class diagrams are some of the most difficult UML diagrams to draw.&amp;nbsp; To draw detailed and useful diagrams a person would have to study UML and Object Oriented principles for a long time.&amp;nbsp; Therefore, this page will give a very high level overview of the process.&amp;nbsp; To find list of where to find more information see the&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Resources page.&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;Before drawing a class diagram consider the three different perspectives of the system the diagram will present; conceptual, specification, and implementation.&amp;nbsp; Try not to focus on one perspective and try see how they all work together.&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;  &lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;When designing classes consider what attributes and operations it will have.&amp;nbsp; Then try to determine how instances of the classes will interact with each other. These are the very first steps of many in developing a class diagram.&amp;nbsp; However, using just these basic techniques one can develop a complete view of the software system.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-weight: normal; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoflTwX3kZKPviAFr8vqomp3b56eBLfkj1luYIhwbAXgbfTslpvsTtD3bDn2aB2dECCDyJxP38DMBVritRL_OewsINrqqbRJEjA6Bd0ABCCM11IDTyt1Yq1tiOkfnyCX1x4J7KCnpbOjU0/s1600/4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;277&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoflTwX3kZKPviAFr8vqomp3b56eBLfkj1luYIhwbAXgbfTslpvsTtD3bDn2aB2dECCDyJxP38DMBVritRL_OewsINrqqbRJEjA6Bd0ABCCM11IDTyt1Yq1tiOkfnyCX1x4J7KCnpbOjU0/s400/4.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Arial; font-size: 14pt;&quot;&gt;Sequence diagram&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: maroon; font-family: Arial; font-size: 14.0pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-US;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: maroon; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt; margin-bottom: 6pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial;&quot;&gt;A&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;sequence diagram&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;in&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Unified Modeling Language&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(UML) is a kind of&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;interaction diagram&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;that shows how processes operate with one another and in what order. It is a construct of a&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Message Sequence Chart. Sequence diagrams are sometimes called event diagrams, event scenarios, and&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;timing diagrams.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;A sequence diagram shows, as parallel vertical lines (&lt;/span&gt;&lt;i&gt;lifelines&lt;/i&gt;), different processes or objects that live simultaneously, and, as horizontal arrows, the messages exchanged between them, in the order in which they occur. This allows the specification of simple runtime scenarios in a graphical manner.&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAK2GT-Uu-vQJE1xE3unoYFzVPg5gIyEH_DOtB_CvVSy8rDNsOxXfuaxiI7FMr_l7LCdpxqQ4WqXH9qOfqkXFvO3OzZkmHYbQ8QN8uCn6JOvBCFjVPRbsSssxviATkk_ZwzGiPMKIs9rrF/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAK2GT-Uu-vQJE1xE3unoYFzVPg5gIyEH_DOtB_CvVSy8rDNsOxXfuaxiI7FMr_l7LCdpxqQ4WqXH9qOfqkXFvO3OzZkmHYbQ8QN8uCn6JOvBCFjVPRbsSssxviATkk_ZwzGiPMKIs9rrF/s400/1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;&quot; name=&quot;N10095&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 10.5pt; mso-bidi-font-family: Arial;&quot;&gt;Figure: A sequence diagram that has incoming and outgoing messages&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 10.5pt; mso-bidi-font-family: Arial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;&quot; name=&quot;N10095&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 10.5pt; mso-bidi-font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;&quot; name=&quot;N10095&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 10.5pt; mso-bidi-font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHkXyQ5h57C05duomX0sW7Cr7TZgKMyXXLWQpuvoIA4yCb2-k5STNAl-beD5veK1t19G6_7-qPNY41waMWPEEKWo1QdmWuJF05EKo4ZHX-zlLwhyphenhyphenkjgWo17_mFRrKdhny5QmXN71ydj67s/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;338&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHkXyQ5h57C05duomX0sW7Cr7TZgKMyXXLWQpuvoIA4yCb2-k5STNAl-beD5veK1t19G6_7-qPNY41waMWPEEKWo1QdmWuJF05EKo4ZHX-zlLwhyphenhyphenkjgWo17_mFRrKdhny5QmXN71ydj67s/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;&quot; name=&quot;N10095&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background: white; color: black; font-size: 10.5pt; mso-bidi-font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/7685265059440667369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/08/few-important-uml-diagrams.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7685265059440667369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7685265059440667369'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/08/few-important-uml-diagrams.html' title='Few Important UML Diagrams'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkqfe_a-wuQ3MSoMe_jvbCQKa-YYJAvSvpXTzB-BNXOurlmANKHEZ27oBS7YMaY6I_h2OhU-JAXuSM3OybojS3EydX-20MTlk_hUpoTSYd-yR585FoauleqZjdM4eTwQU2Dv7EVBKgHcGe/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-7657370485273918671</id><published>2011-06-14T02:42:00.001+05:30</published><updated>2014-02-21T09:49:51.183+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Factory Method Design Pattern in Java"/><title type='text'>Factory Method Design Pattern in Java</title><content type='html'>Let us examine a practical scenario which is suitable for factory method pattern.&lt;br /&gt;
We are developing an enterprise application. You are responsible for authentication module. But you are not sure how you are going to do authentication. You can have authentication against LDAP, database or any other centralized directory. So you first define an interface for authentication with single method authorize() This method returns true if user is successfully authenticated or false if not authenticated.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;interface&lt;/span&gt;&lt;/b&gt; UserAuthentication &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; authorize&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;OK, now let us create concreate implementation for this interface. Since you can have multiple ways of authenticating against users, you would like to create multiple derived classes.&lt;br /&gt;
Let us create a class which authenticate against users table in database using JDBC.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;class&lt;/span&gt;&lt;/b&gt; JDBCUserAuthentication &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;implements&lt;/span&gt;&lt;/b&gt; UserAuthentication &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; authorize&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; result&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;// implementation for authentication using JDBC&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//if authenticated&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//result=true&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//else&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//result=false&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;return&lt;/span&gt;&lt;/b&gt; result&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Similarly another class which authenticate against LDAP.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;class&lt;/span&gt;&lt;/b&gt; LDAPUserAuthentication &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;implements&lt;/span&gt;&lt;/b&gt; UserAuthentication &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; authorize&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; result&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;// implementation for authentication using LDAP&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//if authenticated&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//result=true&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//else&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//result=false&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;return&lt;/span&gt;&lt;/b&gt; result&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Well, now we have two implementations, one using JDBC and another using LDAP. Now let us create factory class.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;class&lt;/span&gt;&lt;/b&gt; UserAuthenticationFactory &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;public&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;static&lt;/span&gt;&lt;/b&gt; UserAuthentication getUserAuthentication&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #003399;&quot;&gt;String&lt;/span&gt; type&lt;span style=&quot;color: #009900;&quot;&gt;){&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;if&lt;/span&gt;&lt;/b&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;type.&lt;span style=&quot;color: #006633;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;jdbc&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)){&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;return&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;new&lt;/span&gt;&lt;/b&gt; JDBCUserAuthentication&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;else&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;type.&lt;span style=&quot;color: #006633;&quot;&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;ldap&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)){&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;return&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;new&lt;/span&gt;&lt;/b&gt; LDAPUserAuthentication&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;else&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;return&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;new&lt;/span&gt;&lt;/b&gt; JDBCUserAuthentication&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;In the above class we define a static method getUserAuthentication() which instantiates appropriate sub class based on parameter.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;When you do authentication your code snippet may be as follows.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre&gt;&lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//declare isAuthorized variable&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt; isAuthorized&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #000066;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//get UserAuthentication object&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;UserAuthentication userAuthentication&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UserAuthenticationFactory.&lt;span style=&quot;color: #006633;&quot;&gt;getUserAuthentication&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;jdbc&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;isAuthorized&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;userAuthentication.&lt;span style=&quot;color: #006633;&quot;&gt;authorize&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;isAuthorized&lt;span style=&quot;color: #009900;&quot;&gt;){&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//redirect to home page&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;else&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;//redirect to login page&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;Here we call static method of our factory class which in turn instantiates JDBCUserAuthentication class because we pass parameter as as “jdbc”. But the user who write client call for authentication do not require to know which derived class is instantiated and its implementation details.&lt;br /&gt;
I hope you got enough clarity about factory method pattern and its implementation in practical scenario.</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/7657370485273918671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/06/factory-method-design-pattern-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7657370485273918671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7657370485273918671'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/06/factory-method-design-pattern-in-java.html' title='Factory Method Design Pattern in Java'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-4537214803644327004</id><published>2011-06-10T00:20:00.002+05:30</published><updated>2014-02-21T09:50:04.792+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate 3.0"/><title type='text'>Hibernate 3.0</title><content type='html'>&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;What is Hibernate?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate 3.0, the latest Open Source persistence technology at the heart of J2EE EJB 3.0. Hibernate maps the Java classes to the database tables. It also provides the data query and retrieval facilities that significantly reduces the development time.&amp;nbsp; Hibernate is not the best solutions for data centric applications that only uses the stored-procedures to implement the business logic in database. It is most useful with object-oriented domain modes and business logic in the Java-based middle-tier. Hibernate allows transparent persistence that enables the applications to switch any database. Hibernate can be used in Java Swing applications, Java Servlet-based applications, or J2EE applications using EJB session beans.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;High level architecture of hibernate:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPoIL4LRfyqya9so3KC-_EHRl-WN2XC2i7res3Xk2K9_jvIXcRuVrXSRIpZfhPifh79GgPR59hhb7Qy7pIqqfAH-iRpPZgtB97G06xFl4aoF997kGOvyi7PED2Mr6mWSgW66vprVpjl1JO/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;382&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPoIL4LRfyqya9so3KC-_EHRl-WN2XC2i7res3Xk2K9_jvIXcRuVrXSRIpZfhPifh79GgPR59hhb7Qy7pIqqfAH-iRpPZgtB97G06xFl4aoF997kGOvyi7PED2Mr6mWSgW66vprVpjl1JO/s400/1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The above diagram shows that Hibernate is using the database and configuration data to provide persistence services (and&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;persistent objects) to the application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate architecture has three main components:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Connection Management&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt; margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Transaction management:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
Transaction management service provide the ability to the user to execute more than one database statements at a time.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt; margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt; margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Object relational mapping:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Session.save()&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;method, Hibernate reads the state of the variables of that object and executes the necessary query.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Configuring Hibernate&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;In this application Hibernate provided connection pooling and transaction management is used for simplicity. Hibernate uses the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;hibernate.cfg.xml&lt;/b&gt; to create the connection pool and setup required environment.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here is the code:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;/div&gt;&lt;property name=&quot;hibernate.hbm2ddl.auto&quot;&gt;&lt;span id=&quot;goog_1348935260&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1348935261&quot;&gt;&lt;/span&gt;&lt;/property&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi04HeyRNA1e-ux2KGNqIh-Hy3mpcL5p8EW0o7g0Pp4uJYKTZTuirxSQcHOAKhnm5pRvZUbftbUCDKjAIMtkm9HQW17XGiDNgTK10LUQttEsHouboBBD51xOodCXawhr85SZzOQ-DNZ2JIy/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi04HeyRNA1e-ux2KGNqIh-Hy3mpcL5p8EW0o7g0Pp4uJYKTZTuirxSQcHOAKhnm5pRvZUbftbUCDKjAIMtkm9HQW17XGiDNgTK10LUQttEsHouboBBD51xOodCXawhr85SZzOQ-DNZ2JIy/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt; &amp;nbsp; &lt;mapping resource=&quot;&amp;lt;b&amp;gt;contact.hbm.xml&amp;lt;/b&amp;gt;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/mapping&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;In the above configuration file we specified to use the &quot;&lt;b&gt;hibernatetutorial&quot;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;which is running on&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;localhost &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;and the user of the database is root with no password. The&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;dialect&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;property&amp;nbsp; is &lt;b&gt;org.hibernate.dialect.MySQLDialect&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;which tells the Hibernate that we are using MySQL Database. Hibernate supports many database. With the use of the&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;(Object/Relational Mapping and Transparent Object Persistence for Java and SQL Databases),&amp;nbsp;we can use the following databases dialect type property:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;DB2      -&amp;nbsp;org.hibernate.dialect.DB2Dialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;HypersonicSQL      -&amp;nbsp;org.hibernate.dialect.HSQLDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Informix      -&amp;nbsp;org.hibernate.dialect.InformixDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Ingres      -&amp;nbsp;org.hibernate.dialect.IngresDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Interbase      -&amp;nbsp;org.hibernate.dialect.InterbaseDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Pointbase      -&amp;nbsp;org.hibernate.dialect.PointbaseDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;PostgreSQL      -&amp;nbsp;org.hibernate.dialect.PostgreSQLDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Mckoi SQL      -&amp;nbsp;org.hibernate.dialect.MckoiDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Microsoft SQL Server      -&amp;nbsp;org.hibernate.dialect.SQLServerDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;MySQL      -&amp;nbsp;org.hibernate.dialect.MySQLDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Oracle (any version)      -&amp;nbsp;org.hibernate.dialect.OracleDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Oracle 9      -&amp;nbsp;org.hibernate.dialect.Oracle9Dialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Progress      -&amp;nbsp;org.hibernate.dialect.ProgressDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;FrontBase      -&amp;nbsp;org.hibernate.dialect.FrontbaseDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;SAP DB      -&amp;nbsp;org.hibernate.dialect.SAPDBDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Sybase -&amp;nbsp;org.hibernate.dialect.SybaseDialect&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Sybase Anywhere      -&amp;nbsp;org.hibernate.dialect.SybaseAnywhereDialect&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;The &lt;mapping resource=&quot;&amp;lt;b&amp;gt;contact.hbm.xml&amp;lt;/b&amp;gt;&quot;&gt; property is the mapping for our contact table.&lt;/mapping&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Writing First Persistence Class&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate uses the Plain Old Java Objects (POJOs) classes to map to the database table. We can configure the variables to map to the database column. Here is the code for Contact.java:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;Java&amp;nbsp;Class&amp;nbsp;to&amp;nbsp;map&amp;nbsp;to&amp;nbsp;the&amp;nbsp;datbase&amp;nbsp;Contact&amp;nbsp;Table&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;Contact&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;String&amp;nbsp;firstName;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;String&amp;nbsp;lastName;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;String&amp;nbsp;email;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;long&amp;nbsp;&lt;/b&gt;id;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;Email&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;String&amp;nbsp;getEmail()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;email;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;First&amp;nbsp;Name&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;String&amp;nbsp;getFirstName()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;firstName;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;Last&amp;nbsp;name&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;String&amp;nbsp;getLastName()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;lastName;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;string&amp;nbsp;Sets&amp;nbsp;the&amp;nbsp;Email&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setEmail(String&amp;nbsp;string)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;email&amp;nbsp;=&amp;nbsp;string;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;string&amp;nbsp;Sets&amp;nbsp;the&amp;nbsp;First&amp;nbsp;Name&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setFirstName(String&amp;nbsp;string)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;firstName&amp;nbsp;=&amp;nbsp;string;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;string&amp;nbsp;sets&amp;nbsp;the&amp;nbsp;Last&amp;nbsp;Name&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setLastName(String&amp;nbsp;string)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;lastName&amp;nbsp;=&amp;nbsp;string;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;ID&amp;nbsp;Returns&amp;nbsp;ID&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;long&amp;nbsp;&lt;/b&gt;getId()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;id;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;/**&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;l&amp;nbsp;Sets&amp;nbsp;the&amp;nbsp;ID&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setId(&lt;b&gt;long&amp;nbsp;&lt;/b&gt;l)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;id&amp;nbsp;=&amp;nbsp;l;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Mapping the Contact Object to the Database Contact table&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;apple-style-span&quot;&gt;The file contact.hbm.xml is used to map Contact Object to the Contact table in the database. Here is the code for contact.hbm.xml:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMJhX3hFUl99UDAdxOOo_VkAS6neCWtXf2xALKuetdZbPof9_e8Yk0dAGJE8a4KApDMtL-o0vIhxj1-vwgcfv96Szobe-_IIwhJ56ZnqS2xx0kNXqy68m7VAgiyCesDvBdenRZQ93jK4pw/s1600/3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;317&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMJhX3hFUl99UDAdxOOo_VkAS6neCWtXf2xALKuetdZbPof9_e8Yk0dAGJE8a4KApDMtL-o0vIhxj1-vwgcfv96Szobe-_IIwhJ56ZnqS2xx0kNXqy68m7VAgiyCesDvBdenRZQ93jK4pw/s400/3.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Setting Up MySQL Database&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
In the configuration file(hibernate.cfg.xml) we have specified to use&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;hibernatetutorial&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;database running on localhost.&amp;nbsp; So, create the databse (&quot;&lt;b&gt;hibernatetutorial&quot;)&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;on the MySQL server running on localhost.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Developing Code to Test Hibernate example&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
Now we are ready to write a program to insert the data into database. We should first understand about the Hibernate&#39;s Session. Hibernate Session is the main runtime interface between a Java application and Hibernate. First we are required to get the Hibernate Session.SessionFactory allows application to create the Hibernate Sesssion by reading the configuration from hibernate.cfg.xml file.&amp;nbsp; Then the save method on session object is used to save the contact information to the database: &lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;session.save(contact)&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Here is the code of FirstExample.java&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.SessionFactory;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.Configuration;&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Roy&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;Hibernate&amp;nbsp;example&amp;nbsp;to&amp;nbsp;inset&amp;nbsp;data&amp;nbsp;into&amp;nbsp;Contact&amp;nbsp;table&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;FirstExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&amp;nbsp;hibernate.cfg.xml&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Configuration().configure().buildSessionFactory();&lt;br /&gt;
&amp;nbsp;session&amp;nbsp;=sessionFactory.openSession();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Create&amp;nbsp;new&amp;nbsp;instance&amp;nbsp;of&amp;nbsp;Contact&amp;nbsp;and&amp;nbsp;set&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;values&amp;nbsp;in&amp;nbsp;it&amp;nbsp;by&amp;nbsp;reading&amp;nbsp;them&amp;nbsp;from&amp;nbsp;form&amp;nbsp;object&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Inserting&amp;nbsp;Record&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Contact&amp;nbsp;contact&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Contact();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;contact.setId(3);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;contact.setFirstName(&quot;Biswajit&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;contact.setLastName(&quot;Roy&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;contact.setEmail(&quot;biswajitroy04@gmail.com&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.save(contact);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Done&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;finally&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;Actual&amp;nbsp;contact&amp;nbsp;insertion&amp;nbsp;will&amp;nbsp;happen&amp;nbsp;at&amp;nbsp;this&amp;nbsp;step&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.flush();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 1;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Understanding Hibernate O/R Mapping&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Now let&#39;s understand the each component of the mapping file.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;To recall here is the content of contact.hbm.xml:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW-KLThqzelQX_7nVy1XeSN2mNA4z0SNExALa1KzvKeWEljKigj4_7pg2tzUIuZ8nbWWjTnnRZGboL6e3770Lz4VVFwfHQVaqS5JD98oFlCoMAYUnbMq9kJgYEyhNXHt1raTvQXBR_1Llj/s1600/4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;311&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW-KLThqzelQX_7nVy1XeSN2mNA4z0SNExALa1KzvKeWEljKigj4_7pg2tzUIuZ8nbWWjTnnRZGboL6e3770Lz4VVFwfHQVaqS5JD98oFlCoMAYUnbMq9kJgYEyhNXHt1raTvQXBR_1Llj/s400/4.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Hibernate mapping documents are simple xml documents. Here are important elements of the mapping file:&lt;/span&gt;&lt;/div&gt;&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;hibernate-mapping&gt;      element&lt;/hibernate-mapping&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
The first or root element of hibernate mapping document is      &lt;hibernate-mapping&gt; element. Between the &amp;lt;&lt;b&gt;hibernate-mapping&amp;gt;&lt;/b&gt;&amp;nbsp;tag      class element(s) are present.&lt;br /&gt;
&amp;nbsp;&lt;/hibernate-mapping&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;class&gt; element&lt;/class&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
The &lt;class&gt; element maps the class object with corresponding entity      in the database. It also tells what table in the database has to access      and what column in that table it should use. Within one      &lt;hibernate-mapping&gt; element, several &lt;class&gt; mappings are      possible.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;/class&gt;&lt;/hibernate-mapping&gt;&lt;/class&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;id&gt; element&lt;/id&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
The &lt;id&gt; element in unique identifier to identify and object. In      fact &lt;id&gt; element map with the primary key of the table. In our code      :&lt;br /&gt;
&lt;id column=&quot;ID&quot; name=&quot;id&quot; type=&quot;long&quot;&gt;&lt;br /&gt;
primary key maps to the&amp;nbsp;&lt;b&gt;ID&lt;/b&gt;&amp;nbsp;field of the table&amp;nbsp;&lt;b&gt;CONTACT&lt;/b&gt;.      The attributes of the&amp;nbsp;id&amp;nbsp;element are:&lt;/id&gt;&lt;/id&gt;&lt;/id&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level2 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 72.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;name:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The property name used by the       persistent class.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level2 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 72.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;column:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;The column used to store       the primary key value.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level2 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 72.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;type:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;The Java data type used.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level2 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 72.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;unsaved-value:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;This is the value used       to determine if a class has been made persistent. If the value of the id       attribute is null, then it means that this object has not been persisted.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;generator&gt; element&lt;/generator&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
The&amp;nbsp;&lt;b&gt;&lt;generator&gt;&amp;nbsp;&lt;/generator&gt;&lt;/b&gt;method&lt;b&gt;&amp;nbsp;&lt;/b&gt;is used to      generate the primary key for the new record. Here is some of the commonly      used generators :&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;*&lt;/b&gt;&amp;nbsp;&lt;b&gt;Increment&amp;nbsp;&lt;/b&gt;- This is used to generate primary      keys of type long, short or int that are unique only. It should not be      used in the clustered deployment environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;*&amp;nbsp; Sequence&lt;/b&gt;&amp;nbsp;- Hibernate can also use the sequences to      generate the primary key. It can be used with DB2, PostgreSQL, Oracle, SAP      DB databases.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;* Assigned&lt;/b&gt;&amp;nbsp;- Assigned method is used when application code      generates the primary key.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;property&gt; element&lt;/property&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
The&amp;nbsp;property&amp;nbsp;elements define standard Java attributes and their mapping into database schema. The&amp;nbsp;property&amp;nbsp;element supports the&amp;nbsp;column&amp;nbsp;child element to specify additional properties, such as the index name on a column or a specific column type.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Understanding Hibernate &lt;generator&gt; element&lt;/generator&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The &lt;generator&gt; element&lt;/generator&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;This is the optional element under &lt;id&gt; element. The &lt;generator&gt; element is used to specify the class name to be used to generate the primary key for new record while saving a new record. The &lt;param /&gt;element is used to pass the parameter (s) to the&amp;nbsp; class. Here is the example of generator element from our first application:&lt;/generator&gt;&lt;/id&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;b&gt;&lt;generator class=&quot;assigned&quot;&gt;&lt;br /&gt;
&lt;/generator&gt;&lt;/b&gt;In this case &lt;generator&gt; element do not generate the primary key and it is required to set the primary key value before calling save() method.&lt;/generator&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here are the list of some commonly used generators in hibernate:&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;background: #FFFFCC; mso-cellspacing: 0cm; mso-padding-alt: 0cm 0cm 0cm 0cm; mso-yfti-tbllook: 1184; width: 80.0%;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-irow: 0;&quot;&gt;   &lt;td style=&quot;background: #FFFF99; padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Generator&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FFFF99; padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Description&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;increment&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;It generates identifiers of type   long, short or int that are unique only when no other process is inserting   data into the same table. It should not the used in the clustered   environment.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;identity&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;It supports identity columns in   DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier   is of type long, short or int.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;sequence&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The sequence generator uses a   sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in   Interbase. The returned identifier is of type long, short or int&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 4;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;hilo&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;hilo&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt; generator uses a hi/lo algorithm to efficiently generate   identifiers of type long, short or int, given a table and column (by default   hibernate_unique_key and next_hi respectively) as a source of hi values. The   hi/lo algorithm generates identifiers that are unique only for a particular   database. Do not use this generator with connections enlisted with JTA or   with a user-supplied connection.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 5;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;seqhilo&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The seqhilo generator uses a hi/lo   algorithm to efficiently generate identifiers of type long, short or int,   given a named database sequence.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 6;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;uuid&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The uuid generator uses a 128-bit   UUID algorithm to generate identifiers of type string, unique within a   network (the IP address is used). The UUID is encoded as a string of   hexadecimal digits of length 32.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 7;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;guid&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;It uses a database-generated GUID   string on MS SQL Server and MySQL.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 8;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;native&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;It picks identity, sequence or &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;hilo&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt; depending upon the capabilities of the underlying   database.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 9;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;assigned&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;lets the application to assign an   identifier to the object before save() is called. This is the default   strategy if no &lt;generator&gt; element is specified.&lt;/generator&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 10;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;select&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;retrieves a primary key assigned   by a database trigger by selecting the row by some unique key and retrieving   the primary key value.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 11; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 16.0%;&quot; width=&quot;16%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;foreign&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;padding: 0cm 0cm 0cm 0cm; width: 84.0%;&quot; width=&quot;84%&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;uses the identifier of another   associated object. Usually used in conjunction with a &lt;one-to-one&gt;   primary key association.&lt;/one-to-one&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Using Hibernate &lt;generator&gt; to generate id incrementally&lt;/generator&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Create Table in the mysql database:&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;User the following sql statement to create a new table in the database.&lt;br /&gt;
&amp;nbsp;CREATE TABLE `book` (&lt;br /&gt;
`id` int(11) NOT NULL default &#39;0&#39;,&lt;br /&gt;
`bookname` varchar(50) default NULL,&lt;br /&gt;
PRIMARY KEY (`id`)&lt;br /&gt;
) TYPE=MyISAM&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Developing POJO Class (Book.java)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
Book.java is our POJO class which is to be persisted to the database table &quot;book&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Roy&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;Java&amp;nbsp;Class&amp;nbsp;to&amp;nbsp;map&amp;nbsp;to&amp;nbsp;the&amp;nbsp;database&amp;nbsp;Book&amp;nbsp;table&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;package &lt;/b&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;Book&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;long&amp;nbsp;&lt;/b&gt;lngBookId;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;String&amp;nbsp;strBookName;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;Returns&amp;nbsp;the&amp;nbsp;lngBookId.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;long&amp;nbsp;&lt;/b&gt;getLngBookId()&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;lngBookId;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;lngBookId&amp;nbsp;The&amp;nbsp;lngBookId&amp;nbsp;to&amp;nbsp;set.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setLngBookId(&lt;b&gt;long&amp;nbsp;&lt;/b&gt;lngBookId)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;this&lt;/b&gt;.lngBookId&amp;nbsp;=&amp;nbsp;lngBookId;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;Returns&amp;nbsp;the&amp;nbsp;strBookName.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;String&amp;nbsp;getStrBookName()&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;strBookName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;strBookName&amp;nbsp;The&amp;nbsp;strBookName&amp;nbsp;to&amp;nbsp;set.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;void&amp;nbsp;&lt;/b&gt;setStrBookName(String&amp;nbsp;strBookName)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;this&lt;/b&gt;.strBookName&amp;nbsp;=&amp;nbsp;strBookName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Adding Mapping entries to contact.hbm.xml&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
Add the following mapping code into the contact.hbm.xml file&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7oxF0lM5d9OVQn96vILxcWXBkGxmSPd4XFbWfICmd7rhUd2OMHOjno9TLiF_o7TZ30waAIiBLf5zb3kgYa_HGUEFs_S7-gqCaAS5Pq805e4lVaU-GKJqDH4cT9eCT12jmELRAqAs54Yzh/s1600/5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7oxF0lM5d9OVQn96vILxcWXBkGxmSPd4XFbWfICmd7rhUd2OMHOjno9TLiF_o7TZ30waAIiBLf5zb3kgYa_HGUEFs_S7-gqCaAS5Pq805e4lVaU-GKJqDH4cT9eCT12jmELRAqAs54Yzh/s400/5.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Write the client program and test it out&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
Here is the code of our client program to test the application.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;Example&amp;nbsp;to&amp;nbsp;show&amp;nbsp;the&amp;nbsp;increment&lt;br /&gt;
class&amp;nbsp;of&amp;nbsp;hibernate&lt;br /&gt;
generator&amp;nbsp;element&amp;nbsp;to&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;automatically&amp;nbsp;generate&lt;br /&gt;
the&amp;nbsp;primay&amp;nbsp;key&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;package&amp;nbsp;&lt;/b&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
//Hibernate&amp;nbsp;Imports&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.SessionFactory;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.Configuration;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;IdIncrementExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main&lt;br /&gt;
(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&lt;br /&gt;
hibernate.cfg.xml&amp;nbsp;and&lt;br /&gt;
prepare&amp;nbsp;hibernate&amp;nbsp;for&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&lt;br /&gt;
&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Configuration().configure()&lt;br /&gt;
.buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session&amp;nbsp;=sessionFactory.openSession();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;org.hibernate.Transaction&amp;nbsp;tx&amp;nbsp;=&lt;br /&gt;
session.beginTransaction();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Create&amp;nbsp;new&amp;nbsp;instance&lt;br /&gt;
of&amp;nbsp;Contact&amp;nbsp;and&amp;nbsp;set values&amp;nbsp;in&lt;br /&gt;
&amp;nbsp;it&amp;nbsp;by&amp;nbsp;reading&amp;nbsp;them&amp;nbsp;from&amp;nbsp;form&amp;nbsp;object&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;&lt;br /&gt;
Inserting&amp;nbsp;Book&amp;nbsp;object&lt;br /&gt;
into&amp;nbsp;database..&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Book&amp;nbsp;book&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Book();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;book.setStrBookName(&quot;Hibernate&lt;br /&gt;
Tutorial&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.save(book);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Book&amp;nbsp;object&lt;br /&gt;
persisted&amp;nbsp;to&amp;nbsp;the&amp;nbsp;database.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;tx.commit();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.flush();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;finally&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;To test the program Select Run-&amp;gt;Run As -&amp;gt; Java Application from the eclipse menu bar. This will create a new record into the book table.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Hibernate Update Query&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Create a java class:&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here is the code of our java file (UpdateExample.java), where we will update a field name &quot;InsuranceName&quot;&amp;nbsp;with a value=&quot;Jivan&amp;nbsp;Dhara&quot; from a row of the insurance table.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here is the code of delete query:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;UpdateExample&amp;nbsp;.java&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.Date;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.SessionFactory;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Transaction;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.Configuration;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;UpdateExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;args&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;TODO&amp;nbsp;Auto-generated&amp;nbsp;method&amp;nbsp;stub&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;sess&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;fact&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Configuration()&lt;br /&gt;
.configure().buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;sess&amp;nbsp;=&amp;nbsp;fact.openSession();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Transaction&amp;nbsp;tr&amp;nbsp;=&amp;nbsp;sess.beginTransaction();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Insurance&amp;nbsp;ins&amp;nbsp;=&amp;nbsp;(Insurance)sess.get&lt;br /&gt;
(Insurance.class,&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Long(1));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;ins.setInsuranceName(&quot;Jivan&amp;nbsp;Dhara&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;ins.setInvestementAmount(20000);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;ins.setInvestementDate(&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Date());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;sess.update(ins);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;tr.commit();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;sess.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Update&amp;nbsp;successfully!&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Hibernate Delete Query&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Create a java class:&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here is the code of our java file (DeleteHQLExample.java), which we will delete a row from the insurance table using the query&amp;nbsp;&quot;delete&amp;nbsp;from&amp;nbsp;Insurance&amp;nbsp;insurance&amp;nbsp;where&amp;nbsp;id&amp;nbsp;=&amp;nbsp;2&quot;&lt;/span&gt;&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Here is the code of delete query:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;DeleteHQLExample.java&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Query;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.SessionFactory;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Transaction;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.Configuration;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;DeleteHQLExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;Criteria&amp;nbsp;Query&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;TODO&amp;nbsp;Auto-generated&amp;nbsp;method&amp;nbsp;stub&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;sess&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;fact&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
Configuration().configure().buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;sess&amp;nbsp;=&amp;nbsp;fact.openSession();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;String&amp;nbsp;hql&amp;nbsp;=&amp;nbsp;&quot;delete&amp;nbsp;from&lt;br /&gt;
Insurance&amp;nbsp;insurance&amp;nbsp;where&amp;nbsp;id&amp;nbsp;=&amp;nbsp;2&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&amp;nbsp;sess.createQuery(hql);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;row&amp;nbsp;=&amp;nbsp;query.executeUpdate();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;(row&amp;nbsp;==&amp;nbsp;0){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Doesn&#39;&lt;br /&gt;
t&amp;nbsp;deleted&amp;nbsp;any&amp;nbsp;row!&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;else&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Deleted&lt;br /&gt;
&amp;nbsp;Row:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;sess.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Hibernate Query Language&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate Query Language or HQL for short is extremely powerful query language. HQL is much like SQL&amp;nbsp; and are case-insensitive, except for the names of the Java Classes and properties. Hibernate Query Language is used to execute queries against database. Hibernate automatically generates the sql query and execute it against underlying database if HQL is used in the application. HQL is based on the relational object models and makes the SQL object oriented. Hibernate Query Language uses Classes and properties instead of tables and columns. Hibernate Query Language is extremely powerful and it supports Polymorphism, Associations, Much less verbose than SQL.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Why to use HQL?&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Full support for relational      operations:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;HQL      allows representing SQL queries in the form of objects. Hibernate Query      Language uses Classes and properties instead of tables and columns.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Return result as Object:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The HQL queries return the      query result(s) in the form of object(s), which is easy to use. This      elemenates the need of creating the object and populate the data from      result set.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Polymorphic Queries:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;HQL fully supports&amp;nbsp;&lt;b&gt;polymorphic      queries&lt;/b&gt;. Polymorphic queries results the query results along with all      the child objects if any.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Easy to Learn:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;Hibernate Queries are      easy to learn and it can be easily implemented in the applications.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Support for Advance features:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;HQL contains many advance      features such as pagination, fetch join with dynamic profiling,      Inner/outer/full joins, Cartesian products. It also supports Projection,      Aggregation (max, avg) and grouping, Ordering, Sub queries and SQL      function calls.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Database independent:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;Queries written in HQL      are database independent (If database supports the underlying feature).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Understanding HQL Syntax&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Any Hibernate Query Language may consist of following elements:&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l3 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Clauses&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l3 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Aggregate functions&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l3 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Subqueries&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Clauses in the HQL are:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;from&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;select&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;where&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;order by&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;group by&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Aggregate functions are:&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;avg(...)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;,&amp;nbsp;&lt;b&gt;sum(...)&lt;/b&gt;,&amp;nbsp;&lt;b&gt;min(...)&lt;/b&gt;,&amp;nbsp;&lt;b&gt;max(...)&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;count(*)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-list: l0 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;count(...), count(distinct      ...), count(all...)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Subqueries&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
Subqueries are nothing but its a query within another query. Hibernate supports Subqueries if the underlying database supports it.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;HQL from clause Example&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;from Insurance insurance&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Here is the full code of the from clause example:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.*;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.*;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;Select&amp;nbsp;HQL&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;SelectHQLExample&amp;nbsp;{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&amp;nbsp;hibernate.cfg.xml&lt;br /&gt;
&amp;nbsp;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
Configuration().configure().buildSessionFactory();&lt;br /&gt;
&amp;nbsp;session&amp;nbsp;=sessionFactory.openSession();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;//Using&amp;nbsp;from&amp;nbsp;Clause&lt;br /&gt;
&amp;nbsp;&amp;nbsp;String&amp;nbsp;SQL_QUERY&amp;nbsp;=&quot;from&amp;nbsp;Insurance&amp;nbsp;insurance&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&amp;nbsp;session.createQuery(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;for&lt;/b&gt;(Iterator&amp;nbsp;it=query.iterate();it.hasNext();){&lt;br /&gt;
Insurance&amp;nbsp;insurance=(Insurance)it.next();&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;ID:&amp;nbsp;&quot;&amp;nbsp;+&lt;br /&gt;
insurance.getLngInsuranceId());&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;First&lt;br /&gt;
&amp;nbsp;Name:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;insurance.getInsuranceName());&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
}&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
}&lt;b&gt;finally&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Hibernate Select Clause&lt;/span&gt;&lt;/h1&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Select insurance.lngInsuranceId, insurance.insuranceName, insurance.investementAmount, insurance.investementDate from Insurance insurance&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Hibernate generates the necessary sql query and selects all the records from Insurance table. Here is the code of our java file which shows how select HQL can be used:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.*;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.*;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Roy&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;HQL&amp;nbsp;Select&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;SelectClauseExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&amp;nbsp;hibernate.cfg.xml&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Configuration().configure()&lt;br /&gt;
.buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session&amp;nbsp;=sessionFactory.openSession();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Create&amp;nbsp;Select&amp;nbsp;Clause&amp;nbsp;HQL&lt;br /&gt;
&amp;nbsp;String&amp;nbsp;SQL_QUERY&amp;nbsp;=&quot;Select&amp;nbsp;insurance.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;lngInsuranceId,insurance.insuranceName,&quot;&amp;nbsp;+&lt;br /&gt;
&amp;nbsp;&quot;insurance.investementAmount,insurance.&lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;investementDate&amp;nbsp;from&amp;nbsp;Insurance&amp;nbsp;insurance&quot;;&lt;br /&gt;
&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&amp;nbsp;session.createQuery(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&lt;b&gt;for&lt;/b&gt;(Iterator&amp;nbsp;it=query.iterate();it.hasNext();){&lt;br /&gt;
&amp;nbsp;Object[]&amp;nbsp;row&amp;nbsp;=&amp;nbsp;(Object[])&amp;nbsp;it.next();&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;ID:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[0]);&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Name:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[1]);&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Amount:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[2]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;finally&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;HQL Where Clause Example&lt;/span&gt;&lt;/h1&gt;&lt;div style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;from Insurance where lngInsuranceId=&#39;1&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Where Clause can be used with or without Select Clause. Here the example code:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.*;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.*;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;HQL&amp;nbsp;Where&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;Where&amp;nbsp;Clause&amp;nbsp;With&amp;nbsp;Select&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;WhereClauseExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&amp;nbsp;hibernate.cfg.&lt;br /&gt;
xml&amp;nbsp;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&amp;nbsp;&lt;b&gt;new&lt;br /&gt;
&lt;/b&gt;Configuration().configure().&lt;br /&gt;
buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session&amp;nbsp;=sessionFactory.openSession();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;***************&lt;br /&gt;
****************&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Query&amp;nbsp;using&lt;br /&gt;
Hibernate&amp;nbsp;Query&amp;nbsp;Language&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Query&amp;nbsp;using&amp;nbsp;Hibernate&amp;nbsp;Query&amp;nbsp;Language&lt;br /&gt;
&amp;nbsp;String&amp;nbsp;SQL_QUERY&amp;nbsp;=&quot;&amp;nbsp;from&amp;nbsp;Insurance&lt;br /&gt;
&amp;nbsp;as&amp;nbsp;insurance&amp;nbsp;where&amp;nbsp;insurance.&lt;br /&gt;
lngInsuranceId=&#39;1&#39;&quot;;&lt;br /&gt;
&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&amp;nbsp;session.createQuery&lt;br /&gt;
(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&lt;b&gt;for&lt;/b&gt;(Iterator&amp;nbsp;it=query.iterate()&lt;br /&gt;
;it.hasNext();){&lt;br /&gt;
&amp;nbsp;Insurance&amp;nbsp;insurance=(Insurance)it&lt;br /&gt;
.next();&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;ID:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;insurance.&lt;br /&gt;
getLngInsuranceId());&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Name:&amp;nbsp;&quot;&lt;br /&gt;
+&amp;nbsp;insurance. getInsuranceName());&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;****************&lt;br /&gt;
***************&quot;);&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Where&amp;nbsp;Clause&amp;nbsp;With&lt;br /&gt;
&amp;nbsp;Select&amp;nbsp;Clause&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Where&amp;nbsp;Clause&amp;nbsp;With&amp;nbsp;Select&amp;nbsp;Clause&lt;br /&gt;
&amp;nbsp;SQL_QUERY&amp;nbsp;=&quot;Select&amp;nbsp;insurance.&lt;br /&gt;
lngInsuranceId,insurance.insuranceName,&quot;&amp;nbsp;+&lt;br /&gt;
&amp;nbsp;&quot;insurance.investementAmount,&lt;br /&gt;
insurance.investementDate&amp;nbsp;from&amp;nbsp;Insurance&lt;br /&gt;
&amp;nbsp;insurance&amp;nbsp;&quot;+&amp;nbsp;&quot;&amp;nbsp;where&amp;nbsp;insurance.&lt;br /&gt;
lngInsuranceId=&#39;1&#39;&quot;;&lt;br /&gt;
&amp;nbsp;query&amp;nbsp;=&amp;nbsp;session.createQuery(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&lt;b&gt;for&lt;/b&gt;(Iterator&amp;nbsp;it=query.iterate();it.&lt;br /&gt;
hasNext();){&lt;br /&gt;
&amp;nbsp;Object[]&amp;nbsp;row&amp;nbsp;=&amp;nbsp;(Object[])&amp;nbsp;it.next();&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;ID:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[0]);&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Name:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[1]);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;***************&lt;br /&gt;
****************&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;catch&lt;/b&gt;(Exception&amp;nbsp;e){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;b&gt;finally&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;HQL Order By Example&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Order by clause is used to retrieve the data from database in the sorted order by any property of returned class or components. HQL supports Order By Clause. In our example we will retrieve the data sorted on the insurance type. Here is the java example code:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.*;&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;* HQL&amp;nbsp;Order&amp;nbsp;by&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;HQLOrderByExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&amp;nbsp;hibernate.&lt;br /&gt;
cfg.xml&amp;nbsp;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&lt;br /&gt;
&amp;nbsp;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Configuration().configure()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;.buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session&amp;nbsp;=&amp;nbsp;sessionFactory.openSession();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Order&amp;nbsp;By&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;&amp;nbsp;String&amp;nbsp;SQL_QUERY&amp;nbsp;=&amp;nbsp;&quot;&amp;nbsp;from&amp;nbsp;Insurance&amp;nbsp;as&lt;br /&gt;
insurance&amp;nbsp;order&amp;nbsp;by&amp;nbsp;insurance.insuranceName&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&lt;br /&gt;
session.createQuery(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;(Iterator&amp;nbsp;it&lt;br /&gt;
=&amp;nbsp;query.iterate();&amp;nbsp;it.hasNext();)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Insurance&amp;nbsp;insurance&amp;nbsp;=&amp;nbsp;(Insurance)&amp;nbsp;it.next();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;ID:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;insurance.&lt;br /&gt;
getLngInsuranceId());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(&quot;Name:&amp;nbsp;&quot;&amp;nbsp;+&lt;br /&gt;
insurance.getInsuranceName());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;b&gt;catch&amp;nbsp;&lt;/b&gt;(Exception&amp;nbsp;e)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;b&gt;finally&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1 style=&quot;line-height: 18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;HQL Group By Clause Example&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Group by clause is used to return the aggregate values by grouping on returned component. HQL supports Group By Clause. In our example we will calculate the sum of invested amount in each insurance type. Here is the java code for calculating the invested amount insurance wise:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;package&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;com.tutorial.hibernate;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.Session;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;org.hibernate.cfg.*;&lt;br /&gt;
&lt;b&gt;import&amp;nbsp;&lt;/b&gt;java.util.*;&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&amp;nbsp;@author&amp;nbsp;Roy&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
HQL&amp;nbsp;Group&amp;nbsp;by&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;HQLGroupByExample&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;&lt;/b&gt;main(String[]&amp;nbsp;args)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Session&amp;nbsp;session&amp;nbsp;=&amp;nbsp;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;b&gt;try&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;step&amp;nbsp;will&amp;nbsp;read&lt;br /&gt;
hibernate.cfg.xml&amp;nbsp;and&amp;nbsp;prepare&amp;nbsp;hibernate&amp;nbsp;for&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SessionFactory&amp;nbsp;sessionFactory&amp;nbsp;=&lt;br /&gt;
&lt;b&gt;new&amp;nbsp;&lt;/b&gt;Configuration().configure()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;.buildSessionFactory();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session&amp;nbsp;=&amp;nbsp;sessionFactory.openSession();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;//Group&amp;nbsp;By&amp;nbsp;Clause&amp;nbsp;Example&lt;br /&gt;
&amp;nbsp;&amp;nbsp;String&amp;nbsp;SQL_QUERY&amp;nbsp;=&amp;nbsp;&quot;select&amp;nbsp;sum&lt;br /&gt;
(insurance.investementAmount),&lt;br /&gt;
insurance.insuranceName&amp;nbsp;&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;+&amp;nbsp;&quot;from&amp;nbsp;Insurance&amp;nbsp;insurance&lt;br /&gt;
group&amp;nbsp;by&amp;nbsp;insurance.insuranceName&quot;;&lt;br /&gt;
&amp;nbsp;Query&amp;nbsp;query&amp;nbsp;=&amp;nbsp;session.createQuery(SQL_QUERY);&lt;br /&gt;
&amp;nbsp;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;(Iterator&amp;nbsp;it&amp;nbsp;=&lt;br /&gt;
query.iterate();&amp;nbsp;it.hasNext();)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;Object[]&amp;nbsp;row&amp;nbsp;=&amp;nbsp;(Object[])&amp;nbsp;it.next();&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;&lt;br /&gt;
Invested&amp;nbsp;Amount:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[0]);&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;&lt;br /&gt;
Insurance&amp;nbsp;Name:&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;row[1]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;session.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;b&gt;catch&amp;nbsp;&lt;/b&gt;(Exception&amp;nbsp;e)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;System.out.println(e.getMessage());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;b&gt;finally&amp;nbsp;&lt;/b&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/4537214803644327004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/06/hibernate-30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4537214803644327004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4537214803644327004'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/06/hibernate-30.html' title='Hibernate 3.0'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPoIL4LRfyqya9so3KC-_EHRl-WN2XC2i7res3Xk2K9_jvIXcRuVrXSRIpZfhPifh79GgPR59hhb7Qy7pIqqfAH-iRpPZgtB97G06xFl4aoF997kGOvyi7PED2Mr6mWSgW66vprVpjl1JO/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-158630486778045264</id><published>2011-06-09T23:19:00.002+05:30</published><updated>2014-02-21T09:50:17.043+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="EJB"/><title type='text'>EJB</title><content type='html'>&lt;h2&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot;&gt;EJB stands for &quot;Enterprise &lt;span class=&quot;klink&quot;&gt;JavaBeans&lt;/span&gt;&quot; which are server-side component that encapsulates the business logic of an application and for developing secure, scalable, transactional and multi-user components in a J2EE environment.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Benefits of &lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Enterprise&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt; Beans &lt;/span&gt;&lt;/h2&gt;For several reasons, enterprise beans simplify the development of large, distributed applications. First, because the &lt;span class=&quot;klink&quot;&gt;EJB&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;container&lt;/span&gt; provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. The EJB container--not the bean developer--is responsible for system-level services such as transaction management and security authorization. &lt;br /&gt;
Second, because the beans--and not the clients--contain the application&#39;s business logic, the client developer can focus on the presentation of the client. The client developer does not have to code the routines that implement business rules or access databases. As a result, the clients are thinner, a benefit that is particularly important for clients that run on small devices. &lt;br /&gt;
Third, because enterprise beans are portable components, the application assembler can build new applications from existing beans. These applications can run on any compliant &lt;span class=&quot;klink&quot;&gt;J2EE server&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;When to Use &lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Enterprise&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt; Beans &lt;/span&gt;&lt;/h2&gt;You should consider using enterprise beans if your application has any of the following requirements: &lt;br /&gt;
&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;The application must be scalable. To accommodate a growing number of users, you may need to distribute an application&#39;s components across multiple machines. Not only can the enterprise beans of an application run on different machines, but their location will remain transparent to the clients.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;Transactions are required to ensure data integrity. &lt;/span&gt;Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12.0pt; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;The application will have a variety of clients. With just a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Beans, Clients, Containers, and Servers&lt;/span&gt;&lt;/h3&gt;An EJB is essentially a managed component that is created, controlled, and destroyed by the J2EE container in which it lives. This control allows the container to control the number of EJBs currently in existence and the resources they are using, such as memory and database connections. Each container will maintain a pool of EJB instances that are ready to be assigned to a client. When a client no longer needs an EJB, the EJB instance will be returned to the pool and all of its resources will be released. At times of heavy load, even EJB instances that are still in use by clients will be returned to the pool so they can service other clients. When the original client makes another request of its EJB, the container will reconstitute the original EJB instance to service the request. This pooling and recycling of EJB instances means that a few EJB instances, and the resources they use, can be shared between many clients. This maximizes the scalability of the EJB-based application.&lt;br /&gt;
&lt;br /&gt;
The client that uses the EJB instance does not need to know about all of this work by the container. As far as the client is concerned, it is talking to a remote component that supports defined business methods. How those methods are implemented and any magic performed by the container, such as just-in-time instantiation of that specific component instance, are entirely transparent to the client part of the application.&lt;br /&gt;
&lt;br /&gt;
The EJB benefits from certain services provided by the container, such as automatic security, automatic transactions, lifecycle management, and so on. To do this, the EJB must conform to certain rules and implement an appropriate interface that allows the container to manage the component. The EJB is packaged with configuration information that indicates the component&#39;s requirements, such as transaction and security requirements. The container will then use this information to perform authentication and control transactions on behalf of the component—the component does not have to contain code to perform such tasks.&lt;br /&gt;
&lt;br /&gt;
The primary purpose of the container is to control and provide services for the EJBs it contains. When it needs to use some underlying functionality, such as creating a transaction on behalf of a bean, it uses the facilities of the underlying EJB server. The EJB server is the base set of services on top of which the container runs. Different types of EJB will run in different containers, but many different EJB containers can run on a single EJB server. EJB servers are generally delivered as part of a J2EE-compliant application server (examples include BEA WebLogic and IBM WebSphere). You will install and run the application server, which will provide the underlying services required of an EJB server and will host EJB containers.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;More on EJB Container&lt;/span&gt;&lt;/h2&gt;Enterprise beans are software components that run in a special environment called an &lt;span class=&quot;klink&quot;&gt;EJB container&lt;/span&gt;. The container hosts and manages an enterprise bean in the same manner that the &lt;span class=&quot;klink&quot;&gt;Java Web&lt;/span&gt; Server hosts a servlet or an HTML browser hosts a Java applet. An enterprise bean cannot function outside of an EJB container. The EJB container manages every aspect of an enterprise bean at runtimes including remote access to the bean, security, persistence, transactions, concurrency, and access to and pooling of resources. &lt;br /&gt;
&lt;h2&gt;  &lt;/h2&gt;The container isolates the enterprise bean from direct access by client applications. When a client application invokes a remote method on an enterprise bean, the container first intercepts the invocation to ensure persistence, transactions, and securities are applied properly to every operation a client performs on the bean. The container manages security, transactions, and persistence automatically for the bean, so the bean developer doesn&#39;t have to write this type of logic into the bean code itself. The enterprise bean developer can focus on encapsulating business rules, while the container takes care of everything else.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzVAAWT0Q0liT-wY69cYUfiHNWJqzaGeNvfjF1uI8DanNQTl-TiQOLuhgWDnmOzWN3rHDF9WmeFlaSrW_bSZr62MTqhZIODRk7yItyNPuR1cdF-t5XaxzJ8i425Vb1QNvNvIJUQ0A61HhC/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzVAAWT0Q0liT-wY69cYUfiHNWJqzaGeNvfjF1uI8DanNQTl-TiQOLuhgWDnmOzWN3rHDF9WmeFlaSrW_bSZr62MTqhZIODRk7yItyNPuR1cdF-t5XaxzJ8i425Vb1QNvNvIJUQ0A61HhC/s400/1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-size: 12pt; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;  &lt;/h2&gt;Containers will manage many beans simultaneously in the same fashion that the Java WebServer manages many servlets. To reduce memory consumption and processing, containers pool resources and manage the lifecycles of all the beans very carefully. When a bean is not being used, a container will place it in a pool to be reused by another client, or possibly evict it from memory and only bring it back when its needed. Because client applications don&#39;t have direct access to the beans--the container lies between the client and bean--the client application is completely unaware of the containers resource management activities. A bean that is not in use, for example, might be evicted from memory on the server, while its remote reference on the client remains intact. When the client invokes a method on the remote reference, the container simply re-incarnates the bean to service the request. The client application is unaware of the entire process. &lt;br /&gt;
An enterprise bean depends on the container for everything it needs. If an enterprise bean needs to access a JDBC connection or another enterprise bean, it does so through the container; if an enterprise bean needs to access the identity of its caller, obtain a reference to itself, or access properties it does so through the container. The enterprise bean interacts with its container through one of three mechanisms: callback methods, the EJBContext interface, or the Java Naming and Directory Interface (JNDI).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Callback Methods &lt;/b&gt;&lt;/div&gt;Every bean implements a subtype of the &lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;EnterpriseBean&lt;/span&gt;&lt;/code&gt; interface which defines several methods, called callback methods. Each callback method alerts the bean TO a different event in its lifecycle and the container will invoke these methods to notify the bean when it&#39;s about to activate the bean, persist its state to the database, end a transaction, remove the bean from memory, etc. The callback methods give the bean a chance to do some housework immediately before or after some event.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;EJBContext&lt;/b&gt; &lt;/div&gt;Every bean obtains an &lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;EJBContext&lt;/span&gt;&lt;/code&gt; object, which is a reference directly to the container. The &lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;EJBContext&lt;/span&gt;&lt;/code&gt; interface provides methods for interacting with the container so that that bean can request information about its environment like the identity of its client, the status of a transaction, or to obtain remote references to itself.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Java Naming and Directory Interface &lt;/b&gt;&lt;/div&gt;Java Naming and Directory Interface (JNDI) is a standard extension to the &lt;span class=&quot;klink&quot;&gt;Java platform&lt;/span&gt; for accessing naming systems like LDAP, NetWare, file systems, etc. Every bean automatically has access to a special naming system called the Environment Naming Context (ENC). The ENC is managed by the container and accessed by beans using JNDI. The JNDI ENC allows a bean to access resources like JDBC connections, other enterprise beans, and properties specific to that bean.&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;So the Container Services are&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Distribution via proxies&lt;/i&gt;—The container will generate a client-side stub and server-side skeleton for the EJB. The stub and skeleton will use RMI over IIOP to communicate.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Lifecycle management&lt;/i&gt;—Bean initialization, state management, and destruction is driven by the container, all the developer must do is implement the appropriate methods.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Naming and registration&lt;/i&gt;—The EJB container and server will provide the EJB with access to naming services. These services are used by local and remote clients to look up the EJB and by the EJB itself to look up resources it may need.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Transaction management&lt;/i&gt;—Declarative transactions provide a means for the developer to easily delegate the creation and control of transactions to the container.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Security and access control&lt;/i&gt;—Again, declarative security provides a means for the developer to easily delegate the enforcement of security to the container.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;Persistence (if you want)&lt;/i&gt;—Using the Entity EJB&#39;s container-managed persistence mechanism, state can be saved and restored without having to write a single line of code.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 36pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Enterprise&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt; Beans&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To create an EJB server-side component, an enterprise bean developer provides two interfaces that define a bean&#39;s business methods, plus the actual bean implementation class. The client then uses a bean&#39;s public interfaces to create, manipulate, and remove beans from the EJB server. The implementation class, to be called the bean class, is instantiated at runtime and becomes a distributed object.&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Enterprise&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt; beans live in an EJB container and are accessed by client applications over the network through their remote and home interfaces. The remote and home interfaces expose the capabilities of the bean and provide all the method needed to create, update, interact with, and delete the bean. A bean is a server-side component that represents a business concept like a Customer or a HotelClerk.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCaNH96WPTfQfZBT9_ogMxnGXTKgCKkVgwbXKIkIrC5q9H8LNHWaIQ6KejTVUg-k2grvzaWXGQROGhu0mglKcOjMMScI593nMy02zyOg3Jd1flS6m2Bb3XWaWrmtt3juY9-TvtLpcGSjkc/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;303&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCaNH96WPTfQfZBT9_ogMxnGXTKgCKkVgwbXKIkIrC5q9H8LNHWaIQ6KejTVUg-k2grvzaWXGQROGhu0mglKcOjMMScI593nMy02zyOg3Jd1flS6m2Bb3XWaWrmtt3juY9-TvtLpcGSjkc/s320/2.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Remote and Home Interfaces&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
The remote and home interfaces represent the bean, but the container insulates the beans from direct access from client applications. Every time a bean is requested, created, or deleted, the container manages the whole process. &lt;br /&gt;
The home interface represents the life-cycle methods of the component (create, destroy, find) while the remote interface represents the business method of the bean. The remote and home interfaces extend the javax.ejb.EJBObject and javax.ejb.EJBHome interfaces respectively. These EJB interface types define a standard set of utility methods and provide common base types for all remote and home interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkxO1zTIM_TUJ7g0RPjuzNxwbPv8ZVqU0T0WjAId8OyGpziGn6iyGl5OzUoO8zRnpHKCfmrxKf3c4qRl87Ql4IgB-_a3WJ5bdv2TjM4rYS43KFKFC7Fnu_cwgpTrK3Ry2lX7iNdtryBej/s1600/3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkxO1zTIM_TUJ7g0RPjuzNxwbPv8ZVqU0T0WjAId8OyGpziGn6iyGl5OzUoO8zRnpHKCfmrxKf3c4qRl87Ql4IgB-_a3WJ5bdv2TjM4rYS43KFKFC7Fnu_cwgpTrK3Ry2lX7iNdtryBej/s400/3.jpg&quot; width=&quot;347&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;mso-cellspacing: 0cm; mso-padding-alt: 3.75pt 3.75pt 3.75pt 3.75pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;padding: 3.75pt 3.75pt 3.75pt 3.75pt;&quot;&gt;Clients use the bean&#39;s home interface to obtain references to the bean&#39;s   remote interface. The remote interface defines the business methods like   accessor and mutator methods for changing a customer&#39;s name, or business   methods that perform tasks like using the HotelClerk bean to reserve a room   at a hotel. Below is an example of how a Customer bean might be accessed from   a client application.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Types of EJB &lt;/span&gt;&lt;/h1&gt;EJB components come in three varieties, each with its own defined role and life cycle: &lt;br /&gt;
&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;Session beans&lt;/b&gt; —      These may be either &lt;i&gt;stateful&lt;/i&gt; or &lt;i&gt;stateless&lt;/i&gt;, and are primarily      used to encapsulate business logic, carry out tasks on behalf of a client,      and act as controllers or managers for other beans. &lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; tab-stops: list 36.0pt;&quot;&gt;&lt;b&gt;Entity beans&lt;/b&gt; —      Entity beans represent persistent objects or business concepts that exist      beyond a specific application&#39;s lifetime; they are typically stored in a      relational database. Entity beans can be developed using &lt;i&gt;bean-managed      persistence&lt;/i&gt;, which is implemented by the developer, or &lt;i&gt;container-managed      persistence&lt;/i&gt;, implemented by the container. &lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  &lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Message-driven beans&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt; — Message-driven beans listen asynchronously for Java Message Service (&lt;b&gt;JMS&lt;/b&gt;) messages from any client or component and are used for loosely coupled, typically batch-type, processing.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/158630486778045264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/06/ejb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/158630486778045264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/158630486778045264'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/06/ejb.html' title='EJB'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzVAAWT0Q0liT-wY69cYUfiHNWJqzaGeNvfjF1uI8DanNQTl-TiQOLuhgWDnmOzWN3rHDF9WmeFlaSrW_bSZr62MTqhZIODRk7yItyNPuR1cdF-t5XaxzJ8i425Vb1QNvNvIJUQ0A61HhC/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-2452757810928810361</id><published>2011-05-30T22:41:00.002+05:30</published><updated>2014-02-21T09:50:31.003+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Class Loading"/><title type='text'>Java Class Loading</title><content type='html'>&lt;h2&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Internals of Java Class Loading&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Class loading is one of the most powerful mechanisms provided by the Java language specification. Even though the internals of class loading falls under the &quot;advanced topics&quot; heading, all Java programmers should know how the mechanism works and what can be done with it to suit their needs. This can save time that would otherwise have been spent debugging &lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;ClassNotFoundException&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;ClassCastException&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;, etc.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: windowtext; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Class and Data&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: windowtext; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span lang=&quot;EN-US&quot;&gt;A&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;class&lt;/i&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;represents the code to be executed, whereas&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;data&lt;/i&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;represents the state associated with that code. State can change; code generally does not. When we associate a particular state to a class, we have an instance of that class. So different instances of the same class can have different state, but all refer to the same code. In Java, a class will usually have its code contained in a .class file, though there are exceptions. Nevertheless, in the Java runtime, each and every class will have its code also available in the form of a first-class Java object, which is an instance of&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;java.lang.Class&lt;/span&gt;&lt;/code&gt;. Whenever we compile any Java file, the compiler will embed a public, static, final field named&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class&lt;/span&gt;&lt;/code&gt;, of the type&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;java.lang.Class&lt;/span&gt;&lt;/code&gt;, in the emitted byte code. Since this field is public, we can access it using dotted notation, like this:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: none repeat scroll 0% 0% rgb(239, 239, 239);&quot;&gt;&lt;code&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;java.lang.Class klass = Myclass.class; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot;&gt;Once a class is loaded into a JVM, the same class (I repeat, the&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;same&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;class) will not be loaded again. This leads to the question of what is meant by &quot;the same class.&quot; Similar to the condition that an object has a specific state, an identity, and that an object is always associated with its code (class), a class loaded into a JVM also has a specific identity, which we&#39;ll look at now.&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot;&gt;In Java, a class is identified by its fully qualified class name. The fully qualified class name consists of the package name and the class name. But a class is uniquely identified in a JVM using its fully qualified class name along with the instance of the &lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;ClassLoader&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;that loaded the class. Thus, if a class named&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Cl&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;in the package&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Pg&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;is loaded by an instance&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;kl1&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;of the class loader &lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;KlassLoader&lt;/span&gt;&lt;/code&gt;, the class instance of&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;C1&lt;/span&gt;&lt;/code&gt;, i.e.&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;C1.class&lt;/i&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;is keyed in the JVM as&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(Cl, Pg, kl1)&lt;/span&gt;&lt;/code&gt;. This means that the two class loader instances&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(Cl, Pg, kl1)&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(Cl, Pg, kl2)&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;are not one and the same, and classes loaded by them are also completely different and not type-compatible to each other.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: windowtext; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Java Class Loader&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;A Delegation Model (version 1.2 onwards) is used for loading class to the JVM. Class Loaders are structured in java is in a way that at start-up time the JVM doesn’t need to know anything about the classes that will be loaded at run time.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Class loaders mainly perform two functions. First, when the VM needs to load the byte code for a class, it asks a class loader to find the corresponding byte code. Each class loader will use their own method to find the requested byte code (class),then it loads it from the local disk or fetch them across the Net using any protocol including other classes and interfaces are loaded as they referenced in the byte code being executed, the main class . Then it creates an instance of the java.lang.Class of loaded byte code. This makes the class become available to the JVM for execution. Second, class loaders define the name spaces seen by different classes and how those name spaces relate to each other.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Delegation Model&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;In delegation model, the class loaders has hierarchical order forming a tree structure,the bootstrap class loader as the root of this tree.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMYun0D2b3I2K45ycd5wp6KnbDqkSqXT98hdntkeQEQtzACOkZ21-01V2Pcsr93vQI_m3wEA-npUWjTjF-jF6uulFncGXhgj2AzroMdbDQQ7X_8zH5PB1bh3uH-xua-K7-8FctZQac-5Hk/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMYun0D2b3I2K45ycd5wp6KnbDqkSqXT98hdntkeQEQtzACOkZ21-01V2Pcsr93vQI_m3wEA-npUWjTjF-jF6uulFncGXhgj2AzroMdbDQQ7X_8zH5PB1bh3uH-xua-K7-8FctZQac-5Hk/s1600/1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Bootstrap Class Loader&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Java core API classes, which are essential at the JVM load are loaded by the bootstrap (often known as primordial) Class Loader. This class loader loads the class files from local file system using the file accessing options of current OS to open/read. It’s read the class files in the form of byte arrays, providing essential resources on the JVM start up. Sometimes this Class Loader is referred as the “internal” class loader or the “default” class loader also.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Extension class loader&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The extension class loader is &lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;primary responsibility to load classes from the extension directories and provides ability to simply drop in new JVM extensions, without requiring modification to the user’s classpath.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;System Class Loader&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The Application-specific classes are loaded by the system (often known application) Class Loader.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;If all the class loader failed to load the required class, it will generate a java.lang.ClassNotFoundException else a java.lang.NoClassDefFoundError . There is a parent -child relationship is maintained by these class loaders, except boot strap class loader these class loaders has a parent.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The delegation model follows these steps when the client request for a particular class.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;1.&amp;nbsp; JVM first check whether the requested class has already been loaded (JVM caches all the classes that are loaded) by the any Class Loader. If yes, the class is returned.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;2.&amp;nbsp; If the class is not loaded, the request is forwarded to the parent Class Loader. This delegation will go up to the bootstrap Class Loader.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;3.&amp;nbsp; If the delegation failed to load the class , then current Class Loader will search for the requested class. In its defined locations .&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;4.&amp;nbsp; If the class loading failed, it will generate a java.lang.ClassNotFoundException .&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6.0pt; mso-line-height-alt: 10.5pt; vertical-align: baseline;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The Java class loader architecture provide a large amount of flexibility for developers in the application is assembling and extension process.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 6pt; vertical-align: baseline;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3 style=&quot;line-height: 12.75pt; margin-top: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: windowtext; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Phases of class loading&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;font-weight: normal; line-height: 12.75pt; margin-top: 0cm;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;There are three phases of concrete class loading:&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;physical loading&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;linking&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;, and&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;initializing&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE5nn9zkTZK4riopYfs7-y40j2zjv0WQL-lbzCVKlCoxznAc8XEnCKrRgOaWEX6ik_usX4QfYXfWhpLFFsZKxoHVM4L7uxhpTP9gaRHwWakYakgx1gY4Gh2To-LPHtKaZCRho5rIMFRmUQ/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE5nn9zkTZK4riopYfs7-y40j2zjv0WQL-lbzCVKlCoxznAc8XEnCKrRgOaWEX6ik_usX4QfYXfWhpLFFsZKxoHVM4L7uxhpTP9gaRHwWakYakgx1gY4Gh2To-LPHtKaZCRho5rIMFRmUQ/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin: 0cm 0cm 0.0001pt; text-indent: -18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;In in first phase of&amp;nbsp;&lt;b&gt;physical loading&lt;/b&gt;&amp;nbsp;required class file will be searched in specified classpaths. If the file is found it is read and the byte code is loaded. This process gives a basic memory structure to the class object, such concepts like methods, fields, and other referenced classes are not known at this stage. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin: 0cm 0cm 0.0001pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin: 0cm 0cm 0.0001pt; text-indent: -18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Linking&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;can be broken down into three main stages, because it is complex phase: &lt;/span&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Bytecode verification&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;through class loader, which executes a number of checks on the bytecodes.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Class preparation.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;This stage prepares the necessary data structures that represent fields, methods and implemented interfaces that are defined within the class.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Resolving&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;of all the other classes referenced by a particular class. The classes can be referenced in a number of ways:&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Superclasses&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Interfaces&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Field types&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Types in method signatures&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Types of local variables used in methods&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;During the&amp;nbsp;&lt;b&gt;initializing phase&lt;/b&gt;&amp;nbsp;any static initializers contained within a class are executed so that, static fields are initialized to their default values.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 7.5pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;It is interesting, that class loading&amp;nbsp;&lt;b&gt;can be performed in a lazy manner&lt;/b&gt;&amp;nbsp;and therefore some parts of the class loading process may be done on first use of the class rather than at load time.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin: 7.5pt 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3 style=&quot;line-height: 12.75pt; margin-top: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: windowtext; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Exceptions&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;line-height: 12.75pt; margin-bottom: 7.5pt; margin-left: 0cm; margin-right: 0cm; margin-top: 7.5pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The biggest challenge in dealing with class-loading problems is that problems rarely manifest themselves during the class-loading process but rather during the usage of a class later on. In following shown two class loading related exceptions, with potential causes&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 12.75pt; margin: 7.5pt 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;ClassNotFoundException&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;An archive, directory, or other source for the classes was not added to the class loader asked to load the class, or to its parent.&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;A class loader’s parent is not set correctly.&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The wrong class loader is used to load the class in question.&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;NoClassDefFoundError&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.75pt; margin: 0cm 0cm 0.0001pt; text-indent: -18pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;An archive, directory, or other source for the classes was not added to the class loader asked to load the class, or to its parent.&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;A class loader’s parent is not set correctly.&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Symbolic links in a class are inaccessible by the containing class’s class loader, such as a&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;child class loader&lt;/i&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 12.75pt; margin: 7.5pt 0cm;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/2452757810928810361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/05/java-class-loading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/2452757810928810361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/2452757810928810361'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/05/java-class-loading.html' title='Java Class Loading'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMYun0D2b3I2K45ycd5wp6KnbDqkSqXT98hdntkeQEQtzACOkZ21-01V2Pcsr93vQI_m3wEA-npUWjTjF-jF6uulFncGXhgj2AzroMdbDQQ7X_8zH5PB1bh3uH-xua-K7-8FctZQac-5Hk/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-1966480668753877476</id><published>2011-05-30T22:12:00.000+05:30</published><updated>2014-02-21T09:50:45.670+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="JDK-JRE-JVM"/><title type='text'>JDK-JRE-JVM</title><content type='html'>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:WordDocument&gt;   &lt;w:View&gt;Normal&lt;/w:View&gt;   &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:DoNotShowRevisions/&gt;   &lt;w:DoNotPrintRevisions/&gt;   &lt;w:DoNotShowMarkup/&gt;   &lt;w:Compatibility&gt;    &lt;w:BreakWrappedTables/&gt;    &lt;w:SnapToGridInCell/&gt;    &lt;w:ApplyBreakingRules/&gt;    &lt;w:WrapTextWithPunct/&gt;    &lt;w:UseAsianBreakRules/&gt;    &lt;w:UseFELayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-para-margin:0cm;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:10.0pt;
 font-family:&quot;Times New Roman&quot;;
 mso-fareast-font-family:&quot;Times New Roman&quot;;}
&lt;/style&gt; &lt;![endif]--&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;JDK (Java Development Kit)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;Java Development Kit&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt; is a bundle of software that you can use to develop Java based applications. Java Development Kit is needed for developing java applications. JDK needs more Disk space as it Contains JRE along with various development tools. JDK can be downloaded/supported freely from java.sun.com It includes JRE, set of API classes, Java compiler &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;(javac.exe)&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;, &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;Java&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;ilad&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;launcher (java.exe), &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Webstart And additional files needed to write Java applets and applications.&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;Compiler converts java code into byte code. Java&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;application&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;launcher opens a&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;i&gt;JRE&lt;/i&gt;&lt;/b&gt;, loads the class, and invokes its main method.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;JDK&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;is mainly targeted for java development. I.e. you can create a Java file (with the help of Java packages), compile a Java file and run a java file.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 11.5pt;&quot;&gt;JRE (Java Runtime Environment)&lt;/span&gt;&lt;/h2&gt;&lt;span class=&quot;ilad&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;Java Runtime Environment&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system.&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;The&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;Java Virtual Machine&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;provides a platform-independent way of executing code; programmers can concentrate on writing software, without having to be concerned with how or where it will run.&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 11.5pt;&quot;&gt;JVM (Java Virtual Machine)&lt;/span&gt;&lt;/h2&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;As we all aware when we compile a&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;i&gt;Java file&lt;/i&gt;&lt;/b&gt;, output is not an &#39;exe&#39; but it&#39;s a &#39;.class&#39; file. &#39;.class&#39; file consists of&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;i&gt;Java byte codes&lt;/i&gt;&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;The&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;i&gt;JVM&lt;/i&gt;&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;is called &quot;virtual&quot; because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Verdana; font-size: 10.0pt;&quot;&gt;There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/1966480668753877476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/05/jdk-jre-jvm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/1966480668753877476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/1966480668753877476'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/05/jdk-jre-jvm.html' title='JDK-JRE-JVM'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-523636219769144974</id><published>2011-05-08T16:12:00.007+05:30</published><updated>2014-02-21T09:51:03.325+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java RMI"/><title type='text'>Java RMI</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Java Remote Method Invocation&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;This is a technical literature study which purpose is to describe the basic parts of Java Remote Method Invocation. &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Remote Method Invocation, abbreviated as RMI, provides support for&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;distributed objects in Java, i.e. it allows objects to invoke methods on remote objects. The&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;calling objects can use the exact same syntax as for local invocations.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The Java RMI model has two general requirements. The first requirement is that the RMI&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;model shall be simple and easy to use and the second requirement it that the model shall fit into the Java language in a natural way.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Distributed Object Application&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;An RMI application is often composed of two separate programs, a server and a client. The server creates remote objects and makes references to those objects&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;accessible. Then it waits for clients to invoke methods on the objects. The client gets remote references to remote objects in the server and invokes methods on those remote objects. The RMI model provides an distributed object application to the programmer. It&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;is a mechanism that the server and the client use to communicate and pass information&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;between each other. A distributed object application has to handle the following properties:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;&lt;b&gt;Locate remote objects: &lt;/b&gt;The system has to obtain references to remote objects. This&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;can be done in two ways. Either by using RMI’s naming facility, the rmiregistry, or by&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;passing and returning remote objects.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;&lt;b&gt;Communicate with remote objects: &lt;/b&gt;The programmer doesn’t have to handle&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;communication between the remote objects since this is handled by the RMI system.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The remote communication looks like an ordinary method invocation for the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;programmer.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;&lt;b&gt;Load class byte codes for objects that are passed as parameters or return values:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;All mechanisms for loading an object’s code and transmitting data is provided by the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;RMI system.&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Figure A-1, below, illustrates an RMI distributed application. In this example the RMI&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;registry is used to obtain references to a remote object. First the server associates a name with a remote object in the RMI registry (see note 1 in figure A-1). When a client wants access to a remote object it looks up the object, by its name, in the registry (see note 2 in figure A-1). Then the client can invoke methods on the remote object (see note 3 in figure A-1) at the server.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg32V4k_36T3NEfkUIyefQN-UTjfWKMXtGlOHz7D0SljqLbwNjP_h99kST8P0huDyLHUSrM2DN3gYBB8MrZSgZserferwHbqL-ojA99oBglFGSc64x1yU-ErSD72Q-tE1g7QBYTMBmmHwdb/s1600/fig0.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;177&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg32V4k_36T3NEfkUIyefQN-UTjfWKMXtGlOHz7D0SljqLbwNjP_h99kST8P0huDyLHUSrM2DN3gYBB8MrZSgZserferwHbqL-ojA99oBglFGSc64x1yU-ErSD72Q-tE1g7QBYTMBmmHwdb/s320/fig0.gif&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Figure A-1. An Illustration of a distributed object application.&lt;/b&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Interfaces and Classes&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Since Java RMI is a single-language system, the programming of distributed application in RMI is rather simple [CDK01, p194]. All interfaces and classes for the RMI system are defined in the &lt;i&gt;java.rmi &lt;/i&gt;package [SUN02 ,p6]. Figure A-2, below, illustrates the relationship between some of the classes and interfaces. The &lt;i&gt;RemoteObject &lt;/i&gt;class implements the &lt;i&gt;Remote &lt;/i&gt;interface while the other classes extend &lt;i&gt;RemoteObject&lt;/i&gt;.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpBXwcyxJsxX3R6T3H-AYYW-XVoReSL5XvzCmTRFZk3gZYIwLcVwzA-qqd3yZr5FHjO6PhKCa5e9-Pwe5wDUwJHwjnlwFpWzcQKCfCU-GlcyUT_2lYfrR0nWHLCEixSdz_79IquAjVtyC/s1600/fig1.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpBXwcyxJsxX3R6T3H-AYYW-XVoReSL5XvzCmTRFZk3gZYIwLcVwzA-qqd3yZr5FHjO6PhKCa5e9-Pwe5wDUwJHwjnlwFpWzcQKCfCU-GlcyUT_2lYfrR0nWHLCEixSdz_79IquAjVtyC/s400/fig1.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Figure A-2. Interfaces and Classes in the &lt;i&gt;java.rmi &lt;/i&gt;package.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The Remote Interface&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;A remote interface is defined by extending the &lt;i&gt;Remote &lt;/i&gt;interface that is provided in the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;java.rmi package. The remote interface is the interface that declares methods that clients can invoke from a remote virtual machine [SUN02 ,p6]. The remote interface must satisfy the following conditions:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;It must extend the interface &lt;i&gt;Remote&lt;/i&gt;.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;Each remote method declaration in the remote interface must include the exception&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;RemoteException &lt;/i&gt;(or one of it’s superclasses) in it’s thrown clause.&lt;span style=&quot;font-family: Arial; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The RemoteObject Class&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;RMI server functions are provided by the class &lt;i&gt;RemoteObject &lt;/i&gt;and its subclasses&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;RemoteServer&lt;/i&gt;, &lt;i&gt;UnicastRemoteObject &lt;/i&gt;and &lt;i&gt;Activatable&lt;/i&gt;. Here is a short description of what the diffrent classes handle:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;RemoteObject provides implementations of the methods &lt;i&gt;hashCode&lt;/i&gt;, &lt;i&gt;equals &lt;/i&gt;and&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;toString &lt;/i&gt;in the class &lt;i&gt;java.lang.Object&lt;/i&gt;.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;· &lt;/span&gt;The classes UnicastRemoteObject and Activatable create remote objects and export&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;them, i.e. the classes make the remote objects available to remote clients.&lt;span style=&quot;font-family: Arial; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The RemoteException Class&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The class &lt;i&gt;RemoteException &lt;/i&gt;is a superclass of the exceptions that the RMI system throws&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;during a remote method invocation. Each remote method that is declared in a&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;remote interface must specify &lt;i&gt;RemoteException &lt;/i&gt;(or one of it’s superclasses) in it’s throws&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;clause to ensure the robustness of applications in the RMI system.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;When a remote method invocation fails, the exception RemoteException is thrown.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Communication failure, protocol errors and failure during marshalling or unmarshalling of parameters or return values are some reasons for RMI failure.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;RemoteException &lt;/i&gt;is an exception that must be handled by the caller of the remote method, i.e. it is a checked exception. The compiler ensures that the programmer have handled these exceptions.&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Three-layer architecture&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtJQvZRDKiC0c7nz2DoCiSMT-eiw842LYJVN21F3dPcDeomTakvqDpYT0G0Wb1uL110heS-LX2MEeoeXZpfrbEGxlIuftKeN8GduFQkbu6J6hP5IhRxoxq46Aja0xDmkH-Sm8RmBBqYOdt/s1600/fig2.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtJQvZRDKiC0c7nz2DoCiSMT-eiw842LYJVN21F3dPcDeomTakvqDpYT0G0Wb1uL110heS-LX2MEeoeXZpfrbEGxlIuftKeN8GduFQkbu6J6hP5IhRxoxq46Aja0xDmkH-Sm8RmBBqYOdt/s400/fig2.gif&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: TimesNewRoman;&quot;&gt;RMI consists of three layers:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;stubs &amp;amp; skeletons: this layer intercepts method calls made by the client to the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;interface reference and redirects them to a remote RMI service&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;remote reference layer: this layer understands how to interpret and manage&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;references made from clients to the remote service objects.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;In JDK 1.1, this layer connects clients to remote service objects that are running and&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;exported on a server. The connection is a one-to-one (unicast) link.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;In the Java 2 SDK, this layer was enhanced to support the activation of dormant&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;remote service objects via &lt;i&gt;Remote Object Activation&lt;/i&gt;. When a method call is made&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;to the proxy for an activatable object, RMI determines if the remote service&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;implementation object is dormant. If it is dormant, RMI will instantiate the object&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;and restore its state from a disk file. Once an activatable object is in memory, it&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;behaves just like JDK 1.1 remote service implementation objects.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;transport layer: based on TCP/IP. Provides connectivity via sockets. An internal&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;protocol, the &lt;i&gt;Java Remote Method Protocol (JRMP) &lt;/i&gt;is used for communication.&lt;/span&gt;&lt;span style=&quot;font-family: TimesNewRoman;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;The General RMI Architecture&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8YR-R3xiLvKVMay6TXEvK9-wCZnGdC7f0chmGSulTt7vb40LWIrTOLfZqlBAvcg_loMhW2Ep2tAuiUgXnUE5MAb4n55JxTwmk34eqTRQOlzfNd9SXRFnlexxJFsu0Hrr3S4aB6bLfoHUr/s1600/fig4.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8YR-R3xiLvKVMay6TXEvK9-wCZnGdC7f0chmGSulTt7vb40LWIrTOLfZqlBAvcg_loMhW2Ep2tAuiUgXnUE5MAb4n55JxTwmk34eqTRQOlzfNd9SXRFnlexxJFsu0Hrr3S4aB6bLfoHUr/s400/fig4.gif&quot; width=&quot;337&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;margin-top: 0cm;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The server must first bind its name to the      registry&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The client lookup the server name in the      registry to establish remote references.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The Stub      serializing the parameters to skeleton, the skeleton invoking the remote      method and serializing the result back to the stub.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;The Stub and Skeleton&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-G5NaEzLh82Y3BSAEBRRh4kGfbok-r3ilEaxTj1od0RofS-ZP5kh9q2PrQyQMfd88ePhX0ymSaODZ4UxEKTMeHQAxtl8zgJjJY2-HpFAZts7R-MRC24xgBSOFAfQyXzQ4fmRkkMVDCTlw/s1600/fig5.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-G5NaEzLh82Y3BSAEBRRh4kGfbok-r3ilEaxTj1od0RofS-ZP5kh9q2PrQyQMfd88ePhX0ymSaODZ4UxEKTMeHQAxtl8zgJjJY2-HpFAZts7R-MRC24xgBSOFAfQyXzQ4fmRkkMVDCTlw/s400/fig5.gif&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGN37vCz7mkhDMfaOQEbT_a7UMOlSTAQMW7nYXyGCInf6Uu4Ytg4JUuytL6cjPIwj59gbN_2MLbpRp0t6DdCYxRMIPecxVRkkt6y3-BxYb-My44bPBXpeavES6cnUF-nKuNxZVXfLow-BC/s1600/fig3.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGN37vCz7mkhDMfaOQEbT_a7UMOlSTAQMW7nYXyGCInf6Uu4Ytg4JUuytL6cjPIwj59gbN_2MLbpRp0t6DdCYxRMIPecxVRkkt6y3-BxYb-My44bPBXpeavES6cnUF-nKuNxZVXfLow-BC/s400/fig3.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;margin-top: 0cm;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;A client invokes a remote method, the call      is first forwarded to stub.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The stub is responsible for sending the      remote call over to the server-side skeleton&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The stub opening a socket to the remote      server, marshaling the object parameters and forwarding the data stream to      the skeleton.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-autospace: none;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;A skeleton contains a method that receives      the remote calls, unmarshals the parameters, and invokes the actual remote      object implementation.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Steps for Developing an RMI System&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;1. Define the remote interface&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;2. Develop the remote object by implementing the remote interface.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;3. Develop the client program.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;4. Compile the Java source files.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;5. Generate the client stubs and server skeletons.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;6. Start the RMI registry.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;7. Start the remote server objects.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;8. Run the client &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Step 1:&amp;nbsp; Defining the Remote&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;•&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;To create an RMI application, the first step is the defining of a remote interface between the client and server objects.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;/* SampleServer.java */&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;public interface SampleServer &lt;b&gt;extends Remote&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; public int sum(int a,int b) throws RemoteException;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Step 2: Develop the remote object&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 20pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The server is a simple unicast remote server. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 20pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Create server by extending java.rmi.server.UnicastRemoteObject. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 20pt;&quot;&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The server uses the RMISecurityManager to protect its resources while engaging in remote communication.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;/* SampleServerImpl.java */&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.server.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.registry.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;public class SampleServerImpl &lt;b&gt;extends UnicastRemoteObject&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implements SampleServer&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; SampleServerImpl() throws RemoteException&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; super();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Implement the remote methods&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;/* SampleServerImpl.java */&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; public int sum(int a,int b) throws RemoteException&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a + b;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The server must bind its name to the registry, the client will look up the server name.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Use java.rmi.Naming class to bind the server name to registry. In this example the name call “SAMPLE-SERVER”.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;In the main method of your server object, the RMI security manager is created and installed.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;/* SampleServerImpl.java */&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; public static void main(String args[])&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.setSecurityManager(new RMISecurityManager());&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //set the security manager&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create a local instance of the object&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SampleServerImpl Server = new SampleServerImpl();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //put the local instance in the registry&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;Naming.rebind(&quot;SAMPLE-SERVER&quot; , Server);&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Server waiting.....&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (java.net.MalformedURLException me)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Malformed URL: &quot; + me.toString());&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (RemoteException re)&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Remote exception: &quot; + re.toString());&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Step 3: Develop the client program&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;In order for the client object to invoke methods on the server, it must first look up the name of server in the registry. You use the java.rmi.Naming class to lookup the server name.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The server name is specified as URL in the from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( rmi://host:port/name )&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Default RMI port is 1099.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The name specified in the URL must exactly match the name that the server has bound to the registry. In this example, the name is “SAMPLE-SERVER”&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The remote method invocation is programmed using the remote interface name (remoteObject) as prefix and the remote method name (sum) as suffix.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;import java.rmi.server.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;public class SampleClient&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; public static void main(String[]&amp;nbsp; args)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set the security manager for the client&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.setSecurityManager(new RMISecurityManager());&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //get the remote object from the registry&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Security Manager loaded&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String url = &quot;//localhost/SAMPLE-SERVER&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SampleServer remoteObject = &lt;b&gt;(SampleServer)Naming.lookup(url)&lt;/b&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Got remote object&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot; 1 + 2 = &quot; + &lt;b&gt;remoteObject.sum(1,2)&lt;/b&gt; );&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (RemoteException exc) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Error in lookup: &quot; + exc.toString()); }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (java.net.MalformedURLException exc) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Malformed URL: &quot; + exc.toString());&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (java.rmi.NotBoundException exc)&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;NotBound: &quot; + exc.toString());&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;Step 4 &amp;amp; 5: Compile the Java source files &amp;amp; Generate the client stubs and server skeletons&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; Assume the program compile and executing at elpis on ~/rmi&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Once the interface is completed, you need to generate stubs and skeleton code. The RMI system provides an RMI compiler (rmic) that takes your generated interface class and procedures stub code on its self.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 90.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 90.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;elpis:~/rmi&amp;gt; set CLASSPATH=”~/rmi”&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 90.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;elpis:~/rmi&amp;gt; javac SampleServer.java&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 90.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;elpis:~/rmi&amp;gt; javac SampleServerImpl.java&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 90.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;elpis:~/rmi&amp;gt; rmic SampleServerImpl&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  elpis:~/rmi&amp;gt; javac SampleClient.java&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Step 6: Start the RMI registry&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The RMI applications need install to Registry. And the Registry must start manual by call rmiregisty. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;The rmiregistry us uses port 1099 by default. You can also bind rmiregistry to a different port by indicating the new port number as : rmiregistry &lt;new port=&quot;&quot;&gt;&lt;/new&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elpis:~/rmi&amp;gt; rmiregistry&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Remark: On Windows, you have to type in from the command line:&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt; start rmiregistry&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Steps 7 &amp;amp; 8: Start the remote server objects &amp;amp; Run the client&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Once the Registry is started, the server can be started and will be able to store itself in the Registry. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 24pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Because of the grained security model in Java 2.0, you must setup a security policy for RMI by set java.security.policy to the file policy.all&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;elpis:~/rmi&amp;gt; java –Djava.security.policy=policy.all SampleServerImpl&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;elpis:~/rmi&amp;gt; java –Djava.security.policy=policy.all SampleClient&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Java Policy File&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 18pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;In Java 2, the java application must first obtain information regarding its privileges. It can obtain the security policy through a policy file. In above example, we allow Java code to have all permissions,&amp;nbsp; the contains of the policy file policy.all is:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; grant {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permission java.security.AllPermission;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; };&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 18pt;&quot;&gt;&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span dir=&quot;LTR&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;Now, we given an example for assigning resource permissions:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-align: justify; text-autospace: none; text-indent: -27.0pt; text-justify: inter-ideograph;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; grant {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permission java.io.filePermission “/tmp/*”, “read”, “write”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permission java.net.SocketPermission “somehost.somedomain.com:999”,”connect”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permission java.net.SocketPermission “*:1024-65535”,”connect,request”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permission java.net.SocketPermission “*:80”,”connect”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; };&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27pt; text-indent: -27pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Sample program&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Client invokes a remote method with strings as parameter&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Server returns a string containing the reversed input string and a message&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Define the remote interface (HelloInterface.java)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public interface HelloInterface extends Remote {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public String say(String msg) throws RemoteException;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;We define an interface for a remote class that includes one remote method:&amp;nbsp;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;say &lt;/i&gt;accepts a String as an input parameter and returns a String as a result&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Note that the interface extends Remote and that each method (there’s only one here)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;throws RemoteException. These classes are defined in the java.rmi package, so we import it.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Define the remote class (Hello.java)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.server.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public class Hello&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;extends UnicastRemoteObject&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;implements HelloInterface {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;private String message;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public Hello(String msg) throws RemoteException {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;message = msg;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public String say(String m) throws RemoteException {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;// return the input message - reversed input plus our standard message&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;return new StringBuffer(m).reverse().toString() + &quot;\n&quot; + message;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The remote class defines two methods:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Hello is our constructor and will be used by the server to set define the standard&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;message that will always be sent back to the client.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;say is a method that takes a string as the input. It returns a string containing the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;input with the characters reversed followed by a newline followed by our standard&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;message (set in the constructor).&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Note that:&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;- the class extends UnicastRemoteObject&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;this will allow the methods to be invoked remotely&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;- the class implements the interface we defined&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;- each method must throw RemoteException because remote procedure calls might fail&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;- the say method accepts a String and returns a String. String is defined to be&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Serializable. If you were to accept or return an object you defined, it would have to&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;be defined to implement Serializable.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The server (HelloServer.java)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.server.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public class HelloServer {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public static void main(String argv[]) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;if (System.getSecurityManager() == null)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.setSecurityManager(new RMISecurityManager());&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;try {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;// instantiate the service with the standard message &amp;amp; tell registry&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Naming.rebind(&quot;Hello&quot;, new Hello(&quot;Hello, world!&quot;));&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println(&quot;Server is running...&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;} catch(Exception e) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println(&quot;Hello Server failed: &quot; + e);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The server is a plain program that is responsible for:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;1. Creating and installing a security manager. We do this with:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;System.setSecurityManager(new RMISecurityManager());&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The security manager makes sure that classes that get loaded do not perform&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;operations that they are not allowed to perform.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;2. Registering at least one remote object with the object registry.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;We do this with:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Naming.rebind(object_name, object);&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;where object_name is a String that names the remote object&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;and object is the remote object that we are registering.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;All that our server does is:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;set the security maanger&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;create the remote object&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;register it&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;print a message saying “Server is running…”&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The client (HelloClient.java)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;import java.rmi.*;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public class HelloClient {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;public static void main(String argv[]) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;try {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;if (args.length &amp;lt; 0) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.err.println(“usage: java HelloClient string …\n”);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.exit(1);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;HelloInterface hello = (HelloInterface)Naming.lookup(&quot;//localhost/Hello&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;for (int i=0; i &amp;lt; args.length; ++I)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println(hello.say(args[i]));&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;} catch (Exception e) {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println(”Helloclient exception: &quot; + e);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The client invokes the remote method.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;To do this, the client must have a handle (reference) to the remote object.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The object registry allows the client to get this reference to a remote object.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;To get the reference to the remote object, we need to know:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;1. Internet name (or address) of machine that is running the object registry for&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;which the remote object is registered (can omit if localhost)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;2. Port on which the object registry is running (can omit if it is 1099 - default)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;3. Name of the object within the object registry.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The Naming.lookup method obtains an object handle from the object registry&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;running on localhost on the default port (we could have just looked up “Hello” in&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;this case).&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The result of &lt;b&gt;Naming.lookup &lt;/b&gt;must be cast to the type of the Remote Interface&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;------&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The remote invocation of the object is the call to &lt;b&gt;hello.say(“abc”)&lt;/b&gt;. It returns a&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;String which we print. Remember again, that we can get a String &lt;i&gt;only &lt;/i&gt;because&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;String is a Serializable class.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The policy (policy)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;grant {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;permission java.security.AllPermission;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The policy file controls which clients have which permissions. The one in this&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;example grants everyone global permission (&lt;i&gt;not a good one to use in a production&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;i&gt;environment!&lt;/i&gt;).&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;The policy file is not needed when programming with JDK &amp;lt; 1.2&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;The Java security manager contains a number of &lt;i&gt;check &lt;/i&gt;methods (e.g&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;i&gt;checkConnect&lt;/i&gt;&lt;/b&gt;). In the default manager, these are implemented by calling a&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;i&gt;checkPermission &lt;/i&gt;&lt;/b&gt;method. The type of permission is specified by a parameter of&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;type &lt;b&gt;Permission &lt;/b&gt;that is passed to &lt;b&gt;checkPermission&lt;/b&gt;. The method checks whether&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;the permission is implied by a list of granted permissions.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;To specify or change the security policy, there is a class named Policy. A program&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;can get its policy by calling &lt;b&gt;Policy.getPolicy() &lt;/b&gt;or set it (if it has permissions) with&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Policy.setPolicy(). The security policy is typically specified by a policy&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;configuration file which is reaad when the program starts.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Compile&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Compile the interface and classes:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;javac HelloInterface.java Hello.java&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;javac HelloServer.java HelloClient.java&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Create the class files for stubs:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;rmic Hello&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• rmic creates:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Hello_Skel.class &lt;/span&gt;&lt;/b&gt;skeleton - server-side stub&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Hello_Stub.class &lt;/span&gt;&lt;/b&gt;client-site stub&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;We first compile the remote interface and classes using javac. Then we generate the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;class files for the client and server stubs with the rmi compiler:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;rmic Hello&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;This produces two class files:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Hello_Skel.class is the skeleton (a name for a server-stub)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Hello_Stub.class is the client stub function&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;Run&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Start the object registry (in the background):&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;rmiregistry &amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Start the server (in the background):&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;java -Djava.security.policy=policy&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;HelloServer &amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• Run the client:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;java HelloClient testing abcdefgh&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;• See the output:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;gnitset&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Hello, world!&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;hgfedcba&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Hello, world!&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 27.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -27.0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Now we’re ready to run the program.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;If the registry is not running, it must be started. Otherwise the server will not be able&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;to register the object and the client will not be able to look it up.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;We start it in the background with:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;rmiregistry &amp;amp;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;If we wanted it to listen on a different port than 1099, we would specify the port&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;number on the command line. For example, to listen on port 5511:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;rmiregistry 5511 &amp;amp;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Next we start the server (also in the background) by running:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;java -Djava.security.policy=policy HelloServer &amp;amp;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;where the -D flag sets the name of the file containing our security policy (our file is&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;named &lt;i&gt;policy &lt;/i&gt;and is in the current directory).&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;Finally, we can run the client with:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;java HelloClient testing abcdefg&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;NOTE: be sure to kill the registry and server processes when you’re done.&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/523636219769144974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/05/java-rmi.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/523636219769144974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/523636219769144974'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/05/java-rmi.html' title='Java RMI'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg32V4k_36T3NEfkUIyefQN-UTjfWKMXtGlOHz7D0SljqLbwNjP_h99kST8P0huDyLHUSrM2DN3gYBB8MrZSgZserferwHbqL-ojA99oBglFGSc64x1yU-ErSD72Q-tE1g7QBYTMBmmHwdb/s72-c/fig0.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-2812619730441483621</id><published>2011-04-17T16:46:00.001+05:30</published><updated>2014-02-21T09:54:33.614+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Log4J"/><category scheme="http://www.blogger.com/atom/ns#" term="log4j PatternLayout"/><title type='text'>log4j PatternLayout</title><content type='html'>log4j PatternLayout &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to generate your logging information in a particular format based on a patten then you can use org.apache.log4j.PatternLayout to format your logging information.&lt;br /&gt;
&lt;br /&gt;
The PatternLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method to structure logging information according to a supplied pattern.&lt;br /&gt;
&lt;br /&gt;
PatternLayout is also a simple Layout object that provides following Bean Property which can be set using configuration file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPGvE1VdgNIsOvZ4hgYGEd_IauProb-xmLKmJnfpBIExZW-wlnizv1RuXlHolUtnyeIlLm13EC0vogVw2BdUGXV91VTeCXtfGlKqAuUikWOIX4BqqZWMM1wVUXIH-v-E2DMei_VVafTqq/s1600/1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; r6=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPGvE1VdgNIsOvZ4hgYGEd_IauProb-xmLKmJnfpBIExZW-wlnizv1RuXlHolUtnyeIlLm13EC0vogVw2BdUGXV91VTeCXtfGlKqAuUikWOIX4BqqZWMM1wVUXIH-v-E2DMei_VVafTqq/s1600/1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Pattern Conversion Characters:&lt;br /&gt;
&lt;br /&gt;
Below table explains characters used in the above pattern and all other characters which you can use in your custom pattern:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaubhdZko_G0pPeaJE5cWen1ByNJkGL2G6WnEvGiJAfWO94lxOYCmDT2kwFyNdChD22tJNnxauIqYRvFtHN444Kcls4DRWZzi9v77I1cPpykQDU23Hwmg_oNwl7-NyZbaApHoPshuRWKmu/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; r6=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaubhdZko_G0pPeaJE5cWen1ByNJkGL2G6WnEvGiJAfWO94lxOYCmDT2kwFyNdChD22tJNnxauIqYRvFtHN444Kcls4DRWZzi9v77I1cPpykQDU23Hwmg_oNwl7-NyZbaApHoPshuRWKmu/s1600/2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Format Modifiers:&lt;br /&gt;
&lt;br /&gt;
By default the relevant information is output as is. However, with the aid of format modifiers it is possible to change the minimum field width, the maximum field width and justification.&lt;br /&gt;
&lt;br /&gt;
Following table covers various modifiers scenarios:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWuSylDIGVuuMg3H7H24fid1w-acuUaJiVM685Lb0s2Gd2BuPflrQIcdIVpz8daGWXObz7MXKxwwlfR5yd5-tsxUuDzh-EKL-XdrV4lRkpIhUKoKfzf0JRNmTsjeRJh-Qm7WOsmun-IQg8/s1600/3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; r6=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWuSylDIGVuuMg3H7H24fid1w-acuUaJiVM685Lb0s2Gd2BuPflrQIcdIVpz8daGWXObz7MXKxwwlfR5yd5-tsxUuDzh-EKL-XdrV4lRkpIhUKoKfzf0JRNmTsjeRJh-Qm7WOsmun-IQg8/s1600/3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
PatternLayout Example:&lt;br /&gt;
&lt;br /&gt;
Following is a simple configuration file for PatternLayout:&lt;br /&gt;
&lt;br /&gt;
# Define the root logger with appender file&lt;br /&gt;
log = /usr/home/log4j&lt;br /&gt;
log4j.rootLogger = DEBUG, FILE&lt;br /&gt;
# Define the file appender&lt;br /&gt;
log4j.appender.FILE=org.apache.log4j.FileAppender&lt;br /&gt;
log4j.appender.FILE.File=${log}/log.out&lt;br /&gt;
# Define the layout for file appender&lt;br /&gt;
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd}-%t-%x-%-5p-%-10c:%m%n&lt;br /&gt;
&lt;br /&gt;
Now consider the following Java Example which would generate logging information:&lt;br /&gt;
&lt;br /&gt;
import org.apache.log4j.Logger;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.sql.SQLException;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
&lt;br /&gt;
public class log4jExample{&lt;br /&gt;
&lt;br /&gt;
/* Get actual class name to be printed on */&lt;br /&gt;
static Logger log = Logger.getLogger(&lt;br /&gt;
log4jExample.class.getName());&lt;br /&gt;
public static void main(String[] args)&lt;br /&gt;
throws IOException,SQLException{&lt;br /&gt;
log.debug(&quot;Hello this is an debug message&quot;);&lt;br /&gt;
log.info(&quot;Hello this is an info message&quot;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Compile and run the above program, it would create a log.out file in /usr/home/log4j directory which would have following log information:&lt;br /&gt;
&lt;br /&gt;
2010-03-23-main--DEBUG-log4jExample:Hello this is an debug message&lt;br /&gt;
2010-03-23-main--INFO -log4jExample:Hello this is an info message</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/2812619730441483621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/log4j-patternlayout.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/2812619730441483621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/2812619730441483621'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/log4j-patternlayout.html' title='log4j PatternLayout'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPGvE1VdgNIsOvZ4hgYGEd_IauProb-xmLKmJnfpBIExZW-wlnizv1RuXlHolUtnyeIlLm13EC0vogVw2BdUGXV91VTeCXtfGlKqAuUikWOIX4BqqZWMM1wVUXIH-v-E2DMei_VVafTqq/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-5775821051502278880</id><published>2011-04-17T16:26:00.000+05:30</published><updated>2014-02-21T09:54:33.617+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Log4J"/><category scheme="http://www.blogger.com/atom/ns#" term="log4j PatternLayout"/><title type='text'>log4j HTMLLayout</title><content type='html'>log4j&amp;nbsp; HTMLLayout &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to generate your logging information in a HTML-formatted file then you can use org.apache.log4j.HTMLLayout to format your logging information.&lt;br /&gt;
&lt;br /&gt;
The HTMLLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method from its base class to provide HTML-style formatting.&lt;br /&gt;
&lt;br /&gt;
This provided the following information to be displayed:&lt;br /&gt;
&lt;br /&gt;
• The time elapsed from the start of the application before a particular logging event was generated.&lt;br /&gt;
• The name of the thread that invoked the logging request.&lt;br /&gt;
• The level associated with this logging request.&lt;br /&gt;
• The name of the logger and logging message.&lt;br /&gt;
• The optional location information for the program file and the line number from which this logging was invoked.&lt;br /&gt;
&lt;br /&gt;
HTMLLayout is a very simple Layout object that provides following methods:&lt;br /&gt;
&lt;br /&gt;
1 setContentType(String)&lt;br /&gt;
Sets the content type of the text/html HTML content. Default is text/html.&lt;br /&gt;
&lt;br /&gt;
2 setLocationInfo(String)&lt;br /&gt;
Sets the location information for the logging event. Default is false.&lt;br /&gt;
&lt;br /&gt;
3 setTitle(String)&lt;br /&gt;
Sets the title for the HTML file. Default is Log4j Log Messages.&lt;br /&gt;
&lt;br /&gt;
HTMLLayout Example:&lt;br /&gt;
&lt;br /&gt;
Following is a simple configuration file for HTMLLayout:&lt;br /&gt;
&lt;br /&gt;
# Define the root logger with appender file&lt;br /&gt;
log = /usr/home/log4j&lt;br /&gt;
log4j.rootLogger = DEBUG, FILE&lt;br /&gt;
&lt;br /&gt;
# Define the file appender&lt;br /&gt;
log4j.appender.FILE=org.apache.log4j.FileAppender&lt;br /&gt;
log4j.appender.FILE.File=${log}/htmlLayout.html&lt;br /&gt;
&lt;br /&gt;
# Define the layout for file appender&lt;br /&gt;
log4j.appender.FILE.layout=org.apache.log4j.HTMLLayout&lt;br /&gt;
log4j.appender.FILE.layout.Title=HTML Layout Example&lt;br /&gt;
log4j.appender.FILE.layout.LocationInfo=true&lt;br /&gt;
&lt;br /&gt;
Now consider the following Java Example which would generate logging information:&lt;br /&gt;
&lt;br /&gt;
import org.apache.log4j.Logger;&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.sql.SQLException;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
&lt;br /&gt;
public class log4jExample{&lt;br /&gt;
/* Get actual class name to be printed on */&lt;br /&gt;
static Logger log = Logger.getLogger(&lt;br /&gt;
log4jExample.class.getName());&lt;br /&gt;
public static void main(String[] args)&lt;br /&gt;
throws IOException,SQLException{&lt;br /&gt;
log.debug(&quot;Hello this is an debug message&quot;);&lt;br /&gt;
log.info(&quot;Hello this is an info message&quot;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Compile and run the above program, it would create a htmlLayout.html file in /usr/home/log4j directory which would have following log information:&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------------------------------------------&lt;br /&gt;
Log session start time Mon Mar 22 13:30:24 AST 2010&lt;br /&gt;
&lt;br /&gt;
Time&amp;nbsp;&amp;nbsp;Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Level&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Category&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;File:Line&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Message&lt;br /&gt;
&lt;br /&gt;
0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; main&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEBUG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log4jExample&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log4jExample.java:15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hello this is an debug message&lt;br /&gt;
&lt;br /&gt;
6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;main&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log4jExample&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log4jExample.java:16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Hello this is an info message&lt;br /&gt;
&lt;br /&gt;
You would use a web browser to open htmlLayout.html file. It is also important to note that the footer for the and tags is completely missing.&lt;br /&gt;
&lt;br /&gt;
One of the big advantages of having the log file in HTML format is that it can be published as a web page for remote viewing.</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/5775821051502278880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/log4j-htmllayout.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/5775821051502278880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/5775821051502278880'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/log4j-htmllayout.html' title='log4j HTMLLayout'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-8289496216063502220</id><published>2011-04-17T16:10:00.000+05:30</published><updated>2015-03-21T01:20:26.594+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Log4J"/><title type='text'>Multiple Appenders Using XML File</title><content type='html'>Log4j XML Configuration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example we will see how to create more than one appender using xml configuration file. This example is similar to the one we saw before using the properties file (example). So I will simply compare both. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following code shows the log4j.properties file we used in the previous example.&lt;br /&gt;
&lt;br /&gt;
log4j.rootLogger=DEBUG, CA, FA &lt;br /&gt;
&lt;br /&gt;
#Console Appender &lt;br /&gt;
log4j.appender.CA=org.apache.log4j.ConsoleAppender &lt;br /&gt;
log4j.appender.CA.layout=org.apache.log4j.PatternLayout &lt;br /&gt;
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n &lt;br /&gt;
#File Appender &lt;br /&gt;
log4j.appender.FA=org.apache.log4j.FileAppender &lt;br /&gt;
log4j.appender.FA.File=sample.log &lt;br /&gt;
log4j.appender.FA.layout=org.apache.log4j.PatternLayout &lt;br /&gt;
log4j.appender.FA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n &lt;br /&gt;
# Set the logger level of File Appender to WARN &lt;br /&gt;
log4j.appender.FA.Threshold = WARN&lt;br /&gt;
&lt;br /&gt;
The following code shows the corresponding log4j.xml file. &lt;br /&gt;
&lt;br /&gt;
&lt;!--l version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;--&gt;&lt;br /&gt;
&lt;!--DOCTYPE log4j:configuration SYSTEM &quot;log4j.dtd&quot;--&gt;&lt;br /&gt;
&lt;configuration xmlns:log4j=&quot;http://jakarta.apache.org/log4j/&quot;&gt;&lt;/configuration&gt;&lt;br /&gt;
&lt;appender class=&quot;org.apache.log4j.ConsoleAppender&quot; name=&quot;CA&quot;&gt;&lt;br /&gt;
&lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt;&lt;br /&gt;
&lt;param name=&quot;ConversionPattern&quot; value=&quot;%-4r [%t] %-5p %c %x - %m%n&quot; /&gt;&lt;br /&gt;
&lt;/layout&gt;&lt;br /&gt;
&lt;/appender&gt;&lt;br /&gt;
&lt;appender class=&quot;org.apache.log4j.FileAppender&quot; name=&quot;FA&quot;&gt;&lt;br /&gt;
&lt;param name=&quot;File&quot; value=&quot;sample.log&quot; /&gt;&lt;br /&gt;
&lt;param name=&quot;Threshold&quot; value=&quot;WARN&quot; /&gt;&lt;br /&gt;
&lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt;&lt;br /&gt;
&lt;param name=&quot;ConversionPattern&quot; value=&quot;%-4r [%t] %-5p %c %x - %m%n&quot; /&gt;&lt;br /&gt;
&lt;/layout&gt;&lt;br /&gt;
&lt;/appender&gt;&lt;br /&gt;
&lt;root&gt;&lt;br /&gt;
&lt;level value=&quot;DEBUG&quot;&gt;&lt;br /&gt;
&lt;appender-ref ref=&quot;CA&quot;&gt;&lt;br /&gt;
&lt;appender-ref ref=&quot;FA&quot;&gt;&lt;br /&gt;
&lt;/appender-ref&gt;&lt;/appender-ref&gt;&lt;/level&gt;&lt;/root&gt;</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/8289496216063502220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/multiple-appenders-using-xml-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/8289496216063502220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/8289496216063502220'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/multiple-appenders-using-xml-file.html' title='Multiple Appenders Using XML File'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-7621707586615820962</id><published>2011-04-17T16:06:00.000+05:30</published><updated>2014-02-21T09:54:33.619+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Log4J"/><title type='text'>Multiple Appenders Using Properties File</title><content type='html'>Log4j Multiple Appender Example&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example you will see how to create a console and file appender and add it to the rootLogger.&lt;br /&gt;
&lt;br /&gt;
The log4j.properties file is shown below. &lt;br /&gt;
&lt;br /&gt;
log4j.rootLogger=DEBUG, CA, FA &lt;br /&gt;
#Console Appender &lt;br /&gt;
log4j.appender.CA=org.apache.log4j.ConsoleAppender &lt;br /&gt;
log4j.appender.CA.layout=org.apache.log4j.PatternLayout &lt;br /&gt;
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n &lt;br /&gt;
#File Appender &lt;br /&gt;
log4j.appender.FA=org.apache.log4j.FileAppender &lt;br /&gt;
log4j.appender.FA.File=sample.log &lt;br /&gt;
log4j.appender.FA.layout=org.apache.log4j.PatternLayout &lt;br /&gt;
log4j.appender.FA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n &lt;br /&gt;
# Set the logger level of File Appender to WARN &lt;br /&gt;
log4j.appender.FA.Threshold = WARN&lt;br /&gt;
Here we create two appenders ConsoleAppender and FileAppender. You need to set the File attribute of the FileAppender to the log file name, here it is sample.log. Add the FileAppender (FA) and the ConsoleAppender (CA) to the rootLogger. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also set the logger level for each appender seperately. Here the FileAppender logger level is set to WARN. Only WARN, ERROR and FATAL level log messages will be logged in the sample.log file. Since we don&#39;t set any log level explicitly for the ConsoleAppender it will inherit the rootLogger level, that is DEBUG. &lt;br /&gt;
&lt;br /&gt;
Here is our example code. &lt;br /&gt;
&lt;br /&gt;
import org.apache.log4j.Logger; &lt;br /&gt;
import org.apache.log4j.PropertyConfigurator; &lt;br /&gt;
public class HelloWorld { &lt;br /&gt;
static final Logger logger = Logger.getLogger(HelloWorld.class); &lt;br /&gt;
public static void main(String[] args) { &lt;br /&gt;
PropertyConfigurator.configure(&quot;log4j.properties&quot;); &lt;br /&gt;
logger.debug(&quot;Sample debug message&quot;); &lt;br /&gt;
logger.info(&quot;Sample info message&quot;); &lt;br /&gt;
logger.warn(&quot;Sample warn message&quot;); &lt;br /&gt;
logger.error(&quot;Sample error message&quot;); &lt;br /&gt;
logger.fatal(&quot;Sample fatal message&quot;); &lt;br /&gt;
} &lt;br /&gt;
}&lt;br /&gt;
The output on the cosole. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[main] DEBUG com.vaannila.helloworld.HelloWorld - Sample debug message &lt;br /&gt;
&lt;br /&gt;
[main] INFO com.vaannila.helloworld.HelloWorld - Sample info message &lt;br /&gt;
[main] WARN com.vaannila.helloworld.HelloWorld - Sample warn message &lt;br /&gt;
[main] ERROR com.vaannila.helloworld.HelloWorld - Sample error message &lt;br /&gt;
[main] FATAL com.vaannila.helloworld.HelloWorld - Sample fatal message&lt;br /&gt;
The contents of the sample.log file. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[main] WARN com.vaannila.helloworld.HelloWorld - Sample warn message &lt;br /&gt;
[main] ERROR com.vaannila.helloworld.HelloWorld - Sample error message &lt;br /&gt;
[main] FATAL com.vaannila.helloworld.HelloWorld - Sample fatal message</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/7621707586615820962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/multiple-appenders-using-properties.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7621707586615820962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/7621707586615820962'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/multiple-appenders-using-properties.html' title='Multiple Appenders Using Properties File'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-56197894517213157</id><published>2011-04-13T20:23:00.028+05:30</published><updated>2014-02-21T09:55:04.102+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="EJB 3 Persistence"/><title type='text'>EJB 3 Persistence</title><content type='html'>EJB 3 Persistence&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java Persistence API is the standard API used for the management of the persistent data and object/relational mapping. Java Persistence API is added in Java EE 5 platform. Every application server compatible with Java EE 5 supports the Java Persistent APIs.&lt;br /&gt;
&lt;br /&gt;
Java Persistence API ensures the management of persistence and object/relational mapping. These are helpful while using the JPA in the development of applications using the platform for Java EE 5. It provides O-R mapping facility to manage relational data in java application. &lt;br /&gt;
&lt;br /&gt;
Features of JPA: &lt;br /&gt;
&lt;br /&gt;
Java Persistence API is a lightweight framework based on POJO for object-relational mapping. Java language metadata annotations and/or XML deployment descriptor is used for the mapping between Java objects and a relational database. It allows the SQL-like query language that works for both static as well as dynamic queries. It also allows the use of the pluggable persistence API. Java Persistence APIs are mainly depends on metadata annotations. API includes:&lt;br /&gt;
&lt;br /&gt;
• Java Persistence API&lt;br /&gt;
&lt;br /&gt;
• Metadata annotations&lt;br /&gt;
&lt;br /&gt;
• Java Persistence query language&lt;br /&gt;
&lt;br /&gt;
Advantages of JPA:&lt;br /&gt;
&lt;br /&gt;
Java Persistence API is build upon the best ideas from the persistence technologies like TopLink, JDO and Hibernate. Java Persistence API is compatible with Java SE environment as well as Java EE and allows developers to take advantages of the standard persistence API. &lt;br /&gt;
&lt;br /&gt;
Persistency of data is not so easy for most of the enterprise applications because for this they require access to the relational database like Oracle 10g. It is your responsibility to update and retrieve the database by writing the code using SQL and JDBC. While several object-relational (O-R) frameworks such as JBoss Hibernate and OracleTopLink make persistence challenges simpler and became popular. They let the java developer free from writing JDBC code and to concentrate only on the business logic. In EJB 2.x, container manage persistence (CMP) try to solve the persistence challenges but not successful completely.&lt;br /&gt;
&lt;br /&gt;
Persistence tier of the application can be developed in several ways but Java platform does not follow any standard that can be used by both Java EE and Java SE environment. But the Java Persistence API (JPA) part of EJB 3.0 spec (JSR-220) makes the persistence API standard for the Java platform. O/R mapping vendors like Hibernate and TopLink as well as JDO vendors and other leading application server vendors are receiving the JSR-220.&lt;br /&gt;
&lt;br /&gt;
Here we are describing EJB3 JPA by using the simple domain object model by an example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Working process of an EJB application using JPA:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzeCuCz_i5TyOBh7SeHHUFiijmaqkhnDFuPh1gsymGWBwgRuYvFj29j89HPDs7kXWuxozLjS1wo-qUCoD3cWNr1gv4JajM0b781ZJ0zD0s3VzK5z2vo2rCanXK-kHpM3t4Q8c3QMyDB4x7/s1600/persistance.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; r6=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzeCuCz_i5TyOBh7SeHHUFiijmaqkhnDFuPh1gsymGWBwgRuYvFj29j89HPDs7kXWuxozLjS1wo-qUCoD3cWNr1gv4JajM0b781ZJ0zD0s3VzK5z2vo2rCanXK-kHpM3t4Q8c3QMyDB4x7/s1600/persistance.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Basics of EJB3 JPA and O-R Mapping Framework:&lt;br /&gt;
&lt;br /&gt;
It defines a declarative way known as O-R mapping metadata to perform O-R mapping. Most of the framework use XML to store the O-R mapping metadata.&lt;br /&gt;
&lt;br /&gt;
An API is required to manipulate like to perform CRUD (CRUD stands for create, read, update, and delete) operations. The API allows you to persist, remove, update or retrieve the object from the database. O-R framework performs operations using the API and the O-R mapping metadata on your behalf. &lt;br /&gt;
&lt;br /&gt;
Use of a query language for retrieving objects from the database is the proper way since improper SQL statements may result in slow down the performance of the operation performing on the database. A query language allows retrieving the entities from the database and spares you from writing the SQL SELECT statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Metadata Annotation in Action: Metadata annotations are first time introduced in Java SE 5.0. To make the development easy all the components of Java EE including EJB3 uses the metadata annotations. In EJB3 JPA annotation defines the objects, O-R mappings, and the relationships among them. JPA also have another option to use XML descriptor, But use of the metadata annotations make the development simpler and more efficient.&lt;br /&gt;
&lt;br /&gt;
Entities: &lt;br /&gt;
&lt;br /&gt;
An entity can be considered as a light weight persistence domain object. An entity defines a table in a relational database and each instance of an entity corresponds to a row in that table. An entity refers to a logical collection of data that can be stored or retrieved as a whole. For example, in a banking application, Customer and BankAccount can be treated as entities. Customer name, customer address etc can be logically grouped together for representing a Customer entity. Similarly account number, total balance etc may be logically grouped under BankAccount entity.&lt;br /&gt;
&lt;br /&gt;
Persistence fields or persistent properties define the persistent state of an entity. To map the entities and their relationship to the data in the relational database these entities use the object-relational mapping.&lt;br /&gt;
&lt;br /&gt;
Requirements of Entity Classes: There are some requirements that an entity must follow:&lt;br /&gt;
&lt;br /&gt;
• The class must contain either a public or a protect no argument constructor, while it can contain other constructors.&lt;br /&gt;
&lt;br /&gt;
• The class as well as methods and persistence instance variables must not be declared as final.&lt;br /&gt;
&lt;br /&gt;
• Use the annotation javax.persistence.Entity to annotate the class.&lt;br /&gt;
&lt;br /&gt;
• Declare the persistence instance variables as protected, private or package-private so that they can directly accessed only by the entity class&#39;s methods.&lt;br /&gt;
&lt;br /&gt;
• Entity class may extend the entity as well as non-entity classes or vice-versa.&lt;br /&gt;
&lt;br /&gt;
• The class must implement the serializable interface if an entity instance is passed by value.&lt;br /&gt;
&lt;br /&gt;
Persistence Fields and Properties in Entity Classes: There are two ways to access the persistent state of an entity either by instance variables or by using the JavaBeans-style properties. The fields or the properties must follow the Java language types: &lt;br /&gt;
&lt;br /&gt;
• Java primitive types&lt;br /&gt;
• java.lang.String&lt;br /&gt;
• Other serialization types including:&lt;br /&gt;
• wrappers of java primitive types&lt;br /&gt;
• java.util.Date&lt;br /&gt;
• java.util.Calender&lt;br /&gt;
• java.math.BigDecimal&lt;br /&gt;
• java.math.BigInteger&lt;br /&gt;
• java.sql.Time&lt;br /&gt;
• java.sql.Date&lt;br /&gt;
• java.sql.TimeStamp&lt;br /&gt;
• User-defined serializable types&lt;br /&gt;
• char[]&lt;br /&gt;
• Character[]&lt;br /&gt;
• byte[]&lt;br /&gt;
• Byte[]&lt;br /&gt;
• Enumerated types&lt;br /&gt;
• Other entities and/or collection of entities&lt;br /&gt;
• Embedded classes&lt;br /&gt;
&lt;br /&gt;
Entity uses the persistent fields while mapping annotations. Annotations are applied to the entity&#39;s instance variable. On the other hand entity uses the persistence properties while mapping annotations. Annotations are applied to the entity&#39;s getter methods for JavaBeans-style properties. We cannot apply mapping annotations to both fields as well as properties simultaneously in a single entity.&lt;br /&gt;
&lt;br /&gt;
Persistence Fields: Persistence accesses the entity class instance variables directly at runtime, if the entity class uses persistence fields. It is necessary to apply the object/relational mapping annotation on the instance variables.&lt;br /&gt;
&lt;br /&gt;
Persistent Properties: Entity must follow the method conventions of JavaBeans components while using the persistent properties. JavaBeans-style properties use getter and setter methods that are used after the entity class&#39;s instance variable names. There is a getter and a setter method for each persistence property. In case of a boolean property you may use isProperty instead of getProperty. Let’s take an example to clarify this:&lt;br /&gt;
&lt;br /&gt;
Suppose an entity of type customer uses persistent property that has a private instance variable named firstName, the class defines two methods named getFirstName and setFirstName to retrieve and set the values of the instance variable. Use the following method signature for a single-valued persistent property.&lt;br /&gt;
&lt;br /&gt;
• Type getProperty()&lt;br /&gt;
• void setProperty(Type type)&lt;br /&gt;
&lt;br /&gt;
Multi-valued (Collection-valued) persistent fields and properties must use the supported Java collection interfaces without worrying whether the entity uses the persistence fields or properties. The collection interfaces may be used at the following places:&lt;br /&gt;
&lt;br /&gt;
• java.util.Collection&lt;br /&gt;
• java.util.Set&lt;br /&gt;
• java.util.Map&lt;br /&gt;
• java.util.List&lt;br /&gt;
&lt;br /&gt;
If the entity class uses persistent fields then the method signatures of the collection types must be one of these collection types. Suppose an entity of type customer includes a persistent property that uses a set of phone numbers then it should have the following methods:&lt;br /&gt;
&lt;br /&gt;
Set&lt;phonenumber&gt; getPhoneNumber() {}&lt;br /&gt;
void setPhoneNumbers(Set&lt;phonenumber&gt;) {}&lt;br /&gt;
&lt;br /&gt;
The O-R mapping annotations must be applied to the getter methods. Note here that mapping annotations cannot be applied to the fields or properties marked transient or annotated transient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Primary Keys in Entities: &lt;br /&gt;
&lt;br /&gt;
Each entity contains a unique identity contained in the object. E.g. A customer entity has an identity that might be identified by the customer number. A primary key allows a client to be a particular entity instance. Every unique entity must be associated with a primary key. To prove its uniqueness every entity may have either a simple or a composite primary key. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To denote the primary key property or field Simple primary key use javax.persistence.Id annotations.&lt;br /&gt;
&lt;br /&gt;
Composite primary keys must be composed of either a single persistent property or field or a set of single persistent properties or fields. Composite primary keys uses javax.persistence.IdClass and javax.persistence.EmbededId.&lt;br /&gt;
&lt;br /&gt;
The primary key, or the fields of the composite primary key (like property or field) must follow one of the following Java language types.&lt;br /&gt;
&lt;br /&gt;
• Java primitive types&lt;br /&gt;
• Java primitive wrapper types&lt;br /&gt;
• java.lang.String&lt;br /&gt;
• java.util.Date (the temporal type should be DATE)&lt;br /&gt;
• java.sql.Date&lt;br /&gt;
&lt;br /&gt;
Floating point types are not allowed to use in primary keys.&lt;br /&gt;
&lt;br /&gt;
Multiplicity in Entity Relationships: &lt;br /&gt;
&lt;br /&gt;
There are four types of multiplicities defined for entity relationships like one-to-one, one-to-many, many-to-one, and many-to-many.&lt;br /&gt;
&lt;br /&gt;
One-to-one: When each entity instance is mapped to a single instance of another entity, then the mapping is known as one- to-one&lt;br /&gt;
&lt;br /&gt;
mapping. One-to-one relationships use the javax.persistence.OneToOne annotation on the corresponding persistent field or property.&lt;br /&gt;
&lt;br /&gt;
For Example: A reference variable in java contains the address of a single object so that there exists only one-to-one mapping between the object of the reference variable.&lt;br /&gt;
&lt;br /&gt;
One-to-many: When an entity instance is related to many instances of other entities, then the relation is known as one-to-many. These types of relationships use the javax.persistence.OneToManyannotation on the corresponding field or property.&lt;br /&gt;
&lt;br /&gt;
For Example: A sales order may contain the order of multiple items so there is a one-to-many relationship between the sales order and the items.&lt;br /&gt;
&lt;br /&gt;
Many-to-many: When the multiple instances of an entity have the mapping to the multiple instances of the other entity then the mapping is said to many-to-many mapping. Many-to-many mapping relationships use the javax.persistence.ManyToMany annotation corresponding to the field or property.&lt;br /&gt;
&lt;br /&gt;
For Example: A college student has the admission in several courses while each course may have many students. Therefore there is many-to-many relationship between the students and the courses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Direction in Entity Relationships: A relationship can be either unidirectional or bi-directional. &lt;br /&gt;
&lt;br /&gt;
Unidirectional Relationship: A unidirectional relationship is a relationship in which only one of the two entities have the owing side. In unidirectional relationship only one entity can have the relationship property or field that may refer to the other.&lt;br /&gt;
&lt;br /&gt;
Example: In the example given above, the List_Item contains the relationship field that refers to the other entity named as Product, while the Product doesn&#39;t have any knowledge about the List_Item that refers to it.&lt;br /&gt;
&lt;br /&gt;
Bi-directional Relationships: A bi-directional relationship is the relationship in which both the entities have the owing side. In bi-directional relationship each entity in the relation have the relationship fields or property.&lt;br /&gt;
&lt;br /&gt;
Example: Suppose the Order in the above example have the knowledge about the List_Item instance it has and also suppose that the List_Item have the knowledge about what the Order it belongs to, then the relationship between them is said to be the bi-directional relation.&lt;br /&gt;
&lt;br /&gt;
Rules: There are some rules that each bi-directional relationship must follow:&lt;br /&gt;
&lt;br /&gt;
• You must use its owing side simply using the mappedBy element of the @OneToOne, @OneToMany, or @ManyToMany annotation of the inverse side of a bi-directional relationship.mappedBy element is used to designate the field or property in an entity.&lt;br /&gt;
&lt;br /&gt;
• In a one-to-one bi-directional relationship, owing side is the side that contains the corresponding foreign key.&lt;br /&gt;
&lt;br /&gt;
• In a many-to-one bi-directional relationships the many side is always the owing side of the relationship and must not define the mappedBy element.&lt;br /&gt;
&lt;br /&gt;
• In case of many-to-many bi-directional relationships either side may be the owing side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let’s have an Example now&lt;br /&gt;
&lt;br /&gt;
Create the Entity Class&lt;br /&gt;
&lt;br /&gt;
In the Simple EJB Project, within the com.webage.ejbs package, create a new class called Customer.&lt;br /&gt;
In the Customer class, add the following import statement.&lt;br /&gt;
&lt;br /&gt;
import javax.persistence.*; &lt;br /&gt;
&lt;br /&gt;
Many of the annotations and classes for the persistence API will come from this package.&lt;br /&gt;
&lt;br /&gt;
First, we must designate this class as an Entity. This is done using the @Entity annotation. Add this annotation at the class level as shown below.&lt;br /&gt;
&lt;br /&gt;
@Entity &lt;br /&gt;
&lt;br /&gt;
public class Customer { &lt;br /&gt;
&lt;br /&gt;
Next, we will make the Customer class implement java.io.Serializable. Doing so will allow us to use this class are parameters to a remote business interface method. Add the code shown in bold face.&lt;br /&gt;
&lt;br /&gt;
public class Customer implements Serializable { &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the following two member variables. They will form the attributes (or database columns) for the entity.&lt;br /&gt;
&lt;br /&gt;
private int id;&lt;br /&gt;
private String name;&lt;br /&gt;
&lt;br /&gt;
Generate getter and setter methods for these fields (right click on the editor and select Source-&amp;gt;Generate Getters and Setters). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The id field will act as the primary key column of the Customer. Declare that fact using the @Id annotation as shown below.&lt;br /&gt;
&lt;br /&gt;
@Id&lt;br /&gt;
private int id;&lt;br /&gt;
&lt;br /&gt;
Save changes. That&#39;s it, the Entity class is now complete.&lt;br /&gt;
&lt;br /&gt;
Create the persistence.xml File &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The persistence.xml file must be created within the META-INF directory of the EJB module. This file defines persistence units. Each unit is basically a reference to the data source that will be used to access the database. The unit can also contain configuration such as the type of database (Oracle, MySQL etc.) and if database tables should be automatically created by the persistence engine.&lt;br /&gt;
&lt;br /&gt;
Within Simple EJB Project, create a folder called META-INF. Within this folder, create a new file called persistence.xml. In that file, add the following content.&lt;br /&gt;
&lt;br /&gt;
&lt;persistence version=&quot;1.0&quot; xmlns=&quot;http://java.sun.com/xml/ns/persistence&quot;&gt;&lt;/persistence&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;persistence-unit name=&quot;my_persistence_ctx&quot;&gt;&lt;/persistence-unit&gt;&lt;br /&gt;
&lt;jta-data-source&gt;jdbc/__default&lt;/jta-data-source&gt;&lt;br /&gt;
&lt;properties&gt;&lt;/properties&gt;&lt;br /&gt;
&lt;!--Use the java2db feature --&gt;&lt;br /&gt;
&lt;property name=&quot;toplink.ddl-generation&quot; value=&quot;drop-and-create-tables&quot;&gt;&lt;/property&gt;&lt;br /&gt;
&lt;!-- Generate the sql specific to Derby database --&gt;&lt;br /&gt;
&lt;property name=&quot;toplink.platform.class.name&quot; value=&quot;oracle.toplink.essentials.platform.database.DerbyPlatform&quot;&gt;&lt;/property&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note the following aspects of this file: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The name of the unit is my_persistence_ctx. We will use this name to look it up from the code.&lt;br /&gt;
&lt;br /&gt;
2. The unit will use a data source with JNDI name jdbc/__default. This data source is automatically defined when Glassfish is installed. In real life, you will probably use a database such as MySQL, Oracle or DB2. In that case, you must first define a data source using the Glassfish administration console.&lt;br /&gt;
&lt;br /&gt;
3. We configure the persistence engine to automatically drop and create tables when the EJB JAR is deployed. This is a good choice during heavy development when the Entity classes are changing rapidly. If you do not wish the system to create tables, you can set the value of the toplink.ddl-generation property to none.&lt;br /&gt;
&lt;br /&gt;
4. We set the SQL dialect to be specific to Derby. Examples of other platform classes are &quot;oracle.toplink.essentials.platform.database.DB2Platform&quot; for DB2 and &quot;oracle.toplink.essentials.platform.database.oracle.OraclePlatform&quot; for Oracle.&lt;br /&gt;
&lt;br /&gt;
Save and close the persistence.xml file.&lt;br /&gt;
&lt;br /&gt;
Use the Entity from a Session EJB &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will use the Customer Entity from the SimpleBean session bean created in the first tutorial. First, we will insert a few customers to the database.&lt;br /&gt;
&lt;br /&gt;
Open the business interface SimpleBean.java. Add a new method as follows:&lt;br /&gt;
&lt;br /&gt;
public void createCustomers();&lt;br /&gt;
&lt;br /&gt;
Save and close the file.&lt;br /&gt;
&lt;br /&gt;
Now, open the implementation class SimpleBeanImpl.java. Add a new member variable to obtain reference to the persistence unit as follows:&lt;br /&gt;
&lt;br /&gt;
@PersistenceContext(name=&quot;my_persistence_ctx&quot;)&lt;br /&gt;
&lt;br /&gt;
EntityManager em;&lt;br /&gt;
&lt;br /&gt;
Note, how we use the name of the persistence unit here.&lt;br /&gt;
&lt;br /&gt;
Add this method:&lt;br /&gt;
&lt;br /&gt;
public void createCustomers() {&lt;br /&gt;
&lt;br /&gt;
Customer c1 = new Customer();&lt;br /&gt;
c1.setId(1);&lt;br /&gt;
c1.setName(&quot;XYZ&quot;);&lt;br /&gt;
em.persist(c1); &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The call to the EntityManager.persist() method will result in a SQL INSERT statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and close the file.&lt;br /&gt;
&lt;br /&gt;
Deploy the EJB JAR&lt;br /&gt;
&lt;br /&gt;
Deploy the EJB JAR file by exporting Simple EJB Project into the autodeploy folder as already mentioned in the previous tutorial.&lt;br /&gt;
&lt;br /&gt;
Write the Client&lt;br /&gt;
&lt;br /&gt;
In the Simple Client Project, open TestClient.java. Below this line:&lt;br /&gt;
&lt;br /&gt;
SimpleBean bean = (SimpleBean) ctx.lookup(&quot;ejb/SimpleBeanJNDI&quot;);&lt;br /&gt;
&lt;br /&gt;
Add:&lt;br /&gt;
&lt;br /&gt;
bean.createCustomers();&lt;br /&gt;
Save the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run the Client &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run the TestClient class as already described in the previous tutorial.&lt;br /&gt;
&lt;br /&gt;
Note, you can run the client only once. Running it again will cause primary key collision and the customer cannot be added.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inspect the Database&lt;br /&gt;
&lt;br /&gt;
select * from customer; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Add More Database Access Feature &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we will add the ability to retrieve a Customer, update and delete it. This can be done entirely using the session EJB. We don&#39;t have to change the Entity class.&lt;br /&gt;
&lt;br /&gt;
First, add the following methods to the business interface SimpleBean.java.&lt;br /&gt;
&lt;br /&gt;
public Customer getCustomer(int id);&lt;br /&gt;
public void updateCustomer(Customer c);&lt;br /&gt;
public void deleteCustomer(Customer c);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and close the file.&lt;br /&gt;
&lt;br /&gt;
Implement these new methods in SimpleBeanImpl.java as follows.&lt;br /&gt;
&lt;br /&gt;
public Customer getCustomer(int id) {&lt;br /&gt;
Customer c = em.find(Customer.class, new Integer(id));&lt;br /&gt;
return c; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void updateCustomer(Customer c) {&lt;br /&gt;
em.merge(c);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public void deleteCustomer(Customer c) {&lt;br /&gt;
c = em.merge(c); //Must do this&lt;br /&gt;
em.remove(c);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
The EntityManager.merge() call will flag the Customer instance so that the data is used to update the underlying row. The updateCustomer() method relies on this behavior. The actual SQL UPDATE statement is issued at a later time, before the transaction is completed. The EntityManager.remove() call, results in a SQL DELETE statement to be executed. Note: To remove an entity, we must use a managed instance. The Customer object instance passed to the deleteCustomer() method is called detached as it is not currently managed by the EntityManager in any way. Merging will make the instance managed. A managed instance is always associated with the underlying row in the table. That means, the merge call will implicitly do a SELECT SQL call (if the instance is currently detached). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Re-deploy the EJB JAR file.&lt;br /&gt;
&lt;br /&gt;
Update the Client&lt;br /&gt;
&lt;br /&gt;
Open TestClient.java.&lt;br /&gt;
&lt;br /&gt;
Below the line:&lt;br /&gt;
&lt;br /&gt;
bean.createCustomers();&lt;br /&gt;
&lt;br /&gt;
Add:&lt;br /&gt;
&lt;br /&gt;
Customer c = bean.getCustomer(1);&lt;br /&gt;
System.out.println(&quot;Retrieved customer: &quot; + c.getName());&lt;br /&gt;
bean.deleteCustomer(c);&lt;br /&gt;
&lt;br /&gt;
Save changes.&lt;br /&gt;
&lt;br /&gt;
Make sure that you have re-deployed the EJB JAR file. Now, run the client. The Console view should show the message:&lt;br /&gt;
&lt;br /&gt;
Retrieved customer: XYZ&lt;br /&gt;
&lt;br /&gt;
Also, now you can run the client repeatedly as we delete the customer data.</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/56197894517213157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/ejb-3-persistence.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/56197894517213157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/56197894517213157'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/ejb-3-persistence.html' title='EJB 3 Persistence'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzeCuCz_i5TyOBh7SeHHUFiijmaqkhnDFuPh1gsymGWBwgRuYvFj29j89HPDs7kXWuxozLjS1wo-qUCoD3cWNr1gv4JajM0b781ZJ0zD0s3VzK5z2vo2rCanXK-kHpM3t4Q8c3QMyDB4x7/s72-c/persistance.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-9192860627763432240</id><published>2011-04-09T15:28:00.000+05:30</published><updated>2014-02-21T09:56:13.249+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced Encryption Standard (AES)"/><category scheme="http://www.blogger.com/atom/ns#" term="Encryption and Decryption"/><title type='text'>Advanced Encryption Standard (AES)</title><content type='html'>Advanced Encryption Standard&lt;br /&gt;
&lt;br /&gt;
In cryptography, the Advanced Encryption Standard (AES) is a symmetric-key encryption standard adopted by the U.S. government. The standard comprises three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger collection originally published as Rijndael. Each of these ciphers has a 128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. The AES ciphers have been analyzed extensively and are now used worldwide, as was the case with its predecessor, the Data Encryption Standard (DES).&lt;br /&gt;
&lt;br /&gt;
AES was announced by National Institute of Standards and Technology (NIST) as U.S. FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standardization process in which fifteen competing designs were presented and evaluated before Rijndael was selected as the most suitable (see Advanced Encryption Standard process for more details). It became effective as a Federal government standard on May 26, 2002 after approval by the Secretary of Commerce. It is available in many different encryption packages. AES is the first publicly accessible and open cipher approved by the NSA for top secretinformation.&lt;br /&gt;
&lt;br /&gt;
The Rijndael cipher was developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, and submitted by them to the AES selection process. Rijndael is a wordplay based upon the names of the two inventors.&lt;br /&gt;
&lt;br /&gt;
AES is based on a design principle known as a Substitution permutation network. It is fast in both software and hardware. Unlike its predecessor, DES, AES does not use a Feistel network.&lt;br /&gt;
&lt;br /&gt;
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum of 128 bits. The blocksize has a maximum of 256 bits, but the keysize has no theoretical maximum.&lt;br /&gt;
&lt;br /&gt;
AES operates on a 4×4 matrix of bytes, termed the state (versions of Rijndael with a larger block size have additional columns in the state). Most AES calculations are done in a special finite field.&lt;br /&gt;
&lt;br /&gt;
The AES cipher is specified as a number of repetitions of transformation rounds that convert the input plaintext into the final output of ciphertext. Each round consists of several processing steps, including one that depends on the encryption key. A set of reverse rounds are applied to transform ciphertext back into the original plaintext using the same encryption key.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Simple Data Encryption/Decryption Example with AES&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
For encryption we must use a secret key along with an algorithm. In the following example we use an algorithm called AES 128 and the bytes of the word &quot;ThisIsASecretKey&quot; as the secret key (the best secret key we found in this world). &lt;br /&gt;
&lt;br /&gt;
AES algorithm can use a key of 128 bits (16 bytes * 8); so we selected that key.&lt;br /&gt;
&lt;br /&gt;
package org.roy.crypto; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.security.*;&lt;br /&gt;
import java.security.spec.InvalidKeySpecException;&lt;br /&gt;
import javax.crypto.Cipher; &lt;br /&gt;
import javax.crypto.spec.SecretKeySpec;&lt;br /&gt;
import sun.misc.*;&lt;br /&gt;
&lt;br /&gt;
public class SimpleProtector {&lt;br /&gt;
&lt;br /&gt;
private static final String ALGORITHM = &quot;AES&quot;;&lt;br /&gt;
&lt;br /&gt;
private static final byte[] keyValue = &lt;br /&gt;
new byte[] { &#39;T&#39;, &#39;h&#39;, &#39;i&#39;, &#39;s&#39;, &#39;I&#39;, &#39;s&#39;, &#39;A&#39;, &#39;S&#39;, &#39;e&#39;, &#39;c&#39;, &#39;r&#39;, &#39;e&#39;, &#39;t&#39;, &#39;K&#39;, &#39;e&#39;, &#39;y&#39; };&lt;br /&gt;
&lt;br /&gt;
public static String encrypt(String valueToEnc) throws Exception {&lt;br /&gt;
&lt;br /&gt;
Key key = generateKey();&lt;br /&gt;
Cipher c = Cipher.getInstance(ALGORITHM);&lt;br /&gt;
c.init(Cipher.ENCRYPT_MODE, key);&lt;br /&gt;
byte[] encValue = c.doFinal(valueToEnc.getBytes());&lt;br /&gt;
String encryptedValue = new BASE64Encoder().encode(encValue);&lt;br /&gt;
return encryptedValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public static String decrypt(String encryptedValue) throws Exception {&lt;br /&gt;
&lt;br /&gt;
Key key = generateKey();&lt;br /&gt;
Cipher c = Cipher.getInstance(ALGORITHM);&lt;br /&gt;
c.init(Cipher.DECRYPT_MODE, key);&lt;br /&gt;
byte[] decordedValue = new BASE64Decoder().decodeBuffer(encryptedValue);&lt;br /&gt;
byte[] decValue = c.doFinal(decordedValue);&lt;br /&gt;
String decryptedValue = new String(decValue);&lt;br /&gt;
return decryptedValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
private static Key generateKey() throws Exception {&lt;br /&gt;
Key key = new SecretKeySpec(keyValue, ALGORITHM);&lt;br /&gt;
// SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);&lt;br /&gt;
// key = keyFactory.generateSecret(new DESKeySpec(keyValue));&lt;br /&gt;
return key;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
We use &quot;generateKey()&quot; method to generate a secret key for AES algorithm with a given key. You can change the used algorithm by changing this Key generation; the commented out code shows the use of DES algorithm (Data Encryption Standard). Following is a simple class to test the above implementation.&lt;br /&gt;
&lt;br /&gt;
package org.roy.crypto;&lt;br /&gt;
&lt;br /&gt;
public class TestSimpleProtector {&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) throws Exception {&lt;br /&gt;
String password = &quot;mypassword&quot;;&lt;br /&gt;
String passwordEnc = SimpleProtector.encrypt(password);&lt;br /&gt;
String passwordDec = SimpleProtector.decrypt(passwordEnc);&lt;br /&gt;
&lt;br /&gt;
System.out.println(&quot;Plain Text : &quot; + password);&lt;br /&gt;
System.out.println(&quot;Encrypted : &quot; + passwordEnc);&lt;br /&gt;
System.out.println(&quot;Decrypted : &quot; + passwordDec);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following is the output we got from above test; so you clearly see that the original text is reproduced after the decryption operation.&lt;br /&gt;
&lt;br /&gt;
Plain Text : mypassword&lt;br /&gt;
Encrypted : sBhCap4urE50a/dGuhNgrw==&lt;br /&gt;
Decrypted : mypassword&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Another Simple Example:&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
import java.security.*;&lt;br /&gt;
import javax.crypto.*;&lt;br /&gt;
import javax.crypto.spec.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class AES {&lt;br /&gt;
&lt;br /&gt;
public static String asHex (byte buf[]) {&lt;br /&gt;
StringBuffer strbuf = new StringBuffer(buf.length * 2);&lt;br /&gt;
int i;&lt;br /&gt;
for (i = 0; i &amp;lt; buf.length; i++) {&lt;br /&gt;
if (((int) buf[i] &amp;amp; 0xff) &amp;lt; 0x10)&lt;br /&gt;
strbuf.append(&quot;0&quot;);&lt;br /&gt;
strbuf.append(Long.toString((int) buf[i] &amp;amp; 0xff, 16));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return strbuf.toString();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) throws Exception {&lt;br /&gt;
&lt;br /&gt;
String message=&quot;AES still rocks!!&quot;;&lt;br /&gt;
// Get the KeyGenerator&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US;&quot;&gt;KeyGenerator kgen = KeyGenerator.&lt;span class=&quot;me1&quot;&gt;getInstance&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: grey; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US;&quot;&gt;(&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US;&quot;&gt;&quot;AES&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: grey; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US;&quot;&gt;)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
kgen.init(128); // 192 and 256 bits may not be available&lt;br /&gt;
&lt;br /&gt;
// Generate the secret key specs.&lt;br /&gt;
SecretKey skey = kgen.generateKey();&lt;br /&gt;
byte[] raw = skey.getEncoded();&lt;br /&gt;
&lt;br /&gt;
SecretKeySpec skeySpec = new SecretKeySpec(raw, &quot;AES&quot;);&lt;br /&gt;
&lt;br /&gt;
// Instantiate the cipher&lt;br /&gt;
Cipher cipher = Cipher.getInstance(&quot;AES&quot;);&lt;br /&gt;
&lt;br /&gt;
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);&lt;br /&gt;
byte[] encrypted = cipher.doFinal((args.length == 0 ? message : args[0]).getBytes());&lt;br /&gt;
System.out.println(&quot;encrypted string: &quot; + asHex(encrypted));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cipher.init(Cipher.DECRYPT_MODE, skeySpec);&lt;br /&gt;
byte[] original = cipher.doFinal(encrypted);&lt;br /&gt;
String originalString = new String(original);&lt;br /&gt;
System.out.println(&quot;Original string: &quot; + originalString + &quot; &quot; + asHex(original));&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OUTPUT:&lt;br /&gt;
&lt;br /&gt;
encrypted string: 91369a3b74c6feede0eff48fcf004f67d26cdd0b4907b44fd2147a4077ded0d1&lt;br /&gt;
Original string: AES still rocks!! 414553207374696c6c20726f636b732121</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/9192860627763432240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/advanced-encryption-standard-aes.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/9192860627763432240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/9192860627763432240'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/advanced-encryption-standard-aes.html' title='Advanced Encryption Standard (AES)'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-8506702195248911636</id><published>2011-04-09T15:17:00.003+05:30</published><updated>2014-02-21T09:56:13.246+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Encryption Standard (DES)"/><category scheme="http://www.blogger.com/atom/ns#" term="Encryption and Decryption"/><title type='text'>Data Encryption Standard (DES)</title><content type='html'>&lt;h1 style=&quot;border-bottom: #aaaaaa; border-left: medium none; border-right: medium none; border-top: medium none; line-height: 14.4pt; margin: 0cm 0cm 1.2pt; mso-border-bottom-alt: solid #AAAAAA .75pt; mso-padding-alt: 0cm 0cm 0cm 0cm; padding-bottom: 0cm; padding-left: 0cm; padding-right: 0cm; padding-top: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; font-weight: normal;&quot;&gt;Data Encryption Standard&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: #aaaaaa 1pt solid; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-bottom-alt: solid #AAAAAA .75pt; padding-bottom: 0cm; padding-left: 0cm; padding-right: 0cm; padding-top: 0cm;&quot;&gt;The Data Encryption Standard (DES) is a block cipher that uses shared secret encryption. It was selected by the National Bureau of Standards as an official Federal Information Processing Standard (FIPS) for the United States in 1976 and which has subsequently enjoyed widespread use internationally. It is based on a symmetric-key algorithm that uses a 56-bit key. The algorithm was initially controversial because of classified design elements, a relatively short key length, and suspicions about a National Security Agency (NSA) backdoor. DES consequently came under intense academic scrutiny which motivated the modern understanding of block ciphers and their cryptanalysis.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
DES is now considered to be insecure for many applications. This is chiefly due to the 56-bit key size being too small; in January, 1999, distributed.net and the Electronic Frontier Foundation collaborated to publicly break a DES key in 22 hours and 15 minutes. There are also some analytical results which demonstrate theoretical weaknesses in the cipher, although they are infeasible to mount in practice. The algorithm is believed to be practically secure in the form of Triple DES, although there are theoretical attacks. In recent years, the cipher has been superseded by the Advanced Encryption Standard (AES). Furthermore, DES has been withdrawn as a standard by the National Institute of Standards and Technology (formerly the National Bureau of Standards).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;In this article, I show you how do use&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Java Cryptography Extension (JCE)&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;to encrypt or decrypt a text in&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Data Encryption Standard (DES)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;mechanism.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span class=&quot;apple-style-span&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;1. DES Key&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Create a DES Key.&lt;br /&gt;
&lt;br /&gt;
KeyGenerator keygenerator = KeyGenerator.getInstance(&quot;DES&quot;);&lt;br /&gt;
SecretKey myDesKey = keygenerator.generateKey();&lt;br /&gt;
&lt;br /&gt;
2. Cipher Info&lt;br /&gt;
&lt;br /&gt;
Create a Cipher instance from Cipher class, specify the following information and separated by a slashes (/).&lt;br /&gt;
&lt;br /&gt;
• Algorithm name&lt;br /&gt;
• Mode (optional)&lt;br /&gt;
• Padding scheme (optional)&lt;br /&gt;
&lt;br /&gt;
Cipher desCipher; // Create the cipher &lt;br /&gt;
desCipher = Cipher.getInstance(&quot;DES/ECB/PKCS5Padding&quot;);&lt;br /&gt;
&lt;br /&gt;
Note&lt;br /&gt;
&lt;br /&gt;
DES = Data Encryption Standard.&lt;br /&gt;
ECB = Electronic Codebook mode.&lt;br /&gt;
PKCS5Padding = PKCS #5-style padding.&lt;br /&gt;
&lt;br /&gt;
In this case, you created a DES (Data Encryption Standard) cipher in Electronic Codebook mode, with PKCS #5-style padding.&lt;br /&gt;
&lt;br /&gt;
3. Convert It&lt;br /&gt;
&lt;br /&gt;
Convert String into Byte[] array format.&lt;br /&gt;
&lt;br /&gt;
byte[] text = &quot;No body can see me&quot;.getBytes();&lt;br /&gt;
&lt;br /&gt;
4. Encrypt It&lt;br /&gt;
&lt;br /&gt;
Make Cipher in encrypt mode, and encrypt it with Cipher.doFinal() method.&lt;br /&gt;
&lt;br /&gt;
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);&lt;br /&gt;
byte[] textEncrypted = desCipher.doFinal(text);&lt;br /&gt;
&lt;br /&gt;
5. Decrypt It&lt;br /&gt;
&lt;br /&gt;
Make Cipher in decrypt mode, and decrypt it with Cipher.doFinal() method as well.&lt;br /&gt;
&lt;br /&gt;
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);&lt;br /&gt;
byte[] textDecrypted = desCipher.doFinal(textEncrypted);&lt;br /&gt;
&lt;br /&gt;
6. Full Example &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Full Example to show how do use Java’s JCE to encrypt and decrypt text in DES mechanism.&lt;br /&gt;
&lt;br /&gt;
package com.roy.util;&lt;br /&gt;
&lt;br /&gt;
import java.security.InvalidKeyException;&lt;br /&gt;
import java.security.NoSuchAlgorithmException;&lt;br /&gt;
import javax.crypto.BadPaddingException;&lt;br /&gt;
import javax.crypto.Cipher;&lt;br /&gt;
import javax.crypto.IllegalBlockSizeException;&lt;br /&gt;
import javax.crypto.KeyGenerator;&lt;br /&gt;
import javax.crypto.NoSuchPaddingException;&lt;br /&gt;
import javax.crypto.SecretKey;&lt;br /&gt;
&lt;br /&gt;
public class JEncrytion&lt;br /&gt;
{ &lt;br /&gt;
public static void main(String[] argv) {&lt;br /&gt;
&lt;br /&gt;
try{&lt;br /&gt;
KeyGenerator keygenerator = KeyGenerator.getInstance(&quot;DES&quot;);&lt;br /&gt;
SecretKey myDesKey = keygenerator.generateKey();&lt;br /&gt;
&lt;br /&gt;
Cipher desCipher;&lt;br /&gt;
// Create the cipher &lt;br /&gt;
desCipher = Cipher.getInstance(&quot;DES/ECB/PKCS5Padding&quot;);&lt;br /&gt;
&lt;br /&gt;
// Initialize the cipher for encryption&lt;br /&gt;
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);&lt;br /&gt;
&lt;br /&gt;
//sensitive information&lt;br /&gt;
byte[] text = &quot;No body can see me&quot;.getBytes();&lt;br /&gt;
&lt;br /&gt;
System.out.println(&quot;Text [Byte Format] : &quot; + text);&lt;br /&gt;
System.out.println(&quot;Text : &quot; + new String(text));&lt;br /&gt;
&lt;br /&gt;
// Encrypt the text&lt;br /&gt;
byte[] textEncrypted = desCipher.doFinal(text);&lt;br /&gt;
&lt;br /&gt;
System.out.println(&quot;Text Encryted : &quot; + textEncrypted);&lt;br /&gt;
&lt;br /&gt;
// Encode bytes to base64 to get a string&lt;br /&gt;
// new sun.misc.BASE64Encoder().encode(textEncrypted);&lt;br /&gt;
&lt;br /&gt;
// Initialize the same cipher for decryption&lt;br /&gt;
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);&lt;br /&gt;
&lt;br /&gt;
// Decrypt the text&lt;br /&gt;
byte[] textDecrypted = desCipher.doFinal(textEncrypted);&lt;br /&gt;
&lt;br /&gt;
System.out.println(&quot;Text Decryted : &quot; + new String(textDecrypted));&lt;br /&gt;
&lt;br /&gt;
// Decode using utf-8&lt;br /&gt;
// new String(textDecrypted);&lt;br /&gt;
&lt;br /&gt;
}catch(NoSuchAlgorithmException e){&lt;br /&gt;
e.printStackTrace();&lt;br /&gt;
}catch(NoSuchPaddingException e){&lt;br /&gt;
e.printStackTrace();&lt;br /&gt;
}catch(InvalidKeyException e){&lt;br /&gt;
e.printStackTrace();&lt;br /&gt;
}catch(IllegalBlockSizeException e){&lt;br /&gt;
e.printStackTrace();&lt;br /&gt;
}catch(BadPaddingException e){&lt;br /&gt;
e.printStackTrace();&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
Text [Byte Format] : [B@19b5393&lt;br /&gt;
Text : No body can see me&lt;br /&gt;
Text Encryted : [B@4e79f1&lt;br /&gt;
Text Decryted : No body can see me&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;strong&gt;Encrypting a File or Stream with DES&lt;/strong&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a class for encrypting and decrypting files or streams using DES. The class is created with a key and can be used repeatedly to encrypt and decrypt streams using that key.&lt;br /&gt;
&lt;br /&gt;
public class DesEncrypter {&lt;br /&gt;
Cipher ecipher;&lt;br /&gt;
Cipher dcipher;&lt;br /&gt;
&lt;br /&gt;
DesEncrypter(SecretKey key) {&lt;br /&gt;
// Create an 8-byte initialization vector&lt;br /&gt;
byte[] iv = new byte[]{&lt;br /&gt;
(byte)0x8E, 0x12, 0x39, (byte)0x9C,&lt;br /&gt;
0x07, 0x72, 0x6F, 0x5A&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
ecipher = Cipher.getInstance(&quot;DES/CBC/PKCS5Padding&quot;);&lt;br /&gt;
dcipher = Cipher.getInstance(&quot;DES/CBC/PKCS5Padding&quot;);&lt;br /&gt;
&lt;br /&gt;
// CBC requires an initialization vector&lt;br /&gt;
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);&lt;br /&gt;
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);&lt;br /&gt;
&lt;br /&gt;
} catch (java.security.InvalidAlgorithmParameterException e) {&lt;br /&gt;
} catch (javax.crypto.NoSuchPaddingException e) {&lt;br /&gt;
} catch (java.security.NoSuchAlgorithmException e) {&lt;br /&gt;
} catch (java.security.InvalidKeyException e) {&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Buffer used to transport the bytes from one stream to another&lt;br /&gt;
byte[] buf = new byte[1024];&lt;br /&gt;
&lt;br /&gt;
public void encrypt(InputStream in, OutputStream out) {&lt;br /&gt;
try {&lt;br /&gt;
&lt;br /&gt;
// Bytes written to out will be encrypted&lt;br /&gt;
out = new CipherOutputStream(out, ecipher);&lt;br /&gt;
&lt;br /&gt;
// Read in the cleartext bytes and write to out to encrypt&lt;br /&gt;
int numRead = 0;&lt;br /&gt;
while ((numRead = in.read(buf)) &amp;gt;= 0) {&lt;br /&gt;
out.write(buf, 0, numRead);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
out.close();&lt;br /&gt;
} catch (java.io.IOException e) {&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void decrypt(InputStream in, OutputStream out) {&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
// Bytes read from in will be decrypted&lt;br /&gt;
in = new CipherInputStream(in, dcipher);&lt;br /&gt;
// Read in the decrypted bytes and write the cleartext to out&lt;br /&gt;
int numRead = 0;&lt;br /&gt;
while ((numRead = in.read(buf)) &amp;gt;= 0) {&lt;br /&gt;
out.write(buf, 0, numRead);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
out.close();&lt;br /&gt;
} catch (java.io.IOException e) {&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Here&#39;s an example that uses the class:&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
// Generate a temporary key. In practice, you would save this key.&lt;br /&gt;
// See also Encrypting with DES Using a Pass Phrase.&lt;br /&gt;
SecretKey key = KeyGenerator.getInstance(&quot;DES&quot;).generateKey();&lt;br /&gt;
&lt;br /&gt;
// Create encrypter/decrypter class&lt;br /&gt;
DesEncrypter encrypter = new DesEncrypter(key);&lt;br /&gt;
&lt;br /&gt;
// Encrypt&lt;br /&gt;
encrypter.encrypt(new FileInputStream(&quot;cleartext1&quot;),&lt;br /&gt;
new FileOutputStream(&quot;ciphertext&quot;));&lt;br /&gt;
&lt;br /&gt;
// Decrypt&lt;br /&gt;
encrypter.decrypt(new FileInputStream(&quot;ciphertext&quot;),&lt;br /&gt;
new FileOutputStream(&quot;cleartext2&quot;));&lt;br /&gt;
} catch (Exception e) {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Encrypting an Object with DES&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to encrypt a serializable object.&lt;br /&gt;
&lt;br /&gt;
try {&lt;br /&gt;
// Generate a temporary key. In practice, you would save this key.&lt;br /&gt;
// See also Encrypting with DES Using a Pass Phrase.&lt;br /&gt;
SecretKey key = KeyGenerator.getInstance(&quot;DES&quot;).generateKey();&lt;br /&gt;
&lt;br /&gt;
// Prepare the encrypter&lt;br /&gt;
Cipher ecipher = Cipher.getInstance(&quot;DES&quot;);&lt;br /&gt;
ecipher.init(Cipher.ENCRYPT_MODE, key);&lt;br /&gt;
&lt;br /&gt;
// Seal (encrypt) the object&lt;br /&gt;
SealedObject so = new SealedObject(new MySecretClass(), ecipher);&lt;br /&gt;
&lt;br /&gt;
// Get the algorithm used to seal the object&lt;br /&gt;
String algoName = so.getAlgorithm(); // DES&lt;br /&gt;
&lt;br /&gt;
// Prepare the decrypter&lt;br /&gt;
Cipher dcipher = Cipher.getInstance(&quot;DES&quot;);&lt;br /&gt;
dcipher.init(Cipher.DECRYPT_MODE, key);&lt;br /&gt;
&lt;br /&gt;
// Unseal (decrypt) the class&lt;br /&gt;
MySecretClass o = (MySecretClass)so.getObject(dcipher);&lt;br /&gt;
} catch (java.io.IOException e) {&lt;br /&gt;
} catch (ClassNotFoundException e) {&lt;br /&gt;
} catch (javax.crypto.IllegalBlockSizeException e) {&lt;br /&gt;
} catch (javax.crypto.BadPaddingException e) {&lt;br /&gt;
} catch (javax.crypto.NoSuchPaddingException e) {&lt;br /&gt;
} catch (java.security.NoSuchAlgorithmException e) {&lt;br /&gt;
} catch (java.security.InvalidKeyException e) {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class MySecretClass implements java.io.Serializable {&lt;br /&gt;
String s = &quot;the secret&quot;;&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/8506702195248911636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/data-encryption-standard-des.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/8506702195248911636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/8506702195248911636'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/data-encryption-standard-des.html' title='Data Encryption Standard (DES)'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-4309938020879546296</id><published>2011-04-09T15:01:00.001+05:30</published><updated>2015-03-15T03:57:55.585+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Encryption and Decryption"/><title type='text'>Encryption and Decryption</title><content type='html'>&lt;strong&gt;What is encryption?&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Encryption is the conversion of data into a form, called a ciphertext. There are two basic techniques for encrypting information: symmetric encryption (also called secret key encryption) and asymmetric encryption(also called public key encryption).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How encryption works&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Encryption program uses an encryption algorithm (complex mathematical processes) to encrypt and decrypt the data. Encryption algorithm creates specific strings of data used for encryption - keys that consist of long strings of bits or binary numbers. The more bits in the key, the more the number of possible combinations of binary numbers that makes the code more difficult to break. Then encryption algorithm scrambles data by combining the bits in the key with the data bits. In symmetric encryption, the same key is used to scramble (encrypt) and unscramble (decrypt) data. In asymmetric key encryption, two different keys are required - one for encryption and one for decryption.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Why you need encryption&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Nowadays when more and more sensitive information is stored on computers and transmitted over the Internet, we need to ensure information security and safety.&lt;br /&gt;
&lt;br /&gt;
One of the most common uses of encryption is encrypting emails. Sending sensitive messages, documents and files over the Internet is like sending a postcard as all emails are transmitted in an unsecured form. It doesn&#39;t depend on if you send emails via public and private networks. Your message is totally open to interception by anyone along the way - so anybody - your ISP, your boss, etc. can read your emails. Even if you connect to your server and send your emails via SSL, it only means that your emails can&#39;t be seen while transmitting between you and your server. When your email reaches your server, it can be seen by your email service provider. Then your server usually sends your email to the recipient in an unsecured way and your email can also be easily seen by anyone.&lt;br /&gt;
&lt;br /&gt;
Private network, where email goes directly to a mail server and resides there until it is retrieved, also doesn&#39;t provide necessary security level, as you email can be seen e.g. by network administrator, your boss, etc.&lt;br /&gt;
&lt;br /&gt;
Of course, you may believe that your personal email does not contain any private information, but everyone has got something to keep in secret from his family, neighbors or colleagues. It could be financial, sexual, social, political, or professional secrets. There is really only one sure way to protect your email privacy - using encryption.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Symmetric Encryption&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Symmetric Encryption (also known as symmetric-key encryption, single-key encryption, one-key encryption and private key encryption) is a type of encryption where the same secret key is used to encrypt and decrypt information or there is a simple transform between the two keys.&lt;br /&gt;
&lt;br /&gt;
A secret key can be a number, a word, or just a string of random letters. Secret key is applied to the information to change the content in a particular way. This might be as simple as shifting each letter by a number of places in the alphabet. Symmetric algorithms require that both the sender and the receiver know the secret key, so they can encrypt and decrypt all information.&lt;br /&gt;
&lt;br /&gt;
There are two types of symmetric algorithms: Stream algorithms (Stream ciphers) and Block algorithms (Block ciphers).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Types of Symmetric algorithms (Symmetric-key algorithms)&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Symmetric algorithms (Symmetric-key algorithms) use the same key for encryption and decryption. Symmetric-key algorithms can be divided into Stream algorithms (Stream ciphers) and Block algorithms (Block ciphers).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Stream Ciphers&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Stream ciphers encrypt the bits of information one at a time - operate on 1 bit (or sometimes 1 byte) of data at a time (encrypt data bit-by-bit). Stream ciphers are faster and smaller to implement than block ciphers, however, they have an important security gap. If the same key stream is used, certain types of attacks may cause the information to be revealed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Block Ciphers&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Block cipher (method for encrypting data in blocks) is a symmetric cipher which encrypts information by breaking it down into blocks and encrypting data in each block. A block cipher encrypts data in fixed sized blocks (commonly of 64 bits). The most used block ciphers are Triple DES and AES.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some examples of symmetric encryption algorithms:&lt;br /&gt;
&lt;br /&gt;
AES/Rijndael&lt;br /&gt;
&lt;br /&gt;
Blowfish&lt;br /&gt;
&lt;br /&gt;
CAST5&lt;br /&gt;
&lt;br /&gt;
DES&lt;br /&gt;
&lt;br /&gt;
IDEA&lt;br /&gt;
&lt;br /&gt;
RC2&lt;br /&gt;
&lt;br /&gt;
RC4&lt;br /&gt;
&lt;br /&gt;
RC6&lt;br /&gt;
&lt;br /&gt;
Serpent&lt;br /&gt;
&lt;br /&gt;
Triple DES&lt;br /&gt;
&lt;br /&gt;
Twofish&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;AES / Rijndael encryption&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
AES stands for Advanced Encryption Standard. AES is a symmetric key encryption technique which replaces the commonly used Data Encryption Standard (DES).&lt;br /&gt;
&lt;br /&gt;
It was the result of a worldwide call for submissions of encryption algorithms issued by the US Government&#39;sNational Institute of Standards and Technology (NIST) in 1997 and completed in 2000.&lt;br /&gt;
&lt;br /&gt;
The winning algorithm, Rijndael, was developed by two Belgian cryptologists, Vincent Rijmen and Joan Daemen. AES provides strong encryption and was selected by NIST as a Federal Information Processing Standard in November 2001 (FIPS-197).&lt;br /&gt;
&lt;br /&gt;
The AES algorithm usesthree key sizes: a 128-, 192-, or 256-bit encryption key. Each encryption key size causes the algorithm to behave slightly differently, so the increasing key sizes not only offer a larger number of bits with which you can scramble the data, but also increase the complexity of the cipher algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Blowfish&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Blowfish is a symmetric encryption algorithm (64-bit cipher) designed in 1993 by Bruce Schneier as an alternative to existing encryption algorithms. Blowfish has a variable key length - from 32 bits to 448 bits. Since then Blowfish has been analyzed considerably, and is gaining acceptance as a strong encryption algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;CAST&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
CAST stands for Carlisle Adams and Stafford Tavares, the inventors of CAST. CAST is a popular 64-bit block cipher allowing key sizes up to 128 bits. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Data Encryption Standard (DES)&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Data Encryption Standard (DES) is a block cipher with 64-bit block size that uses 56-bit keys. DES was invented over 20 years ago by IBM in response to a public request from the National Bureau of Standards. Due to recent advances in computer technology, some experts no longer consider DES secure against all attacks; since then Triple-DES (3DES) has emerged as a stronger method. Using standard DES encryption, Triple-DES encrypts data three times and uses a different key for at least one of the three passes giving it a cumulative key size of 112-168 bits.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;IDEA&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
IDEA stands for International Data Encryption Algorithm. IDEA is a symmetric encryption algorithm that was developed by Dr. X. Lai and Prof. J. Massey to replace the DES standard. Unlike DES though it uses a 128 bit key. This key length makes it impossible to break by simply trying every key.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;RC2&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
RC2 is a variable-key-length cipher. It was invented by Ron Rivest for RSA Data Security, Inc. Its details have not been published.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;RC4&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
RC4 was developed by Ron Rivest in 1987. It is a variable-key-size stream cipher. It is a cipher with a key size of up to 2048 bits (256 bytes).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;RC6&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
RC6 is a symmetric key block cipher derived from RC5. It was designed by Ron Rivest, Matt Robshaw, Ray Sidney, and Yiqun Lisa Yin to meet the requirements of the Advanced Encryption Standard (AES) competition. RC6 encryption algorithm was selected among the other finalists to become the new federal Advanced Encryption Standard (AES).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Serpent&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Serpent is a block cipher developed by Ross Anderson, Eli Biham and Lars Knudsen. Serpent can work with different combinations of key lengths. Serpent was also selected among other five finalists to become the new federal Advanced Encryption Standard (AES). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Triple DES&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Triple DES is a variation of Data Encryption Standard (DES). It uses a 64-bit key consisting of 56 effective key bits and 8 parity bits. The size of the block for Triple-DES is 8 bytes. Triple-DES encrypts the data in 8-byte chunks. The idea behind Triple DES is to improve the security of DES by applying DES encryption three times using three different keys.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Twofish&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Twofish is a symmetric block cipher. Twofish has a block size of 128 bits and accepts keys of any length up to 256 bits.&lt;br /&gt;
&lt;br /&gt;
Twofish encryption algorithm was designed by Bruce Schneier, John Kelsey, Chris Hall, Niels Ferguson, David Wagner and Doug Whiting. The National Institute of Standards and Technology (NIST) investigated Twofish as one of the candidates for the replacement of the DES encryption algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;What are encryption vulnerabilities?&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Breaking symmetric encryption&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
There are two methods of breaking symmetric encryption - brute force and cryptanalysis.&lt;br /&gt;
&lt;br /&gt;
Brute Force Attack is a form of attack in which each possibility is tried until success is obtained. Typically, a ciphertext is deciphered under different keys until plaintext is recognized. No encryption software that is entirely safe from the brute force method, but if the number of possible keys is high enough, it can make a program astronomically difficult to crack using brute force. But the more bits in a key, the more secure it is, so choose software with as many bits as possible.&lt;br /&gt;
&lt;br /&gt;
Cryptanalysis is a form of attack that attacks the characteristics of the algorithm to deduce a specific plaintext or the key used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Weak passwords&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
In every kind of encryption software, there is some kind of password that must be created so that the recipients of the information can read it. Creating a strong password that cannot be easily guessed is just as important as choosing a good algorithm or strong encryption software.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Remembering passwords&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
If you forget your password, you will not be able to decrypt data that you have encrypted. Be sure to make a backup copy of your password and store it in a safe place.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Secret keys exchanging and storing&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Symmetric key algorithms require sharing the secret key - both the sender and the receiver need the same key to encrypt or decrypt data. Anyone who knows the secret key can decrypt the message. So it is essential that the sender and receiver have a way to exchange secret keys in a secure manner. The weakness of symmetric algorithms is that if the secret key is discovered, all messages can be decrypted. So, secret key need to be changed on a regular basis and kept secure during distribution and while using.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;strong&gt;Asymmetric Encryption (Public Key Encryption)&lt;/strong&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Asymmetric encryption uses different keys for encryption and decryption. The decryption key is very hard to derive from the encryption key. The encryption key is public so that anyone can encrypt a message. However, the decryption key is private, so that only the receiver is able to decrypt the message. It is common to set up &quot;key-pairs&quot; within a network so that each user has a public and private key. The public key is made available to everyone so that they can send messages, but the private key is only made available to the person it belongs to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How Asymmetric Encryption (Public Key Encryption) works:&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The sender and the recipient must have the same software. The recipient makes a pair of keys - public key and private key (both keys can be unlocked with a single password). Public key can be used by anyone with the same software to encrypt a message. Public keys can be freely distributed without worrying since it is only used to scramble (encrypt) the data.The sender does not need the recipient&#39;s password to use his or her public key to encrypt data. The recipient&#39;s other key is a private key that only he or she can use when decrypting the message. Private key should never be distributed since the private key assures that only the intended recipient can unscramble (decrypt) data intended for him or her.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To understand asymmetric encryption better please read an example:&lt;br /&gt;
&lt;br /&gt;
For example, Jonny makes public key A and private key A, and jinni makes public key B and private key B. Jonny and Jinni exchange their public keys. Once they have exchanged keys, Jonny can send an encrypted message to Jinni by using Jinni&#39;s public key B to scramble the message. Jinni uses her private key B to unscramble it. If Jinni wants to send an encrypted message to Jonny, she uses Jonny&#39;s public key A to scramble her message, which Jonny can then unscramble with his private key A. Asymmetric cryptography is typically slower to execute electronically than symmetric cryptography.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some Asymmetric Algorithms (public key algorithms) such as RSA allow the process to work in the opposite direction as well: a message can be encrypted with a private key and decrypted with the corresponding public key. If the recipient wants to decrypt a message with Bob&#39;s public key he/she must know that the message has come from Bob because no one else has sender&#39;s private key. Digital signatures work this way.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some examples of popular asymmetric encryption algorithms:&lt;br /&gt;
&lt;br /&gt;
RSA&lt;br /&gt;
&lt;br /&gt;
DSA&lt;br /&gt;
&lt;br /&gt;
PGP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;RSA encryption&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
RSA is the best known public key algorithm, named after its inventors: Rivest, Shamir and Adleman. RSA uses public and private keys that are functions of a pair of large prime numbers. Its security is based on the difficulty of factoring large integers. The RSA algorithm can be used for both public key encryption and digital signatures. The keys used for encryption and decryption in RSA algorithm, are generated using random data. The key used for encryption is a public key and the key used for decryption is a private key. Public keys are stored anywhere publicly accessible. The sender of message encrypts the data using public key, and the receiver decrypts it using his/her own private key. That way, no one else can intercept the data except receiver.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;DSA&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The Digital Signature Algorithm (DSA) is a United States Federal Government standard or FIPS for digital signatures. It was proposed by the National Institute of Standards and Technology (NIST) in August 1991 for use in their Digital Signature Standard (DSS).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PGP&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
PGP (Pretty Good Privacy) is a public-private key cryptography system which allows for users to more easily integrate the use of encryption in their daily tasks, such as electronic mail protection and authentication, and protecting files stored on a computer. PGP was originally designed by Phil Zimmerman. It uses IDEA, CAST orTriple DES for actual data encryption and RSA (with up to 2048-bit key) or DH/DSS (with 1024-bit signature key and 4096-bit encryption key) for key management and digital signatures. The RSA or DH public key is used to encrypt the IDEA secret key as part of the message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Combination of Symmetric Encryption and Asymmetric Encryption&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
If we want the benefits of both types of encryption algorithms, the general idea is to create a random symmetric key to encrypt the data, and then encrypt that key asymmetrically. Once the key is asymmetrically encrypted, we add it to the encrypted message. The receiver gets the key, decrypts it with their private key, and uses it to decrypt the message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here I will only discuss two symmetric encryption algorithms Data Encryption Standard (DES) and Advanced Encryption Standard (AES)</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/4309938020879546296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/04/encryption-and-decryption.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4309938020879546296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4309938020879546296'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/04/encryption-and-decryption.html' title='Encryption and Decryption'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-4307003251510002669</id><published>2011-03-31T23:06:00.000+05:30</published><updated>2014-02-21T09:57:37.306+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="J2SE 5.0 (Tiger) Features"/><category scheme="http://www.blogger.com/atom/ns#" term="Java versions and their features"/><title type='text'>J2SE 5.0 (Tiger) Features</title><content type='html'>These are the main features of J2SE 5.0 (Tiger)&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Generics&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
When you take an element out of a Collection, you must cast it to the type of element that is stored in the collection. Besides being inconvenient, this is unsafe. The compiler does not check that your cast is the same as the collection&#39;s type, so the cast can fail at run time.&lt;br /&gt;
&lt;br /&gt;
Generic provides a way for you to communicate the type of a collection to the compiler, so that it can be checked. Once the compiler knows the element type of the collection, the compiler can check that you have used the collection consistently and can insert the correct casts on values being taken out of the collection.&lt;br /&gt;
&lt;br /&gt;
How to Use Generics&lt;br /&gt;
&lt;br /&gt;
1. Find a data structure that accepts Object(s)&lt;br /&gt;
&lt;br /&gt;
• ArrayList, LinkedList, HashMap, HashSet&lt;br /&gt;
• Not arrays: they already take explicit types!&lt;br /&gt;
&lt;br /&gt;
2. Declare the data structure with the type(s) in angle brackets immediately after class name&lt;br /&gt;
&lt;br /&gt;
• ArrayList&lt;string&gt; myStrings = new ArrayList&lt;string&gt;();&lt;br /&gt;
• HashMap&lt;string,string&gt; myHashtable = new HashMap&lt;string,string&gt;();&lt;br /&gt;
&lt;br /&gt;
3. Insert objects of the appropriate type&lt;br /&gt;
&lt;br /&gt;
• myStrings.add(&quot;Some String&quot;);&lt;br /&gt;
• myHashtable.put(&quot;Some Key&quot;, &quot;Some Value&quot;);&lt;br /&gt;
&lt;br /&gt;
4. No typecast required on removal&lt;br /&gt;
&lt;br /&gt;
• String myValue = myStrings.get(0);&lt;br /&gt;
• String myOtherValue = myHashtable.get(&quot;Some Key&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ArrayList Example: Explicit Typecasts&lt;br /&gt;
&lt;br /&gt;
ArrayList list = new ArrayList();&lt;br /&gt;
list.add(0, new Integer(42)); &lt;br /&gt;
int total = ((Integer)list.get(0)).intValue();&lt;br /&gt;
&lt;br /&gt;
The cast to Integer on the last line is an example of the typecasting issues that generic types aim to prevent. The issue is that the 1.4.2 Collection API uses the Object class to store the Collection objects, which means that it cannot pick up type mismatches at compile time. The first notification of a problem is a ClassCastException at runtime.&lt;br /&gt;
&lt;br /&gt;
The same example with the generified Collections library is written as follows:&lt;br /&gt;
&lt;br /&gt;
ArrayList&lt;integer&gt; list = new ArrayList&lt;integer&gt;();&lt;br /&gt;
list.add(0, new Integer(42));&lt;br /&gt;
int total = list.get(0).intValue();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Automatic Boxing and Unboxing of Primitive Types&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
As any Java programmer knows, you can’t put an int (or other primitive value) into a collection. Collections can only hold object references, so you have to box primitive values into the appropriate wrapper class (which is Integer in the case of int). When you take the object out of the collection, you get the Integer that you put in; if you need an int, you must unbox the Integer using the intValue method. All of this boxing and unboxing is a pain, and clutters up your code. The autoboxing and unboxing feature automates the process, eliminating the pain and the clutter.&lt;br /&gt;
&lt;br /&gt;
Before&lt;br /&gt;
&lt;br /&gt;
ArrayList&lt;integer&gt; list = new ArrayList&lt;integer&gt;();&lt;br /&gt;
list.add(0, new Integer(42)); &lt;br /&gt;
int total = (list.get(0)).intValue();&lt;br /&gt;
&lt;br /&gt;
After&lt;br /&gt;
&lt;br /&gt;
ArrayList&lt;integer&gt; list = new ArrayList&lt;integer&gt;();&lt;br /&gt;
list.add(0, 42);&lt;br /&gt;
int total = list.get(0);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;The For-Each Loop&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The Iterator class is used heavily by the Collections API. It provides the mechanism to navigate sequentially through a Collection. The new enhanced for loop can replace the iterator when simply traversing through a Collection as follows. The compiler generates the looping code necessary and with generic types no additional casting is required.&lt;br /&gt;
&lt;br /&gt;
The for (:) loop is designed for iteration over array and collections.&lt;br /&gt;
&lt;br /&gt;
Iterating over Arrays:&lt;br /&gt;
&lt;br /&gt;
for (;;) Loop&lt;br /&gt;
int[] ageInfo = {12, 30, 45, 55};&lt;br /&gt;
int sumAge = 0;&lt;br /&gt;
for (int i = 0; i &amp;lt; ageInfo.length; i++)&lt;br /&gt;
sumAge += ageInfo[i];&lt;br /&gt;
&lt;br /&gt;
for (:) Loop&lt;br /&gt;
&lt;br /&gt;
int[] ageInfo = {12, 30, 45, 55};&lt;br /&gt;
int sumAge = 0;&lt;br /&gt;
for (int element : ageInfo)&lt;br /&gt;
sumAge += element;&lt;br /&gt;
&lt;br /&gt;
Note that an array element of a primitive value cannot be modified in the for(:) loop.&lt;br /&gt;
&lt;br /&gt;
Iterating over non-generic Collections:&lt;br /&gt;
&lt;br /&gt;
for(;;) Loop&lt;br /&gt;
&lt;br /&gt;
Collection nameList = new ArrayList();&lt;br /&gt;
nameList.add(&quot;Tom&quot;);&lt;br /&gt;
nameList.add(&quot;Dick&quot;);&lt;br /&gt;
nameList.add(&quot;Harry&quot;);&lt;br /&gt;
for (Iterator it = nameList.iterator();&lt;br /&gt;
it.hasNext(); ) {&lt;br /&gt;
Object element = it.next();&lt;br /&gt;
if (element instanceof String) {&lt;br /&gt;
String name = (String) element;&lt;br /&gt;
//...&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(:) Loop&lt;br /&gt;
&lt;br /&gt;
Collection nameList = new ArrayList();&lt;br /&gt;
nameList.add(&quot;Tom&quot;);&lt;br /&gt;
nameList.add(&quot;Dick&quot;);&lt;br /&gt;
nameList.add(&quot;Harry&quot;);&lt;br /&gt;
for (Object element : nameList) {&lt;br /&gt;
if (element instanceof String) {&lt;br /&gt;
String name = (String) element;&lt;br /&gt;
//...&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Static Import&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
An import statement allows you to give a hint to the compiler as to which class you are &lt;br /&gt;
referring to in your code. It gives you the convenience of using the short name for a class &lt;br /&gt;
(like JButton) instead of the long, fully qualified name (like javax.swing.JButton). &lt;br /&gt;
Remember that import does not tell the compiler where the class resides (classpath does &lt;br /&gt;
that). It only tells the compiler which class you mean to use.&lt;br /&gt;
&lt;br /&gt;
Syntax:&lt;br /&gt;
&lt;br /&gt;
// Static-import-on-demand: imports all static members&lt;br /&gt;
import static FullyQualifiedTypeName.*;&lt;br /&gt;
// Single-static-import: imports a specific static member&lt;br /&gt;
import static FullyQualifiedTypeName.StaticMemberName;&lt;br /&gt;
&lt;br /&gt;
Avoiding the Constant Interface Antipattern&lt;br /&gt;
&lt;br /&gt;
Constant Interface&lt;br /&gt;
&lt;br /&gt;
package mypackage;&lt;br /&gt;
&lt;br /&gt;
public interface MachineStates {&lt;br /&gt;
// Fields are public,&lt;br /&gt;
// static and final.&lt;br /&gt;
int BUSY = 1;&lt;br /&gt;
int IDLE = 0;&lt;br /&gt;
int BLOCKED = -1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Without Static Import&lt;br /&gt;
&lt;br /&gt;
class MyFactory implements&lt;br /&gt;
mypackage.MachineStates {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
int[] states = {IDLE, BUSY, IDLE, BLOCKED };&lt;br /&gt;
for (int s : states)&lt;br /&gt;
System.out.println(s);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
With Static Import&lt;br /&gt;
&lt;br /&gt;
import static mypackage.MachineStates.*; // Imports all static members.&lt;br /&gt;
&lt;br /&gt;
class MyFactory2 {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
int[] states = { IDLE, BUSY, IDLE, BLOCKED };&lt;br /&gt;
for (int s : states)&lt;br /&gt;
System.out.println(s);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Static-import-on-demand: Import of All Static Members&lt;br /&gt;
&lt;br /&gt;
Without Static Import&lt;br /&gt;
&lt;br /&gt;
class Calculate1 {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
double x = 10.0, y = 20.5;&lt;br /&gt;
double squareroot = Math.sqrt(x);&lt;br /&gt;
double hypotenue = Math.hypot(x, y);&lt;br /&gt;
double area = Math.PI * y * y;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With Static Import&lt;br /&gt;
&lt;br /&gt;
import static java.lang.Math.*;&lt;br /&gt;
&lt;br /&gt;
// All static members from Math are imported.&lt;br /&gt;
class Calculate2 {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
double x = 10.0, y = 20.5;&lt;br /&gt;
double squareroot = sqrt(x);&lt;br /&gt;
double hypotenue = hypot(x, y);&lt;br /&gt;
double area = PI * y * y;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Single-static-import: Import of Individual Static Members&lt;br /&gt;
&lt;br /&gt;
import static java.lang.Math.sqrt; // Static method&lt;br /&gt;
import static java.lang.Math.PI; // Static field&lt;br /&gt;
// Only specified static members are imported.&lt;br /&gt;
class Calculate3 {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
double x = 10.0, y = 20.5;&lt;br /&gt;
double squareroot = sqrt(x);&lt;br /&gt;
double hypotenue = Math.hypot(x, y); // Requires type name.&lt;br /&gt;
double area = PI * y * y;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Enums&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Enumerated Types&lt;br /&gt;
&lt;br /&gt;
• An enumerated type defines a finite set of symbolic names and their values.&lt;br /&gt;
• Standard approach is the int enum pattern (or the analogous String enum pattern):&lt;br /&gt;
&lt;br /&gt;
public class MachineState {&lt;br /&gt;
public static final int BUSY = 1;&lt;br /&gt;
public static final int IDLE = 0;&lt;br /&gt;
public static final int BLOCKED = -1;&lt;br /&gt;
//...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Machine {&lt;br /&gt;
int state;&lt;br /&gt;
public void setState(int state) {&lt;br /&gt;
this.state = state;&lt;br /&gt;
}&lt;br /&gt;
//...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class IntEnumPatternClient {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
Machine machine = new Machine();&lt;br /&gt;
machine.setState(MachineState.BUSY); // (1) Constant qualified by class name&lt;br /&gt;
machine.setState(1); // Same as (1)&lt;br /&gt;
machine.setState(5); // Any int will do.&lt;br /&gt;
System.out.println(MachineState.BUSY); // Prints &quot;1&quot;, not &quot;BUSY&quot;.&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Some Disadvantages of the int Enum Pattern&lt;br /&gt;
&lt;br /&gt;
• Not typesafe.&lt;br /&gt;
– Any int value can be passed to the setState() method.&lt;br /&gt;
&lt;br /&gt;
• No namespace.&lt;br /&gt;
– A constant must be qualified by the class (or interface) name, unless the class is extended (or the interface is implemented).&lt;br /&gt;
&lt;br /&gt;
• Uninformative textual representation.&lt;br /&gt;
–&amp;nbsp;Only the value can be printed, not the name.&lt;br /&gt;
&lt;br /&gt;
• Constants compiled into clients.&lt;br /&gt;
–&amp;nbsp;Clients need recompiling if the constant values change.&lt;br /&gt;
&lt;br /&gt;
Typesafe Enum Construct&lt;br /&gt;
&lt;br /&gt;
• The enum construct provides support for enum types:&lt;br /&gt;
&lt;br /&gt;
enum MachineState { BUSY, IDLE, BLOCKED } // Canonical form&lt;br /&gt;
enum Day {&lt;br /&gt;
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
• Keyword enum is used to declare an enum type.&lt;br /&gt;
&lt;br /&gt;
• Overcomes all the disadvantages of the int enum pattern, and is more powerful&lt;br /&gt;
&lt;br /&gt;
Properties of the Enum Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• An enum declaration is a special kind of class declaration:&lt;br /&gt;
– It can be declared at the top-level and as static enum declaration.&lt;br /&gt;
&lt;br /&gt;
// (1) Top level enum declaration&lt;br /&gt;
public enum SimpleMeal&lt;br /&gt;
{ BREAKFAST, LUNCH, DINNER }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class EnumTypeDeclarations {&lt;br /&gt;
// (2) Static enum declaration is OK.&lt;br /&gt;
public enum SimpleMeal&lt;br /&gt;
{ BREAKFAST, LUNCH, DINNER };&lt;br /&gt;
public void foo() {&lt;br /&gt;
// (3) Local (inner) enum declaration is NOT OK!&lt;br /&gt;
enum SimpleMeal&lt;br /&gt;
{ BREAKFAST, LUNCH, DINNER }&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Enum Constructors&lt;br /&gt;
&lt;br /&gt;
• Each constant declaration can be followed by an argument list that is passed to the&lt;br /&gt;
constructor of the enum type having the matching parameter signature.&lt;br /&gt;
&lt;br /&gt;
– An implicit standard constructor is created if no constructors are provided for the enum type.&lt;br /&gt;
&lt;br /&gt;
– As an enum cannot be instantiated using the new operator, the constructors cannot be called explicitly.&lt;br /&gt;
&lt;br /&gt;
public enum Meal {&lt;br /&gt;
BREAKFAST(7,30), LUNCH(12,15), DINNER(19,45);&lt;br /&gt;
Meal(int hh, int mm) {&lt;br /&gt;
assert (hh &amp;gt;= 0 &amp;amp;&amp;amp; hh &amp;lt;= 23): &quot;Illegal hour.&quot;;&lt;br /&gt;
assert (mm &amp;gt;= 0 &amp;amp;&amp;amp; hh &amp;lt;= 59): &quot;Illegal mins.&quot;;&lt;br /&gt;
this.hh = hh;&lt;br /&gt;
this.mm = mm;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Time for the meal.&lt;br /&gt;
private int hh;&lt;br /&gt;
private int mm;&lt;br /&gt;
public int getHour() { return this.hh; }&lt;br /&gt;
public int getMins() { return this.mm; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Methods Provided for the Enum Types&lt;br /&gt;
&lt;br /&gt;
• Names of members declared in an enum type cannot conflict with automatically generated member names:&lt;br /&gt;
&lt;br /&gt;
– The enum constant names cannot be redeclared.&lt;br /&gt;
&lt;br /&gt;
– The following methods cannot be redeclared:&lt;br /&gt;
&lt;br /&gt;
static &lt;this class=&quot;&quot; enum=&quot;&quot;&gt;[]values()&lt;br /&gt;
&lt;br /&gt;
Returns an array containing the constants of this enum class, in the order they are declared.&lt;br /&gt;
&lt;br /&gt;
static &lt;this class=&quot;&quot; enum=&quot;&quot;&gt;valueOf(String name)&lt;br /&gt;
&lt;br /&gt;
Return the enum constant with the specified name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• Enum types are based on the java.lang.Enum class which provides the default behavior.&lt;br /&gt;
&lt;br /&gt;
• Enums cannot declare methods which override the final methods of the java.lang.Enum class:&lt;br /&gt;
&lt;br /&gt;
– clone(), compareTo(Object), equals(Object), getDeclaringClass(), hashCode(), name(), ordinal().&lt;br /&gt;
&lt;br /&gt;
– The final methods do what their names imply, but the clone() method throws an CloneNotSupportedException, as an enum constant cannot be cloned.&lt;br /&gt;
&lt;br /&gt;
• Note that the enum constants must be declared before any other declarations in an enum type.&lt;br /&gt;
&lt;br /&gt;
public class MealClient {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
for (Meal meal : Meal.values())&lt;br /&gt;
System.out.println(meal + &quot; served at &quot; + meal.getHour() + &quot;:&quot; + meal.getMins() + &quot;, has the ordinal value &quot; +&amp;nbsp; meal.ordinal());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Output from the program:&lt;br /&gt;
&lt;br /&gt;
BREAKFAST served at 7:30, has the ordinal value 0&lt;br /&gt;
LUNCH served at 12:15, has the ordinal value 1&lt;br /&gt;
DINNER served at 19:45, has the ordinal value 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enums in a switch statement&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• The switch expression can be of an enum type, and the case labels can be enum constants of this enum type.&lt;br /&gt;
&lt;br /&gt;
public class EnumClient {&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
Machine machine = new Machine();&lt;br /&gt;
machine.setState(MachineState.IDLE);&lt;br /&gt;
// ...&lt;br /&gt;
MachineState state = machine.getState();&lt;br /&gt;
switch(state) {&lt;br /&gt;
//case MachineState.BUSY:// Compile error: Must be unqualified.&lt;br /&gt;
case BUSY: System.out.println(state + &quot;: Try later.&quot;); break;&lt;br /&gt;
case IDLE: System.out.println(state + &quot;: At your service.&quot;); break;&lt;br /&gt;
case BLOCKED: System.out.println(state + &quot;: Waiting on input.&quot;); break;&lt;br /&gt;
//case 2: // Compile error: Not unqualified enum constant.&lt;br /&gt;
default: assert false: &quot;Unknown machine state: &quot; + state;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Varargs&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assume you want to invoke a method with variable number of arguments. The option we&lt;br /&gt;
had on hand in Java 1.4 or earlier was to pass an array. Let’s consider a simple example&lt;br /&gt;
as shown below:&lt;br /&gt;
&lt;br /&gt;
public static int max(int[] values)&lt;br /&gt;
{&lt;br /&gt;
int max = values[0];&lt;br /&gt;
for(int aValue : values)&lt;br /&gt;
{&lt;br /&gt;
if (aValue &amp;gt; max) max = aValue;&lt;br /&gt;
}&lt;br /&gt;
return max;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
We can invoke this method by passing an array with different number of values as illustrated below:&lt;br /&gt;
&lt;br /&gt;
max(new int[] {1, 7, 2, 9, 8});&lt;br /&gt;
max(new int[]{8, 12, 87, 23, 1, 3, 6, 9, 37});&lt;br /&gt;
&lt;br /&gt;
In order to invoke a method that takes variable number of arguments, we had to bundle&lt;br /&gt;
the parameters into an array. While this works, it is not elegant. The varargs introduced in&lt;br /&gt;
Java 5 addresses the elegance issue.&lt;br /&gt;
&lt;br /&gt;
It is not only elegant, it also is very type safe. Let’s take the max method and modify it to use the varargs.&lt;br /&gt;
&lt;br /&gt;
public static int max(int... values)&lt;br /&gt;
&lt;br /&gt;
Notice that the only thing I changed is int[] to int… and I did not modify the&lt;br /&gt;
implementation of the max method. If the previous implementation of the method still&lt;br /&gt;
works after the change to the parameter type, then what is the new syntax and how is it&lt;br /&gt;
related to the array?&lt;br /&gt;
&lt;br /&gt;
A type followed by … is simply a syntax sugar–it’s nothing but an array. However, the&lt;br /&gt;
compiler allows you to pass either an array or a discrete set of values to this method. For&lt;br /&gt;
example, now I can call the modified max method as follows:&lt;br /&gt;
&lt;br /&gt;
max(new int[] {1, 7, 2, 9, 8});&lt;br /&gt;
max(new int[]{8, 12, 87, 23, 1, 3, 6, 9, 37});&lt;br /&gt;
&lt;br /&gt;
max(1, 7, 2, 9, 8);&lt;br /&gt;
max(8, 12, 87, 23, 1, 3, 6, 9, 37);&lt;br /&gt;
&lt;br /&gt;
There’s less clutter in the bottom two lines than in the top two lines. But what’s going on&lt;br /&gt;
when you pass discrete values? The compiler simply rolls the values into an array. So, the&lt;br /&gt;
&lt;br /&gt;
code:&lt;br /&gt;
&lt;br /&gt;
max(1, 7);&lt;br /&gt;
is compiled into:&lt;br /&gt;
max(new int[] {1, 7});&lt;br /&gt;
&lt;br /&gt;
In the above example we passed an array of int. What if we want to pass different types&lt;br /&gt;
of data? Sure we can. Consider the example below:&lt;br /&gt;
&lt;br /&gt;
public static void print(Object... values)&lt;br /&gt;
{&lt;br /&gt;
for(Object obj : values)&lt;br /&gt;
{&lt;br /&gt;
System.out.printf(&quot;%s is of type %s\n&quot;, obj, obj.getClass().getName());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code receives a varargs of type Object. You can invoke it with different types as shown below:&lt;br /&gt;
&lt;br /&gt;
print(1, &quot;test&quot;, &#39;a&#39;, 2.1);&lt;br /&gt;
&lt;br /&gt;
The output from this call is:&lt;br /&gt;
&lt;br /&gt;
1 is of type java.lang.Integer test is of type java.lang.String a is of type java.lang.Character&lt;br /&gt;
2.1 is of type java.lang.Double&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first line should be no surprise if you kept autoboxing in mind–that is the reason for&lt;br /&gt;
the type to be Integer instead of int. We’ve also used the printf statement which&lt;br /&gt;
directly benefits from the varargs concept.&lt;br /&gt;
&lt;br /&gt;
You are not restricted to having only varargs as parameters, that is, you can have regular&lt;br /&gt;
parameters and varargs, if you like. However, varargs, if present, must be trailing. In&lt;br /&gt;
other words, place any regular parameters you like and then place the varargs as shown in&lt;br /&gt;
&lt;br /&gt;
the following example:&lt;br /&gt;
&lt;br /&gt;
public static void print(String msg, Object... values)&lt;br /&gt;
&lt;br /&gt;
Pros and Cons:&lt;br /&gt;
&lt;br /&gt;
• varargs comes in handy when you want to pass variable number of arguments.&lt;br /&gt;
Use it if you need that flexibility and elegance.&lt;br /&gt;
&lt;br /&gt;
• You loose some compile time type safety if your varargs is of type Object.&lt;br /&gt;
However, if it is specific type (like int…), then you have type safety.&lt;br /&gt;
&lt;br /&gt;
• If in your application you expect only three or four parameters to be passed to the&lt;br /&gt;
method, then don’t bother to use varargs.&lt;br /&gt;
&lt;br /&gt;
• If you are not careful, you may have trouble with method overloading as the&lt;br /&gt;
varargs may increase the chance of parameter collision when methods are overloaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Annotations&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Annotations is a new feature from Java 5. Annotations are a kind of comment or meta data you can insert in your Java code. These annotations can then be processed at compile time by pre-compiler tools, or at runtime via Java Reflection. Here is an example of class annotation:&lt;br /&gt;
&lt;br /&gt;
@MyAnnotation(name=&quot;someName&quot;, value = &quot;Hello World&quot;)&lt;br /&gt;
public class TheClass {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The class TheClass has the annotation @MyAnnotation written ontop. Annotations are defined like interfaces. Here is the MyAnnotation definition:&lt;br /&gt;
&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@Target(ElementType.TYPE)&lt;br /&gt;
&lt;br /&gt;
public @interface MyAnnotation {&lt;br /&gt;
public String name();&lt;br /&gt;
public String value();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The @ in front of the interface marks it as an annotation. Once you have defined the annotation you can use it in your code, as shown in the earlier examples.&lt;br /&gt;
&lt;br /&gt;
The two directives in the annotation definition, @Retention(RetentionPolicy.RUNTIME) and@Target(ElementType.TYPE), specifies how the annotation is to be used.&lt;br /&gt;
&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME) means that the annotation can be accessed via reflection at runtime. If you do not set this directive, the annotation will not be preserved at runtime, and thus not available via reflection.&lt;br /&gt;
&lt;br /&gt;
@Target(ElementType.TYPE) means that the annotation can only be used ontop of types (classes and interfaces typically). You can also specify METHOD or FIELD, or you can leave the target out alltogether so the annotation can be used for both classes, methods and fields.&lt;br /&gt;
&lt;br /&gt;
Class Annotations&lt;br /&gt;
&lt;br /&gt;
You can access the annotations of a class, method or field at runtime. Here is an example that accesses the class annotations:&lt;br /&gt;
&lt;br /&gt;
Class aClass = TheClass.class;&lt;br /&gt;
Annotation[] annotations = aClass.getAnnotations();&lt;br /&gt;
for(Annotation annotation : annotations){&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can also access a specific class annotation like this:&lt;br /&gt;
&lt;br /&gt;
Class aClass = TheClass.class;&lt;br /&gt;
Annotation annotation = aClass.getAnnotation(MyAnnotation.class);&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Method Annotations&lt;br /&gt;
&lt;br /&gt;
Here is an example of a method with annotations:&lt;br /&gt;
&lt;br /&gt;
public class TheClass {&lt;br /&gt;
@MyAnnotation(name=&quot;someName&quot;, value = &quot;Hello World&quot;)&lt;br /&gt;
public void doSomething(){}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can access method annotations like this:&lt;br /&gt;
&lt;br /&gt;
Method method = ... //obtain method object&lt;br /&gt;
Annotation[] annotations = method.getDeclaredAnnotations();&lt;br /&gt;
for(Annotation annotation : annotations){&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can also access a specific method annotation like this:&lt;br /&gt;
&lt;br /&gt;
Method method = ... // obtain method object&lt;br /&gt;
Annotation annotation = method.getAnnotation(MyAnnotation.class);&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Parameter Annotations&lt;br /&gt;
&lt;br /&gt;
It is possible to add annotations to method parameter declarations too. Here is how that looks:&lt;br /&gt;
&lt;br /&gt;
public class TheClass {&lt;br /&gt;
public static void doSomethingElse(&lt;br /&gt;
@MyAnnotation(name=&quot;aName&quot;, value=&quot;aValue&quot;) String parameter){&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can access parameter annotations from the Method object like this:&lt;br /&gt;
&lt;br /&gt;
Method method = ... //obtain method object&lt;br /&gt;
Annotation[][] parameterAnnotations = method.getParameterAnnotations();&lt;br /&gt;
Class[] parameterTypes = method.getParameterTypes();&lt;br /&gt;
int i=0;&lt;br /&gt;
for(Annotation[] annotations : parameterAnnotations){&lt;br /&gt;
Class parameterType = parameterTypes[i++];&lt;br /&gt;
for(Annotation annotation : annotations){&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;param: &quot; + parameterType.getName());&lt;br /&gt;
System.out.println(&quot;name : &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Notice how the Method.getParameterAnnotations() method returns a two-dimensionalAnnotation array, containing an array of annotations for each method parameter.&lt;br /&gt;
&lt;br /&gt;
Field Annotations&lt;br /&gt;
&lt;br /&gt;
Here is an example of a field with annotations:&lt;br /&gt;
&lt;br /&gt;
public class TheClass {&lt;br /&gt;
@MyAnnotation(name=&quot;someName&quot;, value = &quot;Hello World&quot;)&lt;br /&gt;
public String myField = null;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can access field annotations like this:&lt;br /&gt;
&lt;br /&gt;
Field field = ... //obtain field object&lt;br /&gt;
Annotation[] annotations = field.getDeclaredAnnotations();&lt;br /&gt;
for(Annotation annotation : annotations){&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
You can also access a specific field annotation like this:&lt;br /&gt;
&lt;br /&gt;
Field field = ... // obtain method object&lt;br /&gt;
Annotation annotation = field.getAnnotation(MyAnnotation.class);&lt;br /&gt;
if(annotation instanceof MyAnnotation){&lt;br /&gt;
MyAnnotation myAnnotation = (MyAnnotation) annotation;&lt;br /&gt;
System.out.println(&quot;name: &quot; + myAnnotation.name());&lt;br /&gt;
System.out.println(&quot;value: &quot; + myAnnotation.value());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other features&lt;br /&gt;
&lt;br /&gt;
In this article we have focused on the language features in Java 5. Java 5 has some other &lt;br /&gt;
&lt;br /&gt;
interesting features as well. Listed below are some select features: &lt;br /&gt;
&lt;br /&gt;
• StringBuilder &lt;br /&gt;
– StringBuffer eliminates object creation overhead, but has synchronization overhead &lt;br /&gt;
– StringBuilder removes that overhead &lt;br /&gt;
&lt;br /&gt;
• Client vs. Server side differences in garbage collection, more adaptive collection &lt;br /&gt;
&lt;br /&gt;
• Improved Image I/O for performance and memory usage &lt;br /&gt;
&lt;br /&gt;
• Reduced application startup time and footprint using shared archive &lt;br /&gt;
&lt;br /&gt;
• Enhancement to Thread Priority &lt;br /&gt;
&lt;br /&gt;
• Ability to get stack trace for a thread or all threads &lt;br /&gt;
&lt;br /&gt;
• UncoughtExceptionHandler on a Thread &lt;br /&gt;
&lt;br /&gt;
• Improved error reporting on fatal exceptions &lt;br /&gt;
&lt;br /&gt;
• System.nanoTime() for nanoseconds granularity for time measurements &lt;br /&gt;
&lt;br /&gt;
• ProcessBuilder &lt;br /&gt;
&lt;br /&gt;
– Easier than Runtime.exec() to start process &lt;br /&gt;
&lt;br /&gt;
• Formatter and Formattable provide ability to format output in printf like style &lt;br /&gt;
&lt;br /&gt;
• Scanner for easier conversion to primitive types – based on regex &lt;br /&gt;
&lt;br /&gt;
• java.lang.instrument allows byte code enhancement at runtime to instrument code &lt;br /&gt;
&lt;br /&gt;
• Collections Framework has Queue, BlockingQueue, and ConcurrentMap interfaces and implementations. Some classes modified to implements new interfaces &lt;br /&gt;
&lt;br /&gt;
• Reflection API supports annotation, enum. Class has been generified &lt;br /&gt;
&lt;br /&gt;
• System.getenv() undeprecated</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/4307003251510002669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/03/j2se-50-tiger-features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4307003251510002669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4307003251510002669'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/03/j2se-50-tiger-features.html' title='J2SE 5.0 (Tiger) Features'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-536391588634200036</id><published>2011-03-29T23:44:00.012+05:30</published><updated>2014-02-21T09:57:37.312+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java versions and their features"/><category scheme="http://www.blogger.com/atom/ns#" term="Scripting Language Support in Java SE 6 (Mustang)"/><title type='text'>Scripting Language Support in Java SE 6 (Mustang)</title><content type='html'>You can now mix in JavaScript technology source code, useful for prototyping. Also useful when you have teams with a variety of skill sets. More advanced developers can plug in their own scripting engines and mix their favourite scripting language in with Java code as they see fit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
J2SE 1.6 includes a modified version of the Rhino JavaScript engine integrated via JSR 223 and a command-line scripting shell, jrunscript, which leverages this support. The shell is of limited use in most applications, but can be a valuable tool in learning and prototyping in Java and arbitrary scripting languages. The jrunscript syntax is:&lt;br /&gt;
&lt;br /&gt;
Usage: jrunscript [options] [arguments...] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Accessing the Scripting Engine&lt;br /&gt;
&lt;br /&gt;
The fundamental interface for all scripting engines is javax.script.ScriptEngine. This interface defines a set of methods expected to be supported by all implementations. An implementation is obtained from the ScriptEngineManager. ScriptEngine implementations are deployed as Jar files (typically in lib/ext). Each such jar contains a text file resource META-INF/services/javax.script.ScriptEngineFactory defining one or more classes implementing ScriptEngineFactory. The ScriptEngineManager utilizes these factories to create specific implementations. The ScriptEngineManager also provides metadata defining the supported script type and version information which is used to resolve requests for a scripting implementation. Obtaining an engine is straightforward: &lt;br /&gt;
&lt;br /&gt;
ScriptEngineManager manager = new ScriptEngineManager();&lt;br /&gt;
ScriptEngine jsEngine = manager.getEngineByName(&quot;js&quot;);&lt;br /&gt;
&lt;br /&gt;
The primary method of the ScriptEngine, eval(), executes a script directly passed as a String or accessed through a Reader. These two variations may be additionally parameterized with either a Bindings or ScriptContext object. &lt;br /&gt;
&lt;br /&gt;
Object eval(String script)&lt;br /&gt;
Object eval(Reader reader)&lt;br /&gt;
Object eval(String script, Bindings n)&lt;br /&gt;
Object eval(Reader reader, Bindings n)&lt;br /&gt;
Object eval(String script, ScriptContext context)&lt;br /&gt;
Object eval(Reader reader, ScriptContext context)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A ScriptContext associates a ScriptEngine with objects in the Java application. Every engine has a default ScriptContext (which can be altered through the API). It groups objects by scope. Each scope has a related Bindings instance containing these objects. Bindings is simply a Map&lt;string, object=&quot;&quot;&gt; which associates scripting variable names with Java instances. &lt;br /&gt;
&lt;br /&gt;
Two scopes are predefined, ScriptContext.GLOBAL_SCOPE and ScriptContext.ENGINE_SCOPE. The first contains attributes shared by all Engines created via a given factory, while the second is specific to the engine implementation. The default context and scope is used by the single argument eval() methods. The Scripting API includes many instances of such convenience methods. A binding or context passed to an eval effectively replaces the default bindings or context for the scope of the method call. &lt;br /&gt;
&lt;br /&gt;
Additional scopes may be defined by contexts specific to an Engine. For example, the HttpScriptContext used in web-based applications defines request, session, and applications scopes corresponding to Servlet scopes. &lt;br /&gt;
&lt;br /&gt;
The below example summarizes basic usage of the Scripting API: &lt;br /&gt;
&lt;br /&gt;
// simple script execution&lt;br /&gt;
jsEngine.eval(&quot;print(&#39;Hello&#39;)&quot;);&lt;br /&gt;
&lt;br /&gt;
// bind scripting variables and use in a script&lt;br /&gt;
jsEngine.put(&quot;a&quot;, 3);&lt;br /&gt;
Integer b = 2;&lt;br /&gt;
jsEngine.put(&quot;b&quot;, b); &lt;br /&gt;
Object retval = jsEngine.eval(&quot;c = a + b; print(&#39;a + b = &#39; + c);&quot;);&lt;br /&gt;
&lt;br /&gt;
// retrieve the bindings we previously added&lt;br /&gt;
Bindings bindings = jsEngine.getBindings(ScriptContext.ENGINE_SCOPE);&lt;br /&gt;
boolean containsKey = bindings.containsKey(&quot;a&quot;);&lt;br /&gt;
System.out.println(containsKey);&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Results in: &lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Hello&lt;br /&gt;
a + b = 5&lt;br /&gt;
true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The checked ScriptException is thrown by methods of the Scripting API. Depending on the Engine, the errant line and column number of the script will be included in the exception.&lt;br /&gt;
&lt;br /&gt;
Compilable and Invocable&lt;br /&gt;
&lt;br /&gt;
Beyond the based ScriptEngine capability, certain implementations may advertise additional capability by implementing the Compilable or Invocable interfaces. &lt;br /&gt;
&lt;br /&gt;
An engine implementing Compilable supports the re-execution of intermediate (e.g. compiled) code from previous compilations. The compile() method returns a CompiledScript based on either a String or Reader. The CompiledScript may be executed repeatedly via its eval() method. &lt;br /&gt;
&lt;br /&gt;
Compilable eng = (Compilable)jsEngine;&lt;br /&gt;
CompiledScript script = eng.compile(&quot;function test() { return 10; }; test();&quot;);&lt;br /&gt;
Object compiledOutput = script.eval();&lt;br /&gt;
System.out.println(compiledOutput); // prints 10.0&lt;br /&gt;
&lt;br /&gt;
An engine implementing Invocable supports the calling of individual functions scripted in the engine via the invoke() method. Arguments and return values are converted between script and Java types based on the engine implementation. Below is a simple example: &lt;br /&gt;
&lt;br /&gt;
jsEngine.eval(&quot;function test(val) { return val; }&quot;);&lt;br /&gt;
Invocable jsInvoke = (Invocable)jsEngine;&lt;br /&gt;
Object invoke = jsInvoke.invoke(&quot;test&quot;, new Object[] {111.0});&lt;br /&gt;
System.out.println(invoke); // prints 111.0&lt;br /&gt;
&lt;br /&gt;
Scripts may be used to implement arbitrary interfaces without direct dependence on the given interface. The following example illustrates definition of a run() method which is bound as the implementation of a Runnable interface at runtime based only on method signature. Below, the invoke() and run() calls invoke the same underlying scripted method. &lt;br /&gt;
&lt;br /&gt;
jsEngine.eval(&quot;function run() { print (&#39;running..&#39;); }&quot;);&lt;br /&gt;
Object invoke2 = jsInvoke.invoke(&quot;run&quot;,null); // prints running...&lt;br /&gt;
&lt;br /&gt;
Runnable r = jsInvoke.getInterface(Runnable.class);&lt;br /&gt;
r.run(); // prints running...</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/536391588634200036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/03/scripting-language-support-in-java-se-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/536391588634200036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/536391588634200036'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/03/scripting-language-support-in-java-se-6.html' title='Scripting Language Support in Java SE 6 (Mustang)'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1262191638215180659.post-4024957495016863317</id><published>2011-03-29T23:31:00.001+05:30</published><updated>2014-02-21T09:57:37.300+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Enhancements in Java SE 6 (Mustang)"/><category scheme="http://www.blogger.com/atom/ns#" term="Java versions and their features"/><title type='text'>Enhancements in Java SE 6 (Mustang)</title><content type='html'>Web Services (Improved Web Service support) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All developers get first-class support for writing XML web service client applications. No messing with the plumbing: You can expose your APIs as .NET interoperable web services with a simple annotation. Not your style? Want to handle the XML directly? Knock yourself out: Java SE 6 adds new parsing and XML to Java object-mapping APIs, previously only available in Java EE platform implementations or the Java Web Services Pack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scripting (Scripting Language Support) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can now mix in JavaScript technology source code, useful for prototyping. Also useful when you have teams with a variety of skill sets. More advanced developers can plug in their own scripting engines and mix their favourite scripting language in with Java code as they see fit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Database (JDBC 4.0 support) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For a great out-of-the-box development experience with database applications, the Java SE 6 development kit – though not the Java Runtime Environment (JRE) – co-bundles the all-Java JDBC database, Java DB based on Apache Derby. No more need to find and configure your own JDBC database when developing a database application! Developers will also get the updated JDBC 4.0, a well-used API with many important improvements, such as special support for XML as an SQL datatype and better integration of Binary Large OBjects (BLOBs) and Character Large OBjects (CLOBs) into the APIs. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More Desktop APIs&lt;br /&gt;
&lt;br /&gt;
GUI developers get a large number of new tricks to play like the ever popular yet newly incorporated SwingWorker utility to help you with threading in GUI apps, JTable sorting and filtering, and a new facility for quick splash screens to quiet impatient users. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Monitoring and Management&lt;br /&gt;
&lt;br /&gt;
The really big deal here is that you don&#39;t need do anything special to the startup to be able to attach on demand with any of the monitoring and management tools in the Java SE platform. Java SE 6 adds yet more diagnostic information, and we co-bundled the infamous memory-heap analysis tool Jhat for forensic explorations of those core dumps.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Compiler Access&lt;br /&gt;
&lt;br /&gt;
Really aimed at people who create tools for Java development and for frameworks like JavaServer Pages (JSP) or Personal Home Page construction kit (PHP) engines that need to generate a bunch of classes on demand, the compiler API opens up programmatic access to javac for in-process compilation of dynamically generated Java code. The compiler API is not directly intended for the everyday developer, but for those of you deafened by your screaming inner geek, roll up your sleeves and give it a try. And the rest of us will happily benefit from the tools and the improved Java frameworks that use this. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pluggable Annotations&lt;br /&gt;
&lt;br /&gt;
It is becoming a running joke in Java technology circles, at least some that contain us, that for every wished-for feature missing in Java technology, there&#39;s a budding annotation that will solve the problem. Joke no more, because Java tool and framework vendors can put a different smile on your face, defining their own annotations and have core support for plugging in and executing the processors that do the heavy lifting that can make custom annotations so cool. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Desktop Deployment&lt;br /&gt;
&lt;br /&gt;
Those of you deploying applications to the desktop will soon discover that it&#39;s a tale of a large number of smaller changes that add up to a big difference to existing applications: better platform look-and-feel in Swing technology, LCD text rendering, and snappier GUI performance overall. Java applications can integrate better with the native platform with things like new access to the platform&#39;s System Tray and Start menu. At long last, Java SE 6 unifies the Java Plug-in technology and Java WebStart engines, which just makes sense. Installation of the Java WebStart application got a much needed makeover. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security&lt;br /&gt;
&lt;br /&gt;
You can have all the security features you like in the platform — and this release adds a few more, like the XML-Digital Signature (XML-DSIG) APIs for creating and manipulating digital signatures — but if you don&#39;t have well supported security administrators, your security may be at risk. So Java SE 6 has simplified the job of its security administrators by providing various new ways to access platform-native security services, such as native Public Key Infrastructure (PKI) and cryptographic services on Microsoft Windows for secure authentication and communication, Java Generic Security Services (Java GSS) and Kerberos services for authentication, and access to LDAP servers for authenticating users. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Quality, Compatibility, Stability&lt;br /&gt;
&lt;br /&gt;
You probably knew that Sun has done regular feature releases of the Java SE platform over the last 10 years. So we certainly feel like we&#39;ve built up some expertise in this area, such as the ever growing 80,000 test cases and several million lines of code testing conformance (being just one aspect of our testing activity). You probably noticed that, unlike the last release, people have been downloading binary snapshots for the last 20 (not just 6) months. And what&#39;s more, they&#39;ve been filing bugs. So, before we even got to beta, we&#39;d fixed a number of quality and regression issues. Doesn&#39;t that add up to a better product? Oh, and by the way, performance is looking better than J2SE 5.0.</content><link rel='replies' type='application/atom+xml' href='http://purejava4all.blogspot.com/feeds/4024957495016863317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://purejava4all.blogspot.com/2011/03/enhancements-in-java-se-6-mustang.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4024957495016863317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1262191638215180659/posts/default/4024957495016863317'/><link rel='alternate' type='text/html' href='http://purejava4all.blogspot.com/2011/03/enhancements-in-java-se-6-mustang.html' title='Enhancements in Java SE 6 (Mustang)'/><author><name>Biswajit Roy</name><uri>http://www.blogger.com/profile/15590560323820492380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>