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

    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!-- START SNIPPET: jndi -->
<beans xmlns:jencks="http://jencks.org/2.0" 
       xmlns:amq="http://activemq.org/config/1.0"
       xmlns:amqra="http://activemq.org/ra/1.0"
       xmlns:util="http://www.springframework.org/schema/util">

  <bean id="jndi" depends-on="broker"
        class="org.apache.xbean.spring.jndi.SpringInitialContextFactory" 
        factory-method="makeInitialContext"
        singleton="true">
    <property name="entries" ref="jndiEntries" />
  </bean>

  <util:map id="jndiEntries">
    <!-- PXE DB datasource -->
    <!--
    <entry key="java:comp/env/jdbc/pxe__pm">
      <bean class="org.hsqldb.jdbc.jdbcDataSource">
        <property name="database" value="jdbc:hsqldb:mem:pxe"/>
        <property name="user" value = "sa"/>
        <property name="password" value = ""/>
      </bean>
    </entry>
    -->
    
    <!-- wsn2005 jms connection factory -->
    <entry key="java:comp/env/jms/wsnotificationCF">
      <bean class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
        <constructor-arg value="${activemq.url}" />
      </bean>
    </entry>

    <!-- transaction manager -->
    <entry key="javax.transaction.TransactionManager" value-ref="transactionManager" />
    <entry key="java:comp/env/smx/TransactionManager" value-ref="transactionManager" />
    
    <!-- bootstrap context -->
    <entry key="java:comp/env/smx/BootstrapContext" value-ref="bootstrapContext" />
    
    <!-- connection context -->
    <entry key="java:comp/env/smx/ConnectionManager" value-ref="connectionManager" />
    
    <!-- Authentication service -->
    <entry key="java:comp/env/smx/AuthenticationService" value-ref="authenticationService" />
    
    <!-- Keystore manager -->
    <entry key="java:comp/env/smx/KeystoreManager" value-ref="keystoreManager" />
  </util:map>

  <!-- A managed JDBC DataSource for derby -->
  <!-- needs tranql derby
  <bean id="localDerbyMCF" class="org.tranql.connector.derby.EmbeddedXAMCF">
    <property name="databaseName" value="data/derby"/>
    <property name="createDatabase" value="true"/>
  </bean>
  <bean id="localDerbyDataSource" class="org.springframework.jca.support.LocalConnectionFactoryBean">
    <property name="managedConnectionFactory" ref="localDerbyMCF"/>
    <property name="connectionManager" ref="connectionManager"/>
  </bean>
  -->
  
  <!-- A managed JMS ConnectionFactory for ActiveMQ -->
  <amqra:managedConnectionFactory 
          id="activemqMCF"
          resourceAdapter="#activemqRA" />
  <amqra:resourceAdapter 
          id="activemqRA"
          serverUrl="vm://localhost"/>
  <jencks:connectionFactory 
          id="activemqCF"
          managedConnectionFactory="#activemqMCF"
          connectionManager="#connectionManager" />
        
</beans>
<!-- END SNIPPET: jndi -->
