Exploring Enterprise Java Beans – Series II

Learning EJB

ການຮຽນຮູ້ EJB,,en,ແລະພວກມັນຖືກ ນຳ ໃຊ້ຢ່າງກວ້າງຂວາງໃນການ ນຳ ໃຊ້ຫລາຍຂະ ໜາດ ໃຫຍ່,,en,ບາງຄັ້ງ,,en,ພວກເຮົາເຫັນວ່າມັນຍາກທີ່ຈະຕອບ ຄຳ ຖາມສະເພາະທີ່ຖືກຖາມໃນເວທີສົນທະນາ,,en,ການ ສຳ ພາດຫຼືສົນທະນາ,,en,ບັນຊີ ຄຳ ຖາມແລະ ຄຳ ຕອບລວບລວມນີ້ຈະຊ່ວຍໃຫ້ທ່ານມີແນວຄິດກ່ຽວກັບແນວຄວາມຄິດທີ່ກ່ຽວຂ້ອງ,,en,ສິ່ງທີ່ມີສອງໄລຍະຂອງວົງຈອນຊີວິດອື່ນໆທີ່ມີຢູ່ ສຳ ລັບການປະຊຸມເຂົ້າ ໜົມ ຖົ່ວ,,en,ອີກສອງໄລຍະຂອງວົງຈອນຊີວິດແມ່ນ,,en,ການໂທຄືນ PrePassivate,,en,ການກັບຄືນໄປບ່ອນ PostActivate,,en,ມັນມີເວລາບໍ່ທີ່ມີຄຸນຄ່າ ສຳ ລັບເມັດຖົ່ວຂອງພາກລັດ,,en,ມັນມີເວລາທີ່ບໍ່ມີຄ່າ ສຳ ລັບເມັດຖົ່ວຂອງພາກລັດ,,en,ຖ້າຖົ່ວບໍ່ຖືກ ນຳ ໃຊ້ໃນຊ່ວງເວລາ ໝົດ ເວລາ, ມັນກໍ່ຖືກລຶບຖິ້ມໂດຍພາຊະນະບັນຈຸຕົວມັນເອງ,,en,ແຕ່ຄວນແນະ ນຳ ໃຫ້ເອົາ ໝາກ ຖົ່ວອອກຫຼັງຈາກ ນຳ ໃຊ້ໂດຍບໍ່ຕ້ອງອີງໃສ່ກົນໄກການ ໝົດ ເວລາ,,en

ການ​ນໍາ​ສະ​ເຫນີ: In this EJB II series, our main objective is to take some of the most important features of EJB and answer the related concepts. EJBs are there for a long time in the market, and they are widely used in many large scale applications. ແຕ່, some time, we find it difficult to answer the specific questions asked in the forum, interviews or discussions. So, this compiled list of questions and answers will definitely give you some idea on the related concepts.







What are the two other life cycle stages available for stateful session bean?

Answer: Two other life cycle stages are
ເປັນ) PrePassivate callback
ຂ) PostActivate callback

Is there any time out value for stateful session beans?

Answer: Yes, there is a time out value for stateful session beans. If the bean is not used during the time out value then it is deleted by the container itself. But it is always advisable to remove the bean after its use without relying on the time out mechanism.

ການໃຊ້ interceptors ແມ່ນຫຍັງໃນຖົ່ວຖົ່ວຫຼື MDBs,,en,ຕົວສະກັດກັ້ນໂດຍທົ່ວໄປແມ່ນໃຊ້ເພື່ອກວດສອບຄວາມຖືກຕ້ອງ,,en,ການກວດສອບຄວາມປອດໄພກ່ອນການຮຽກຮ້ອງວິທີການຢ່າງມີເຫດຜົນທາງທຸລະກິດ,,en,ຈະເປັນແນວໃດ interceptor ໄວ້ໃນຕອນຕົ້ນ,,en,ເຄື່ອງສະກັດກັ້ນແບບ Default ແມ່ນແນວຄິດທີ່ສະ ໜອງ ໂດຍ EJB,,en,ມັນບໍ່ໄດ້ຖືກ ກຳ ນົດໂດຍ ຄຳ ບັນຍາຍໃດໆແທນທີ່ຈະຕ້ອງຂຽນຢ່າງຈະແຈ້ງໃນ ຄຳ ອະທິບາຍການ ນຳ ໃຊ້ຂອງໂມດູນ EJB,,en,ຄໍາສັ່ງຂອງການປະຕິບັດຂອງ interceptors ທີ່ແຕກຕ່າງກັນແມ່ນຫຍັງ,,en,ພວກມັນຖືກຮຽກຮ້ອງຕາມ ລຳ ດັບຕໍ່ໄປນີ້,,en,ເຄື່ອງສະກັດຕົ້ນສະບັບ,,en,ຜູ້ສະກັດກັ້ນຫ້ອງຮຽນ,,en,ວິທີການສະກັດກັ້ນວິທີການ,,en,ມັນເປັນໄປໄດ້ທີ່ຈະປິດການໃຊ້ງານຂອງການຂັດຂວາງໃດໆ,,en,ຄຳ ອະທິບາຍເຊັ່ນ @ExcludeDefaultInterceptors ແລະ @ExcludeClassInterceptors ສາມາດໃຊ້ເພື່ອປິດການ ນຳ ໃຊ້,,en,ການສັກຢາເພິ່ງພາແມ່ນຫຍັງໃນ EJB,,en?

