Zkontrolovat změnu chování při sloučení cíle vkládání odkazu na prostředky

Ve specifikaci Servlet 3.0 jsou prvky <injection-target> odkazu na prostředek definované v souboru web-fragment.xml přidány do nadřízeného souboru web.xml pouze, když definice odkazu na prostředek web.xml se stejným názvem nemá žádné prvky <injection-target>. Specifikace Servlet 3.1 objasňuje, že pro odkaz na prostředek stejného názvu jsou všechny prvky <injection-target> v deskriptorech web-fragment.xml přidány do nadřízeného seznamu deskriptorů web.xml prvků <injection-target>. Funkce Servlet 3.1 může změnit existující chování aplikace aktivací cílů vkládání, které byly dříve vyloučeny ze souboru web.xml.

Toto pravidlo značí prvek <injection-target> v souboru web-fragment.xml, pokud soubor web.xml obsahuje prvek <injection-target> v rámci prvku <resource-ref>, který je definován se stejným názvem jako prvek <resource-ref> v souboru web-fragment.xml.

Následující příklady demonstrují změnu chování, když použijete kombinaci souboru web.xml a souboru web-fragment.xml:

web.xml:

<resource-ref>
	<res-ref-name>ReferenceName</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
	<injection-target>
		<injection-target-class>Class1</injection-target-class>
		<injection-target-name>Resource1</injection-target-name>
	</injection-target>
</resource-ref>

web-fragment.xml:

<resource-ref>
	<res-ref-name>ReferenceName</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
	<injection-target>
		<injection-target-class>Class2</injection-target-class>
		<injection-target-name>Resource2</injection-target-name>
	</injection-target>
</resource-ref>

Ve verzi Servlet 3.0 kombinovaný výsledek ignoruje cíl vkládání pro Class2:

<resource-ref>
	<res-ref-name>ReferenceName</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
	<injection-target>
		<injection-target-class>Class1</injection-target-class>
		<injection-target-name>Resource1</injection-target-name>
	</injection-target>
</resource-ref>

Ve verzi Servlet 3.1 kombinovaný výsledek používá cíl vkládání pro Class2:

<resource-ref>
	<res-ref-name>ReferenceName</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
	<injection-target>
		<injection-target-class>Class1</injection-target-class>
		<injection-target-name>Resource1</injection-target-name>
	</injection-target>
	<injection-target>
		<injection-target-class>Class2</injection-target-class>
		<injection-target-name>Resource2</injection-target-name>
	</injection-target>
</resource-ref>

Další informace o změnách chování Servlet 3.1 viz následující prostředek: Změny chování Servlet 3.1.