Getting Started with Enterprise JavaBeans™

G

Appendix B

Tutorial Home Section Home Previous Section Next Section

Get

Get

Deployment

Figure B-1: The J2EE Reference Implementation deploytool
deploytool


     Enterprise JavaBean configuration is defined in deployment descriptors, which are XML documents. Tools like deploytool (pictured in Figure B-1) generate or update the descriptors when you set the configuration elements. For example, here's the relatively brief ejb-jar.xml deployment descriptor generated for MetricCvtJAR in Deploying the Metric Converter Example:

<ejb-jar>
  <display-name>MetricCvtJAR</display-name>
  <enterprise-beans>
    <session>
      <display-name>MetricCvtEJB</display-name>
      <ejb-name>MetricCvtEJB</ejb-name>
      <home>MetricCvtRemoteHome</home>
      <remote>MetricCvtRemote</remote>
      <local-home>MetricCvtLocalHome</local-home>
      <local>MetricCvtLocal</local>
      <ejb-class>MetricCvtBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>
      <security-identity>
        <description></description>
        <use-caller-identity></use-caller-identity>
      </security-identity>
    </session>
  </enterprise-beans>
</ejb-jar>

Most developers decide rather quickly that they would prefer not to do this process manually.

     J2EE deployment can be a daunting task (enough so that the EJB specification defines a role for an expert deployer) for two reasons. The first is that J2EE provides an enormous amount of declarative functionality for the developer. While this is a Good Thing, the downside is that the functionality must be declared, and with so many options, the task quickly becomes very complicated. The second is that while portions of packaging, like ejb and web descriptor elements, are mandated by the specification, the overall deployment process is not standardized; each vendor provides its own means of deployment and requires additional associated proprietary descriptors.

     deploytool hides this fact of J2EE life somewhat by generating both the standard and necessary proprietary descriptors. You can't really tell from the settings which are standard and which are proprietary to the Reference Implementation. For the curious, a look into the .ear file generated by deploytool will reveal that the J2EE RI creates its own sun-j2ee-ri.xml file that begins with a <j2ee-ri-specific-information> tag — not particularly encouraging for portability.

     The tutorial walks you through setting up the deployment descriptors and actual deployment with deploytool after the discussion for each example. If you make changes to the files referenced by the descriptors (that is, if you add, remove, or recompile them) and need to redeploy, first select "Update Files" from the Tools menu, then select "Deploy". Alternatively, you can use the "Update and Redeploy" selection.

     The following sections, taken from the J2EE XML DTD for the EJB 2.0 deployment descriptor (see Resources), show the elements that can be described for EJB components.


     The entity element declares an entity bean. The declaration consists of:

	- an optional description
	- an optional display name
	- an optional small icon file name
	- an optional large icon file name
	- a unique name assigned to the enterprise bean
	  in the deployment descriptor
	- the names of the entity bean's remote home and remote
	  interfaces, if any
	- the names of the entity bean's local home and local
	  interfaces, if any
	- the entity bean's implementation class
	- the entity bean's persistence management type
	- the entity bean's primary key class name
	- an indication of the entity bean's reentrancy
	- an optional specification of the entity bean's cmp-version
	- an optional specification of the entity bean's abstract
	  schema name
	- an optional list of container-managed fields
	- an optional specification of the primary key field
	- an optional declaration of the bean's environment entries
	- an optional declaration of the bean's EJB references
	- an optional declaration of the bean's local EJB references
	- an optional declaration of the security role references
	- an optional declaration of the security identity
	  to be used for the execution of the bean's methods
	- an optional declaration of the bean's resource manager
	  connection factory references
	- an optional declaration of the bean's
	  resource environment references
	- an optional set of query declarations
	  for finder and select methods for an entity
	  bean with cmp-version 2.x.


     The message-driven element declares a message-driven bean.  The declaration 
consists of:

	- an optional description
	- an optional display name
	- an optional small icon file name
	- an optional large icon file name
	- a name assigned to the enterprise bean in
	  the deployment descriptor
	- the message-driven bean's implementation class
	- the message-driven bean's transaction management type
	- an optional declaration of the message-driven bean's
	  message selector
	- an optional declaration of the
	  acknowledgment mode for the message-driven bean
	  if bean-managed transaction demarcation is used
	- an optional declaration of the
	  intended destination type of the message-driven bean
	- an optional declaration of the bean's environment entries
	- an optional declaration of the bean's EJB references
	- an optional declaration of the bean's local EJB references
	- an optional declaration of the security
	  identity to be used for the execution of the bean's methods
	- an optional declaration of the bean's resource manager
	  connection factory references
	- an optional declaration of the bean's resource
	  environment references.


     The session element declares an [sic] session bean. The declaration 
consists of:

	- an optional description
	- an optional display name
	- an optional small icon file name
	- an optional large icon file name
	- a name assigned to the enterprise bean
	  in the deployment description
	- the names of the session bean's remote home and
	  remote interfaces, if any
	- the names of the session bean's local home and
	  local interfaces, if any
	- the session bean's implementation class
	- the session bean's state management type
	- the session bean's transaction management type
	- an optional declaration of the bean's environment entries
	- an optional declaration of the bean's EJB references
	- an optional declaration of the bean's local EJB references
	- an optional declaration of the security role references
	- an optional declaration of the security identity to be
	  used for the execution of the bean's methods
	- an optional declaration of the bean's resource manager
	  connection factory references
	- an optional declaration of the bean's resource environment
	  references.


     You can view the generated deployment descriptors at any time by selecting the appropriate EJB jar file, then choosing "Tools"—>"Descriptor Viewer" from the deploytool menu.

     Getting Started with Enterprise JavaBeans uses the J2EE RI deploytool and takes the path of deployment by example, for the reasons above and the simple fact that explaining every option could take another complete tutorial. With the number of applications and beans in the tutorial, the developer should pick up the basic patterns fairly quickly. For more detailed information about deployment, see the J2EE and EJB specifications, along with the other Resources.



Tutorial Home Section Home Previous Section Next Section