Answer: Interceptors are generally used to check validation, security checks before the invocation of business logic methods.

What is a default interceptor?

Answer: Default interceptor is a concept provided by the EJB 3.0 specification. It is not defined by any annotation rather it has to be written explicitly in the deployment descriptor of the EJB module.

What is the order of execution of different interceptors?

Answer: They are invoked in the following order
ເປັນ) Default interceptor
ຂ) Class interceptor
c) Method interceptor

Is it possible to disable invocation of any interceptor?

Answer: Yes, Annotations like @ExcludeDefaultInterceptors and @ExcludeClassInterceptors can be used to disable invocation.

What is dependency injection in EJB 3.0 specification?

Answer: ການສັກຢາຂື້ນກັບການເພິ່ງພາອາໄສແມ່ນວິທີການທີ່ມີປະສິດທິພາບໃນການໄດ້ຮັບຊັບພະຍາກອນ Java EE ໂດຍບໍ່ຕ້ອງເບິ່ງ JNDI,,en,ມັນເຮັດໃຫ້ຄໍາຮ້ອງສະຫມັກບວກໃສ່ວ່າງ,,en,ຄຳ ບັນລະຍາຍທີ່ໃຊ້ ສຳ ລັບສັກຢາ EJB ເຂົ້າໃນລະຫັດລູກຄ້າແມ່ນຫຍັງ,,en,ຄຳ ສັ່ງທີ່ມີຊື່ວ່າ '@EJB' ແມ່ນໃຊ້ ສຳ ລັບສັກເຂົ້າ ໜົມ ຖົ່ວໃຫ້ລູກຄ້າ,,en,ຄຳ ບັນລະຍາຍທີ່ໃຊ້ ສຳ ລັບການສີດຊັບພະຍາກອນ,,en,ຄຳ ບັນຍາຍ ‘@Resource’ ຖືກໃຊ້ ສຳ ລັບການສີດຊັບພະຍາກອນ,,en,ເປັນຫຍັງການໃຊ້ຫົວສີດ,,en,ຊັບພະຍາກອນບໍ່ຄວນຖືກໃສ່ໂດຍກົງເຂົ້າໃນລະຫັດສະ ໝັກ,,en,ຊັບພະຍາກອນຄວນແຍກອອກເປັນສ່ວນປະກອບທີ່ແຕກຕ່າງກັນແລະມັນຈະເຮັດໃຫ້ລະຫັດປ່ຽນແປງໄດ້ຫຼາຍຂື້ນ,,en,ຫົວສີດທີ່ ກຳ ນົດໄວ້ແມ່ນໃຊ້ເພື່ອຮັບໃຊ້ຈຸດປະສົງນີ້,,en,ການໃຊ້ ຄຳ ອະທິບາຍການ ນຳ ໃຊ້ແມ່ນຫຍັງ,,en,ທຸກໆວຽກໃນ EJB,,en,ແມ່ນເຮັດໂດຍ ຄຳ ບັນຍາຍ,,en. It makes the application loosely coupled.

What is the annotation used for EJB injection into a client code?

Answer: The ‘@EJB annotation’ is used to inject session beans into a client.

What is the annotation used for resource injection?

Answer: The ‘@Resource’ annotation is used for injecting resources.

Why setter injection is used?

