<?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: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-5599217793777408588</id><updated>2011-11-27T17:16:36.136-08:00</updated><category term='Secure Communication Using Java Security APIs'/><category term='Compare between EJB3.0 and EJB2.0'/><category term='Financial Cryptography and Information security in Financial Services'/><category term='J2EE Applications Performance Tuning Part 1'/><category term='Continuous Integration best practices'/><category term='Enterprise System Maintenance/Production Support'/><category term='Abstract Factory Pattern tutorial creating threads'/><category term='Hibernate over JDBC'/><category term='Enterprise Messaging Architecture Design'/><category term='Scheduling and thread pooling in Spring tutorial'/><category term='J2EE Application Performance Tuning Part 2'/><title type='text'>IT ecosystem</title><subtitle type='html'>Technologies and Global Trends</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-628866999205748712</id><published>2011-10-09T00:34:00.000-07:00</published><updated>2011-10-29T23:09:38.228-07:00</updated><title type='text'>IT Program Management, a Retrospective Analysis</title><content type='html'>The global IT workspace today is inundated with IT organizations who are delivering highly complex solutions to enterprise scale customers. The delivery of such solutions generally ends up in efforts which disseminates into several parallel projects. The key success factors for such solutions require much stronger governance and management infrastructure.&lt;br&gt;&lt;br /&gt;An IT program generally comprises of multiple projects running in parallel to deliver a solution. Hence there are much more complexities in managing programs then a project. The ramification of a program failure has a ripple effect on the client organization and also the solution provider as it ends up being a failure of multiple projects.&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Program Governance&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;An individual project governance structure generally consists of a project manager, a technical specialist capable of integrating technology with business philosophy and a business sponsor who is responsible for ensuring that the deliverables are in line with the business goals to be met.&lt;br&gt;&lt;br /&gt;A program governance structure on the contrary generally has a steering committee comprising of senior level personnel whose accountability and role is often decided by the board of directors, a program manager entrusted by the steering committee to guide the workforce and ensure that the program achieves its desired results. A set of project managers reporting to the program manager are responsible for managing individual parallel projects which form a part of the program.&lt;br&gt;&lt;br /&gt;In short program management generally requires a three to four layered management structure as compared to project management which generally requires a single or double layered management structure.&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Program’s success&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;The Role of PMO&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;The success of a program depends on the foundation of the technical and a comprehensive administrative infrastructure. The administrative infrastructure is provided in the form of a PMO. The PMO is responsible for resource loading, facilities management, expense monitoring with respect to allocated budget, KPI creation on program’s progress.&lt;br&gt; &lt;br /&gt;&lt;strong&gt;The Role of technical specialist/Architect&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;The technical infrastructure is provided by a technical specialist and his team overseeing and ensuring the creation of robust application architecture and Data centre operations. The success also depends on the selection of a methodologies and best practices in technical,administrative and business process areas.&lt;br&gt; &lt;br /&gt;&lt;strong&gt;The role of Methodologies and Best Practices&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;&lt;em&gt;Acheving Technical efficiency &amp; Sustainability&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;On the technical front The delivery of a quality software product requires focus on the application’s architecture, artifact design and delivery model. Careful selection and efficient use of industry standard methodologies and frameworks can bolster the stability of the technical infrastructure and ensure quality product delivery.Frameworks like TOGAF and Zacman provides a robust architectural foundation whereas development methodologies like CMMI for a waterfall approach and SCRUM, RUP, DSDM and Enterprise XP for an agile approach can streamline the development cycle and enable on-time delivery of quality software artifacts. System maintenance and upgrade can be streamlined by implementing service management methodologies like ITIL, which predominantly focuses on service desk management. &lt;br&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;&lt;em&gt;Achieving Business Process Excellence &lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;Streamlining of the business processes within the client organization is also required.Industry standards and best practices like Six Sigma can provide the necessary impetus in this regard.&lt;br&gt; &lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;&lt;em&gt;Achieving Governance Goals&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;Some restructuring of organization’s governance framework might also be required. This may well be an assimilation of bureaucratic and matrix structures.&lt;br&gt; &lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Continuous Monitoring&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;The project’s objectives can be met only by periodic audits and reviews to track progress with respect to delivery schedule, expenses incurred, payment milestones etc.&lt;br&gt;&lt;br /&gt; Strict controls are required from program management perspective to ensure that functional requirements are signed off by customer and an effective change control mechanism is put in place to reduce scope creep.&lt;br&gt;&lt;br /&gt;Program management metrics if prepared in adherence to the program’s objective can significantly help in measuring the current progress made and optimize the processes to fulfill the program’s objective.&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Building a Product roadmap&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;The program management should have a strategic focus on building a product roadmap. This will increase ROI.&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Conclusion&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;Hence as discussed above, efficient program management requires careful evaluation of the strategic goals of the program, a robust management infrastructure, a careful selection of matrices to measure progress and a vision to build a product roadmap.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-628866999205748712?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/628866999205748712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2011/10/it-program-management-retrospective.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/628866999205748712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/628866999205748712'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2011/10/it-program-management-retrospective.html' title='IT Program Management, a Retrospective Analysis'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-3389791666337369226</id><published>2010-02-03T08:43:00.000-08:00</published><updated>2010-02-03T09:20:21.708-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Financial Cryptography and Information security in Financial Services'/><title type='text'>Financial Cryptography and Information security in Financial Services</title><content type='html'>What is financial cryptography?&lt;br /&gt;&lt;br /&gt;Financial cryptography is the use of cryptography in dealing with financial transactions, it's foundation is based on the following key parameters that ensures successful and secure financial transactions: &lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;•   Secure communication architecture reliability&lt;br /&gt;•   Control on user access rights.&lt;br /&gt;•   Security product's Governance&lt;/strong&gt;&lt;/span&gt;  &lt;br /&gt;&lt;br /&gt; &lt;strong&gt;Financial Cryptographic zones in Internet Banking Applications&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;  Cryptography in financial institutions operates within cryptographic zones. For instance in an Internet banking application financial Cryptography will operate in the following zones.&lt;br /&gt;&lt;br /&gt;     - Account Holder's secure Login Zone (Login to bank's website)&lt;br /&gt;     - Bank's web server-to-application server communication and authentication zone&lt;br /&gt;     - Banks Application Server-to-Business domain layer communication zone&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Security Risks in internet-based financial/banking applications.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;br /&gt;    - Spoofed site.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    SSL proxies can create spoofed SSL sessions and intercept sensitive data like the user's credentials. In this scenario the web server's certificate invalidity will be reported by the browser but very few internet users will realize and acknowledge this certificate invalidity as a security risk. &lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;br /&gt;    - Vulnerability of data exiting SSL session communication channel.&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    Once the data comes out of an SSL session communication channel it is in unencrypted form and can be intercepted.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Financial Cryptography in Merchant Banking/Card payment systems&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In Merchant banking/card payment systems financial cryptography secures transaction cycle from the Merchant to the acquirer to the card issuer. It reduces the risks encurred by the Acquirer and card Issuer bank.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Financial Cryptography in ACH and global financial messaging services&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-3389791666337369226?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/3389791666337369226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2010/02/financial-cryptography-and-information.html#comment-form' title='34 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/3389791666337369226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/3389791666337369226'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2010/02/financial-cryptography-and-information.html' title='Financial Cryptography and Information security in Financial Services'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>34</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-854696249189126479</id><published>2009-11-17T04:38:00.000-08:00</published><updated>2009-11-24T06:24:49.432-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Secure Communication Using Java Security APIs'/><title type='text'>Secure Communication Using Java Security APIs</title><content type='html'>&lt;p&gt;&lt;font size="4"&gt;What is secure Communication ?&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;Secure communication between two business entities must ensure the following :&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;strong&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Data Integrity&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Confidentiality&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Authentication&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Non-repudiation&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;strong&gt;Data Integrity&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When information is sent by one business entity to another, the communication framework must ensure that the data has not been tampered with or altered in any way. &lt;br /&gt;&lt;br /&gt;This is achieved by creating a message digest i.e. a hash based on the data and sending it to the recipient along with the data.(see authentication section below for more details).&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;strong&gt;Confidentiality&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Only the intended recipient of the information should be able to read and understand the information. Confidentiality is achieved by using Cryptography techniques i.e. converting the plain text into encrypted cipher text using key-based symmetric or asymmetric encryption algorithms.&lt;br /&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;Symmetric Algorithm&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;Symmetric algorithm uses the same key for encryption and decryption, the key is referred to as secret key. Some of the popular symmetric algorithms are DES and triple DES and IDEA.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;Merits&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;br /&gt;&lt;li&gt;Symmetric algorithm is faster than asymmetric algorithm.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Hardware implementation is possible, which can result in very high-speed data encryption.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;De-merits&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;br /&gt;&lt;li&gt;Problem of both parties mutually agreeing on a key.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Preserving the secrecy of the key can also pose challenges, as the same key must be known to more than one person i.e. both the sender and the receiver. So, failure in being able to preserve the secrecy of the key on any one side will result in a complete breakdown of the security infrastructure.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;Asymmetric algorithm&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;There are two keys involved in this. A public key and a private key forming a keypair. Data encrypted by public key from a keypair can be decrypted using the private key and vice-versa.&lt;br /&gt;&lt;br /&gt;The public key of the recipient is known to the sender and is used to encrypt the information. The recipient then uses his private key to decrypt the message.It is to be noted here that the recipient's private key is not shared with anyone else.&lt;br /&gt;Popular asymmetric algorithms are DSA and RSA.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;Merits&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;br /&gt;&lt;li&gt;No bottleneck of mutual agreement by both parties on a single key.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The security infrastructure is dependent on two keypairs i.e. four separate keys and not just one secret key, making the setup more robust.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="margin-left:20px;"&gt;&lt;strong&gt;De-Merits&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;li&gt;Asymmetric encryption, decryption using keypairs is a slow process and if large amounts of data is involved, it can be time consuming and require a lot of system resources.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There should be some form of proof to ensure that the information received has the stamp of approval from the intended sender. This is achieved by a digital signature from the sender.&lt;br /&gt;&lt;br /&gt;A digital signature is an encrypted message digest i.e. an encrypted hash.&lt;br /&gt;&lt;br /&gt;A message digest is a hash generated using hashing algorithms like MD5 or SHA-1. These algorithms accept input data and generates a hash based on that data. MD5 produces a 128-bit hash whereas SHA-1 produces a 160-bit hash. &lt;br /&gt;&lt;br /&gt;A digital signature of the sender is created by :&lt;br /&gt;&lt;ul style="margin-left:20px"&gt;&lt;br /&gt;&lt;li&gt;Generating a message digest as explained above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Then encrypting the message digest using the sender's private key.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;How does the digital signature fulfil the authentication requirements ?&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The encryption of the hash using the sender's private key provides the stamp of approval from the sender because the private key should only be known to the sender, as per the principles of the asymmetric algorithm security setup. This fulfils authentication requirement. &lt;br /&gt;&lt;br /&gt;The hash itself fulfils the data integrity requirement. &lt;br /&gt;&lt;br /&gt;The recipient needs to first:&lt;br /&gt;&lt;ul style="margin-left:20px"&gt;&lt;br /&gt;&lt;li&gt;Decrypt the encrypted hash.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Then regenerate a hash based on the information received from sender.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Compare the newly generated hash with the one received as part of the digital signature. If both match then the data has reached the recipient unaltered/untampered.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;strong&gt;Non-Repudiation&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There should also be a means to vouch for the fact that the information and digital signature has come from the original sender and not from someone else, fraudulently using the sender's identity. &lt;br /&gt;&lt;br /&gt;This can be confirmed by a digital certificate issued by a trusted third party i.e. a certificate Authority (CA). &lt;br /&gt;&lt;br /&gt;&lt;em&gt;How to obtain a digital certificate ?&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;In order to get a digital certificate a sender needs to :&lt;br /&gt;&lt;ul style="margin-left:20px"&gt;&lt;br /&gt;&lt;li&gt;Generate a keypair.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Then send the public key along with some proof of identification to a certificate authority. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;If the CA is satisfied with the proof of identification supplied, a certificate is issued by the CA by signing the sender's public key with the private key of  CA.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;This certificate is often referred to as X.509 certificate. &lt;br /&gt;&lt;br /&gt;&lt;em&gt;What is certificate Chaining ?&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;If just one certificate authority cannot provide the required trust, then one can use certificate chaining i.e. one CA vouching for another&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;p color="#3333FF"&gt;&lt;font size="4"&gt;-: Java Security APIs for secure communication&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;There are four main API’s for security in Java:&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Java Cryptography Architecture (JCA)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Java Cryptography Extensions (JCE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Java Secure Socket Extensions (JSSE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Java Authentication and Authorization Services (JAAS)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;Java Cryptography Architecture (JCA)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java Cryptography Architecture (JCA) encapsulates the overall architecture of Java’s cryptography concepts and algorithms.JCA includes both &lt;strong&gt;java.security &lt;/strong&gt;and &lt;strong&gt;javax.crypto &lt;/strong&gt;packages.&lt;br /&gt;&lt;br /&gt;Some of the engine classes used by JCA to provide cryptographic concepts are as follows:&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- MessageDigest&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Signature&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- KeyFactory&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- KeyPairGenerator&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Cipher&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;Java Cryptography Extensions (JCE)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Java Cryptography Extensions (JCE) provides software implementations that enables developers to encrypt data, create message digests and perform key management activities.&lt;br /&gt;&lt;br /&gt;The JCE APIs cover the following implementations:&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Symmetric bulk encryption, such as DES, RC2, and IDEA&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Asymmetric encryption, such as RSA&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Password-based encryption (PBE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Key generation and key agreement&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Message Authentication Codes (MAC)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;Java Secure Socket Extensions (JSSE)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java Secure Socket Extensions (JSSE) provides application developers a framework and an implementation for SSL and TLS transport layer protocols. This enables secure data transmission between application client and server via a HTTP or FTP request.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333FF;"&gt;Java Authentication and Authorization Services (JAAS)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java Authentication and Authorization Service enables developers to setup client restrictions and access control to application's functionality.&lt;br /&gt;&lt;br /&gt;This is generally provided by the policies and permissions setup and controlled by the Java SandBox and JVM.&lt;br /&gt;&lt;br /&gt;The JAAS-related classes and interfaces are as follows:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;-: Common classes :-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Subject&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Principal&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Credential&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;-: Authentication classes and interfaces :-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- LoginContext&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- LoginModule&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- CallbackHandler&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Callback&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;-: Authorization classes :-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Policy&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- AuthPermission&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- PrivateCredentialPermission.&lt;br /&gt;&lt;br /&gt;All of them belong to either the &lt;strong&gt;Java.Security &lt;/strong&gt;or &lt;strong&gt;java.Security.auth &lt;/strong&gt;packages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-854696249189126479?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/854696249189126479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/11/secure-communication-using-java.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/854696249189126479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/854696249189126479'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/11/secure-communication-using-java.html' title='Secure Communication Using Java Security APIs'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-7065724841684628158</id><published>2009-09-08T03:46:00.000-07:00</published><updated>2009-11-10T04:54:24.300-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='J2EE Application Performance Tuning Part 2'/><title type='text'>J2EE Application Performance Tuning Part 2</title><content type='html'>&lt;p align="center"&gt;&lt;font size="4"&gt;-: Caching objects in Hibernate to improve performance in J2EE Applications :-&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;What is caching?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The general concept of caching is that when an object is first read from an external storage, a copy of it will be stored in an area referred to as cache.For subsequent readings the object can be retrieved from the cache directly, which is faster than retrieving it from external storage. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Levels of caching in Hibernate&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;As a high performance O/R mapping framework, Hibernate supports the caching of persistent objects at different levels.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;-&lt;&lt;&lt;/strong&gt; First Level caching &lt;strong&gt;&gt;&gt;-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In hibernate by default objects are cached with session scope. This kind of caching is called “first level caching”. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;-&lt;&lt;&lt;/strong&gt; Second Level Caching &lt;strong&gt;&gt;&gt;-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;First level caching doesn't help when the same object needs to be read across different sessions. In order to enable this one needs to turn on "second level caching" in hibernate i.e. setting up objects caches that are accessable across multiple sessions. &lt;br /&gt;Second level caching can be done on class associations on collections and on database query statements.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Caching frameworks for non-distributed and distributed J2EE application environments.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Hibernate supports many caching frameworks like EHCache, OSCache, SwarmCache, JBossCache and Terracota.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In a non-distrinuted environment EHCache framework is a good choice, it is also the default cache provider for hibernate.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;In a distributed environment a good choice would be Terracota, which is a highly powerful open source framework that supports distributed caching and provides network attached memory.&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;font size="4"&gt;-: Identifying and dealing with memory leaks :- &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;Memory leaks can occur due to:&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Logical flaws in the code.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- System's architecture setup.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Application server's incompatibility with third party products.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In a large enterprise scale application it is not always easy to identify memory leaks, so under certain circumstances one will need to run the application inside a memory profiler to identify memory leaks. &lt;span style="color:#6666cc;"&gt;"JProfiler"&lt;/span&gt; is one that is quite popular.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some memory leak scenarios caused be erroneous code are as follows:&lt;/span&gt;&lt;ul style="margin-left:20px;"&gt;&lt;br /&gt;&lt;li&gt;ResultSet and Statement objects created using pooled connections. When the connection is closed it just returns to the connection pool ut doesn't close the ResultSet or Statement objects.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Collection elements not removed after use in the application.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#6666cc;"&gt;Incorrect scoping of variables&lt;/span&gt; i.e. if a variable is needed only in a method but is declared as member variable of a class, then its lifetime is unnecessarily is extended to that of the class, which will hold up memory or a longer time period.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;strong&gt;some simple memory leak examples to follow: &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example 1.&lt;/strong&gt; Memory leak caused by &lt;em&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;** collection elements not removed &amp; incorrect scoping of variables **.&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;// The following code throws:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;java.lang.OutOfMemoryError: Java heap space ".&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;// This is because method &lt;strong&gt;MemoryLeakingMethod(HashMap&lt;Integer,Employees&gt; emps)&lt;/strong&gt;&lt;br /&gt;// is invoked with a class variable as method parameter.&lt;br /&gt;// so the memory used by it cannot be reclaimed by garbage&lt;br /&gt;// collector between method executions unless, it is&lt;br /&gt;// nullified or collection elements removed.&lt;br /&gt;// multiple calls to the method with different variables&lt;br /&gt;// will fill up the java heap space.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;so, &lt;br /&gt;         public class MemoryLeakClass {&lt;br /&gt;         &lt;br /&gt;         private HashMap&lt;Integer, Employees&gt; emp01,emp02,emp03...;&lt;br /&gt;         ..........&lt;br /&gt;         public static void main(String[] args) {&lt;br /&gt;               &lt;br /&gt;                MemoryLeakClass m = new MemoryLeakClass();&lt;br /&gt;     &lt;span style="color:#6666cc;"&gt;m.MemoryLeakingMethod(&lt;strong&gt;m.emp01&lt;/strong&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                try{   &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.currentThread().sleep(10000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.gc(); &amp;nbsp; &lt;span style="color:#6666cc;"&gt;// trying to reclaim memory used by m.emp01 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // but, not possible because &lt;strong&gt;m.emp01 &lt;/strong&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // is a class variable with instance scope&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // and maintains strong reference.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // However, memory will be &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // reclaimed if WeakHashMap used &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // instead of HashMap&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    }catch(InterruptedException e){e.printStackTrace();}&lt;br /&gt;&lt;br /&gt;                &lt;span style="color:#6666cc;"&gt;m.MemoryLeakingMethod(&lt;strong&gt;m.emp02&lt;/strong&gt;);&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#6666cc;"&gt;m.MemoryLeakingMethod(&lt;strong&gt;m.emp03&lt;/strong&gt;);&lt;/span&gt;&lt;br /&gt;                ...........multiple executions..&lt;br /&gt;               &lt;span style="color:#FF0000"&gt;java.lang.OutOfMemoryError: Java heap space&lt;/span&gt;&lt;br /&gt;                &lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -: Method: MemoryLeakingMethod(HashMap&lt;Integer,Employees&gt; emps)  :-&lt;br /&gt;  &lt;br /&gt;         public void MemoryLeakingMethod(HashMap&lt;Integer,Employees&gt; emps){&lt;br /&gt;  &lt;br /&gt;                // The HashMap 'emps' passed to this method is a class variable. &lt;br /&gt;  &lt;br /&gt;  System.out.println("*** Memory leaking method ***"+" Run: "+run++);&lt;br /&gt;        &lt;br /&gt;  try { &lt;br /&gt;   &lt;br /&gt;      for(int i=0;i&lt;100000;i++){&lt;br /&gt;       emp = new Employees();&lt;br /&gt;&lt;br /&gt;                        // populating 'Employees' object.&lt;br /&gt;&lt;br /&gt;       emp.setName(rs.getString("name"));&lt;br /&gt;       emp.setMeritalStatus(rs.getString("meritalStatus"));&lt;br /&gt;                        ...........&lt;br /&gt;&lt;br /&gt;                        // adding Employees object to HashMap class variable 'emps'&lt;br /&gt;&lt;br /&gt;       emps.put(new Integer(i), emp);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;  }catch(SQLException e){e.printStackTrace();} &lt;br /&gt;   catch (java.text.ParseException e) {&lt;br /&gt;   // TODO Auto-generated catch block&lt;br /&gt;   e.printStackTrace();&lt;br /&gt;  } &lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; *** &lt;&lt; If the variable scoping cannot be changed then using a WeakHashMap instead of a HashMap can solve this problem.This is because a weakReference gets freed aggressively by the garbage collector. So the garbage collection code in the main method mentioned above will reclaim the memory between method executions.&gt;&gt; ***&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;The following change to the above code will prevent an OutOfMemoryError:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Change:&lt;/strong&gt; private HashMap&lt;Integer, Employees&gt; emp01,emp02,emp03...;&lt;br /&gt;&lt;strong&gt;with  :&lt;/strong&gt; private WeakHashMap&lt;Integer, Employees&gt; emp01,emp02,emp03...;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="center" color=":#6666cc"&gt;&lt;font size="4"&gt;-: WeakHashMap vs HashMap :-&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;A WeakHashMap is identical to a HashMap in terms of it's functionality, except that the entries in it do not maintain a strong references against it's keys, so the garbage collector may remove the keys from the WeakHashMap and subsequently garbage collect the object. In other works the WeakHashMap behaves like a weakly referenced object.&lt;br /&gt;&lt;br /&gt;&lt;p align="center" color=":#6666cc"&gt;&lt;font size="4"&gt;-: Serializable vs Externalizable :-&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;Serialization can be a slow process if you have a large object graph and if the classes in the object graph contain large number of variables. The serializable interface by default will serialize the state of all the classes forming the object graph.&lt;br /&gt;&lt;br /&gt;Sometimes it may not be a requirement to serialize the state of all the classes/superclasses in the object graph. This can normally be done by declaring the unwanted class variables as &lt;strong&gt;transient&lt;/strong&gt;. But what if this needs to be decided at runtime? The solution is to replace the serializable implementation with externalizable. &lt;br /&gt;&lt;br /&gt;The externalizable interface provides full control to the class implementing it on which states to maintain and which ones to discard and this can be done conditionally at run-time using the two methods &lt;strong&gt;readExternal&lt;/strong&gt; and &lt;strong&gt;writeExternal&lt;/strong&gt;. This complete control over marshalling and unmarshalling at run-time can result in being able to achieve improved application performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;***&lt;/strong&gt; A note of caution though.. The methods readExternal and writeExternal are public methods so one has to look at the security aspects of the code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-7065724841684628158?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/7065724841684628158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/09/j2ee-application-performance-tuning.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/7065724841684628158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/7065724841684628158'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/09/j2ee-application-performance-tuning.html' title='J2EE Application Performance Tuning Part 2'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-85490040380338526</id><published>2009-08-10T09:51:00.000-07:00</published><updated>2009-11-17T04:38:29.966-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='J2EE Applications Performance Tuning Part 1'/><title type='text'>J2EE Applications Performance Tuning Part 1</title><content type='html'>When it comes to enterprise scale Java applications there maybe severe performance degradations due to software architecture design flaws and application Infrastructure setup.&lt;br /&gt;&lt;br /&gt;The performance degradation can occur due to faulty code causing:&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Memory Leaks&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Inefficient thread pooling and connection pooling.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Leaky Sessions&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Absence of optimised caching mechanism&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Improper use of synchronization &amp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Collections framework  implementation classes in code.&lt;HR&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Memory leaks&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Memory leaks occur when faulty application code results in lingering reference being maintained of unused/unwanted objects even after process completion. Thus preventing the garbage collector from re-claiming the memory occupied by these unwanted objects. This will result in more and more leaked objects filling up the heap (especially the tenured space in the heap) and cause severe performance degradation of the application and may finally result in an OutOfMemoryError, if the JVM is unable to allocate enough memory for a new instance of an object in the heap.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;u&gt;&lt;em&gt;&lt;strong&gt;-:Possible Solutions:- &lt;/strong&gt;&lt;/em&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;1.&lt;/strong&gt;&lt;/span&gt; Inspect the growth pattern of the Heap to identify trends.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;2.&lt;/strong&gt;&lt;/span&gt; Start the application inside a memory profiler. Execute a request take a snapshot of the heap. Then re-execute the request and again take a snapshot of the heap. compare the two snapshots and try and identify live objects which belong to the older request and should not appear in the results of the second execution. You may need to re-run the request a number of times before being able to identify leaked objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;3.&lt;/strong&gt;&lt;/span&gt; A temporary solution to the problem may be an  application server re-start. However solutions 1,2 mentioned above can be used to identify objects causing memory leaks and the application refactored to resolve the issue permanently.&lt;HR&gt;  &lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Inefficient thread pooling and database connection pooling configurations&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Improper sizing of the thread execution pool in an application server may result in severe performance degradation. This is because the thread pool size determines the number of simultaneous requests that can be processed at one time by the application server. If the pool size is too small, then this will result in a large number of requests waiting in the queue to be picked up. Alternatively if the pool size is too large, then a lot of time will be wasted due to context switching between threads.&lt;br /&gt;&lt;br /&gt;Improper sizing of database connection pooling e.g. JDBC connection pooling can also result in severe performance degradation. This is because if the pool size is too small then a large number of requests will have to wait due to unavailability of database connection. Alternatively if the connection pool is too large, then a lot of application server resources will be wasted in maintaining a large number of connections and there will be a excessive load on the database as well, resulting in poor database performance.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;u&gt;&lt;em&gt;&lt;strong&gt;-:Possible Solutions:- &lt;/strong&gt;&lt;/em&gt;&lt;/u&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;1.&lt;/strong&gt;&lt;/span&gt;Analyze CPU usage vs Thread pool usage percentage. &lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;li&gt;If CPU usage is low but thread pool usage is high, this is an indication that the thread pool is too small and optimum system resources not being utilized by the application. Hence the pool size should be increased proportionately.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;If CPU usage is high but thread pool usage is low, this is an indication that the thread pool is too large and lot of resources are being used for context switching between threads. Hence the pool size should be reduced proportionately.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;2.&lt;/strong&gt;&lt;/span&gt;Analyze CPU usage vs JDBC connection pool usage percentage.&lt;br /&gt;&lt;ul style="margin-left:20px;"&gt;&lt;li&gt;Low CPU usage but high JDBC connection pool utilization indicates connection pool is too small resulting in database and CPU resources being under utilized.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;High CPU usage but low JDBC connection pool utilization indicates connection pool is too large and needs to be reduced in size.&lt;/li&gt;&lt;/ul&gt;&lt;HR&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Leaky Sessions&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;A leaky session does not leak anything, it actually consumes memory that belongs to session objects causing memory leak. This memory is eventually reclaimed when the session times out. These kind of sessions can also result in an application's performance degradation due to high memory consumption and can even result in OutOfMemoryError and application server crash if they happen to get created in large numbers.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;u&gt;&lt;em&gt;&lt;strong&gt;-:Possible Solutions:- &lt;/strong&gt;&lt;/em&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;1.&lt;/span&gt;&lt;/strong&gt;Increase the Heap size to accomodate the sessions causing memory problems.&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;2.&lt;/span&gt;&lt;/strong&gt; Encourage application users to logoff when not using the application, in order to reduce the number of active sessions.&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;3.&lt;/span&gt;&lt;/strong&gt; Decrease the session timeout interval if possible so that the session expires within a shorter time window which can reduce the number of active sessions at any given time resulting in less memory usage.  &lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;strong&gt;4.&lt;/span&gt;&lt;/strong&gt; Refactor the application if possible to reduce the information held by session scoped variables.&lt;br /&gt;&lt;br /&gt;&lt;HR&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Absence of optimised caching mechanism&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;An absence of optimised caching mechanism can also result in poor application performance.If an enterprise scale application does not have a in-memory distributed caching mechanism, then the scalability of the application will be severely affected and over a period of time with increasing transactional load on the system will result in deteriotating system performance. Cache clusters with in-memory distributed caching mechanism can prevent this from happening.&lt;br /&gt;&lt;br /&gt;Frameworks like Ehcache or Terracota allows distributed caching.&lt;br /&gt;&lt;br /&gt;They allow:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Both memory and disk cache storage.&lt;/li&gt;&lt;br /&gt;&lt;li&gt; Provide APIs for caching Hibernate,JMS, SOAP/REST web service objects.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Enables efficient cache handling using cacheManagers, cache listeners, cache loaders, cache exception handlers etc.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;HR&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Improper use of Synchronization &amp; Collections framework implementation classes in code.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A J2EE application's performance can be severely affected due to improper use of synchronization and inefficient use of the implementation classes of java collections framework.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Large synchronized blocks in code can slow down application performance due to lengthy locking periods.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Try and avoid using Vectors and HashTables wherever possible and replace them with ArrayList and HashMaps.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-85490040380338526?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/85490040380338526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/08/performance-tuning-in-j2ee-applications.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/85490040380338526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/85490040380338526'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/08/performance-tuning-in-j2ee-applications.html' title='J2EE Applications Performance Tuning Part 1'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-8589599514032794133</id><published>2009-07-01T06:25:00.000-07:00</published><updated>2009-07-13T02:16:27.802-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Messaging Architecture Design'/><title type='text'>Enterprise Messaging Architecture Design using JMS</title><content type='html'>When it comes to choosing a messaging solution, one must ensure that the messaging architecture is:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Robust&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Scalable&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Supports both point-to-point and publish-subscribe models.&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Efficiently handles high volume of asynchronous requests.&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Allows seamless integration with a SOA framework.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An enterprise messaging architecture that caters for the above can be designed using the following core J2EE design patterns:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Message Broker&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Service Activator &lt;br /&gt;&amp;nbsp;&amp;nbsp;- Service To Worker&lt;br /&gt;&amp;nbsp;&amp;nbsp;- Web Service endpoint Proxy&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;Sample Code below using &lt;strong&gt;Message Broker, Service Activator and Service To Worker &lt;/strong&gt; J2EE core design patterns:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;-- JMSMessageBroker interface&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;import javax.jms.JMSException;&lt;br /&gt;import javax.naming.NamingException;&lt;br /&gt;&lt;br /&gt;public interface JMSMessageBroker {&lt;br /&gt;&lt;br /&gt;  void sendTextMessageToQueue(String msg) throws NamingException, JMSException;&lt;br /&gt;  void sendObjectMessageToQueue(Serializable msg) throws JMSException, NamingException;&lt;br /&gt;  void receiveFromQueue();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSMessageBrokerImpl class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;import javax.jms.JMSException;&lt;br /&gt;import javax.jms.Message;&lt;br /&gt;import javax.jms.MessageConsumer;&lt;br /&gt;import javax.jms.MessageProducer;&lt;br /&gt;import javax.jms.ObjectMessage;&lt;br /&gt;import javax.jms.Queue;&lt;br /&gt;import javax.jms.QueueConnection;&lt;br /&gt;import javax.jms.QueueConnectionFactory;&lt;br /&gt;import javax.jms.QueueSession;&lt;br /&gt;import javax.jms.Session;&lt;br /&gt;import javax.jms.TextMessage;&lt;br /&gt;import javax.naming.NamingException;&lt;br /&gt;&lt;br /&gt;public class JMSMessageBrokerImpl implements JMSMessageBroker {&lt;br /&gt;&lt;br /&gt; private QueueConnectionFactory connectionFactory;&lt;br /&gt; private JMSServiceLocator jmsServiceLocator;&lt;br /&gt; private Queue queue;&lt;br /&gt; private QueueConnection queueConnection;&lt;br /&gt; private QueueSession queueSession;&lt;br /&gt; private MessageProducer messageProducer;&lt;br /&gt; private TextMessage textMessage;&lt;br /&gt; private ObjectMessage objectMessage;&lt;br /&gt; private MessageConsumer messageConsumer;&lt;br /&gt; private Message mesg;&lt;br /&gt;    private String text;&lt;br /&gt;    private Object obj;&lt;br /&gt;    &lt;br /&gt; public void receiveFromQueue() {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  &lt;br /&gt;  try {&lt;br /&gt;   &lt;br /&gt;     connectionFactory = (QueueConnectionFactory) jmsServiceLocator.getQueueConnectionFactory();&lt;br /&gt;              queueConnection = connectionFactory.createQueueConnection();&lt;br /&gt;     queue = jmsServiceLocator.getQueue();&lt;br /&gt;     queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;              messageConsumer = queueSession.createConsumer(queue);&lt;br /&gt;     mesg = (TextMessage)messageConsumer.receive();&lt;br /&gt;     &lt;br /&gt;     if(mesg instanceof TextMessage){&lt;br /&gt;      &lt;br /&gt;      text = ((TextMessage)mesg).getText();&lt;br /&gt;     }&lt;br /&gt;     else if(mesg instanceof ObjectMessage){&lt;br /&gt;      &lt;br /&gt;      obj = ((ObjectMessage)mesg).getObject();&lt;br /&gt;     }&lt;br /&gt;  }catch(NamingException e){e.printStackTrace();}&lt;br /&gt;   catch(JMSException e1){e1.printStackTrace();}&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void sendObjectMessageToQueue(Serializable msg) throws JMSException, NamingException {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  &lt;br /&gt;  connectionFactory = (QueueConnectionFactory) jmsServiceLocator.getQueueConnectionFactory();&lt;br /&gt;  queueConnection = connectionFactory.createQueueConnection();&lt;br /&gt;  queue = jmsServiceLocator.getQueue();&lt;br /&gt;  queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;  messageProducer = queueSession.createProducer(queue);&lt;br /&gt;  &lt;br /&gt;  objectMessage = queueSession.createObjectMessage(msg);&lt;br /&gt;  messageProducer.send(objectMessage);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void sendTextMessageToQueue(String msg) throws NamingException, JMSException {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;   &lt;br /&gt;   connectionFactory = (QueueConnectionFactory) jmsServiceLocator.getQueueConnectionFactory();&lt;br /&gt;   queueConnection = connectionFactory.createQueueConnection();&lt;br /&gt;   queue = jmsServiceLocator.getQueue();&lt;br /&gt;   queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;   messageProducer = queueSession.createProducer(queue);&lt;br /&gt;   &lt;br /&gt;   textMessage = queueSession.createTextMessage(msg);&lt;br /&gt;   messageProducer.send(textMessage);   &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSTaskManager interface&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public interface JMSTaskManager {&lt;br /&gt;&lt;br /&gt; void processRequest() throws InterruptedException;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSTaskManagerImpl class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;public class JMSTaskManagerImpl implements JMSTaskManager, Serializable {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; private JMSCommandProcessorImpl jmsCommandProcessor;&lt;br /&gt; private Object businessService;&lt;br /&gt; private String action;&lt;br /&gt; private Object[] arguments;&lt;br /&gt;&lt;br /&gt; public JMSTaskManagerImpl(Object businessService, String action,&lt;br /&gt;   Object[] arguments) {&lt;br /&gt;  // TODO Auto-generated constructor stub&lt;br /&gt;  this.businessService = businessService;&lt;br /&gt;  this.action          = action;&lt;br /&gt;  this.arguments       = arguments;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void processRequest() throws InterruptedException {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;&lt;br /&gt;  jmsCommandProcessor = new JMSCommandProcessorImpl();&lt;br /&gt;  jmsCommandProcessor.processRequest(businessService,action,arguments);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSCommandProcessor interface&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public interface JMSCommandProcessor {&lt;br /&gt;&lt;br /&gt; void processRequest(Object businessService, String action, Object[] arguments) throws InterruptedException;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSCommandProcessorImpl class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;import java.lang.reflect.InvocationTargetException;&lt;br /&gt;import java.lang.reflect.Method;&lt;br /&gt;import java.util.Date;&lt;br /&gt;&lt;br /&gt;public class JMSCommandProcessorImpl implements JMSCommandProcessor,Serializable {&lt;br /&gt;&lt;br /&gt; private static int seqno;&lt;br /&gt; private Command command;&lt;br /&gt; &lt;br /&gt; public JMSCommandProcessorImpl() {&lt;br /&gt;  // TODO Auto-generated constructor stub&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void processRequest(Object businessService, String action, Object[] arguments) throws InterruptedException {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;&lt;br /&gt;  command = new Command(businessService,action,arguments);&lt;br /&gt;  Thread task = new Thread(command);&lt;br /&gt;  task.setName(businessService.getClass().getName()+seqno++);&lt;br /&gt;  task.start();&lt;br /&gt;&lt;br /&gt;  synchronized(task){&lt;br /&gt;   task.wait();&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; class Command implements Runnable {&lt;br /&gt;  &lt;br /&gt;  private Object businessService;&lt;br /&gt;  private String action;&lt;br /&gt;  private Method[] methods;&lt;br /&gt;  private Method method;&lt;br /&gt;  private Object[] arguments;&lt;br /&gt;  &lt;br /&gt;  Command(Object businessService,String action,Object[] arguments){&lt;br /&gt;   this.businessService = businessService;&lt;br /&gt;   this.action = action;&lt;br /&gt;   this.arguments = arguments;&lt;br /&gt;  }&lt;br /&gt;  public void run() {&lt;br /&gt;   &lt;br /&gt;   try {&lt;br /&gt;    &lt;br /&gt;     Class cls = this.businessService.getClass();&lt;br /&gt;     Object service = cls.newInstance();  &lt;br /&gt;     methods = cls.getMethods();&lt;br /&gt;     &lt;br /&gt;     for(Method method : methods){&lt;br /&gt;      this.method = method;&lt;br /&gt;      if(action.equals(method.getName())){&lt;br /&gt;       break;&lt;br /&gt;      }&lt;br /&gt;      &lt;br /&gt;     }&lt;br /&gt;     synchronized(this){&lt;br /&gt;         method.invoke(service, arguments);&lt;br /&gt;         notify();&lt;br /&gt;     }&lt;br /&gt;     &lt;br /&gt;   }catch(InstantiationException e){e.printStackTrace();}&lt;br /&gt;    catch(IllegalAccessException e1){e1.printStackTrace();}&lt;br /&gt;    catch(InvocationTargetException e3){e3.printStackTrace();}&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;--JMSMessageListener class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;import javax.jms.JMSException;&lt;br /&gt;import javax.jms.Message;&lt;br /&gt;import javax.jms.MessageListener;&lt;br /&gt;import javax.jms.ObjectMessage;&lt;br /&gt;&lt;br /&gt;import com.mockrunner.mock.jms.MockObjectMessage;&lt;br /&gt;&lt;br /&gt;public class JMSMessageListener implements MessageListener {&lt;br /&gt;&lt;br /&gt; private Serializable JmsTaskManager;&lt;br /&gt;&lt;br /&gt; public void onMessage(Message msg) {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  &lt;br /&gt;  if(msg instanceof ObjectMessage){&lt;br /&gt;  &lt;br /&gt;   try {&lt;br /&gt;  &lt;br /&gt;         msg.acknowledge();&lt;br /&gt;         JmsTaskManager = ((ObjectMessage)msg).getObject();&lt;br /&gt;         ((JMSTaskManager)JmsTaskManager).processRequest();&lt;br /&gt;         &lt;br /&gt;   }catch(JMSException e){e.printStackTrace();}&lt;br /&gt;    catch(InterruptedException e1){e1.printStackTrace();}&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-8589599514032794133?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/8589599514032794133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/07/enterprise-messaging-architecture.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/8589599514032794133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/8589599514032794133'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/07/enterprise-messaging-architecture.html' title='Enterprise Messaging Architecture Design using JMS'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-2951234300986429533</id><published>2009-05-21T03:55:00.000-07:00</published><updated>2009-05-21T06:39:32.061-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Continuous Integration best practices'/><title type='text'>Continuous Integration best practices</title><content type='html'>Continuous integration is a practice, which if incorporated in the software development life cycle results in increased ability to spot errors before they are introduced into the system. &lt;br /&gt;&lt;br /&gt;This development practice greatly reduces regression bugs in the system and is an inherent part of agile software development methodologies like XP and SCRUM.&lt;br /&gt;&lt;br /&gt;Continuous Integration best practices are as follows:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1.&lt;/strong&gt; When the developer commits the code in a version control system like, say for e.g. CVS. A new build should start automatically.&lt;br /&gt;&lt;strong&gt;2.&lt;/strong&gt; If the build is successful, automated tests should run without any manual intervention.&lt;br /&gt;&lt;strong&gt;3. &lt;/strong&gt;If the tests are successful, the integration cycle ends or else checkout the code that has broken the build and fix it.&lt;br /&gt;&lt;br /&gt;Continuous integration can be implemented using the following products:&lt;br /&gt;&lt;br /&gt;- CruiseControl&lt;br /&gt;- Hudson&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-2951234300986429533?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/2951234300986429533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/05/continuous-integration-best-practices.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/2951234300986429533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/2951234300986429533'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/05/continuous-integration-best-practices.html' title='Continuous Integration best practices'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-9149202948179863370</id><published>2009-05-18T07:52:00.000-07:00</published><updated>2009-05-18T10:33:30.170-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise System Maintenance/Production Support'/><title type='text'>Enterprise System Maintenance/Production Support</title><content type='html'>&lt;strong&gt;Enterprise System maintenance and production support, Challenges and possible solutions&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Enterprise systems generally have a tiered architecture comprising of the following tiers:&lt;br /&gt;&lt;br /&gt;- &amp;nbsp;&amp;nbsp; A presentation layer of (e.g. HTML,JSPs)&lt;br /&gt;- &amp;nbsp;&amp;nbsp; A Service Layer (e.g. JMS message brokers and web service brokers)&lt;br /&gt;- &amp;nbsp;&amp;nbsp; A Business Domain Layer of (e.g. java,C++)&lt;br /&gt;- &amp;nbsp;&amp;nbsp; A Persistence Layer of (e.g. RDBMS like Oracle,Sybase etc)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&lt;strong&gt;Challenges &amp; Solutions&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Requirement of Multi-skilled support personnel&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Support personnel must be familiar with multiple software platforms, multiple programming languages various architectural frameworks and tools of the trade. It is not always easy to get the right person for the job.&lt;br /&gt;&lt;br /&gt;Possible solutions can be in the form of : &lt;br /&gt;&lt;br /&gt;a) Using a cross-functional team, although I think this is only a temporary solution and can create nightmares to fulfil SLA requirements.&lt;br /&gt;b) Continuous periodic skill upgrade programmes. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Complexity and cost of setting up test environments to mimic production.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;It is difficult and not cost effective to provide test environments that can mimic the production setup. This sometimes makes it difficult to replicate production bugs due to differences in configuration and hardware capabilities.&lt;br /&gt;&lt;br /&gt;Possible solution can be a phased approach to investigation and also breaking up the possible fix and applying it in a phased manner.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Immergence of agile methodologies, a paradigm shift throwing new challenges &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Iterative incremental development techniques can result in an increase in the frequency of maintenance releases, which increases the possibility of regression bugs being introduced in the system. &lt;br /&gt;&lt;br /&gt;Possible solution could be pre-release meetings between support and development teams and proper co-ordination between the two teams during production releases. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Complexities encountered in testing integrated distributed system components&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Integrating multiple distributed system components across multiple platforms also including legacy code and proprietary software often presents operational scenarios which are difficult to test e.g. SSO proxy testing or web service calls to third party software.&lt;br /&gt;&lt;br /&gt;Possible solutions are some involvement of architects and designers at this stage to ensure proper use of mocking objects. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Skill retention and learning curve challenges&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Excessive manpower movement can result in shortfalls in skill retentions and knowledge distribution within the team.&lt;br /&gt;&lt;br /&gt;The team leader should ensure that proper handover takes place when members leave the project.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Requirement of a tiered application support structure which has its pros and cons&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The merits of a tiers application support structure is that it enables faster problem resolution due to segregation of problem domain across multiple teams 1st line , 2nd line etc. Using a dynamic problem escalation and feedback mechanism.&lt;br /&gt;&lt;br /&gt;Demerits of this support structure is sometimes dealing with problems of overlapping responsibilities between teams for certain production problems.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;An Industry standard Support Structure to Support Enterprise System is shown below &lt;/strong&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;click on diagram to view larger picture&lt;/em&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_cPCPLPXADos/ShF4lkv0NUI/AAAAAAAAAEo/se5ZwmPJEiQ/s1600-h/tieredsupportstructure.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 170px;" src="http://2.bp.blogspot.com/_cPCPLPXADos/ShF4lkv0NUI/AAAAAAAAAEo/se5ZwmPJEiQ/s320/tieredsupportstructure.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5337179620325471554" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-9149202948179863370?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://javaknowledgestorm.blogspot.com' title='Enterprise System Maintenance/Production Support'/><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/9149202948179863370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/05/enterprise-system-maintenanceproduction.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/9149202948179863370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/9149202948179863370'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/05/enterprise-system-maintenanceproduction.html' title='Enterprise System Maintenance/Production Support'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_cPCPLPXADos/ShF4lkv0NUI/AAAAAAAAAEo/se5ZwmPJEiQ/s72-c/tieredsupportstructure.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-1870173441172583780</id><published>2009-04-28T08:13:00.000-07:00</published><updated>2009-04-28T09:45:29.449-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate over JDBC'/><title type='text'>Hibernate Vs JDBC Performance</title><content type='html'>&lt;strong&gt;==&lt; The Hibernate advantage over JDBC &gt;==&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Concurrency Support&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;JDBC&lt;/span&gt; there is no check that always every user has updated data this check has to be added by the developer.&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;Hibernate&lt;/span&gt; maintains this concurrency check using a version field.It checks this version field in the database table before every update operation.&lt;br /&gt;&lt;br /&gt;So, if two users retrieve data from the same table and modify it and if one of them saves the modification, the version gets updated. Now when the second user tries to save his data hibernate doesn't allow it because the data he retrieved was modified and his version doesn't match with the version in the database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Caching and Connection Pooling&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;JDBC&lt;/span&gt;, caching and connection pooling is maintained by hand-coding.&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;Hibernate&lt;/span&gt; provides excellent caching support and connection pooling for better application performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Transaction Management&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;JDBC&lt;/span&gt; one has to explicitly handle transaction management in the code.&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;Hibernate&lt;/span&gt; provides injected transaction management.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Programming Overhead&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;JDBC&lt;/span&gt; one has to do a lot of coding in the form of SQL queries to handle persistant data in database.&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;Hibernate&lt;/span&gt; there is no need to write code in the form of SQL queries to save and retrieve the data, thus reduces programming overhead and development time.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Maintenance Costs&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Applications using &lt;span style="color:#6666cc;"&gt;JDBC&lt;/span&gt; contain large amounts of code that handles database persistant data. This code is subjected to changes whenever there is a change in database table structure leading to high maintenance cost.&lt;br /&gt;&lt;br /&gt;In &lt;span style="color:#6666cc;"&gt;Hibernate&lt;/span&gt; the actual mapping between database tables and program objects is done in a XML descriptor file. So any changes to a database table will only need a change in the XML file resulting in centralized maintenance and reduction of maintenance costs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-1870173441172583780?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/1870173441172583780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/04/hibernate-over-jdbc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/1870173441172583780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/1870173441172583780'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/04/hibernate-over-jdbc.html' title='Hibernate Vs JDBC Performance'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-4841619432584570868</id><published>2009-04-15T02:47:00.000-07:00</published><updated>2009-04-22T07:03:44.312-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Compare between EJB3.0 and EJB2.0'/><title type='text'>Compare between EJB3.0 and EJB2.0</title><content type='html'>&lt;strong&gt;Configuration &amp; Performance improvements in EJB3.0 over EJB2.0&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;1.&lt;/strong&gt; EJB2.0 uses XMLDescriptor files to define bean configuration and dependencies and performs JNDI lookups for object references which is slow on performance.&lt;br /&gt;EJB3.0 uses POJOs with newly introduced metadata annotation instead of JNDI lookups and XMLDeployment Descriptor files.This architecture results in better performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.&lt;/strong&gt; In EJB2.0 one has to write Home and Remote Interfaces and also implement standard interfaces like javax.ejb.SessionBean which requires the implementation of container callback methods like ejbPassivate, ejbActivate, ejbLoad, ejbStore etc.&lt;br /&gt;EJB3.0 is a simple POJO and doesn't need to implement Home or Remote Interfaces and other standard interfaces like javax.ejb.SessionBean. So no need to implement container callback methods like ejbPassivate, ejbActivate, ejbLoad, ejbStore etc. This results in a simplified configuration and better performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Flexibility &amp; Portability improvements in EJB3.0 over EJB2.0&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;1.&lt;/strong&gt; EJB2.0 objects are heavyweight.&lt;br /&gt;   EJB 3.0 entities do not need to implement the interfaces explained above, so they are  lightweight and easy to convert from a DAO to Entity bean or vice versa.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.&lt;/strong&gt; In EJB2.0 EJB-QL is not very flexible and has limitations.&lt;br /&gt;   EJB3.0 uses a refined EJB-QL which allows multiple levels of joins and hence database queries written are very flexible&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3.&lt;/strong&gt; EJB2.0 uses entity beans to access the database.&lt;br /&gt;EJB3.0 supports Java Persistence API for all its data needs which is more generalized and eliminates portability issues.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4.&lt;/strong&gt; EJB2.0 needs a EJB Container to run.&lt;br /&gt;EJB3.0 does not need to implement standard interfaces and hence can be loaded and run in independent JVM without the need of an EJB container.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5.&lt;/strong&gt; EJB2.0 has limitations in terms of its pluggability with third party persistence providers.&lt;br /&gt;EJB3.0 can be used with pluggable third party persistence providers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6.&lt;/strong&gt; In EJB2.0 security is provided through the use of Deployment descriptors.&lt;br /&gt;In EJB3.0 Security can be provided through annotations which simplifies the configuration and setup tasks and also reduces performance overheads.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-4841619432584570868?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/4841619432584570868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/04/differences-between-ejb20-and-ejb30.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/4841619432584570868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/4841619432584570868'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/04/differences-between-ejb20-and-ejb30.html' title='Compare between EJB3.0 and EJB2.0'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-290385641863005230</id><published>2009-03-26T09:19:00.000-07:00</published><updated>2009-04-22T08:55:18.678-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scheduling and thread pooling in Spring tutorial'/><title type='text'>Scheduling and thread pooling in Spring tutorial</title><content type='html'>The Spring Framework contains integration classes for scheduling support and &lt;a href="http://javaknowledgestorm.blogspot.com/search/label/Abstract%20Factory%20Pattern%20tutorial%20creating%20threads"&gt;thread&lt;/a&gt; pooling.&lt;br /&gt;&lt;br /&gt;The scheduling support classes act as a wrapper for the java Quartz Scheduler&lt;br /&gt;&lt;br /&gt;They are as follows:&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;org.springframework.scheduling.quartz.QuartzJobBean&lt;br /&gt;org.springframework.scheduling.quartz.JobDetailBean&lt;br /&gt;org.springframework.scheduling.quartz.SimpleTriggerBean&lt;br /&gt;org.springframework.scheduling.quartz.CronTriggerBean&lt;br /&gt;org.springframework.scheduling.quartz.SchedulerFactoryBean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some of the thread pooling support classes are as follows:&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;org.springframework.scheduling.quartz.SimpleThreadPoolTaskExecutor&lt;br /&gt;org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Please see below a simple example using Spring Framework's Quartz scheduling and threadpooling features:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UML Diagram of example using Spring's scheduling and thread pooling features&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;click on diagram to view larger picture&lt;/em&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_cPCPLPXADos/SdCtPAvIPSI/AAAAAAAAAEQ/EDC3FpjWJPU/s1600-h/springschedulingthreadpooling.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_cPCPLPXADos/SdCtPAvIPSI/AAAAAAAAAEQ/EDC3FpjWJPU/s320/springschedulingthreadpooling.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5318941633331871010" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Please see below example Code:&lt;/em&gt; &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MonitorJob.java&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import org.quartz.JobExecutionContext;&lt;br /&gt;import org.quartz.JobExecutionException;&lt;br /&gt;import org.springframework.context.ApplicationContext;&lt;br /&gt;import org.springframework.scheduling.quartz.QuartzJobBean;&lt;br /&gt;&lt;br /&gt;public class MonitorJob extends QuartzJobBean {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private int timeout;&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private static final String APPLICATION_CONTEXT_KEY = "applicationContext";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void setTimeout(int timeout){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.timeout = timeout;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected void executeInternal(JobExecutionContext context)  throws JobExecutionException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated method stub&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;processJobs(context);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private ApplicationContext getApplicationContext(JobExecutionContext context )&lt;br /&gt;    throws Exception {&lt;br /&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ApplicationContext appCtx = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;appCtx = (ApplicationContext)context.getScheduler().getContext().get(APPLICATION_CONTEXT_KEY);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (appCtx == null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new JobExecutionException(&lt;br /&gt;   "No application context available in scheduler context for key \"" + APPLICATION_CONTEXT_KEY + "\"");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return appCtx;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private void processJobs(JobExecutionContext context) {&lt;br /&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MonitorProcessDelegate procDelegate = null;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;ApplicationContext ctx = getApplicationContext(context);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;procDelegate = (MonitorProcessDelegate)ctx.getBean("MonitorProcessDelegate");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}catch (Exception e) { e.printStackTrace();}&lt;br /&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Running job monitor");&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;procDelegate.ListBusinessExceptionCases();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;procDelegate.ListActiveProcesses();&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MonitorProcessDelegate.java&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;import org.springframework.core.task.TaskExecutor;&lt;br /&gt;&lt;br /&gt;public class MonitorProcessDelegate {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private class ActiveProcesses implements Runnable {&lt;br /&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// code for identifying and listing active processes&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void run() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.....&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private class BusinessExceptionCasesBacklog implements Runnable {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// code for identifying and listing business exception cases&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void run() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.....&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private TaskExecutor taskExecutor;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public MonitorProcessDelegate;&lt;span style="color:#6666cc;"&gt;(TaskExecutor taskExecutor)&lt;/span&gt; {&lt;br /&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;this.taskExecutor = taskExecutor;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void ListActiveProcesses() {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;taskExecutor.execute(new ActiveProcesses());&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;public void ListBusinessExceptionCases() {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;taskExecutor.execute(new BusinessExceptionCasesBacklog());&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Spring's Dispatcher servlet's configuration file settings&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;click on diagram to view larger picture&lt;/em&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_cPCPLPXADos/SdDS0Ifs2sI/AAAAAAAAAEY/7zvpbZe_-tY/s1600-h/springschedulingcinfig.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_cPCPLPXADos/SdDS0Ifs2sI/AAAAAAAAAEY/7zvpbZe_-tY/s320/springschedulingcinfig.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5318982953000032962" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-290385641863005230?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/290385641863005230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/03/scheduling-and-thread-pooling-in-spring_26.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/290385641863005230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/290385641863005230'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/03/scheduling-and-thread-pooling-in-spring_26.html' title='Scheduling and thread pooling in Spring tutorial'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_cPCPLPXADos/SdCtPAvIPSI/AAAAAAAAAEQ/EDC3FpjWJPU/s72-c/springschedulingthreadpooling.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5599217793777408588.post-8883628236855323291</id><published>2009-03-26T07:00:00.000-07:00</published><updated>2009-05-22T06:01:30.822-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Abstract Factory Pattern tutorial creating threads'/><title type='text'>Abstract Factory Pattern tutorial creating threads</title><content type='html'>Say for e.g. &lt;br /&gt;&lt;br /&gt;Finance module uses threads with the following attributes:&lt;br /&gt;&lt;br /&gt; ThreadGroup = "Finance"&lt;br /&gt; Priority    = 7&lt;br /&gt;&lt;br /&gt;Reporting module uses threads with the following attributes:&lt;br /&gt;&lt;br /&gt; ThreadGroup = "Report"&lt;br /&gt; Priority    = 5&lt;br /&gt;&lt;br /&gt;Using an AbstractFactoryPattern it is possible to design a framework which will provide transparency to developers in creating threads with application module-specific attributes and also maintaining a centralized control on module-specific thread properties.&lt;br /&gt;&lt;br /&gt;Please see below UML Diagram of the Framework:&lt;br /&gt;&lt;p&gt;&lt;em&gt;Please click on diagram to view larger picture&lt;/em&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_cPCPLPXADos/ScuYPqKe-jI/AAAAAAAAADw/OSltPjr__0M/s1600-h/threadframework.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://2.bp.blogspot.com/_cPCPLPXADos/ScuYPqKe-jI/AAAAAAAAADw/OSltPjr__0M/s320/threadframework.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5317511179824724530" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Sample code of framework:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;AbstractIF.java&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;public interface AbstractIF {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;public Thread createThread();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;AbstractFactoryIF.java&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public interface AbstractFactoryIF {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public AbstractIF createThread(Runnable runnable);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;ThreadFactory.java&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public class ThreadFactory implements AbstractFactoryIF {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;String moduleName;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public ThreadFactory(String moduleName) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.moduleName = moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public AbstractIF createThread(Runnable runnable) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated method stub&lt;br /&gt;&lt;span style="color:#6666cc;"&gt;  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(moduleName.equals("Finance")) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return new CreateFinanceThread(moduleName,runnable);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if(moduleName.equals("Report")){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return new CreateReportThread(moduleName,runnable);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;CreateFinanceThread.java&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public class CreateFinanceThread implements AbstractIF {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private String moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private ThreadGroup threadGroup;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private Runnable runnable;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private Thread t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private &lt;span style="color:#6666cc;"&gt;int priority = 7;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public CreateFinanceThread(String moduleName,Runnable runnable) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.runnable = runnable;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.moduleName = moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public Thread createThread() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated method stub&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;threadGroup = new ThreadGroup(moduleName);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = new Thread(threadGroup,runnable);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;t.setPriority(priority);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;CreateReportThread.java&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public class CreateReportThread implements AbstractIF {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private String moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private ThreadGroup threadGroup;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private Runnable runnable;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private Thread t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private &lt;span style="color:#6666cc;"&gt;int priority = 5;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public CreateReportThread(String moduleName,Runnable runnable) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.runnable = runnable;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.moduleName = moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public Thread createThread() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated method stub&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;threadGroup = new ThreadGroup(moduleName);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = new Thread(threadGroup,runnable);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;t.setPriority(priority);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;ProcessDelegate.java&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;public class ProcessDelegate {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private ThreadFactory threadFactory;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private String moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private Thread t;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public ProcessDelegate(String moduleName) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.moduleName = moduleName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void doproc() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AbstractFactoryIF factory = new ThreadFactory(moduleName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AbstractIF thread = factory.createThread(new Runnable() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void run() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;doStuff(moduleName);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = thread.createThread();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.start();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void doStuff(String moduleName) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do module specific stuff here based on the value of moduleName parameter..&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#6666cc;"&gt;/* The Finance stuff will be run in a thread with:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - ThreadGroup="Finance" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - priority = 7&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The Reporting stuff will be run in a thread with:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - ThreadGroup="Report" &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - priority = 5&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;But this will be transparent to the developer using the &lt;strong&gt;ProcessDelegate&lt;/strong&gt; class.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5599217793777408588-8883628236855323291?l=javaknowledgestorm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaknowledgestorm.blogspot.com/feeds/8883628236855323291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/03/use-of-abstractfactorypattern-providing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/8883628236855323291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5599217793777408588/posts/default/8883628236855323291'/><link rel='alternate' type='text/html' href='http://javaknowledgestorm.blogspot.com/2009/03/use-of-abstractfactorypattern-providing.html' title='Abstract Factory Pattern tutorial creating threads'/><author><name>Pinaki</name><uri>http://www.blogger.com/profile/13988762256245696376</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://4.bp.blogspot.com/-_MTDFGvaB5A/Tn2IbREriWI/AAAAAAAAAG4/jl8R7qsbw_8/s220/Copy%2Bof%2BCopy%2Bof%2B22030806.021.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_cPCPLPXADos/ScuYPqKe-jI/AAAAAAAAADw/OSltPjr__0M/s72-c/threadframework.jpg' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
