ejb-jar.xml Dosyası
Açıklaması şöyle. Yani EJB 3.x kullanıyorsak bu dosyaya gerek olmayabilir.
EJB 3 beans can be configured with annotations in Java Code, Deployment Descriptors in ejb-jar.xml and a mix of both of them.
Eğer kullanacaksak şeklen şöyle
META-INF - ejb-jar.xml - ...
EJB 3.1 için XML içinde "ejb-jar_3_1.xsd" kullanılır
İskeleti şöyle.
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" version="3.1" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> ... </ejb-jar>
Örnek - MDB
Şöyle yaparız. Burada MDB için transaction desteği iptal ediliyor.
<ejb-jar ...> <display-name>My Message Driven Bean</display-name> <enterprise-beans> <message-driven> <display-name>MY_MDB</display-name> <ejb-name>MY_MDB</ejb-name> <ejb-class>com.foo.MessageBean</ejb-class> <messaging-type>com.foo.InboundMessageEndpoint</messaging-type> <transaction-type>Container</transaction-type> </message-driven> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>MY_MDB</ejb-name> <method-name>*</method-name> </method> <trans-attribute>NotSupported</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
Örnek - Session Bean
Şöyle yaparız.
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" version = "3.1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> <enterprise-beans> <session> <ejb-name>MessageFacade</ejb-name> <local-bean/> <ejb-class>com.foo.MessageFacade</ejb-class> <session-type>Stateless</session-type> </session> </enterprise-beans> </ejb-jar>
Burada artık kodda anotasyon kullanmaya gerek yok. Şöyle yaparız
public class MessageFacade { public String hello(){ return "Working without annotations"; } } public class FrontController extends HttpServlet { @EJB MessageFacade facade; ... }
jboss-ejb3.xml Dosyası
jboss-ejb3.xml is a custom deployment descriptor that can be placed in either ejb-jar or war archives. If it is placed in an ejb-jar then it must be placed in the META-INF folder, in a web archive it must be placed in the WEB-INF folder.The contents of jboss-ejb3.xml are merged with the contents of ejb-jar.xml, with the jboss-ejb3.xml items taking precedence.
Örnek
Şöyle yaparız
<jboss xmlns="http://www.jboss.com/xml/ns/javaee"xmlns:jee="http://java.sun.com/xml/ns/javaee"xmlns:mdb="urn:resource-adapter-binding"xmlns:security="urn:security:1.1"><jee:assembly-descriptor><mdb:resource-adapter-binding><jee:ejb-name>MY_MDB</jee:ejb-name><mdb:resource-adapter-name>myEar.ear#batchFileRA</mdb:resource-adapter-name></mdb:resource-adapter-binding></jee:assembly-descriptor></jboss>
Hiç yorum yok:
Yorum Gönder