Answer: The resources should not be directly injected into application code. The resources should be separated in a different component and it will make the code more flexible. The setter injection is used to serve this purpose.

What is the usage of deployment descriptor?

Answer: All the tasks in EJB 3.0 is done by annotations. ແຕ່ສິ່ງດຽວກັນສາມາດ ດຳ ເນີນການໄດ້ໂດຍການໃຊ້ ຄຳ ອະທິບາຍການ ນຳ ໃຊ້,,en,ສະຖານທີ່ຕັ້ງຊື່ສອງຢ່າງທີ່ມີຢູ່ໃນ EJB ແມ່ນຫຍັງ,,en,ຊອງຄຸນນະສົມບັດ,,en,ຕໍ່ໄປນີ້ແມ່ນສອງສະຖານທີ່ຊື່ທີ່ມີຢູ່,,en,JVM-Scoped ejblocal,,en,ພື້ນທີ່ຊື່,,en,ພື້ນທີ່ຊື່ໂລກ JNDI,,en,ຈະເປັນແນວໃດຊື່ຂອງຮູບແບບທີ່ນໍາໃຊ້ສໍາລັບການຫຸ້ມຫໍ່ຄໍາຮ້ອງສະຫມັກວິສາຫະກິດ java ໄດ້,,en,ຊື່ຂອງຮູບແບບແມ່ນໃບສະ ໝັກ ວິສາຫະກິດ,,en,ຫູ,,en,ມັນມີທຸກໂມດູນອື່ນໆເຊັ່ນ WAR,,en,RAR ແລະອື່ນໆ,,fr,ຄຳ ອະທິບາຍການ ນຳ ໃຊ້ທີ່ໃຊ້ໃນການ ນຳ ໃຊ້ ຄຳ ຮ້ອງສະ ໝັກ ວິສາຫະກິດຈາວາແມ່ນຫຍັງ,,en,ຊື່ຂອງ ຄຳ ອະທິບາຍການ ນຳ ໃຊ້ແມ່ນ ejb-jar.xml,,en,ສິ່ງທີ່ມີການຜູກມັດສອງຢ່າງທີ່ໃຊ້ໂດຍພາຊະນະ,,en,ສອງຜູກມັດໄວ້ໃນຕອນຕົ້ນແມ່ນ,,en,ການຜູກມັດສັ້ນ,,en,ຜູກມັດຍາວ,,en,ສິ່ງທີ່ຜູກມັດສັ້ນ,,en,ໃນການຜູກມັດສັ້ນ,,en,ຊື່ຫ້ອງຮຽນທີ່ມີຄຸນນະພາບຂອງ Java ໃນການໂຕ້ຕອບແມ່ນໃຊ້ເທົ່ານັ້ນ,,en,ວິທີການປະຕິບັດການຜູກມັດຍາວ,,en,ໃນການຜູກມັດຍາວ,,en.

What are the two name spaces available in EJB 3.0 feature pack?

Answer: Following are the two name spaces available
ເປັນ) JVM-scoped ejblocal: name space
ຂ) Global JNDI name space







What is the name of the format used for packaging java enterprise applications?

Answer: The name of the format is enterprise application archive (EAR).It contains all other modules like WAR, RAR etc.

What is the name of the deployment descriptor used for deploying java enterprise application?

Answer: The name of the deployment descriptor is ejb-jar.xml.

What are the two default bindings used by the container?

Answer: The two default bindings are
ເປັນ) Short binding
ຂ) Long binding

What is short binding?

Answer: In short binding, package-qualified Java class name of the interface is only used.

How the long binding is performed?

