JSF类路径解析

huangapple go评论64阅读模式
英文:

JSF classpath resolution

问题

我开始在一个包含不同包和不同war中重复的类和jsf名称的遗留jsf代码上工作。一个用于操作员,另一个用于客户。
我想知道这是否是偶然成功,还是类路径解析保证jsf文件将找到正确的后台bean。这两个bean都被命名为beans。

项目的结构如下:

  • com.company.operator(war模块)
    • com.company.operator.Back(类名)
    • operator-module/src/main/webapp/operator/frontend1.xhtml(第一个jsf,引用${back.someFunction})
  • com.company.customer(war模块)
    • com.company.customer.Back(类名)
    • customer-module/src/main/webapp/customer/frontend2.xhtml(第二个jsf,引用${back})
  • com.company.ear(ear模块)

整个应用程序打包到同一个ear中。
是否可能在frontend2.xhtml中的引用${back}被解析为另一个模块中的com.company.operator.Back类?

IntelliJ找到了正确的引用。

英文:

I started to work on a legacy jsf code which contains duplicated class and jsf names in different packages and different wars, of course. One for the operators, the other for the customers.
I would like to know that it's working by accident or the classpath resolution guarantees that the jsf file will find the proper backing bean. Both beans are named beans.

The structure of the project looks like this:

  • com.company.operator (war module)
    • com.company.operator.Back (class name)
    • operator-module/src/main/webapp/operator/frontend1.xhtml (first jsf which references ${back.someFunction})
  • com.company.customer (war module)
    • com.company.customer.Back (class name)
    • customer-module/src/main/webapp/customer/frontend2.xhtml (2nd jsf referencing ${back}
  • com.company.ear (ear module)

The whole application is packaged into the same ear.
Is it possible that the reference ${back} in frontend2.xhtml is resolved to com.company.operator.Back, the class in the other module?

IntelliJ founds the proper references.

答案1

得分: 1

每个WAR文件都由单独的类加载器加载,因此无法看到彼此。

链接:
https://docs.oracle.com/en/middleware/standalone/weblogic-server/14.1.1.0/wlprg/classloading.html#GUID-5163D350-7BA6-4CD8-90DC-9FB9971C018A

https://blogs.oracle.com/javamagazine/post/how-the-jvm-locates-loads-and-runs-libraries

英文:

Every WAR file is loaded by separate classloader, thus cannot see each other.

https://docs.oracle.com/en/middleware/standalone/weblogic-server/14.1.1.0/wlprg/classloading.html#GUID-5163D350-7BA6-4CD8-90DC-9FB9971C018A

https://blogs.oracle.com/javamagazine/post/how-the-jvm-locates-loads-and-runs-libraries

huangapple
  • 本文由 发表于 2023年7月3日 19:12:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76604194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定