Spring 定義 JBoss EJB 的方式
2011/08/10
在Spring 在 JBoss 中定義 EJB 的方式如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-2.5.xsd"> <util:map id="jndiEnv"> <entry key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory" /> <entry key="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces" /> <entry key="java.naming.provider.url" value="jnp://localhost:1099" /> </util:map> <!-- EJB 2 的寫法 --> <jee:remote-slsb id="WorkFlowEngineDS" jndi-name="WorkflowEngine" business-interface="com.dsc.nana.services.engine.WorkflowEngine" resource-ref="true" cache-home="true" lookup-home-on-startup="false" environment-ref="jndiEnv" /> <!-- 以下是 EJB 3 的寫法 --> <jee:jndi-lookup id="NaNaWorkflowEngineDS" jnd-name="WorkflowEngine" environment-ref="jndiEnv" /> <!-- 另外一種寫法 --> <bean id="remoteJndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory" /> <prop key="java.naming.provider.url" value="jnp://localhost:1099" /> <prop key="java.naming.factory.url.pkgs" value="org.jnp.interfaces:org.jboss.naming" /> </props> </property> </bean> <bean id="exportFormInst" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate" ref="remoteJndiTemplate" /> <property name="jndiName" value="WorkflowEngine" /> </bean> </beans>