A sample ejb-jar.xml (EJB 3.0)
ejb-jar.xml
is optional starting from EJB 3.0. Annotations are extensively used to declare metadata in place of descriptor elements. In certain cases, ejb-jar.xml
is still necessary, and 2 such cases I can think of are the declaration of env-entry
and default interceptor.
<?xml version="1.0" encoding="UTF-8"?>This ejb-jar.xml assumes that TestBean is already annotated with either
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>TestBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/fooremote</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>test.FooRemoteIF</remote>
</ejb-ref>
<env-entry>
<description>admin email</description>
<env-entry-name>adminEmail</env-entry-name>
<env-entry-value>admin@example.x</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
<interceptors>
<interceptor>
<interceptor-class>test.Interceptor1</interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>test.Interceptor1</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
@Stateless
or @Stateful
. The descriptor adds a env-entry resource to this session bean's naming environment. This env-entry can be injected into TestBean class, or looked up in TestBean's naming environment.The interceptor-binding element binds Interceptor1 to all EJBs packaged in the current ejb jar.
6 comments:
you can use interceptors without ejb-jar.xml
you can annotate your bean with
@Interceptors({InterceptorClass.class})
@Interceptors can only be used for class-level and method-level interceptors. For default interceptors, which apply to all EJBs in the ejb jar, you have to use ejb-jar.xml.
Hello Webmaster,
I'm a webmaster for www.houseofmemory.com website, I've found your website information and advice to be a very good fit for our visitors so could you please give us the best price for a site wide link on your esteemed website for a period of half and 1 Year? We will make payments Via PayPal so if interested, please mention your PayPal id.
If we are happy with your price, then we will send you the Link details that you can place on your website and we will make the payments to the PayPal id provided by you.
Regards,
Peter Freeman
www.houseofmemory.com
Great and Useful Article.
Online Java Course
Java Online Training
Java Course Online
J2EE training
online J2EE training
Best Recommended books for Spring framework
Java Interview Questions
Java Training Institutes in Chennai
Java Training in Chennai
J2EE Training in Chennai
java j2ee training institutes in chennai
I enjoyed on reading your blog post. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. Please visit my website, Friv 4000 Games is where all the free friv games.
Friv 4000
blogspot
hack7
Post a Comment