Resource filtering configuration

filter.jpg

WebLogic Server introduced the concept of filtering class loader with release 9.2. Filtering class loader is used to filter class loading requests by application. It is configured using prefer-application-packages element in weblogic-application.xml. This configuration also modifies resource loading behavior to some extent. It has been explained in resource loading order section of the documentation.

With release 10.3.1, filtering class loader now supports a more fine grained control over resource loading behavior. A new element prefer-application-resources may be used to configure a resource pattern to filter. If this pattern is configured, any resource lookup whose URI matches the pattern will only be looked up in the application.

Consider an application flight.ear that has a jar file in it's APP-INF/lib directory and assume that this jar file contains META-INF/foo.xml. Further consider another jar file in the system class path that too has META-INF/foo.xml. If the application code uses ClassLoader.getResource(String) or ClassLoader.getResources(String) it'll see the resource from the system class path. But if the application were configured using prefer-application-resources element in weblogic-application.xml, the above resource lookup requests wouldn't find any resource from the system class path:

<prefer-application-resources>
  <resource-name>META-INF/foo.xml</resource-name>
</prefer-application-resources>

getResource with no filtering configuration
Resource from system class path

getResources with no filtering configuration
Resource from system class path
Resource from the application

getResource with above filtering configuration
Resource from application

getResources with above filtering configuration
Resource from application

Please note that resource-name element supports “*” wild card pattern. So we could have used something like “META-INF/*” as resource name as well.

In case the resource being looked up does not match the pattern configured using prefer-application-resources, the look up behavior reverts to the default resource loading behavior of filtering class loader, as described here. If prefer-application-packages is not declared, then resource loading behavior would revert to java default.

(Picture licensed from Roshnii under creative commons)

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Posts about application development

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today