缺省情况下,Java™ EE 应用程序无法访问 Liberty 中提供的第三方 API。您还可以在 server.xml 文件或包含的文件中显式移除访问权。
关于此任务
在以下示例中,称为 Scholar 的应用程序先前已配置成访问第三方 API,如从 Java EE 应用程序访问第三方 API中所述。您想要移除此访问权,以及在应用程序现在使用缺省访问设置的配置中显式进行此操作。
应用程序还使用称为 Alexandria 的公共库。此库位于 ${server.config.dir}/mylib/Alexandria 目录中。
过程
- 为应用程序配置类装入操作,以显示应用程序不再能访问第三方 API。
在
server.xml 文件或包含的文件中,将
third-party 从包含的 apiTypeVisibility 属性值集中移除:
<application id="scholar" name="Scholar" type="ear" location="scholar.ear">
<classloader apiTypeVisibility="spec, ibm-api" commonLibraryRef="Alexandria" />
</application>
- 可选: 如果应用程序使用任何公共库,请将这些库设为使用相同的 API 类型可视性设置。
在
server.xml 文件或包含的文件中,添加下列代码:
<library id="Alexandria" apiTypeVisibility="spec, ibm-api">
<fileset dir="${server.config.dir}/mylib/Alexandria" includes="*.jar" scanInterval="5s" />
</library>