Please click here for the white paper as a PDF

Transcription

Please click here for the white paper as a PDF
Converting to JBuilder – Sybase Edition from PowerJ with EAServer v4.1
By Ian Thain, eBD SWAT Team, Sybase Inc
Table of Contents
Table of Contents ........................................................................................................................................... 2
General Configuration .................................................................................................................................... 3
Overview ........................................................................................................................................................ 4
JBuilder 6 Enterprise – Sybase Edition ................................................................................................... 4
EAServer Plug-in for JBuilder ................................................................................................................... 5
Why JBuilder was adopted by Sybase Inc.................................................................................................. 5
JBuilder vs. PowerJ .................................................................................................................................... 5
Using code generated from PowerJ within JBuilder ...................................................................................... 6
Reusing session EJB’s................................................................................................................................ 6
Reusing JSP’s ........................................................................................................................................... 10
Reusing Servlets ....................................................................................................................................... 15
Reusing Client Apps................................................................................................................................. 16
EAServer specific properties & J2EE properties...................................................................................... 17
2
General Configuration
•
To follow this white paper requires EAServer 4.1 and JBuilder 6 Enterprise – Sybase Edition
•
JBuilder 6 – Sybase Edition includes the EAS Plug-in v2.0
•
If you already have JBuilder 6 the EAServer plug-in can be downloaded from
http://www.sybase.com/easerverplugins#JBuilder
•
Ensure that the Jaguar Server(jdk13) is started.
•
Start up the Portfolio database. From a DOS or CMD prompt, switch into the directory where the
Portfolio database is located. For example:
cd Program Files\Sybase\PowerJ40\PowerJ Samples\myPortfolio\Database
Then type:
•
dbsrv7 -n myPortfolio_server -x tcpip myPortfolio.db
(Or run the .bat file)
Create a Jaguar Connection Cache to the myPortfolio database. To do this:
1) In Jaguar Manager click on Connection Caches. Right click the right hand pane and choose New
Connection Cache.
2) Name the connection cache Portfolio and click OK.
3) On the General tab enter the following information:
Database Type:
Server Name:
User Name:
Password:
Sybase_ASA
NetworkProtocol=Tds:Server=localhost:Port=2638
dba
sql
4) On the Driver tab enter com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource as the DLL or
Class Name, making sure JDBC is selected. Note that this is using the Sybase JConnect 5.2
Driver.
5) On the Cache tab make sure Enable Cache-by-name Access is checked. Click OK.
6) Right-click on the Portfolio connection cache and choose Connection Cache Properties. On the
General tab click on the Ping button. A success message should appear.
3
Overview
JBuilder 6 Enterprise – Sybase Edition
JBuilder™ is the most comprehensive award-winning cross-platform visual development environment for
building applications, applets, JSP/Servlets, JavaBeans™, Enterprise JavaBeans and distributed J2EE
applications for the Java 2 Platform. More information can be found at http://www.borland.com/jbuilder/
JBuilder is written in Java and uses one window to perform most development functions. This window is
called the AppBrowser. The AppBrowser contains several panes internally to perform these development
tasks. In the above screenshot, on the left hand side, can be seen the Project Pane and below it the
Structure Pane. On the right hand side is the Content Pane with its associated File View Tabs.
The new features of JBuilder 6 include:
• Two-way EJB 2.0 visual designer
• Integration with additional application servers such as EAServer 4.1
• UML code visualization
• Refactoring
• Unit testing
• Documentation tools
• Availability on Mac OS X
4
EAServer Plug-in for JBuilder
The EAServer Plug-in for JBuilder allows users to develop, debug and deploy J2EE applications on
EAServer with JBuilder, and enables IT to leverage investments in JBuilder infrastructure and training.
With the plug-in, JBuilder deploys J2EE components (EJB, Servlet and JSP) and applications (WAR, JAR
and EAR) directly to EAServer. Additionally, developers can remotely debug components and applications
running on EAServer.
Why JBuilder was adopted by Sybase Inc
Relationship with Borland reaffirms Sybase's commitment to deliver best-in-class technology in an open,
comprehensive, independent e-Business infrastructure platform. Also re-read the overview of JBuilder,
which mentions its excellent feature set.
JBuilder vs. PowerJ
JBuilder has support for J2ME development as part of its Mobile Set extension.
JBuilder is written in Java and therefore multi-platform.
JBuilder 7 (available May 20) will have support for Java 2 v1.4.
5
Using code generated from PowerJ within JBuilder
The following examples will deploy a stateless EJB and a JSP that calls that same EJB.
Reusing session EJB’s
This method can be used to reuse EJB code generated within PowerJ
1.
In JBuilder, create a Project. (File → New Project)
2.
Add an EJB 1.x object from the object gallery
Follow the wizard entering a new EJB module if necessary.
6
3.
Enter the same package name and EJB name as the EJB that you created with PowerJ
4.
Rebuild the project
5.
Copy the xxxBean.java file from the PowerJ directory over the JBuilder generated code in the src
folder (and within any package name specified)
7
6.
Open the xxxBean.java code and select EJB|EJB 1.x interface generator
7.
It is OK to overwrite the deployment descriptor entry at this time and also the Home and Remote
interfaces
8
8.
Select the methods you wish to expose
9.
Add any application server specific properties via the sybase-easerver-config.xml
NOTE – Please refer to the section entitled EAServer specific properties & J2EE Properties
10. Rebuild the project
11. Deploy to EAServer
9
Reusing JSP’s
This method can be used to reuse JSP code generated within PowerJ
NOTE – At this time with the JBuilder EAS Plug-in v2.0, WAR’s cannot be deployed to EAServer. As a
work around the WAR has to be added to a EAR group within JBuilder, only then can the EAR be
deployed via the plug-in to EAS
1.
In JBuilder, create a Web App to the previous Project. (File → New)
2.
Create a new JSP from the same dialog above. Use the same JSP name as you created in PowerJ.
3.
The JSP will be created under the project folder
10
4.
Make sure there are no dependencies set for the EAServer 4.1 client in the Web App properties
5.
Rebuild the project
6.
Copy the .jsp file from the PowerJ directory over the JBuilder generated code in the defaultroot
folder
7.
Make sure the JNDI lookup package is correct.
11
8.
Add any specific properties via the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet-mapping>
<servlet-name>Jsp1</servlet-name>
<url-pattern>/Jsp1</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Jsp1</servlet-name>
<display-name>Jsp1</display-name>
<jsp-file>/Jsp1.jsp</jsp-file>
</servlet>
</web-app>
9.
Rebuild the project
10. Create a new EAR group using the Web App created earlier
12
Include the WebApp in this EAR group
11. Rebuild the EAR
12. Deploy to EAServer
13
13. Use Jaguar Manager to check the EAR deployment
14. Refresh EAServer
15. Access the JSP via browser
14
Reusing Servlets
This method can be used to reuse Servlet code generated within PowerJ
1.
In JBuilder, create a Project. (File → New Project)
2.
Add a Servlet from the object gallery
3.
Enter the same package name and Servlet name as the Servlet that you created with PowerJ
4.
Rebuild the project
5.
Copy the servlet.java file from the PowerJ directory over the JBuilder generated code in the src
folder (and within any package name specified)
6.
Open the servlet.java code to check that the servlet is correct
7.
Add any specific properties via the web.xml
8.
Rebuild the project
9.
Deploy to EAServer
15
Reusing Client Apps
This section deals with reusing PowerJ created Apps within JBuilder.
NOTE - The example below shows a simple Application that uses standard Java components, including
Layout Managers (No PowerJ components etc)
1.
Copy the .java files from the PowerJ folders to a location that will contain your JBuilder project.
Make sure that these .java files are located under a src folder (and within any package name
specified). For example TestAPP\src
2.
Create the JBuilder project TestAPP. JBuilder will detect the .java files under the src folder and
include them into the project
3.
Change any reference of the PowerJ generated method CreateTheForm(), to the JBuilder method
jbInit(). This private method is called every time the view is switched to the design tab and
without it the form will not display in JBuilder.
4.
This will allow the JBuilder designer to display the App.
16
EAServer specific properties & J2EE properties
This section deals with reusing EAServer specific properties and J2EE properties within JBuilder.
1.
Any EAServer properties that were specified in the application server specific properties dialog of
PowerJ v4 are another matter. Within PowerJ these are not created in the Archive file, but are set
in EAServer via PowerJ calling EAServer API’s programmatically from the IDE.
!
!
!
!
!
ejb-jar.xml
Manifest.mf
Currency.class
CurrencyBean.class
CurrencyHome.class
PowerJ
EAServer Specific
properties set via
EAServer API calls
Deploy
EAServer
2.
JBuilder on the other hand, using the EAServer plug-in, creates these EAServer properties in the
Archive file, using sybase-easerver-config.xml. EAServer uses this when the Archive file is
deployed to EAServer.
!
!
!
!
!
!
ejb-jar.xml
Manifest.mf
Currency.class
CurrencyBean.class
CurrencyHome.class
sybase-easerver-config.xml
JBuilder
Deploy
EAServer
17
3.
Example of sybase-easerver-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sybase-easerver-config SYSTEM
"http://download.sybase.com/specifications/xsd/sybase-easerver-config_1_0.dtd">
<sybase-easerver-config>
<macro begin="${" end="}">
<definition name="comp" value="com.sybase.jaguar.component" />
<configure type="update" entity="Package:cmptest">
<property name="com.sybase.jaguar.package.security-role.everybody"
value="everybody" />
<property name="com.sybase.jaguar.package.security-roles"
value="(name=everybody, description=)" />
</configure>
<configure type="update" entity="Component:cmptest/Currency">
<property name="com.sybase.jaguar.component.debug" value="true" />
<property name="mapField:currencyLn" value="currency_ln" />
<property name="mapField:currencyCd" value="currency_cd" />
<property name="com.sybase.jaguar.component.storage"
value="CtsComponents/JdbcStorage(cache=Portfolio,table=map:CURRENCY)" />
</configure>
</macro>
</sybase-easerver-config>
4.
If the code you with to reuse has been deployed to EAServer then the
sybase-easerver-config.xml file can be created from EAServer in the following manner. Firstly
export a J2EE compliant archive from EAServer, specifying that you want the EAServer XML
Configuration File as seen below
5.
The sybase-easerver-config.xml can be extracted file from this Archive, then copied over the file
created by JBuilder.
6.
Any J2EE standard configuration properties, which you may have set in PowerJ, can be specified
through JBuilder’s many dialogs for each type of component. As an alternative, you may use the
PowerJ generated ejb-jar.xml file or the same file from the EAServer exported J2EE archive,
extracted and copied over the JBuilder version
18
Sybase Incorporated
Worldwide Headquarters
5000 Hacienda Drive
Dublin, CA 94568-7902, USA
Tel: 1-800-8-Sybase, Inc.
Fax: 1-510-922-3210
www.sybase.com
Copyright © 2002 Sybase, Inc. All rights reserved. Unpublished rights reserved under U.S. copyright laws. Sybase and the Sybase logo are
trademarks of Sybase, Inc. All other trademarks are property of their respective owners. ® indicates registration in the United States.
Specifications are subject to change without notice. Printed in the U.S.A.
19