This document describes the naming conventions that the BluePrints team uses for its sample applications. These conventions pertain to the various components and modules in the Java 2 Platform, Enterprise Edition (J2EE). By applying these conventions, your modules and components will be easier to identify and organize, thus enhancing their maintenance and promoting better coordination on large projects.
All conventions described here are compliant to Code Conventions for the Java Programming Language.
This includes the archive names and the display names in the deployment descriptors for a J2EE application and the different J2EE modules and also the base name for a J2EE component. A J2EE application is packaged as an Enterprise ARchive (EAR) file with a .ear extension. Enterprise JavaBeans modules are packaged as JAR files with a .jar extension. Web modules are packaged as JAR files with a .war (Web ARchive) extension.
Description | References in the Code Conventions | |
---|---|---|
Application Name | The application name is used as the application archive name. By default, the application name should be indicative of the application and should be
written in all-lowercase ASCII letters. In case of conflict, the application name should be a more specific and descriptive version:
Application archive:
Example: petstore.ear // enterprise archive
or (in case of conflict): The application display name (in the application deployment descriptor) is the expanded 1 application name written in mixed cases: Example: or (in case of conflict): |
Follows naming conventions for packages |
Enterprise JavaBeans (EJB) Module Name | The module name is used as the EJB archive name. By default, the module name should be based on the package name and should be
written in all-lowercase ASCII letters. In case of conflict, the module name should be a more specific version (including other part of the package name):
EJB archive:
EJB client archive:
Example: or (in case of conflict): The module display name (in the EJB deployment descriptor) is the expanded module name written in mixed cases: Example: or (in case of conflict): |
Follows naming conventions for packages |
Web Module Name | The module name is used as the web archive name. By default, the module name should be based on the package name and should be
written in all-lowercase ASCII letters. In case of conflict, the module name should be a more specific version (including other part of the package name):
Web archive:
Applet client archive:
Midlet client archive:
Application client archive:
Example: or (in case of conflict): bppetstore-applet-client.jar // Applet archive The module display name (in the Web deployment descriptor) is the expanded module name written in mixed cases: Example: or (in case of conflict): |
Follows naming conventions for packages |
Component Name | The component is the base name of the EJB or web component class name and should be
written in mixed case with the first letter of each internal word capitalized.
Example: |
Follows naming conventions for classes |
This includes naming conventions for the different parts of an enterprise bean. Wherever these names go in the deployment descriptor, it has been specified. The conventions listed here does not mention the type of the bean explicitly, except for the display name in the deployment descriptor.
Description |
References in the Code Conventions |
|
---|---|---|
Entity Bean | Local interface:
<component-name> or
<component-name>
Local
Local home interface:
Remote interface:
Remote home interface:
Implementation class:
Primary key implementation: <component-name>
PK
Abstract schema: Name in the EJB deployment descriptor:
Display name in the EJB deployment descriptor:
|
Follows naming conventions for classes |
Session Bean | Local interface:
<component-name>
or
<component-name>
Local
Local home interface:
Remote interface:
Remote home interface:
Implementation class:
Name in the EJB deployment descriptor:
Display name in the EJB deployment descriptor:
|
Follows naming conventions for classes |
Message Driven Bean | Implementation class:
<component-name>
Bean
Name in the deployment descriptor:
Display name in the EJB deployment descriptor:
|
Follows naming conventions for classes |
This includes naming conventions for Servlets and JavaServer Pages TM and their related artifacts like Servlet filters and JavaServer Pages TM tags
Description |
References in the Code Conventions |
|
---|---|---|
Servlet | Implementation class:
<component-name>
Servlet
Name in the Web deployment descriptor:
Display name in the Web deployment descriptor:
|
Follows naming conventions for classes |
Filter | Implementation:
<component-name>
Filter
Name in the Web deployment descriptor:
Display name in the Web deployment descriptor:
|
Follows naming conventions for classes |
Listener | For classes implement following listener interfaces:
Implementation:
Name in the Web deployment descriptor:
Display name in the Web deployment descriptor:
|
Follows naming conventions for classes |
JavaServer Pages TM | JSP (file) name should always begin with a lower-case letter. The name may consists of multiple words, in which case the words are placed immediately adjacent and each word commences with an upper-case letter. A JSP name can be just a simple noun or a short sentence. A verb-only JSP name should be avoided, as it does not convey sufficient information to developers.
Example:
Here're conventions for other file types.
|
Follows Code Convention for the Java Server Pages |
JavaServer Pages TM Tag Names |
|
Follows Code Convention for the Java Server Pages |
This includes naming conventions for Web service clients and endpoints and the necessary configuration files.
Description |
References in the Code Conventions |
|
---|---|---|
Service Name | The service name is the base name of the EJB or JAX-RPC endpoint class name and should be
written in mixed case with the first letter of each internal word capitalized.
Example: |
Follows naming conventions for classes |
EJB service endpoint | Service endpoint interface :
<service-name>
SEI
Service implementation class :
|
Follows naming conventions for classes |
JAX-RPC service endpoint | Service endpoint interface :
<service-name>
SEI
Service implementation class :
|
Follows naming conventions for classes |
JAX-RPC message handler | Client side handler :
<service-name>
ClientHandler
Server side handler :
|
Follows naming conventions for classes |
Configuration files | WSDL file :
<service-name>
Example: JAX-RPC mapping file :
Example: wscompile configuration file :
Example: wscompile configuration file for client :
Example: |
EJB reference name is the logical name you use in your source code for a JNDI lookup of the home interface of the referenced bean. This name also apperas as the value of the ejb-ref-name element within the ejb-ref element in the deployment decriptor of the referencing component.
Web service reference name is the name used by Web service clients for a JNDI lookup to obtain a reference to a Web service. This name also apperas as the value of the service-ref-name element within the service-ref element in the deployment decriptor of the referencing component.
Resource reference name and resource environment reference name are used by components for a JNDI lookup of the connection factories and resources. The referencing component also declares these names in its deployment decriptor . Resource reference name apperas as the value of the res-ref-name element within the resource-ref element in the deployment decriptor . Resource environment reference name appears as the value of the resource-env-ref-name element within the resource-env-ref element
Environment entry names are the names used by a component for a JNDI lookup of some customizable parameters. T his name also apperas as the value of the env-entry-name element within the env-entry element in the deployment decriptor of the component.
All the reference names are relative to java:comp/env.
Description | References in the Code Conventions | |
---|---|---|
EJB References | By default, the EJB reference name should be based on the component name. The component name should be written
in mixed case with the first letter of each internal word capitalized
If you have only the local or the remote interface, you may want to use just
In case of conflict, the EJB reference name should be a more specific version of the component name. Example: Say you have a
Customer EJB module (
In case, the Customer module had two ContactInfo objects: one for customer, and one for supplier; the names will be: |
Follows naming conventions for classes |
Web service references | The Web service reference name should be based on the service name. The service name should be written
in mixed case with the first letter of each internal word capitalized
Example: |
|
Resource References |
The resource reference name should be based on the resource name. The resource name should be written in mixed case with the first letter of each internal word capitalized
|
|
Environment Entries |
The paramter name should be written in mixed case with the first letter of each internal word capitalized. Parameters may be grouped under a common context name. Example: |
This applies to the databases that map to CMP entity beans. This convention does not apply when you are mapping CMP entities to a prexisting schema, since the database entities already have names.
Description |
References in the Code Conventions |
|
---|---|---|
Database | If your organization already has a convention for database naming, follow that. Otherwise, name CMP databases after the application.
For example: PetStore DB |
Description | References in the Code Conventions | |
---|---|---|
XML Documents | One possible notation:
Element names follow the code convention of class names and should be written in mixed case with the first letter of each internal word capitalized. Attribute names follow the code convention of variable names and should be written in mixed case with a lower case first letter. Enumerated Attribute values follow the code convention of constants and should be written in upper case with words seperated by underscores. Example: Another possible notation: Element names are written in lower case with words separeted by a hyphen '-'. Attribute names follow the code convention of variable names and should be written in mixed case with a lower case first letter. Enumerated attribute values follow the code convention of constants and should be written in upper case with words seperated by underscores. Example: Any other notation as long as it is consistent across your application |
Follows Classes, Variable, Constant |
Description | References in the Code Conventions | |
---|---|---|
Deployment Descriptors 2 |
J2EE application deployment descriptor:
application.xml
J2EE application client deployment descriptor:
Web services deployment descriptor:
EJB deployment descriptor:
Sun Java System Application Server specific EJB deployment descriptor:
Web deployment descriptor:
Sun Java System Application Server specific Web deployment descriptor:
Manifest file for the J2EE application client archive:
Manifest file for the EJB archive:
|
1 All abbreviations expanded, like “OrderProcessingCenter” for OPC.
2 Note that these file names are not the actual names that exist in the jar files. The actual names are fixed as per relevant specifications. For example, all the manifest files are named as
MANIFEST.MF
and placed in the
META-INF/
directory inside the jar files. The names
application-client-manifest.mf
or
ejb-jar-manifest.mf
are prototype names that help in distinguishing them from each other when they are placed in the same source directory.