| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <HTML> |
| <HEAD> |
| <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> |
| <TITLE>Enterprise Application Development with NetBeans IDE</TITLE> |
| <link rel="stylesheet" type="text/css" href="https://netbeans.org/netbeans.css"> |
| </HEAD> |
| <BODY> |
| |
| <H1>Enterprise Application Development with NetBeans IDE</H1> |
| |
| <div class="articledate" style="margin-left: 0px;">Authors: V. Prabakar, Dr. B.V. Kumar, Prakash Narayan and PCM Reddy</div> |
| |
| <h2>Introduction</h2> |
| |
| <P>The NetBeans Integrated Development |
| Environment (IDE) is one solution for all your Java development |
| needs. It is ideal for Java programmers - not just a generic environment that |
| tries to provide a little something for everyone. In this white paper we would like to share a IDE |
| success story from Infosys (<A HREF="http://www.infosys.com/">www.infosys.com</A>), |
| a global consulting and IT Services company, on how the NetBeans IDE |
| helped them to turn a concept demo into a real life enterprise |
| application. |
| </P> |
| <P><BR> |
| </P> |
| <P>Here is a quote from the Infosys |
| Principal Architect, “It started with an intention to build a demo |
| application using the NetBeans IDE for internal training in our |
| organization. But as we added features into the application – it |
| was remarkably easy, thanks to the new and intuitive features in both |
| Java EE 5 and the NetBeans IDE – we only ended up being thirsty to |
| add more and more functionality into our real application”.</P> |
| |
| <H2>The Application</H2> |
| |
| <P>Enterprise Asset Management |
| is vast and spans inventory management, supplier management, |
| CRM solutions, billing solutions, work flow management, resource |
| tracking, order management, and synchronization of various artifacts |
| across factory premises, warehouses and sales desks. The team was |
| asked to concentrate on the very basics, which included asset |
| management, asset tracking, order management, inventory management |
| and a simple and tailor-made customer relationship management implementation. The figure below |
| shows the overall system use case. |
| </P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_5aaa5ae7.jpg" NAME="graphics6" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| <P>Asset Management use case</P> |
| </DIV> |
| |
| <H2>Why NetBeans IDE?</H2> |
| |
| <P>The NetBeans IDE is a robust, free, open source Java IDE that |
| provides the developer with everything they need to create |
| cross-platform desktop, web and mobile applications straight out of |
| the box. It comes with the following features:</P> |
| |
| <div class="indent"> |
| <H3>Supported Java technologies :</h3><br> |
| <UL> |
| <LI><P>Latest Java SE, Java EE support |
| including annotations and JPA</P> |
| <LI><P>NetBeans Enterprise Pack - SOA |
| Tools including excellent Visual editors for BPEL, XML Schema and |
| Visual BPEL Debugger</P> |
| <LI><P>NetBeans Visual Web Pack - Visual |
| editor for JSF projects</P> |
| <LI><P>NetBeans Mobile Pack - The Best |
| Java Mobile Application editor for CLDC and CDC</P> |
| <LI><P>NetBeans Profiler</P> |
| <LI><P>NetBeans GUI Builder for Swing |
| based Rich GUI applications</P> |
| </UL> |
| |
| |
| |
| <H3>Other Key IDE features :</h3><br> |
| |
| <UL> |
| <LI VALUE=1><P>Best out of the box experience</P> |
| <LI><P>The best Ant support for projects </P> |
| <LI><P>Web wervice security</P> |
| <LI><P>JUnit support</P> |
| <LI><P>Supports multiple version control |
| systems</P> |
| <LI><P>Excellent forum support and lot of |
| learning resources</P> |
| <LI><P>Multi-platform support and |
| look and feel (Windows, Linux, Solaris and MacOS)</P> |
| <LI><P>Multi-language support including |
| Java, C/C++, JavaScript and Groovy etc.</P> |
| <LI><P>Support for multiple application |
| servers and database servers</P> |
| <LI><P>Auto update, easy to configure, |
| localization, accessibility support, and many more features</P> |
| </UL> |
| </div> |
| |
| <H2>Enterprise Application Development Experience:</H2> |
| |
| <P>NetBeans IDE provides |
| excellent out-of-the-box experience from simple Java SE/EE |
| development to enterprise application programming. The NetBeans IDE |
| includes programmer-friendly features like annotations, code |
| completion, refactoring, dependency injection in Java SE 5 and |
| powerful Java Persistence API in EJB 3.0. The UML functionality in |
| NetBeans IDE helps to reverse engineer Java code and apply design |
| patterns to Java code.</P> |
| |
| <P>The Enterprise Asset Management |
| The application consists of a web interface to manage assets and purchase |
| orders. Now we will see how this application is developed |
| using NetBeans IDE.</P> |
| |
| <div class="indent"> |
| <h3>Create Java Application:</h3><br> |
| |
| <P>In the IDE's |
| File Menu, choose New Project. In the category “General”, select “Java Application”. |
| Click on Next and set Project Name to “EAM-Asset”. We will |
| add persistent classes for Asset. <!-- TODO--> Similarly Create Java Project |
| “EAM-PO.” This will be used for purchase order persistent classes.</P> |
| |
| |
| <h3>DataBase Connection:</h3><br> |
| |
| <P>NetBeans IDE has an easy to use interface |
| for databases. JavaDB is installed as a part of Sun Java System |
| Application server or GlassFish Server installation. The following |
| picture shows database integration in NetBeans IDE. It is easy to |
| configure other JDBC drivers/servers.</P> |
| <P><BR> |
| </P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m19cbb3d1.jpg" NAME="graphics1" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>EAM-Asset application (Persistence classes from database tables)</h3><br> |
| |
| <P>Create a Java Application “EAM-Asset”. |
| Add “Entity class from database”. The Entity Class wizard connects |
| to the Java DB server and fetches the tables list from the database. In this case, |
| we are using “MASTERASSETTABLE” as shown below.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m109ba5bd.jpg" NAME="graphics3" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <P>This wizard allows users to edit the |
| entity class's name. For example “Masterassettable” can be changed |
| to “Asset”. |
| </P> |
| <P>In the same panel there is a button for |
| creating a “Persistence Unit” which will be created and added to the |
| Web application automatically.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m66422143.jpg" NAME="graphics2" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Adding Annotations to Asset class</h3><br> |
| |
| <P>Once the “Asset” class is created, we added the following inheritance |
| strategy and discriminator in the code.</P> |
| <pre>“@Inheritance(strategy=InheritanceType.SINGLE_TABLE)” |
| “@DiscriminatorColumn(name="assetType")”</pre> |
| <P><BR></P> |
| |
| <h3>Code Completion Support for Annotations:</h3><br> |
| |
| <P>NetBeans IDE provides full code completion support for |
| annotations and attributes, which means less compilation errors and |
| time saving. See the following picture for code completion for Java |
| persistence annotations.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_2bde64d1.jpg" NAME="graphics4" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| <h3>Code completion support for attributes in Annotations:</h3><br> |
| </DIV> |
| |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m30788d3f.jpg" NAME="graphics5" BORDER=0><BR CLEAR=LEFT>Code |
| completion also supports attributes. |
| </P><P><BR></P> |
| </DIV> |
| |
| <P>We use the “HardDrive” and “Monitor” |
| classes by extending the Asset class. |
| Similarly, we created the <b>EAM-PO</B> |
| (Enterprise Asset Manager Purchase Order) application, using |
| "LineItems" and "PurchaseOrder" tables as we |
| discussed earlier.</P> |
| <P>We also added the following classes to the <B>EAM-PO |
| application.</B></P> |
| <ul> |
| <li>HardDriveLineItem extends "LineItem" |
| and implements methods. |
| <li>MonitorLineItem extends "LineItem" |
| and Implement methods. |
| </ul> |
| <P><BR><BR> |
| </P> |
| |
| <h3>NamedQueries are generated Automatically:</h3><br> |
| |
| <P>We added the following custom NamedQuery to the existing |
| NamedQueries list in PurchaseOrder.java.</P> |
| <pre> @NamedQuery(name = |
| "PurchaseOrder.findByShipment", query = "SELECT m FROM |
| PurchaseOrder m WHERE m.shippingAddress = :shipment")</pre> |
| |
| |
| <div class="align-center"> |
| <P><br><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_2f78ad3d.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_2f78ad3d.jpg" WIDTH="600" NAME="graphics8" BORDER=0><br CLEAR=LEFT>(Click to zoom)</a><BR CLEAR=LEFT> |
| </P> |
| <P><BR></P> |
| </DIV> |
| |
| <h3>Web interface for asset management application.</h3><br> |
| |
| <P>We created a Web Application named “<B>EAM-AsserMgmt-web</B>” and added the following servlets:</P> |
| <UL> |
| <LI><P>AssetMaster</P> |
| </UL> |
| |
| <P>We added a JDBC resource and called it "jdbc/myDatasource" |
| using existing the DataBase Connection Pool, or the user can create a new |
| connection pool.</P> |
| <P><BR></P> |
| |
| <h3>Adding JDBC Resource:</h3><br> |
| |
| |
| <div class="align-center"> |
| <P><br><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m219dcbcb.jpg" NAME="graphics9" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Verification of JDBC Resources:</h3><br> |
| |
| <P>Once the JDBC Pool and Resource are registered with the |
| application server, they can be verified in the IDE's Runtime Tab.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m14f46c9e.jpg" NAME="graphics14" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Creating PersistenceUnit:</h3><br> |
| |
| <P>Adding a persistence unit was |
| never an easy task, but with the IDE's project wizard it is simplified |
| now.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_33207bb2.jpg" NAME="graphics10" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Adding PersistenceContext to Servlet :</h3><br> |
| |
| <P>We selected each of the servlets and added |
| @PersistenceContext, @Resources. |
| </P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_15ecf5de.jpg" NAME="graphics12" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <P>This will automatically add a “persists” method |
| as shown below.</P> |
| |
| |
| <div class="align-center"> |
| <P><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m5429e4c4.jpg" NAME="graphics11" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </div> |
| |
| <P>“AssertValidation.js” and “commonstyle.css” |
| are added to the application.</P> |
| <P><BR></P> |
| <P>Then we implemented the required logic in the following |
| servlets.</P> |
| <UL> |
| <LI VALUE=1><P>DeleteAsset</P> |
| <LI><P>EditAsset</P> |
| <LI><P>ListAssets |
| </P> |
| </UL> |
| <P><BR> |
| </P> |
| |
| <h3>Fix Imports Automatically</h3><br> |
| |
| <P>Whenever new classes are added to servlets |
| including annotations, the IDE fixes imports automatically.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_62913406.jpg" NAME="graphics15" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Add Try-Catch Automatically</h3><br> |
| |
| <P>If there are any lines of code that need to be wrapped |
| by a try-catch-block, the NetBeans editor does this automatically.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_193ea7bd.jpg" NAME="graphics16" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Refactoring support in NetBeans IDE</h3><br> |
| |
| <P>The user can make use of various IDE's refactoring features to manage code. |
| </P> |
| |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_18532f12.jpg" NAME="graphics17" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| <P><BR></P> |
| </DIV> |
| |
| <P>For instance, finding the usage of a variable in the NetBeans editor, or finding |
| any unused variables in the code.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m42d7f7d1.jpg" NAME="graphics18" BORDER=0><BR CLEAR=LEFT> |
| </P><p><br></p> |
| </div> |
| |
| <h3>Visually Editing Web.xml</h3><br> |
| |
| <P>The web deployment descriptor provides a visual |
| representation of “web.xml”. It is easy to navigate between |
| different sections of web.xml. |
| </P> |
| |
| <div class="align-center"> |
| <P><BR><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_1044a3f8.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_1044a3f8.jpg" NAME="graphics13" width="600" BORDER=0><BR CLEAR=LEFT>(Click to zoom)</A><BR CLEAR=LEFT> |
| </P><p><br></p> |
| </div> |
| |
| <h3>Setting Breakpoints in the Code</h3><br> |
| |
| <P>Setting breakpoints in the code and debugging the application is |
| very simple in NetBeans IDE.</P> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_6c23dd55.jpg" NAME="graphics20" WIDTH=291 HEIGHT=89 BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <P>We added the following servlets to EAM-PO-web |
| application.</P> |
| <UL> |
| <LI>CancelPurchaseOrderServlet |
| <LI>CheckPOStatusServlet |
| <LI>EditPurchaseOrderServlet |
| <LI>GetAssetPropertiesServlet |
| <LI>MasterPurchaseOrderServlet |
| <LI>SaveEditPurchaseOrderServlet |
| <LI>SavePurchaseOrderServlet |
| </UL> |
| <P>Then we added the JDBC resource, @PersistenceContext and |
| @Resources in Servlets, and implemented the business logic in the servlets. |
| </P> |
| <P><BR> |
| </P> |
| |
| <h3>Creating UML Model from Java Classes</h3><br> |
| |
| <P>The NetBeans UML plugin was used |
| to do analysis and round-trip engineering on the Java Code. NetBeans UML |
| offers several enterprise class features. |
| </P> |
| <UL> |
| <LI><P><B>Forward and reverse |
| engineering:</B> You can generate Java code from your model as |
| well as create UML models from your existing Java source. |
| </P> |
| <LI><P><B>Markerless code generation:</B> |
| The code generated by the UML module is free of any artificial |
| markers, e.g. comments or tags, introduced solely to support code |
| generation. |
| </P> |
| <LI><P><B>Support for diagrams:</B> |
| </P> |
| <LI>Activity diagram |
| <LI>Class diagram |
| <LI>Collaboration diagram |
| <LI>Component diagram |
| <LI>Deployment diagram |
| <LI>Sequence diagram |
| <LI>State diagram |
| <LI>Use Case diagram |
| <LI><P><B>Requirements gathering:</B> |
| You can bring application design requirements into your model via an |
| XML file or import them from Telelogic's DOORS requirements tool. |
| </P> |
| <LI><P><B>Predefined and Extensible |
| Design Patterns</B>: There is a full set of design patterns |
| including EJB 1.1, EJB 2.0 and Gang of Four (23 patterns). |
| </P> |
| <LI><P><B>Rational Rose Import</B>: You |
| can import models created by Rational Rose into your project |
| allowing easy migration of existing projects. |
| </P> |
| <LI><P><B>Web Reporting</B>: |
| </P> |
| </UL> |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_373fa44f.jpg" NAME="graphics7" BORDER=0><BR CLEAR=LEFT> |
| </P> |
| </DIV> |
| |
| <h3>Executing the application</h3><br> |
| |
| <P>After we cleaned, built and deployed both the web applications, we selected |
| each webapplication and ran it from |
| the IDE. The welcome page of each webapplication is launched in |
| the webbrowser.</P> |
| <P><BR></P> |
| |
| |
| <div class="align-center"> |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m4904d98d.jpg" NAME="graphics25" BORDER=0> |
| <BR CLEAR=LEFT>PurchaseOrder servlet<BR CLEAR=LEFT><P><BR></P> |
| </P> |
| |
| <p><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_5bd5497.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_5bd5497.jpg" |
| NAME="graphics26" BORDER=0 width="600"></a><BR CLEAR=LEFT>Create |
| Purchase Order. (Click to zoom)</P> |
| <P><BR></P> |
| |
| <P><BR><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m14190cfd.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m14190cfd.jpg" NAME="graphics27" width="600" BORDER=0></a><BR CLEAR=LEFT>Purchase Order Details (Click to zoom) |
| </P><P><BR></p> |
| |
| <P><BR><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m53435a5.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m53435a5.jpg" NAME="graphics29" width="600" BORDER=0></a><BR CLEAR=LEFT>Verify Purchase Order in Database (Click to zoom) |
| </P> |
| |
| <P><BR><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m461c2891.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m461c2891.jpg" NAME="graphics28" width="600" BORDER=0></a><BR CLEAR=LEFT>Purchase |
| Order Summary (Click to zoom)</P> |
| <P><BR></P> |
| |
| <P><BR><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_12115bcf.jpg" NAME="graphics19" BORDER=0><BR CLEAR=LEFT>Executing “Assetmanagement” Servlet. |
| </P> |
| <P><BR></P> |
| <P><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m170b3cd6.jpg" NAME="graphics21" BORDER=0><BR CLEAR=LEFT>Adding |
| a harddisk to asset list. Similarly add a Monitor.</P> |
| <P><BR></P> |
| |
| <P><BR></P> |
| <P><a href="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m44a3860a.jpg"><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m44a3860a.jpg" NAME="graphics22" BORDER=0 width="600"></a><BR CLEAR=LEFT>Verify hard drive and monitor records are added |
| in database. (Click to zoom)<BR> |
| </P> |
| <P><BR></P> |
| |
| <P><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_7866160a.jpg" NAME="graphics23" BORDER=0><BR CLEAR=LEFT>Editing asset.<BR> |
| </P><P><BR></P> |
| |
| <P><IMG SRC="../../images_www/articles/assetmanagement-whitepaper/assetmanagement_whitepaper_html_m3828a8e4.jpg" NAME="graphics24" BORDER=0><BR CLEAR=LEFT>Asset List<BR> |
| </P><P><BR></P> |
| </DIV> |
| </div> |
| |
| <H2>Summary</H2> |
| |
| <P>Developing enterprise scale |
| applications was never so simple, definitely. NetBeans IDE and the NetBeans |
| Packs empower enterprise application developers to reduce the |
| complexity and increase productivity. Several scripting modules are |
| being added to NetBeans IDE which enables it to serve broader |
| development needs. NetBeans IDE makes enterprise development much |
| simpler and much less boilerplate. |
| </P> |
| <P><BR></P> |
| <div class="feedback-box"> |
| <a href="/about/contact_form.html?to=3&subject=Feedback:assetmanagement whitepaper kb/article">Send Us Your Feedback</a> |
| </div> |
| <br style="clear:both;" /> |
| <H1>Resources for further reading</H1> |
| |
| <UL> |
| <LI><A HREF="https://netbeans.org/">http://www.netbeans.org</A> |
| <LI><A HREF="https://netbeans.org/kb/55/index.html">https://netbeans.org/kb/55/index.html</A> |
| <LI><A HREF="https://netbeans.org/features/soa/index.html">https://netbeans.org/features/soa/index.html</A> |
| <LI><A HREF="https://netbeans.org/features/ide/index.html">https://netbeans.org/features/ide/index.html</A> |
| <LI><A HREF="http://ajax.dev.java.net/">http://ajax.dev.java.net/</A> |
| <LI><A HREF="http://scripting.netbeans.org/">http://scripting.netbeans.org/</A> |
| <LI>SOA support in NetBeans: <A HREF="http://enterprise.netbeans.org/">http://enterprise.netbeans.org/</A> |
| <LI><A HREF="http://uml.netbeans.org/">http://uml.netbeans.org/</A> |
| <LI><A HREF="http://identity.netbeans.org/">http://identity.netbeans.org/</A> |
| </UL> |
| |
| </BODY> |
| </HTML> |