Creating the MedRec Project Directory
This tutorial describes how to create the main project directory that holds the MedRec source files and compiled classes. The tutorial also explains the high-level directory structure and contents for the MedRec application suite components.
Tutorials that follow provide more detail about the development directory structure and WebLogic Server ant tasks that help you easily build and deploy Enterprise Applications and their subcomponents - Web applications, EJBs, and Web services.
This tutorial includes the following sections:
Before starting this tutorial, create the MedRec domain and MedRec server. See Tutorial 1: Creating a WebLogic Domain and Server Instance for Development.
Follow these steps to create the source directory structure for the MedRec application suite:
- Step 1: Create the tutorial project directory.
- Step 2: Unpack the project subdirectories.
- Step 3: Verify the project directory contents.
- Step 4: Verify the source directory contents.
- Step 5: Edit the \src\medrec.properties file and run substitute.xml.
Step 1: Create the tutorial project directory.
Begin by creating a top-level project directory in which you will store source and output files for the MedRec Enterprise Applications and client programs. Name the directory medrec_tutorial:
mkdir c:\medrec_tutorialStep 2: Unpack the project subdirectories.
BEA provides a .zip file that contains the source files and build subdirectories needed to complete the MedRec tutorials. To populate your project directory with the necessary files and directories:
- Download the medrec_tutorial.zip file from http://edocs.bea.com/wls/docs81/medrec_tutorial.zip. Save the downloaded file to the c:\medrec_tutorial directory.
- Set your command shell environment with the MedRecDomain environment script:
c:\bea\user_projects\domains\MedRecDomain\setEnv.cmd- Move to the MedRec project directory and unpack the downloaded .zip file:
cd c:\medrec_tutorialjar xvf medrec_tutorial.zipStep 3: Verify the project directory contents.
Verify that the following files and subdirectories were created:
dirDirectory of C:\medrec_tutorial02/13/2003 08:59a <DIR> .
02/13/2003 08:59a <DIR> ..
02/13/2003 08:59a <DIR> build
02/13/2003 08:59a <DIR> dist
02/13/2003 08:59a <DIR> lib
02/13/2003 08:59a 2,782,963 medrec_tutorial.zip
02/13/2003 08:59a <DIR> META-INF
02/13/2003 08:59a 4,505 README.TXT
02/13/2003 08:59a <DIR> src
02/13/2003 08:59a 299 substitute.xml
The \build directory contains the compiled classes generated by the various MedRec build scripts. It does not contain editable source files or deployment descriptors, which reside in \src. Each subdirectory in \build represents the compiled classes for MedRec clients (\client) or for a MedRec application (\medrec, \physician, and \startup applications).
If you look at the contents of the \build directory, you notice that certain classes have already been built for you. These include utility classes and the MedRec value objects that many applications in the MedRec tutorial require. Having these classes prebuilt allows you to concentrate on compiling Enterprise Applications using the WebLogic wlcompile task, as described in Tutorial 7: Compiling Applications Using the Split Development Directory.
The \src directory contains the full source for all MedRec applications. You will be working in this directory for most remaining tutorials. Step 4: Verify the source directory contents. describes the subdirectories in \src.
\build and \src together represent a WebLogic Server split development directory. You can deploy individual MedRec applications to a development server by targeting an application subdirectory in \build (such as \build\medrecEar) using weblogic.Deployer or the wldeploy ant task described in Tutorial 9: Deploying MedRec from the Development Environment. WebLogic Server locates the necessary deployment descriptors (available in \src) by examining the .beabuild.txt file located in \build subdirectory.
The \dist directory is also an output directory - it will store the archived .ear files or exploded .ear directories created by the wlpackage task in Tutorial 14: Packaging MedRec for Distribution. Right now it contains only the MedRecService.wsdl file which is required to compile parts of the physicianEar application in Tutorial 7: Compiling Applications Using the Split Development Directory. It will eventually store complete, exploded .ear directories for the different MedRec applications. \dist is not considered part of the split development directory structure, because it is not required for compiling or deploying applications during development. It is used only for storing final, completed applications - .ear files or exploded .ear directories - that you generate after completing the development process.
\lib contains precompiled, third-party .jar files that several of the MedRec applications require. This includes supporting .jars for struts and log4j.
Step 4: Verify the source directory contents.
The \src subdirectory contains the full application source for the MedRec applications, and it is the subdirectory in which you will spend the most time during the remaining tutorials. Take a look at the installed \src directory:
dir srcDirectory of C:\medrec_tutorial\src
02/13/2003 11:22p <DIR> .
02/13/2003 11:22p <DIR> ..
02/13/2003 11:22p 1,909 build.xml
02/13/2003 11:22p <DIR> clients
02/13/2003 11:22p <DIR> common
02/13/2003 11:23p 3,479 medrec.properties
02/13/2003 11:22p <DIR> medrecEar
02/13/2003 11:22p <DIR> physicianEar
02/13/2003 11:22p <DIR> security
02/13/2003 11:22p <DIR> startupEar
The build.xml file in the top level of the medrec_tutorial directory is a project-wide build file. It:
- Cleans up previously-built versions of MedRec before compiling
- Builds the contents of each application subdirectory into the \build directory by calling each application's build.xml file
- Packages each application as an exploded .ear file into the \dist directory
You will use this project-level build.xml before moving the WebLogic Server instance into production mode in Tutorial 13: Compiling the Entire MedRec Project. However, do not try to use it yet - you need to complete the next few tutorials to create the application-level build.xml files that this script calls.
The subdirectories of \src represent either deployable MedRec applications or MedRec components that are used by those applications:
- \clients holds source files for the Java and C# clients of MedRec Web Services.
- \common holds source files for Java classes shared between the MedRec Enterprise Applications. These include:
- Shared constants and JNDI names
- The ServiceLocator class, used to access MedRec services in the service tier
- Factories for creating EJBs and JMS connections
- Value objects, which represent data passed between tiers of the MedRec application
- Image files and Struts action classes shared across MedRec web components
- The \medrecEar and \physicianEar subdirectories store the main Enterprise Applications that make up the MedRec application suite. These subdirectories use the WebLogic Server 8.1 Development Directory structure and ant tasks for building and deploying, and are described in detail in the next tutorials.
- The \security subdirectory contains the MedRec authentication provider shared across applications.
- The \startupEar subdirectory contains the startup class that automatically boots the browser and loads MedRec's main index JSP when you start MedRec on a Windows machine. You do not work directly with this application in the tutorials that follow. However, the application is compiled as part of the overall MedRec build process.
Step 5: Edit the \src\medrec.properties file and run substitute.xml.
\src also contains a medrec.properties file that defines property values used by the project-level build.xml file, as well as the build.xml files used in each applications subdirectory. Follow these instructions to edit the properties file so that it points to your tutorial domain and project directory:
- Use a text editor to open the properties file:
notepad c:\medrec_tutorial\src\medrec.properties- Edit the wl.home property to point to your WebLogic Server installation directory (c:/bea/weblogic81 by default):
wl.home=c:/bea/weblogic81- Edit the medrec.domain.dir property to point to the MedRecDomain directory you created:
medrec.domain.dir=c:/bea/user_projects/domains/MedRecDomain- Edit the medrec.home property to point to your new project directory:
medrec.home.dir=c:/medrec_tutorial- The remaining property definitions build on medrec.home and you do not need to modify them.
- Save your changes and exit the editor.
- Go to the c:\medrec_tutorial directory and run the substitute.xml script:
cd c:\medrec_tutorialant -f substitute.xmlThis script substitutes a variable in the project files with the path to your WebLogic home directory.
Best Practices
- Smaller J2EE projects may not require the nested subdirectories found in the MedRec project directory. For example, a project that produces a single Enterprise application file can have minimal subdirectories such as:
- \myProject - top-level project directory
- \myProject\myEarBuild - output directory for storing compiled and generated files
- \myProject\myEarSrc - source files and editable content for the Enterprise Application
This minimal directory structure still allows you to develop your application using the WebLogic split development directory structure and ant tasks described in Tutorial 6: Understanding the WebLogic Server Split Directory Structure.
The MedRec application suite consists of three separate applications for the patient, physician, and administrator user roles. Using a separate application for each user role allows you to distribute each application function across different WebLogic Server instances as needed. For example, the MedRec sample domain (optionally installed with WebLogic Server) deploys all three applications on a single server instance for easy demonstration purposes. The MedRec tutorials also deploy the applications in a single-server domain, which is typical for development environments. However, you can also deploy the MedRec and Physician applications on two different server instances (in separate domains) to illustrate the use of Web Services between the applications.
The MedRec project directory also contains subdirectories for compiling the client applications that access MedRec via Web Services.
Related Reading