<?xml version="1.0" encoding="UTF-8"?>

<deployment xmlns="urn:jboss:bean-deployer:2.0">

   <bean name="Repository" class="org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository"/>

   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
   </bean>

	<!-- Define the jndi binding advice -->
   <interceptor xmlns="urn:jboss:aop-beans:1.0" name="JndiAspect" class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction">
      <property name="env">
           <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
              <entry>
                 <key>java.naming.factory.initial</key>
                 <value>org.jboss.example.microcontainer.aspects.EnvInitialContextFactory</value>
              </entry>
           </map>
      </property>
   </interceptor>

   <!-- Introduce the KernelControllerContextAware interface to the JndiBinding annotation -->
   <introduction xmlns="urn:jboss:aop-beans:1.0" class="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
      <interfaces>org.jboss.kernel.spi.dependency.KernelControllerContextAware</interfaces>
   </introduction>

   <!-- Apply the jndi binding to all KernelControllerContextAware interface callbacks -->
   <bind xmlns="urn:jboss:aop-beans:1.0" name="JndiBinding" pointcut="execution(* $instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
      <interceptor-ref name="JndiAspect"/>
   </bind>

   <bean name="Bean" class="org.jboss.example.microcontainer.aspects.SimpleBean">
      <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="beans/SimpleBean", aliases={"beans/XmlAnnotatedSimpleBean"})</annotation>
   </bean>

   <bean name="AnnotatedBean" class="org.jboss.example.microcontainer.aspects.AnnotatedSimpleBean" />

   <bean name="lookup" class="org.jboss.example.microcontainer.aspects.SimpleBeanLookup">
      <property name="env">
           <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
              <entry>
                 <key>java.naming.factory.initial</key>
                 <value>org.jboss.example.microcontainer.aspects.EnvInitialContextFactory</value>
              </entry>
           </map>
      </property>
      <demand>JndiBinding</demand>
   </bean>

</deployment>
