简体   繁体   English

在Weblogic启动时启动应用程序(从jar)

[英]start application (from jar) on Weblogic startup

I'm using Weblogic 12c, I need to run app before/with the web app starts. 我正在使用Weblogic 12c,我需要在启动Web应用程序之前/与Web应用程序一起运行。 the app should fetch information and write it to db. 该应用程序应获取信息并将其写入数据库。 I read that in previous versions of WL programmers used to work with ApplicationLifecycleListener, but it is deprecated now. 我读过以前使用过ApplicationLifecycleListener的WL程序员的早期版本,但现在不推荐使用。

I'm compiling the project to ear file. 我正在将项目编译到ear文件。 I also tried to use ejb3.2 eager singleton, but it didn't worked. 我也尝试使用ejb3.2渴望的单例,但是没有用。

Is there any working alternative? 有什么可行的选择吗?

I solved the issue by creating EJB as the following: 我通过如下创建EJB解决了这个问题:

@Singleton
@Startup
public class StartupBean {

@PostConstruct
private void startup() { ... }

@PreDestroy
private void shutdown() { ... }
...
}

Creating the EJB Singleton instances is one of the Weblogic life cycle init calls, I put my java code under startup() method. 创建EJB Singleton实例是Weblogic生命周期init调用之一,我将Java代码放在startup()方法下。

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

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