JBOSS JNDI Bindings

http://docs.jboss.org/ejb3/app-server/tutorial/jndibinding/jndi.html

JNDI Bindings
By default, session beans will bind to JNDI in the form ejbName/remote for remote interfaces and ejbName/local in the case of local interfaces. When the EJBs are deployed in an .ear file, the default jndi binding will be prepended by the name of the .ear file. So if the ear file name is foo.ear the default jndi names would be foo/EJB-NAME/remote and foo/EJB-NAME/local. You can override this behavior by defining your own @org.jboss.ejb3.LocalBinding or @org.jboss.ejb3.remoting.RemoteBinding.

 

Local Interface JNDI Binding.
To change the JNDI name for your local interface use the org.jboss.ejb3.LocalBinding annotation.


@Stateless
@LocalBinding(jndiBinding="custom/MySession")
public class MySessionBean implements MySession
{
}

 


Remote Interface JNDI Binding
To change the JNDI name for your remote interface use the org.jboss.ejb3.RemoteBindings annotation.


@Stateless
@RemoteBinding(jndiName="custom/remote/MySession")
public class MySessionBean implements MySession
{
}

 

Persistence unit JNDI Bindings
Persistence units are not bound into JNDI by default. You can bind them by defining some jboss specific properties in persistence.xml.
          <persistence></persistence>
             <persistence-unit name="manager1"></persistence-unit>
                <jta-data-source></jta-data-source>java:/DefaultDS
                <jar-file></jar-file>MyApp.jar
                <class></class>org.acme.Employee
                <class></class>org.acme.Person
                <class></class>org.acme.Address
                <properties></properties>
                   <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"></property>
                   <property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory"></property>
               
            
         

 

Client
Open up Client.java. You'll see that it looks up the stateless bean under "Calculator". Also notice that there is no Home interface and you can begin executing on the stateless bean right away.


Building and Running
To build and run the example, make sure you have ejb3.deployer installed in JBoss 4.0.x and have JBoss running. See the reference manual on how to install EJB 3.0.
Unix:    $ export JBOSS_HOME=<where your="" jboss="" is="" distribution=""></where>
Windows: $ set JBOSS_HOME=<where your="" jboss="" is="" distribution=""></where>
$ ant
$ ant run

run:
     [java] 1 + 1 = 2
     [java] 1 - 1 = 0

 

Jar structure
EJB 3.0 beans must be packaged in a JAR file with the suffix .jar. Running the ant script above creates a JAR file within the deploy/ directory of JBoss. All that needs to be in that jar is your server-side class files. So basically just the CalculatorBean and the interfaces it implements. JBoss will automatically browse the JAR file to determine if any EJBs are annotated by any classes within it. THere is no precompilation step.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值