歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

JndiTemplate bean配置筆記

EBJ beans.xml

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <beans xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  8.            http://www.springframework.org/schema/context  
  9.            http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  10.            http://www.springframework.org/schema/aop  
  11.            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
  12.            http://www.springframework.org/schema/tx   
  13.            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
  14.            http://www.springframework.org/schema/tx  
  15.            http://www.springframework.org/schema/tx/spring-tx.xsd">  
  16.   
  17.   
  18.     <context:component-scan base-package="com.ccl" />  
  19.     <!-- 總包下浏覽 -->  
  20.   
  21.     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
  22.         destroy-method="close">  
  23.         <property name="driverClassName" value="com.mysql.jdbc.Driver" />  
  24.         <property name="url" value="jdbc:mysql://localhost:3306/jboss" />  
  25.         <property name="username" value="root" />  
  26.         <property name="password" value="sa" />  
  27.   
  28.         <property name="initialSize" value="0" />  
  29.         <property name="maxActive" value="8" />  
  30.         <property name="maxIdle" value="8" />  
  31.         <property name="minIdle" value="0" />  
  32.         <property name="maxWait" value="-1" />  
  33.         <property name="logAbandoned" value="true" />  
  34.         <property name="removeAbandonedTimeout" value="600" /> <!-- 連接洩漏的超時刪除 -->  
  35.   
  36.     </bean>  
  37.   
  38.     <!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">   
  39.         <property name="dataSource" ref="dataSource" /> <property name="packagesToScan">   
  40.         <list> <value>com.ccl.bean</value> </list> </property> <property name="hibernateProperties">   
  41.         <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>   
  42.         <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop>   
  43.         </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">   
  44.         <property name="sessionFactory" ref="sessionFactory"></property> </bean>   
  45.         <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">   
  46.         <property name="dataSource" ref="dataSource"></property> </bean> -->  
  47.   
  48.     <!-- JDNI context -->  
  49.     <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">  
  50.         <property name="environment">  
  51.             <props>  
  52.                 <prop key="java.naming.factory.initial">  
  53.                     org.jnp.interfaces.NamingContextFactory  
  54.                 </prop>  
  55.                 <prop key="java.naming.provider.url">127.0.0.1\:1099</prop>  
  56.                 <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>  
  57.             </props>  
  58.         </property>  
  59.     </bean>  
  60.   
  61.     <!-- JMS connectionFactory -->  
  62.     <bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">  
  63.         <property name="jndiTemplate">  
  64.             <ref bean="jndiTemplate" />  
  65.         </property>  
  66.         <property name="jndiName">  
  67.             <value>UIL2ConnectionFactory</value>  
  68.         </property>  
  69.   
  70.     </bean>  
  71.   
  72.     <!-- JMS destinations -->  
  73.     <bean id="sendDestination" class="org.springframework.jndi.JndiObjectFactoryBean">  
  74.         <property name="jdniTemplate">  
  75.             <ref bean="jdniTemplate" />  
  76.         </property>  
  77.         <property name="jndiName">  
  78.             <value>queue/CreditRequestSendQueue</value>  
  79.         </property>  
  80.     </bean>  
  81.   
  82.     <bean id="receiveDestination" class="org.springframework.jndi.JndiObjectFactoryBean">  
  83.         <property name="jndiTemplate">  
  84.             <ref bean="jndiTemplate" />  
  85.         </property>  
  86.         <property name="jndiName">  
  87.             <value>queue/CreditReqeustReceiveQueue</value>  
  88.         </property>  
  89.     </bean>  
  90.   
  91.     <!-- JMS template -->  
  92.     <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">  
  93.         <property name="connectionFactory">  
  94.             <ref bean="jmsQueueConnectionFactory" />  
  95.         </property>  
  96.         <property name="defaultDestination">  
  97.             <ref bean="destination" />  
  98.         </property>  
  99.         <property name="receiveTimeout">  
  100.             <value>30000</value>  
  101.         </property>  
  102.     </bean>  
  103.   
  104.     <!-- JMS sender -->  
  105.     <bean id="jmsSender" class="com.ccl.jms.JMSSender">  
  106.         <property name="jmsTemplate">  
  107.             <ref bean="jmsTemplate" />  
  108.         </property>  
  109.     </bean>  
  110.   
  111.     <!-- JMS receiver -->  
  112.     <bean id="jmsReceiver" class="com.ccl.jms.JMSReceiver">  
  113.         <property name="jmsTemplate">  
  114.             <ref bean="jmsTemplate" />  
  115.         </property>  
  116.     </bean>  
  117.   
  118.     <!-- this is the Message Driven POJO (MDP) -->  
  119.     <bean id="messageListener" class="com.ccl.jms.SimpleListener"></bean>  
  120.   
  121.     <bean id="jmsContainer"  
  122.         class="org.springframework.jms.listener.DefaultMessageListenerContainer">  
  123.         <property name="connectionFactory" ref="jmsQueueConnectionFactory" />  
  124.         <property name="destination" ref="destination" />  
  125.         <property name="messageListener" ref="messageListener"></property>  
  126.     </bean>  
  127.   
  128.   
  129. </beans>  
MATE-INF下面
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <persistence xmlns="http://java.sun.com/xml/ns/persistence"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence  
  5.           http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"  
  6.     version="1.0">  
  7.   
  8.     <persistence-unit name="jboosdb" transaction-type="JTA">  
  9.   
  10.         <jta-data-source>java:MySqlDS</jta-data-source>  
  11.   
  12.         <properties>  
  13.   
  14.             <property name="hibernate.hbm2ddl.auto" value="update" />  
  15.   
  16.             <property name="hibernate.show_sql" value="true" />  
  17.   
  18.             <property name="hibernate.format_sql" value="true" />  
  19.   
  20.         </properties>  
  21.   
  22.     </persistence-unit>  
  23.   
  24.   
  25. </persistence>  
src:
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <server>  
  3.   
  4.     <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=jboossQueue">  
  5.   
  6.         <attribute name="JNDIName">queue/jboossQueue</attribute>  
  7.   
  8.         <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager  
  9.         </depends>  
  10.   
  11.     </mbean>  
  12.   
  13.     <mbean code="org.jboss.mq.server.jmx.Topic" name="jboss.mq.destination:service=Topic,name=jboossTopic">  
  14.   
  15.         <attribute name="JNDIName">topic/jboossTopic</attribute>  
  16.   
  17.         <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager  
  18.         </depends>  
  19.   
  20.     </mbean>  
  21.   
  22.   
  23. </server>  

jndi.properties

  1. java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory  
  2. java.naming.provider.url=127.0.0.1\:1099  
Copyright © Linux教程網 All Rights Reserved