« Configuring context root for web application libraries | Main | Temporary files for application deployment »

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)

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mte1521/mt-tb.cgi/12987

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on July 23, 2009 4:10 PM.

The previous post in this blog was Configuring context root for web application libraries.

The next post in this blog is Temporary files for application deployment.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle