Wednesday, November 10, 2010

Using BlazeDS conect Flex Java : Speed your code with CDB 4.1

Speed J2EE Productivity with CDB 4.1
In this walkthrough you will :
  •       Check Version of JDK and install Clear Data Builder Plugin4.1 to Eclipse IDE
  •       Create an instance of Tomcat servlet container to run inside Eclipse IDE
  •       Configure the database connection for future exercises

Check Version of JDK and install Clear Data Builder Plugin4.1 to Eclipse IDE
  •           Ensure JDK 1.6 is installed on your system

Download Eclipse IDE with relevent plugin
  •              Download the release build of the Clear Data Builder 4.1 from

  •       Open Eclipse and click help → Install new Software. In the dialog click Add.., navigate to location of the downloaded CDB4.1 archive and add click OK as shown in the snapshot below:
Follow all default prompt to install the plugin. Restart the Eclipse when prompted to.

Create the instance of Apache Tomcat in Eclipse IDE
  •      Create a new server in the server view of the J2EE perspective
  •        In the New Server dialog select Apache Tomcat and click Next
  •        Browse Directory to tomcat installation root and click Choose.
  •      Click finish. Verify that the server entry has been created in Eclipse Servers View

Create the Database Connection Profile
  • Navigate to the DataSource Explorer View that is available in Eclipse JEE perspective. If you don’t see it, go to the menu Window → Show View → Data Management → Data Source Explorer.
  •       Right-mouse click DataBase Connections and select New.



  •  Right-mouse click DataBase Connections and select New


  •   Select the profile type Oracle and click Next


  •   The “New Connection Profile” dialog will show up.



  • If this is the first installation of Oracle Database Profile in your Eclipse workspace, you will need to provide the location of the DBMS driver jar by clicking on the red-circle area next to the Driver combobox.
  • This will open the New Driver Definition dialog shown below:



  •   Click on the Jar List and add the location on your disk of Oracle connector Jar Ojdbc6.jar


 
  •   Select properties tab to provide URL, User Name, and Password
  •   Check your connection by clicking on TestConnection



  •   Expend the new DataSource profile – it should look like this:


 
That’s all. Now You can start CDB project…

New CDB Project Demonstration
*      Select Dynamic web project 


  •        In the dialog below, select the name of project and then click Modify to add CDB facets

  •       In the Project Facets dialogs, expend Clear Data Builder 4.1 Facets.

o   Select CDB Web Project Facet
o   Don’t select CDB Sample Project Facet
o   Select Java Persistence Facet


  •        Click Ok and click next up to following dialog, Make sure Generate web.xml selected
  •       Start Configuration of JPA (Java Persistence API) setting 
  •       Download BlazeDS 4 from
and browse it and click finish

  •   The Incremental build of the CDB will start. You will see following output in Console
  •      From Now you can start flex application in eclipse as usual.
Creating and Preparing JPA Entities for CDB
  •       Right click on Project Explorer, select JPA Tools → Generate Entities from Table
  •        Select Table for which you want to generate Java Annotation Code
  •        Check Table Association
  •   Select package and Sequence or Identity

  •            Click finish, Check Console few things are auto generated.
  •        You can create flex generated code, for this open DTO (Marked with 2 in above image) and add to
@FXClass(kind=FXClassKind.REMOTE)
  •        Run Build.xml undercdb_jpa directory
  •        Clean project and run Ant Built you will see flex VO is generated as java DTO with Underscore prefix
  •        This is not enough you can generate Remote Service Configuration for flex side
Add this annotation to your interface and just save (Note: Make project Build automatically)




Done…
Thanks & Regards
Shailendra kr. shail
@AvaCorp.biz