简体   繁体   English

如何在java中嵌入Weblogic服务器?

[英]How can I embed Weblogic server in java?

我正在寻找在Java中嵌入Weblogic服务器的任何方式,我知道它可能因为我们有用于Weblogic的maven插件,它将Weblogic嵌入maven中,但谷歌搜索它并没有给我有用的输出,有人知道我们怎么能嵌入wemlogic in java程序?

WebLogic doesn't provide an embedded API so, even if it's a pure Java Server and if you can thus call weblogic.Server from Java code, you will have to handle everything yourself (starting the container, waiting until it's started, deploying things, waiting until they are deployed, etc). WebLogic不提供嵌入式API,即使它是纯Java服务器,如果你可以从Java代码调用weblogic.Server ,你也必须自己处理所有事情(启动容器,等到它开始,部署东西,等到他们被部署,等等)。 In other words, this will require some work. 换句话说,这需要一些工作。 Maybe have a look at the sources of Cargo , although Cargo isn't really starting an embedded Weblogic (ie running weblogic.Server in the same JVM). 也许看一下Cargo的来源,虽然Cargo并没有真正启动嵌入式Weblogic(即在同一个JVM中运行weblogic.Server )。 This will give you an idea of what has to be done. 这将让您了解必须完成的工作。 Or, depending on your needs, use Cargo Java API . 或者,根据您的需要,使用Cargo Java API

But if you need a full Java EE server and if this is an option, I would use GlassFish v3 in embedded mode instead of WebLogic, it will be much simpler. 但是如果你需要一个完整的Java EE服务器,如果这是一个选项,我会在嵌入模式下使用GlassFish v3而不是WebLogic,它会更简单。 Check the following links and see yourself: 检查以下链接并了解自己:

Do you need WLS specifically, of any servlet container would do? 你需要WLS,任何servlet容器都可以吗? If the latter is OK, then use Jetty. 如果后者没问题,那就使用Jetty。

WLS is not designed to be embeddable. WLS不是可嵌入的。 But you can do it. 但你可以做到。 After all, WLS is just a class named weblogic.Server. 毕竟,WLS只是一个名为weblogic.Server的类。 Setup classpath correctly, setup PATH and other environment variables (see setDomainEnv.sh and startWeblogic.sh), start that class from Java, and you have an "embedded" WLS. 正确设置类路径,设置PATH和其他环境变量(请参阅setDomainEnv.sh和startWeblogic.sh),从Java启动该类,并且您有一个“嵌入式”WLS。

WebLogic doesn't support embedded mode like Glassfish but you can have control over your Weblogic using "WebLogic Maven Plugin", this provide several maven goals for managing and working with Weblogic instance. WebLogic不支持像Glassfish这样的嵌入式模式,但您可以使用“WebLogic Maven插件”控制Weblogic,这为管理和使用Weblogic实例提供了几个maven目标。

See this link for further information. 有关详细信息,请参阅链接。

There is probably a way, but I don't know it. 可能有一种方法,但我不知道。 My experience from writing maven plugins tells me that the most likely way that the plugin works is that it starts up a new command line process just like you would normally start up the server. 我编写maven插件的经验告诉我,插件最有可能的工作方式是启动一个新的命令行进程,就像你通常启动服务器一样。 So in a sense, not really embedded it. 所以从某种意义上说,并没有真正嵌入它。

The best way to see is to track down the source of the plugin and see how they did it. 最好的方法是跟踪插件的来源,看看他们是如何做到的。

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

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