Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Piotr's mock , question 20 , web fragment discovery

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q20 - Web Fragments Discovery


Considering the idea of web fragments, which statements are true:

a. web fragment's filename, to be discovered by the container, must be named "web-fragment.xml"

b. web fragment's filename, to be discovered by the container, must be named "web_fragment.xml",

c. If a web fragment is packaged as a JAR file, its web fragment XML file needs to be located at the top directory of the JAR file,

d. If a web fragment is packaged as a JAR file, its web fragment XML file needs to be located directly under META-INF/ directory of the JAR file,

e. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located somewhere in the application's classpath,

f. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located directly under WEB-INF/ directory of the application,

g. If a web fragment packaged as a JAR file needs to be discovered by the container, it must be located directly under WEB-INF/lib directory of the application.


Answer and explanation:

a, d, g

Reference: page 65, 8.2.1 "Modularity of web.xml"

Explanation: The name of the web fragment descriptor is web-fragment.xml, so b is incorrect.

If this web-fragment.xml is a part of a JAR file, it must be located under JAR's META-INF/ directory, so c is incorrect.

If this web-fragment.xml is a part of a JAR file and it's supposed to alter or contribute to the final Deployment Descriptor, it must be located under application's WEB-INF/lib directory. The container can, but is not required to discover web fragments which are not located under WEB-INF/lib.



I think for the last sentence of the explanation , the jar file should be in WEB-INF/lib directory, not the web-fragment.xml of that jar file.
In c, it has already mentioned that web-fragment.xml must be in META-INF/ if this xml is part of the jar file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic