Avitek Medical Records Development Tutorials

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

 


Developing the MedRec Applications

 


Tutorial 6: Understanding the WebLogic Server Split Directory Structure

Several subdirectories in the medrec_tutorial project directory—medrecEar, physicianEar, startBrowserEar—use the WebLogic Server split development directory structure for storing source files. The split development directory consists of a directory layout and supporting Ant tasks that help you easily build, deploy, and package Enterprise Application files while automatically maintaining CLASSPATH dependencies. The directory structure is split because source files and editable deployment descriptors reside in one directory while compiled class files and generated deployment descriptors reside in a separate directory.

The split development directory structure is a valuable tool to use for developing your own applications. Because source files and generated files are kept separate, you can easily integrate your development projects with source control systems. The split development directory also allows you to easily deploy your applications without having to first copy files and stage applications—WebLogic Server automatically uses the contents of both the build and source directories to deploy an application.

This tutorial explains the layout and function of the source directory structure used in the MedRec application suite. The next tutorial describes the build directory structure, which is produced when you compile an Enterprise Application using the wlcompile task. The source and build directories together make up a WebLogic split development directory, which you will deploy and package in later tutorials.

This tutorial includes the following sections:

 


Prerequisites

Before starting this tutorial, create the project directory and unpack the MedRec tutorial source files to it using the instructions in Tutorial 5: Creating the MedRec Project Directory.

 


Procedure

The following procedure guides you through the source directory structure for the MedRec application suite:

Step 1: Examine the Enterprise Application directory structure.

The WebLogic split development directory stores source files starting at the Enterprise Application (EAR) level. Even if you are developing only a single Web Application or EJB, you store the relevant component in a top-level directory that represents an Enterprise Application. Note the contents of the physicianEar subdirectory:

prompt> cd c:\medrec_tutorial\src\physicianEar
prompt> dir
 Directory of C:\medrec_tutorial\src\physicianEar
04/05/2007  10:55 AM    <DIR>          .
04/05/2007 10:55 AM <DIR> ..
04/05/2007 10:44 AM <DIR> APP-INF
04/04/2007 12:47 PM 59,687 build.html
04/04/2007 12:47 PM 10,409 build.xml
04/04/2007 12:50 PM 592 ejbgen_tutorial.xml
04/05/2007 10:55 AM <DIR> META-INF
04/05/2007 10:55 AM <DIR> physicianWebApp
04/05/2007 10:44 AM <DIR> physSessionEjbs
04/05/2007 10:44 AM <DIR> webServices
04/04/2007 12:50 PM 284 wlcompile_tutorial.xml
04/04/2007 12:50 PM 381 wldeploy_tutorial.xml
04/04/2007 12:50 PM 1,000 ws_ejb_client_tutorial.xml

As you can see from the directory listing, the Physician application contains a Web Application component (stored in the physicianWebApp directory), EJB components (stored in the physSessionEjbs directory), and a Web Service (stored in the webServices directory). The split development directory structure requires that each EAR component reside in a dedicated source directory. You can name the ear directory and component subdirectories however you want, because the wlcompile Ant task automatically determines the type of component during compilation.

The META-INF subdirectory holds deployment descriptors for the Enterprise Application itself (application.xml and optional weblogic-application.xml files).

Note: The various *_tutorial.xml files are tutorial-related files.

Step 2: Examine the Web Application component directory structure.

MedRec’s Web Applications are developed using Struts, which is an open source Web framework developed by the Apache Jakarta Project.

The source directory structure allows you to easily manage the different file types that constitute a Web Application, such as JSPs and servlets and the files required by the Struts framework. Move to the physicianWebApp subdirectory of the physicianEar source directory and examine its contents:

prompt> cd c:\medrec_tutorial\src\physicianEar\physicianWebApp
prompt> dir
 Directory of C:\medrec_tutorial\src\physicianEar\physicianWebApp
04/05/2007  10:55 AM    <DIR>          .
04/05/2007 10:55 AM <DIR> ..
04/04/2007 12:47 PM 12,950 Confirmation.html
04/04/2007 12:47 PM 1,639 Confirmation.jsp
04/04/2007 12:47 PM 41,763 CreatePrescription.html
04/04/2007 12:47 PM 5,389 CreatePrescription.jsp
04/04/2007 12:47 PM 87,839 CreateVisit.html
04/04/2007 12:47 PM 11,961 CreateVisit.jsp
04/04/2007 12:47 PM 14,708 Error.html
04/04/2007 12:47 PM 1,905 Error.jsp
04/04/2007 12:47 PM 32,486 Login.html
04/04/2007 12:47 PM 4,074 Login.jsp
04/04/2007 12:47 PM 15,377 PatientHeader.html
04/04/2007 12:47 PM 2,309 PatientHeader.jsp
04/04/2007 12:47 PM 7,365 PhysicianHeader.html
04/04/2007 12:47 PM 964 PhysicianHeader.jsp
04/04/2007 12:47 PM 30,765 Search.html
04/04/2007 12:47 PM 3,896 Search.jsp
04/04/2007 12:47 PM 29,938 SearchResults.html
04/04/2007 12:47 PM 4,243 SearchResults.jsp
04/04/2007 12:47 PM 5,971 stylesheet.css
04/04/2007 12:47 PM 24,957 ViewProfile.html
04/04/2007 12:47 PM 3,742 ViewProfile.jsp
04/04/2007 12:47 PM 46,175 ViewRecord.html
04/04/2007 12:47 PM 6,707 ViewRecord.jsp
04/04/2007 12:47 PM 37,675 ViewRecords.html
04/04/2007 12:47 PM 5,504 ViewRecords.jsp
04/05/2007 10:55 AM <DIR> WEB-INF

