简体   繁体   English

Wildfly中的WAR扩展策略

[英]WAR extension strategy in Wildfly

In a WildFly-project, I have a big WAR-File (about 100 MB) which contains the whole application in JAR-Files (EJBs, GUI, Web Services etc) 在一个WildFly项目中,我有一个很大的WAR文件(大约100 MB),其中包含JAR文件中的整个应用程序(EJB,GUI,Web服务等)

In this WAR, there are some Functions which implement a custom Function interface (there are also other classes like AbstractFunction and so on). 在此WAR中,有些函数实现了自定义的Function接口(还有其他一些类,如AbstractFunction等)。 Now I would like to extend the application with user-provided functions (they should be on the class path which can then be accessed by the application. 现在,我想用用户提供的功能扩展应用程序(它们应该在类路径上,然后可以由应用程序访问。

The problem is that I can't deploy the functions before the main WAR because Function , AbstractFunction etc. are the the WAR which is not yet deployed. 问题是我无法在主WAR之前部署Function ,因为FunctionAbstractFunction等是尚未部署的WAR。

Adding a WildFly module with the functions fails for the same reason. 出于相同的原因,使用这些功能添加WildFly模块失败。

One possibility would be to restructure the WAR file so that Function , AbstractionFunction are in an own jar which is deployed separately. 一种可能是重组WAR文件,以使FunctionAbstractionFunction位于单独部署的自己的jar中。 Unfortunately, this would be a major refactoring which is not possible at the time being. 不幸的是,这将是主要的重构,目前尚无法实现。

So is the only (simple) possibility to put the user-defined functions in a JAR into the WAR-file? 那么将用户定义函数放在JAR中放入WAR文件的唯一(简单)可能性是吗?

You can deploy user code as independent jar/war with EJB. 您可以使用EJB将用户代码部署为独立的jar / war。 EJB implements Function . EJB实现Function Main module can lookup and find them through JNDI. 主模块可以通过JNDI查找并找到它们。 Also you have to make common classes like Function and DTO available for user modules and for main war. 另外,您还必须使诸如Function和DTO之类的通用类可用于用户模块和主要战争。 The simplest way is share classes from main war. 最简单的方法是主战中的共享类。 You can add META-INF/jboss-deployment-structure.xml to client modules: 您可以将META-INF / jboss-deployment-structure.xml添加到客户端模块:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
    <dependencies>
        <module name="deployment.main.war"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

PS 聚苯乙烯

I have similar project with structure: 我有类似的项目结构:

  • core.war contains Plugin interface core.war包含插件接口
  • set of plugin*.jar (dependent from core.war) 插件* .jar的集合(取决于core.war)

In my core.war I have code like: 在我的core.war中,我有如下代码:

 Plugin srv = (Plugin) new InitialContext().lookup(jndi);

And my plugin looks like: 我的插件看起来像:

 @Stateless
 public class UserPlugin implements Plugin

JNDI looks like java:global/user-plugin/UserPlugin JNDI看起来像java:global/user-plugin/UserPlugin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM