Introduction. 2
Design EJBs in JBuilder and port
to Together 2
Design EJBs
in Together and port to JBuilder 9
Design Web Applications in
JBuilder and port to Together 18
Design
Web Applications in Together and port to JBuilder 25
Borland Enterprise Studio includes the
following:
- Borland JBuilder - integrated
development environment for Java
- Together Edition for JBuilder -
UML/Design solution for Java
- Borland OptimizeIt suite - performance
optimization solution for Java
- Borland Enterprise Server developer
edition – J2EE 1.3 compliant application server
- Borland JDataStore developer edition –
100% Java database
Since the design and coding of J2EE applications
are much interrelated, the following sections explain how to use
JBuilder and Together to design and code EJB applications.
Though both JBuilder and Together have
capabilities for designing EJB applications, it is recommended to use
JBuilder to design the EJBs. Once the EJBs are designed in JBuilder,
they can be easily viewed in Together and will fit well with the rest
of the design.
Tips : If you are designing J2EE applications from
scratch, use JBuilder to design EJBs and then view in Together.
Lets create a simple session bean using JBuilder
and understand how Borland Enterprise Studio for Java helps in
designing EJBs.
Create a Project in JBuilder
Click File | New
| Project tab from Object Gallery | click Project.
Enter the
project Name as StudioEJBDemo and provide your own
convenient Directory location.
Refer to
Figure 1 for details.
[Figure 1 : Creating a Project in
JBuilder]
Click Finish.
Create an EJBModule in JBuilder
From JBuilder 9, click File | New
| Enterprise tab from Object Gallery | double-click EJBModule.
Name the EJB Module as FlightMod.
Refer to Figure 2 for details.
[Figure 2 : Creating an EJB Module in JBuilder]
Click OK.
After the EJBModule is created, the JBuilder editor
pane becomes a visual design environment for EJB. The developers can
visually create EJBs and the underlying source code will automatically
be created.
Create a Session Bean in JBuilder
Right click EJB Designer pane, click Create EJB,
click Session Bean. Name the session bean as FlightSes.
Refer to Figure 3 for details.
[Figure 3 : Creating a visual session bean in
JBuilder EJB Designer window]
Add a business method to Session Bean
Right-click the visual session bean | Add
| Method.
Refer to Figure 4 for details.
[Figure 4 : Adding a business method to session
bean visually in JBuilder]
Provide the following method information.
Method : getFlightNo,
Return type : String
Input parameters : String
flightName
Interfaces : remote
Refer to Figure 5 for details.
[Figure 5 : Providing method information visually
in JBuilder]
The developers can easily get to the source code
for the session bean FlightSes from the design window.
Right-click FlightSes and click View
Bean Source.
Refer to Figure 6 for details.
[Figure 6 : Easy access to source code from the
design view in JBuilder]
Tips : You can defer the source code changes until the
design has completed. It does not matter for both JBuilder and
Together, as the source code and design are interchangeable with both
the products.
Modify the getFlightNo(String flightName) method
as follows.
public String getFlightNo(String flightName) {
return "555";
}
Make the project
To make the project click CTRL + F9.
Open Project in Together
From JBuilder, right-click the project (StudioEJBDemo)
and click Open project in Together.
Refer to Figure 7 for details.
[Figure 7 : Opening JBuilder project in Together]
Together automatically reverse engineers JBuilder
projects. The FlightSes EJB created in JBuilder is available in
Together.
Tips : JBuilder and Together work seamlessly. JBuilder source code can generate Together
design and vice versa. At any point of time the developer gets the view
of “livesource” without having to worry about the source code and
design go out of sync.
Refer to Figure 8 for Together view of the project
StudioEJBDemo.
[Figure 8 : JBuilder project ported to Together
automatically ]
Once the project is available in
Together, developers can take advantages of the capabilities of
Together like Audits, Matrics, Design Patterns, Documentation
Generation, etc. Also the developers can continue designing other parts
of their application.
Tips : The developers don’t have to run
both JBuilder and Together to keep the design and code in sync.
The design and code are always in sync.
Also as the developers create class
diagrams for other components in Together project, corresponding source
files are automatically created in JBuilder.
If EJBs are already designed in Together, they can
be also ported to JBuilder.
Lets create a simple EJB in together and port it
to JBuilder.
Create a Project in Together
From Together, click File | New Project.
Enter the project name as StudioEJBDemo1
and provide your convenient directory location.
Create an EJBModule in Together
From Together, click File | New |
select Enterprise from Categories | click EJB
Module| click Next.
Refer to Figure 9 for details.
[Figure 9 : Creating EJB Module in Together ]
Provide EJB Module name as FlightEJBMod.
Create a Session Bean in Together
From Together, click File | New |
select Enterprise from Categories| click EJB |
click Next.
Enter the session bean name as FlightSes and EJB
type as Session. Check the checkbox Include EJB in existing EJB
module and provide FlightEJBModule against
Select EJB module.
Refer to Figure 10 for details.
[Figure 10 : Creating a Session bean in Together ]
Click Next.
In the next screen, provide JNDI name as FlightSesBean
and Bean state as Stateless.
Refer to Figure 11 for details.
[Figure 11 : Providing session bean
parameters in Together ]
Click Finish. Now the session bean FlightSesBean
should be visible in the Together designer window.
Add a business method to Session Bean
Right-click the session bean | click New |
click Business method.
Name the business method as getFlightNo.
Refer to Figure 12 for details.
[Figure 12 : Creating business method to
session bean in Together ]
Open Project in JBuilder
Just like JBuilder project can be opened in
Together, Together project can be opened in JBuilder by point and click.
Right-click project StudioEJBDemo1 in Together and
click Open Project in JBuilder.
Refer to Figure 13 for details.
[Figure 13 : Opening Together Project in JBuilder]
Managing Project in JBuilder
When JBuilder gets Together project, it
automatically reads the Java files created by the design in Together.
For this specific case, files related to the FlightSesBean are already available in JBuilder.
But JBuilder can’t render the EJB in the EJB
Designer view. To do that an EJB Module
has to be created in JBuilder.
To create an EJB Module in JBuilder, JBuilder
requires attach the project with an application server. For this paper,
Borland Enterprise Server is used as the target application server. But
developers can select any application server supported by JBuilder.
Select a Target application Server
Right-click project in JBuilder | click Properties
| click Server tab | click Single server for all services
in project | select an application server from the combo box.
Tips : If you don’t have an application server
available from the combo box, then follow JBuilder documentation to
configure JBuilder with the application server of your choice.
Refer to Figure 14 for details..
[Figure 14 : Assigning Borland Enterprise Server
as target application server for JBuilder project]
Create EJBModule in JBuilder
From JBuilder 9, click File | New
| Enterprise tab from Object Gallery | double-click EJBModule..
Refer to Figure 15 for details.
[Figure 15 : Creating EJB Module in JBuilder]
Name the EJBModule as FlightEJBMod.
Import EJB to JBuilder
Now FlightSesBean can be imported to JBuilder’s
EJB Module FlightEJBMod
From JBuilder EJB designer window, right-click and
click Import EJB.
Refer to Figure 16 for details.
[Figure 16 : Importing EJB to JBuilder
EJB Designer]
In the Import EJB window, provide bean name as FlightSes and
select Bean type as Session.
Click the ellipses against Bean
Class, Home interface class and Remote interface class.
You can use the Browse / Search
utility of JBuilder to find the classes.
Refer to Figure 17 for the Browse
Classes window.
[Figure 17 : JBuilder Browse Classes
window to search the classes easily]
Since FlightSesBean doesn’t have local interfaces,
we don’t need to select Local home interface class and Local
interface class.
Figure 18 shows the Import EJB window
after the EJB classes are selected.
[Figure 18 : Import EJB window to import an EJB to
JBuilder]
After importing the EJB, a visual EJB should be
created in JBuilder EJB Designer window. The visual EJB will inherit
the design artifacts from Together. For Example FlightSes has the
getFlightNo remote method.
Refer to Figure 19 for the visual session bean in
JBuilder.
[Figure 19 : Visual session bean in JBuilder after
imported from Together]
Just like EJB applications, the recommended way to
design Web application is using JBuilder. Though both Together and
JBuilder has the design environment, use JBuilder as the preferred way
to create Web applications the port to Together.
Also you can port the Web applications from
Together to JBuilder which is explained in the next section.
Create a Project in JBuilder
From JBuilder, create a new project (click File
| New project) and name the project as StudioWebDemo.
Refer to Figure 20 for details.
[Figure 20 : Create
a project in JBuilder]
Create a Web Application in JBuilder
From JBuilder, click File | New| Web
tab from Object Gallery | click Web Application.
Refer to Figure 21 for details.
[Figure 21 : Create a Web application in JBuilder]
Click OK.
Provide Web application name as StudioWebApp
and Directory as StudioWebApp.
Refer to Figure 22 for details.
[Figure 22 : Provide Web application Name
and Directory in JBuilder Web Application Wizard]
Create a JSP in JBuilder
From JBuilder, click File | New| Web
tab from Object Gallery | click JSP.
In JSP Wizard, provide JSP name as DemoJsp.
Select the checkboxes against Generate
sample bean and Generate error page.
Refer to Figure 23 for details.
[Figure 23 : Provide JSP Name in the JSP Wizard
window of JBuilder]
Click Finish.
Open Project in Together
From JBuilder, right-click Project and click Open
Project in Together.
Refer to Figure 24 for details.
[Figure 24 : Open JBuilder project in Together]
Create a Web Application in Together
From Together, click File
| New | select Web from Categories | click Web
Application| click Next.
Enter the Web application name as StudioWebApp
and Display name as
StudioWebApp .
Click JavaServer pages tab and click Add
and the jsps DemoJsp.jsp and DemoJsp_error.jsp.
Refer to Figure 25 for details.
[Figure 25: Creating a Web application design in
Together and adding JSPs ]
Click Finish.
Now the Web application diagram is created in
Together and containing the JSPs.
Refer to Figure 26 for the details.
[Figure 26 : Web application diagram with JSPs
imported from JBuilder to Together]
The display name of the JSPs can be changed by
right-clicking the JSPs in Together and changing the names.
Refer to Figure 27 for the final view of the Web
application diagram in Together.
[Figure 27 : Web application diagram after
renaming the JSPs]
With this, the porting of Web applications from
JBuilder to Together is complete.
Create a Project in Together
From Together, click File | New
Project. Specify the project name as
StudioWebDemo1.
Refer to the Figure 28 for details.
[Figure 28 : Create a new project in Together]
Create a Web Application in Together
From Together, click File
| New | select Web from Categories
| click Web Application| click Next.
Refer to Figure 29 for details.
[Figure 29 : Create a Web Application in Together]
Click Next.
Enter the Web application name as StudioWebApp1
and Display name as
StudioWebApp1 .
Create a JSP in Together
From Together, click File
| New | select Web from Categories
| click JSP| click Next.
Refer to Figure 30 for details.
[Figure 30 : Creating a JSP in Together]
Click Next.
In the New JavaServer Pages window, a JSP
can be imported or even created. Click the Generate new JSP stub
file radio button. Provide JSP File
Name and Location.
For this paper, the JSP file name is DemoJsp.
From the Options panel, check the checkbox Show
JSPs on Web Application diagram.
Click the radio button Create new diagram named
and provide a name DemoJsp.
Refer to the Figure 31 for the details.
[Figure 31 : New JavaServer Pages window in
Together to create JSP diagram]
Now you can see the JSP diagram created in
Together as shown in Figure 32.
[Figure 32 : JSP diagram in Together]
Open Project in JBuilder
Open Together project in JBuilder by
right-clicking the project in Together and selecting Open Project
in JBuilder.
Note that the Web application diagram and JSP
diagram created in Together is not automatically ported to JBuilder. So
a Web application has to be created in JBuilder and the JSP needs to be
copied to the right directory.
To create a Web application, the JBuilder project
needs to be configured with a Web server. JBuilder install includes
preconfigured Tomcat Web server. But you can configure JBuilder with a
Web server of your choice.
Right-click JBuilder project | click Properties,
click Server tab from Project Properties window.
Click the radio button Single server for all
services in project and choose a Web server from the combo box.
For this paper, Borland Enterprise Server is
selected.
Refer to Figure 33 for details.
[Figure 33 : Selecting a target Web server for
JBuilder project]
Create a Web application in JBuilder
From JBuilder, click File | New| Web
tab from Object Gallery | click Web Application. click OK.
Provide Web application name as StudioWebApp1
and Directory as StudioWebApp1
Copy the JSP to Web application directory
Copy the JSP created in Together (DemoJsp.jsp) to
the Web application directory of JBuilder. Click Refersh.
Refer to figure 34 for details.
[Figure 34: Together Web application ported to
JBuilder]
For more information on evaluating or purchasing
Borland Enterprise Studio for Java, please contact your Borland
representative.
Connect with Us