The top level of the Web Application subdirectory contains the JSPs that make up the application. For each JSP, there is also a corresponding HTML file that simply shows the JSP code in HTML format, with line numbers and color coding for easy reading. These HTML files are included for tutorial purposes only; typically you do not include these types of HTML files in your application. You could also store additional .html files or other static content such as image files here, but it is less cumbersome to store such content in a dedicated subdirectory like \html_files or \images.

Java source files for Web Application components, such as Servlets (also called actions in Struts parlance) or supporting utility classes, are stored in package directories under the component’s WEB-INF\src subdirectory. For example, a utility class for the Physician Web Application is stored in C:\medrec_tutorial\src\physicianEar\physicianWebApp\WEB-INF\src\com\bea\medrec\actions\PhysicianConstants.java.

The wlcompile task automatically compiles the contents of the WEB-INF\src subdirectory into the WEB-INF\classes subdirectory of application’s output directory, so that all components of the Web Application can access those classes.

The WEB-INF subdirectory also stores deployment descriptors for the Web Application component (web.xml and the optional weblogic.xml) and the Struts-related files, such as struts-config.xml.

The images used in the physician Web application are not stored in the physicianWebApp directory, but rather in a common directory shared by all the MedRec applications. The weblogic.xml deployment descriptor file of the physician Web application defines a virtual directory that specifies the exact location of these images, as shown in the following excerpt:

  <virtual-directory-mapping>
<local-path>c:/medrec_tutorial/src/common/web</local-path>
<url-pattern>images/*</url-pattern>
</virtual-directory-mapping>

Step 3: Examine the EJB component directory structure.

Java source files for EJB components are stored in subdirectories that reflect the EJB’s package structure. For example, the source for the Physician Application’s session EJB is stored in C:\medrec_tutorial\src\physicianEar\physSessionEjbs\com\bea\medrec\controller\PhysicianSessionEJB.ejb.

Deployment descriptors for EJB components (such as ejb-jar.xml and the optional weblogic-ejb-jar.xml) can be stored in the component’s META-INF subdirectory. However, if you look at the physSessionEjbs subdirectory, you will notice there is no META-INF subdirectory. This is because all EJBs in the MedRec application suite use ejbgen metadata annotations to specify the shape and behavior of the EJB, rather than defining them in deployment descriptor files. The ejbgen annotations are based on the JDK 5.0 metadata annotations feature. The wlcompile Ant task, when it encounters an *.ejb file, invokes the EJBGen utility, which in turn uses these annotations to generate the EJB deployment descriptors automatically when you compile the application.

Note: In this version of the MedRec application, the EJBs follow the EJB 2.X programming model rather than the new EJB 3.0 programming model of Java EE 5. This means that the EJBs in the application use EJBGen tags in their Java source code rather than the EJB 3.0 metadata annotations, such as @javax.ejb.Stateless.
Note: Additionally, the EJBGen utility is proprietary to WebLogic Server and is not supported in EJB 3.0.

Step 4: Examine the Web Service directory structure.

Java source files for Java EE Web Service components are stored in subdirectories that reflect the Web Service’s package structure. For example, the source for the Physician Web Service (that in turn invokes the a Web Service of the medrecEar application reliably) is stored in C:\medrec_tutorial\src\physicianEar\webServices\com\bea\medrec\webservices\PhysicianWebServices.java.

All Web Services in the MedRec application suite are implemented using Java Web Service (JWS) files. A JWS file is the core of your Web Service; it contains the Java code that determines how it behaves. A JWS file is an ordinary Java class file that uses JDK 5.0 metadata annotations to specify the shape and characteristics of the Web Service. The JWS annotations you can use in a JWS file include the standard ones defined by the Web Services Metadata for the Java Platform specification (JSR-181) as well as a set of WebLogic-specific ones.

The MedRec application then uses the jwsc Web Services Ant task to compile JWS files into a deployable Web Service. As defined by the Enterprise Web Services 1.1 specification (JSR-921), Web Services can be implemented by either plain Java classes (packaged in a Web Application WAR) or a stateless session EJB (packaged in an EJB JAR). The jwsc Ant task automatically determines what type of backend component to generate, and then generates all supporting files, such as deployment descriptors, user-defined data type components, and the WSDL file. This means that, similar to EJBs that use ejbgen annotations, only the JWS file that describes the Web Service is stored in the \src directory.

Note: In this release of WebLogic Server, the wlcompile Ant task does not compile Web Services that have been implemented with JWS files. Rather, you must explicitly call the jwsc Web Service Ant task to generate the Web Service before calling the wlcompile task to compile all other components, such as EJBs. Additional details about jwsc are provided in Tutorial 11: Creating a Java EE Web Service by Programming a JWS File.

 


Best Practices

 


The Big Picture

The MedRec application suite uses three split development directories to hold the source for the medrecEar, physicianEar, and startBrowserEar applications. Utility classes shared among these applications reside in a dedicated directory, common, with a custom build script that does not use the split directory structure. Security components are also staged in a custom build directory.

The top-level build.xml file iterates through the MedRec source directories and coordinates building all of the components at once.

Although the wlcompile Ant task automatically manages most component dependencies during a build, certain split development directories, such as the medrecEar and physicianEar subdirectories, hard-code the build order to enforce dependencies. The source directory structure that you created during the tutorial contains intermediate build steps, which allow you to focus on using the new WebLogic Server Ant tasks without worrying about the dependencies.

 


Related Reading


  Back to Top       Previous  Next