Organizing Shared Classes in a Split Development Directory
The weblogic split develepment directory helps you store shared utility classes and libraries that are required by modules in your Enterprise Application.
Shared Utility Classes
Enterprise Applications frequantly use java utility classes that are shared among application modules.Java utility classes differ from third-party JARs in that the source files are part of the application and must be compiled. Java utility classes are typically libraries used by application modules such as EJBs or Web applications.
Place the source for Java utility classes in a named subdirectory of the top-level Enterprise Application directory. Beneath the named subdirectory, use standard package subdirectory conventions.
the wlcompile Ant task invokes the javac compiler and compiles Java classes into the APP-INF/classes/ directory under the build directory. This ensures that the classes are available to other modules in the deployed application.
Third-party JARs are generally not compiled, but may be versioned using the source control system for your application code. For example, XML parsers, logging implementations, and Web Application framework JAR files are commonly used in applications and maintained along with editable source code.
The classes and libraries stored under APP-INF/classes
and APP-INF/lib
are available to all modules in the Enterprise Application. The application classloader always attempts to resolve class requests by first looking in APP-INF/classes
, then APP-INF/lib
.
(在APP-INF/classes和APP-INF/lib下的类和jar文件能被所有的模块来调用。应用程序的类加载器经常在解决类调用请求的时候尝试先调用/classes下,然后才是/lib下)。
Organizing Libraries and Classes Shared by Multiple EARs
For single ear projects, the split develepment directory conventions suggests keeping third-party jar files in the APP-INF/lib directory of EAR source directory,However a multiple-ear project would require you to maintain a copy of the same third-party jar files in the APP-INF/lib directory of each EAR source directory.This introduces multiple copies of the source JAR files, increases the possibility of some JAR files being at different versions, and requires additional space in your source control system.
To address these problems, consider editing your build script to copy third-party JAR files into the APP-INF/lib
directory of the build directory for each EAR that requires the libraries. This allows you to maintain a single copy and version of the JAR files in your source control system, yet it enables each EAR in your project to use the JAR files.