Answer: In long binding, ID ສ່ວນປະກອບຂອງຖົ່ວຖືກໃຊ້ເປັນຄຸນສົມບັດພິເສດພ້ອມກັບຊື່ຫ້ອງຮຽນໃນການໂຕ້ຕອບທີ່ມີຄຸນນະພາບ,,en,ພາກສ່ວນທີ່ແຕກຕ່າງກັນຂອງ ID ສ່ວນປະກອບແມ່ນຫຍັງ,,en,ID ສ່ວນປະກອບ ສຳ ລັບ EJB ແມ່ນຖືກສ້າງຕັ້ງຂື້ນໂດຍໃຊ້ຊື່ໃບສະ ໝັກ ຂອງຖົ່ວເຫຼືອງ,,en,ຊື່ໂມດູນແລະຊື່ສ່ວນປະກອບ,,en,ທ່ານຕິດອິນເຕີເຟດທ້ອງຖິ່ນບ່ອນໃດ,,en,ທຸກໆການໂຕ້ຕອບໃນທ້ອງຖິ່ນຖືກຜູກມັດເຂົ້າໃນພື້ນທີ່ຂອງໂລກ,,en,ເຊິ່ງສາມາດເຂົ້າເຖິງໄດ້ພາຍໃນ JVM ດຽວກັນ,,en,ທ່ານຕິດອິນເຕີເຟດຫ່າງໄກສອກຫຼີກແລະຍ້ອນຫຍັງ,,en,ທຸກໆການໂຕ້ຕອບທີ່ຢູ່ຫ່າງໄກສອກຫຼີກຖືກຜູກມັດເຂົ້າໃນພື້ນທີ່ຊື່ທົ່ວໂລກເພື່ອໃຫ້ພວກເຂົາສາມາດເຂົ້າເຖິງໄດ້ຈາກທຸກບ່ອນໃນຫ້ອງຜະລິດຕະພັນ Websphere,,en,ການປະຕິບັດທີ່ດີທີ່ສຸດ ສຳ ລັບການຜູກມັດທີ່ກ່ຽວຂ້ອງກັບ EJB ແມ່ນຫຍັງ,,en,ການປະຕິບັດທີ່ດີທີ່ສຸດແມ່ນການຈັດກຸ່ມການຜູກມັດທີ່ກ່ຽວຂ້ອງກັບ EJB ທັງ ໝົດ ພາຍໃຕ້ສະພາບການຂອງ EJB,,en,ທ່ານໃຫ້ຂໍ້ມູນການຜູກມັດຂອງຜູ້ໃຊ້ຢູ່ໃສ?,,en.

What are the different parts of a component ID?

Answer: The component ID for EJB is formed using the enterprise bean’s application name, module name and component name.

Where do you bind local interfaces?

Answer: All local interfaces are bound into the ejblocal: name space, which is accessible only within the same JVM.

Where do you bind the remote interfaces and why?

Answer: All the remote interfaces are bound into the global-scoped name space so that they are accessible from anywhere in the Websphere product cell.

What is the best practice for all EJB related bindings?

Answer: The best practice is to group all the EJB-related bindings under the EJB context.

Where do you provide user defined binding information?

Answer: ຂໍ້ມູນການຜູກມັດທີ່ຜູ້ໃຊ້ ກຳ ນົດໄດ້ຖືກສະ ໜອງ ໃນເອກະສານທີ່ສ້າງຂື້ນ ໃໝ່ ຊື່ວ່າ META-INF / ibm-ejb-jar-bnd.xml,,en,ຕົວເລືອກການຫຸ້ມຫໍ່ສອງຢ່າງມີຫຍັງແດ່,,en,ສອງທາງເລືອກທີ່ມີຢູ່ແມ່ນດັ່ງຕໍ່ໄປນີ້,,en,ການ ນຳ ໃຊ້ໂຄງການ Java ຫລື Java Utility,,en,ການ ນຳ ໃຊ້ໂຄງການ EJB,,en,ສິ່ງທີ່ຕ້ອງແກ້ໄຂໃນ ຄຳ ອະທິບາຍການ ນຳ ໃຊ້ເມື່ອໃຊ້ຕົວເລືອກການຫຸ້ມຫໍ່ຈາວາ,,en,ບັນດາສາຍຕໍ່ໄປນີ້ ຈຳ ເປັນຕ້ອງໄດ້ເພີ່ມເຂົ້າໃນເອກະສານ application.xml,,en,ejb,,en,MyEJB3Module.jar,,en,ພວກເຮົາ ຈຳ ເປັນຕ້ອງເພີ່ມຫຍັງຖ້າໃຊ້ຕົວເລືອກການຫຸ້ມຫໍ່ EJB,,en,ຖ້າພວກເຮົາ ກຳ ລັງໃຊ້ຕົວເລືອກໂຄງການ EJB ແລ້ວ IDE ຈະປັບປຸງ ຄຳ ຮ້ອງສະ ໝັກ ໂດຍອັດຕະໂນມັດ,,en,xml file ແລະ ກຳ ນົດເອກະສານ ejb-jar.xml,,en,ການໃຊ້ເອກະສານ ejb-jar.xml ແມ່ນຫຍັງໃນ EJB3.0 ໂດຍສະເພາະ,,en.

