<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd'> 

<ejb-jar>
   <description>
      This component is used to track basic information about people. 
   </description>

   <display-name>Personnel Component</display-name>

   <enterprise-beans>
      <entity>
         <description>
	    This bean is used to track the individual state of each person.
         </description>
	 <display-name>Person Bean</display-name>

	 <!-- ejb-name
	      This field provides a unique name within this deployment
	      descriptor. There is no direct relationship between this
	      value and the resultant jndi context it is stored.
              -->
	 <ejb-name>Person</ejb-name>

	 <home>ejava.examples.personnel.ejb20.PersonRemoteHome</home>
	 <remote>ejava.examples.personnel.ejb20.PersonRemote</remote>
	 <local-home>ejava.examples.personnel.ejb20.PersonLocalHome</local-home>
	 <local>ejava.examples.personnel.ejb20.PersonLocal</local>
	 <ejb-class>ejava.examples.personnel.ejb20.PersonEJB</ejb-class>

	 <persistence-type>Container</persistence-type>
	 
	 <!-- prim-key-class - lists the primary key class for the bean. 
	    Note that this class is only _required_ when more than one
	    of the bean's fields makeup the primary key for the object.
	    Its public attributes must contain attributes that match in 
	    name and type with the primary key attributes of the object.
	    
	    One can use the primkey-field property if only a single 
	    attribute is necessary.
	    -->
	 <prim-key-class>ejava.examples.personnel.ejb20.PersonPK</prim-key-class>
	 <reentrant>False</reentrant>
	 <abstract-schema-name>Person</abstract-schema-name>

         <!-- cmp-field - describes a container managed attribute -->
	 <cmp-field> <field-name>id</field-name> </cmp-field>
	 <cmp-field> <field-name>firstName</field-name> </cmp-field>
	 <cmp-field> <field-name>lastName</field-name> </cmp-field>
	 <cmp-field> <field-name>address</field-name> </cmp-field>
	 <cmp-field> <field-name>phoneNumber</field-name> </cmp-field>

         <!-- primkey-field - lists a single attribute within the bean
	      that acts as the primary key for the object. This is not
	      used when a primarykey-class is used
          <primary-field></primary-field>
	      -->

         <!-- env-entry - lists properties that will be placed in the 
	      bean's environment at run-time.
	      -->
	 <env-entry>
	    <description>This is a sample env entry.</description>
	    <env-entry-name>example</env-entry-name>
	    <env-entry-type>java.lang.String</env-entry-type>
	    <env-entry-value>Sample Environment Value</env-entry-value>
	 </env-entry>

	 <!-- ejb-ref 
	      This contains the value in the code that the bean will use
	      to locate other beans. It won't be used in this bean.
	      -->
	 <!--
	 <ejb-ref>
	    <description></description>
	    <ejb-ref-name></ejb-ref-name>
	    <ejb-ref-type>Session or Entity</ejb-ref-type>
	    <home></home>
	    <remote></remote>
	    <ejb-link></ejb-link>
	 </ejb-ref>
	 -->
	 
	 <!-- security-role-ref
	      Lists names or security roles specifically tested with the
	      code. This allows the assembler to map the code's value to
	      a role defined in the security-role section. This bean will
	      be using declarative security and thus will not use this
	      feature.
	      -->
         <!--
	 <security-role-ref>
	    <description>MyAdmin is hardcoded within bean.</description>
	    <role-name>MyAdmin<role-name>
	    <role-link>Admin<role-link>
	 </security-role-ref>
	 -->

         <!-- resource-ref 
	    Lists resources the bean code is coded to search for in the
	    the environment. Examples of this would include connection
	    pools for Bean Managed Persistence. This will not be used 
	    in this bean.
	    -->
         <!--
	 <resource-ref>
	    <res-ref-name>jdbc/personnelDB</res-ref-name>
	    <res-type>javax.sql.DataSource</res-type>
	    <res-auth>Container</res-auth>
	 </resource-ref>
	 -->
         
	 <!-- query - defines queries to the container in terms of the 
	      java classes so that the deployment descriptor stays 
	      portable while allowing the conatiner to map the query to its
	      persistence mechanism.
              -->
         <query>
	    <query-method>
	       <method-name>findByName</method-name>
	       <method-params>
	          <method-param>java.lang.String</method-param> <!-- fname -->
	          <method-param>java.lang.String</method-param> <!-- lname -->
	       </method-params>
	    </query-method>
	    <ejb-ql>
	       SELECT OBJECT(p) FROM Person p 
	       WHERE p.firstName = ?1 AND p.lastName = ?2
	    </ejb-ql>
         </query>
         <query>
	    <query-method>
	       <method-name>findAll</method-name>
	       <method-params/>
	    </query-method>
	    <ejb-ql>
	       SELECT OBJECT(p) FROM Person p 
	    </ejb-ql>
         </query>
         <query>
	    <query-method>
	       <method-name>findByAddress</method-name>
	       <method-params>
	          <method-param>java.lang.String</method-param> <!-- fname -->
	       </method-params>
	    </query-method>
	    <ejb-ql>
	       SELECT OBJECT(p) FROM Person p 
	       WHERE p.address = ?1
	    </ejb-ql>
         </query>
         <query>
	    <query-method>
	       <method-name>ejbSelectPhoneNumbers</method-name>
	       <method-params/>
	    </query-method>
	    <ejb-ql>
	       SELECT DISTINCT p.phoneNumber FROM Person p 
	    </ejb-ql>
         </query>

      </entity>

      <entity>
         <description>
	    This bean is used to generate unique IDs.
         </description>
	 <display-name>UIDGenerator Bean</display-name>

	 <ejb-name>UIDGenerator</ejb-name>
	 <local-home>ejava.examples.uid.ejb.UIDGeneratorLocalHome</local-home>
	 <local>ejava.examples.uid.ejb.UIDGeneratorLocal</local>
	 <ejb-class>ejava.examples.uid.ejb.UIDGeneratorEJB</ejb-class>
	 <persistence-type>Bean</persistence-type>
	 <prim-key-class>java.lang.Integer</prim-key-class>
	 <reentrant>False</reentrant>
	 
	 <env-entry>
	    <description>Name of UID table in DB.</description>
	    <env-entry-name>jdbc/tableName</env-entry-name>
	    <env-entry-type>java.lang.String</env-entry-type>
	    <env-entry-value>UIDSequence</env-entry-value>
	 </env-entry>

	 <resource-ref>
	    <res-ref-name>jdbc/uidDB</res-ref-name>
	    <res-type>javax.sql.DataSource</res-type>
	    <res-auth>Container</res-auth>
	 </resource-ref>
      </entity>

      <session>
         <description>
	    Used to handle actions that span people or beans required for
	    use with people.
         </description>

	 <ejb-name>Registrar</ejb-name>
	 <home>ejava.examples.personnel.ejb20.RegistrarRemoteHome</home>
	 <remote>ejava.examples.personnel.ejb20.RegistrarRemote</remote>
	 <ejb-class>ejava.examples.personnel.ejb20.RegistrarEJB</ejb-class>
	 <session-type>Stateless</session-type>
	 <transaction-type>Container</transaction-type>
	 <ejb-ref>
	    <description>Used to generate unique IDs</description>
	    <ejb-ref-name>ejb/UIDGeneratorLocalHome</ejb-ref-name>
	    <ejb-ref-type>Entity</ejb-ref-type>
	    <home>ejava.examples.uid.ejb.UIDGeneratorLocalHome</home>
	    <remote>ejava.examples.uid.ejb.UIDGeneratorLocal</remote>
	    <ejb-link>UIDGenerator</ejb-link>
	 </ejb-ref>
	 <ejb-ref>
	    <description>Used to manage person records</description>
	    <ejb-ref-name>ejb/PersonLocalHome</ejb-ref-name>
	    <ejb-ref-type>Entity</ejb-ref-type>
	    <home>ejava.examples.personnel.ejb20.PersonLocalHome</home>
	    <remote>ejava.examples.personnel.ejb20.PersonLocal</remote>
	    <ejb-link>Person</ejb-link>
	 </ejb-ref>
      </session>
   </enterprise-beans>
   
   <!-- assembly-descriptor
        This contains optional information that may be used during
	application assembly.
	-->
   <assembly-descriptor>
      <!-- security-role
           This contains one or more names of security roles that will
	   interface with the bean.
	   -->
      <security-role>
         <description>Allowed read/write to obejcts</description>
	 <role-name>Admin</role-name>
      </security-role>
      <security-role>
         <description>Allowed read-only access to objects</description>
	 <role-name>User</role-name>
      </security-role>

      <method-permission>
         <description>These are the writable methods.</description>
	 <role-name>Admin</role-name>
	 <method>
	    <!-- ejb-name - names a bean from the deployment descriptor -->
	    <ejb-name>Person</ejb-name>
	    <!-- method-intf - Remote, Home, Local, or LocalHome.  Required 
	         only if appears in multiple interfaces and must
		 distringuish between them.
		 -->
	    <method-intf>Home</method-intf>
	    <method-name>create</method-name>

	    <!-- method-params - Required only of method overloaded. -->
	    <method-params>
	       <method-param>java.lang.String</method-param> <!-- id -->
	    </method-params>
	 </method>

	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>create</method-name>
	    <method-params>
	       <method-param>java.lang.String</method-param> <!-- id -->
	       <method-param>java.lang.String</method-param> <!-- firstName -->
	       <method-param>java.lang.String</method-param> <!-- lastName -->
	       <method-param>java.lang.String</method-param> <!-- address -->
	       <method-param>java.lang.String</method-param> <!-- phNumber -->
	    </method-params>
	 </method>

	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>create</method-name>
	    <method-params>
	       <method-param>ejava.examples.personnel.Person</method-param>
	    </method-params>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>remove</method-name>
	    <method-params>
	       <method-param>java.lang.Object</method-param>
	    </method-params>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>remove</method-name>
	    <method-params>
	       <method-param>javax.ejb.Handle</method-param>
	    </method-params>
	 </method>

	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>setFirstName</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>setLastName</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>setAddress</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>setPhoneNumber</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>setValues</method-name>
	 </method>
      </method-permission>

      <method-permission>
         <description>These are the read-only methods</description>
	 <role-name>Admin</role-name>
	 <role-name>User</role-name>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>findByPrimaryKey</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>findByName</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>findAll</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>findByAddress</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>getFirstName</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>getLastName</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>getAddress</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>getPhoneNumber</method-name>
	 </method>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>getValues</method-name>
	 </method>
      </method-permission>

      <!-- container-transaction
           These properties allow the assembler to determine the
	   transactional properties of each bean method.
	   -->
      <container-transaction>
         <description></description>
	 <method>
	    <ejb-name>Person</ejb-name>
	    <method-name>*</method-name>
	 </method>
	 
	 <!-- trans-attribute
	      NotSupported, Supports, Required, RequiresNew,
	      Mandatory, or Never
	      -->
	 <trans-attribute>Required</trans-attribute>
      </container-transaction>
   
      <container-transaction>
	 <method>
	    <ejb-name>UIDGenerator</ejb-name>
	    <method-name>*</method-name>
	 </method>
	 <trans-attribute>Required</trans-attribute>
      </container-transaction>
   </assembly-descriptor>

   <!-- ejb-client-jar
        Specifies the jar file that contains classes for use by remote
	clients of the component.
	-->
   <ejb-client-jar>PersonnelClient.jar</ejb-client-jar>
</ejb-jar>
