2011年1月11日 星期二

Shared library and isolated shared library

在 000-377 的考題中有兩題考 shared library 的題目. 有一題的答案是 share library 要 associate 到 application class loader. 另一個題的答案是 isoloated shared library 要 associate 到 web module class loader. 這是為什麼呢?

以下為這兩題的題目:

第一題:
A developer informs an administrator that a servlet in one of the Web modules of a new enterprise application needs to access code in a native library. The administrator creates a shared library and adds the native library to its Native library path. With which class loader should the shared library be associated so that the servlet can access the native library without risk of an UnsatisfiedLinkError?

A. The Web modules class loader
B. The nativelibrays class loader
C. The application servers class loader
D. The enterprise applications class loader

此題答案給的為 C.

另一題
A developer informs an administrator that a servlet in one of the Web modules of a new enterprise application needs to access code in a native library. The administrator creates a shared library and adds the native library to its Native library path. What else does the administrator need to do to ensure that the servlet can access the native library without risk of an UnsatisfiedLinkError? Using the administrative console, select:

A. Use an isolated class loader for this shared library on the shared library settings page and associate the shared library with the Web modules class loader.
B. Classes loaded with parent class loader first on the settings page for the enterprise applications class loader and associate the shared library with the enterprise applications class loader.
C. Use an isolated class loader for this shared library on the shared library settings page and inform the developer of the name of the shared library so the developer can include it in the appropriate Java code.
D. Classes loaded with local class loader first on the settings page for the Web modules class loader and associate the shared library with the Web modules class loader.

此題答案給的為 A.

2 則留言:

Hung-Yi Chen 提到...

找到答案囉. 原來是 isolated shared library 是限制此 shared library 只給部份的 application 來使用:
"The Isolated Shared Library will provide a mechanism where you can share a common set of classes across a subset of the applications within the WebSphere Application Server."

Isoloated shared libraries do not have the visibility to the application classes loaded by application class loader.

Reference: http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.was_v7/was/7.0/Administration/WASv7_IsolatedSharedLibraries/player.html?resultof=%22%69%73%6f%6c%61%74%65%64%22%20%22%69%73%6f%6c%22%20%22%63%6c%61%73%73%22%20%22%6c%6f%61%64%65%72%22%20

Hung-Yi Chen 提到...

以下這個解釋的原因比較正確:

Native libraries cannot be loaded more than once by a class loader. Thus, it is preferable for native libraries to use an isolated shared library or to be loaded within shared libraries associated with the class loader of an application server. See the Use an isolated class loader for this shared library setting. http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/ucws_rsharedlib_inst.html