<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
        version="3.0">
   <description>jBoss test application</description>
   <display-name>Test</display-name>
   <enterprise-beans>
      <session>
         <ejb-name>Teller</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Teller</remote>
         <ejb-class>org.jboss.ejb3.test.bank.TellerBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <ejb-ref>
            <ejb-ref-name>ejb/Bank</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <remote>org.jboss.ejb3.test.bank.Bank</remote>
            <ejb-link>Bank</ejb-link>
            <injection-target>
               <injection-target-class>org.jboss.ejb3.test.bank.TellerBean</injection-target-class>
               <injection-target-name>bank</injection-target-name>
            </injection-target>
         </ejb-ref>
         <post-construct>
		     <lifecycle-callback-method>postConstruct</lifecycle-callback-method>
		 </post-construct>
         <security-identity>
            <run-as>
               <role-name>bankTeller</role-name>
            </run-as>
         </security-identity>
      </session>
      <session>
         <ejb-name>Bank</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Bank</remote>
         <ejb-class>org.jboss.ejb3.test.bank.BankBean</ejb-class>
         <session-type>Stateful</session-type>
         
         <init-method>
            <create-method>
               <method-name>init</method-name>
            </create-method>
            <bean-method>
               <method-name>init</method-name>
            </bean-method>
         </init-method>
         <remove-method>
            <bean-method>
               <method-name>remove</method-name>
            </bean-method>
            <retain-if-exception>false</retain-if-exception>
         </remove-method>
	
		 <transaction-type>Container</transaction-type>

         <env-entry>
            <env-entry-name>org.jboss.ejb3.test.bank/id</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>5678</env-entry-value>
         </env-entry>
         <resource-ref>
            <res-ref-name>customerDb</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
            <mapped-name>${test.datasource.jndi}</mapped-name>
            <injection-target>
               <injection-target-class>org.jboss.ejb3.test.bank.BankBean</injection-target-class>
               <injection-target-name>customerDb</injection-target-name>
            </injection-target>
         </resource-ref>
      </session>
      <session>
         <ejb-name>Bank21</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Bank</remote>
         <ejb-class>org.jboss.ejb3.test.bank.BankBean21</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Container</transaction-type>
         <resource-ref>
            <res-ref-name>customerDb</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
            <mapped-name>${test.datasource.jndi}</mapped-name>
            <injection-target>
               <injection-target-class>org.jboss.ejb3.test.bank.BankBean21</injection-target-class>
               <injection-target-name>customerDb</injection-target-name>
            </injection-target>
         </resource-ref>
      </session>
      <entity>
         <display-name>Customer EJB</display-name>
         <ejb-name>Customer</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Customer</remote>
         <ejb-class>org.jboss.ejb3.test.bank.CustomerBean</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>org.jboss.ejb3.test.bank.CustomerPK</prim-key-class>
         <reentrant>true</reentrant>
         <cmp-version>1.x</cmp-version>
         <abstract-schema-name>customer</abstract-schema-name>
         <cmp-field>
            <description>Customer Id</description>
            <field-name>id</field-name>
         </cmp-field>
         <cmp-field>
            <description>Customer name</description>
            <field-name>name</field-name>
         </cmp-field>
         <cmp-field>
            <description>Accounts</description>
            <field-name>accounts</field-name>
         </cmp-field>
         <ejb-ref>
            <ejb-ref-name>ejb/Account</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <home>org.jboss.ejb3.test.bank.AccountHome</home>
            <remote>org.jboss.ejb3.test.bank.Account</remote>
            <ejb-link>Account</ejb-link>
         </ejb-ref>
      </entity>
      <entity>
         <display-name>Account EJB</display-name>
         <ejb-name>Account</ejb-name>
         <remote>org.jboss.ejb3.test.bank.Account</remote>
         <ejb-class>org.jboss.ejb3.test.bank.AccountBeanCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>java.lang.String</prim-key-class>
         <reentrant>true</reentrant>
         <cmp-version>1.x</cmp-version>
         <abstract-schema-name>account</abstract-schema-name>
         <cmp-field>
            <description>Account Id</description>
            <field-name>id</field-name>
         </cmp-field>
         <cmp-field>
            <description>Account owner name</description>
            <field-name>owner</field-name>
         </cmp-field>
         <cmp-field>
            <description>Account balance</description>
            <field-name>balance</field-name>
         </cmp-field>
         <primkey-field>id</primkey-field>
         <ejb-ref>
            <ejb-ref-name>ejb/Customer</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <home>org.jboss.ejb3.test.bank.CustomerHome</home>
            <remote>org.jboss.ejb3.test.bank.Customer</remote>
            <ejb-link>Customer</ejb-link>
         </ejb-ref>
         <query>
            <query-method>
               <method-name>findLargeAccounts</method-name>
               <method-params>
                  <method-param>int</method-param>
               </method-params>
            </query-method>
            <ejb-ql><![CDATA[
               select object(a) 
               from account a
               where a.balance > ?1
            ]]></ejb-ql>
         </query>
      </entity>
   </enterprise-beans>

   <interceptors>
      <interceptor>
         <interceptor-class>org.jboss.ejb3.test.bank.FirstInterceptor</interceptor-class>
         <around-invoke>
            <method-name>oneMethod</method-name>
         </around-invoke>
      </interceptor>   
      <interceptor>
         <interceptor-class>org.jboss.ejb3.test.bank.SecondInterceptor</interceptor-class>
         <around-invoke>
            <method-name>twoMethod</method-name>
         </around-invoke>
      </interceptor>   
      <interceptor>
         <interceptor-class>org.jboss.ejb3.test.bank.ExternalCallbackListener</interceptor-class>
         <post-construct>
            <lifecycle-callback-method>postConstruct</lifecycle-callback-method>
         </post-construct>
         <pre-destroy>
            <lifecycle-callback-method>preDestroy</lifecycle-callback-method>
         </pre-destroy>
         <post-activate>
            <lifecycle-callback-method>postActivate</lifecycle-callback-method>
         </post-activate>
         <pre-passivate>
            <lifecycle-callback-method>prePassivate</lifecycle-callback-method>
         </pre-passivate>
      </interceptor>   
   </interceptors>

   <assembly-descriptor>
      <security-role>
         <role-name>bankCustomer</role-name>
      </security-role>
      <security-role>
         <role-name>bankTeller</role-name>
      </security-role>

      <method-permission>
         <role-name>bankCustomer</role-name>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetChecked</method-name>
         </method>
      </method-permission>
      <method-permission>
         <unchecked/>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetUnchecked</method-name>
         </method>
      </method-permission>
      <method-permission>
         <role-name>bankTeller</role-name>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>storeCustomerId</method-name>
         </method>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>retrieveCustomerId</method-name>
         </method>
      </method-permission>

      <container-transaction>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetWithNotSupportedTransaction</method-name>
         </method>
         <trans-attribute>NotSupported</trans-attribute>
      </container-transaction>
      <container-transaction>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>greetWithRequiredTransaction</method-name>
            <method-params>
               <method-param>java.lang.String</method-param>
            </method-params>
         </method>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>testTransactionTimeout</method-name>
         </method>
         <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
         <method>
            <ejb-name>Bank</ejb-name>
            <method-name>testTransactionTimeout</method-name>
         </method>
         <trans-attribute>RequiresNew</trans-attribute>
      </container-transaction>

      <interceptor-binding>
         <ejb-name>Bank</ejb-name>
         <interceptor-class>org.jboss.ejb3.test.bank.ExternalCallbackListener</interceptor-class>
         <interceptor-class>org.jboss.ejb3.test.bank.FirstInterceptor</interceptor-class>
		 <interceptor-class>org.jboss.ejb3.test.bank.SecondInterceptor</interceptor-class>
      </interceptor-binding>
      <interceptor-binding>
         <ejb-name>Bank21</ejb-name>
         <interceptor-class>org.jboss.ejb3.test.bank.FirstInterceptor</interceptor-class>
		 <interceptor-class>org.jboss.ejb3.test.bank.SecondInterceptor</interceptor-class>
      </interceptor-binding>

      <exclude-list>
         <method>
            <ejb-name>Teller</ejb-name>
            <method-name>excludedMethod</method-name>
         </method>
      </exclude-list>
   </assembly-descriptor>
</ejb-jar>