What are the two packaging options available?

Answer: Two available options are as follows
ເປັນ) Using a Java project or Java Utility project
ຂ) Using an EJB project







What is to be edited in the deployment descriptor when using the java packaging option?

Answer: The following lines need to be added in the application.xml file
<module>
<ejb>MyEJB3Module.jar</ejb>
</module>

Do we need to add anything if use EJB packaging option?

Answer: No, if we are using the EJB project option then the IDE automatically updates the application,xml file and set a ejb-jar.xml file.

What is the usage of ejb-jar.xml file in EJB3.0 specification?

Answer: ອີງຕາມຂໍ້ ກຳ ນົດ EJB3.0 ມັນບໍ່ ຈຳ ເປັນຕ້ອງຂຽນຫຍັງໃນເອກະສານ ejb-jar.xml ເພາະວ່າທຸກຢ່າງຖືກກ່າວເຖິງຜ່ານ ຄຳ ບັນຍາຍ,,en,ສະນັ້ນການ ນຳ ໃຊ້ຕົ້ນຕໍຂອງເອກະສານ ejb-jar.xml ແມ່ນການລົບລ້າງ ຄຳ ບັນລະຍາຍຫລືເຮັດລາຍລະອຽດໃຫ້ໂດຍ ຄຳ ບັນຍາຍ,,en,ຈະເປັນແນວໃດຮູບແບບການທົນນານໄດ້ຖືກນໍາໃຊ້ໃນການສະເພາະ EJB3.0,,en,API ຄວາມອົດທົນຂອງ java,,en,ຖືກ ນຳ ໃຊ້ໃນສະເປັກ EJB3.0,,en,ຄຸນປະໂຫຍດຂອງ JPA ແມ່ນຫຍັງ,,en,JPA ໃຊ້ຮູບແບບການໂຕ້ຕອບການບໍລິການທີ່ສາມາດພົກພາໄດ້,,en,ສະນັ້ນມັນງ່າຍທີ່ຈະໃຊ້ກັບການຈັດຕັ້ງປະຕິບັດຂອງຜູ້ໃຫ້ບໍລິການທີ່ແຕກຕ່າງກັນ,,en,ສາມສ່ວນທີ່ ສຳ ຄັນຂອງ JPA ແມ່ນຫຍັງ,,en,ຕໍ່ໄປນີ້ແມ່ນສາມພາກສ່ວນໃຫຍ່ຂອງ JPA,,en,metadata ການສ້າງແຜນທີ່ທີ່ກ່ຽວຂ້ອງກັບວັດຖຸ,,en,ພາສາສອບຖາມ,,en,ໜ່ວຍ ງານໃດໃນ JPA,,en,ວັດຖຸຕົ້ນຕໍທີ່ໃຊ້ເພື່ອຄວາມຄົງທົນໃນ JPA ແມ່ນເອີ້ນວ່າ ໜ່ວຍ ງານ,,en,ມີ ໜ່ວຍ ງານຂະຫຍາຍ / ຈັດຕັ້ງປະຕິບັດການຮຽນຫຼືອິນເຕີເນັດໃດໆ,,en. So the main usage of ejb-jar.xml file is to override the annotations or complete the details provided by the annotations.

What persistence model is used in EJB3.0 specification?

Answer: The java persistence API (JPA) is used in EJB3.0 specification.

What is the advantage of JPA?

Answer: JPA uses a pluggable service interface model. So it is easy to use with different provider implementations.

What are the three major parts of JPA?

Answer: Following are the three major parts of JPA
ເປັນ) The java persistence API
ຂ) Object relational mapping metadata
c) Query language

What is entity in JPA?

Answer: The main object used for persistence in JPA is called entity.

Does entity extend/implement any class or interface?

Answer: No, ໜ່ວຍ ງານແມ່ນວັດຖຸເກົ່າແກ່ທີ່ເກົ່າແກ່ແລະມັນບໍ່ໄດ້ຂະຫຍາຍຫຼືປະຕິບັດການຮຽນຫຼືອິນເຕີເຟດໃດໆ,,en,techalpine.com/exploring-enterprise-java-beans-series-ii,,en.







============================================= ============================================== Buy best TechAlpine Books on Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Enjoy this blog? Please spread the word :)

Follow by Email
LinkedIn
LinkedIn
Share