开发者

java process to notify the shell spring load completion

开发者 https://www.devze.com 2023-04-12 13:16 出处:网络
I use spring in a stand alone web application, which means there\'s no servlet container but rather it runs in a JVM machine:

I use spring in a stand alone web application, which means there's no servlet container but rather it runs in a JVM machine:

public开发者_如何转开发 class A {
    public static void main(String[] args) throws Exception {       
        AbstractApplicationContext  context = new ClassPathXmlApplicationContext("applicationContext.xml");
        context.registerShutdownHook();
    }   
}

Once built, i run it from a bash shell like this, for the sake of simplicity let's call it process 'main' and figure that it's run in a shell script:

me@local$ java A

This command starts a JVM and runs the main function above in the 'main' process, this main function never returns and thus:

  1. i find it hard to figure out how the process would notify the shell from any event in spring. I'm using jmx to monitorize the process and i need the shell to be aware of the spring load completion for it's used to start other processes that depends upon this process 'main' and the bash script.
  2. The script where the process is started cannot continue.

For point 2, the obvious answer:

me@local$ java A &

Doesn't build anything, since eventhough the script can continue, i cannot notify the shell when spring finished to load.

Thanks in advance.


Why is it not enough just to output something on console after your application is ready? Also, you could connect by jmx right after a java process has been launched, then you could monitor jmx beans.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号