gpt4 book ai didi

java - 如何确定Weblogic服务器处于生产模式还是开发模式?

转载 作者:行者123 更新时间:2023-11-30 03:51:38 24 4
gpt4 key购买 nike

我在(从应用程序的代码)检测服务器是否在生产模式或开发模式下运行时遇到问题,因为它需要不同的行为。这个链接看起来很有前途:http://coder-in-training.blogspot.de/2012/04/specifying-projectstage-in-jndi-with.html但服务器模式每次都默认为生产模式。你知道从java代码中确定Weblogic启动模式的方法吗?

谢谢!

最佳答案

我假设您正在通过 JMX 连接连接到域。在您的 Java 代码中,您可以执行以下操作:

MBeanServerConnection conn = JMXConnectorFactory.connect(url, hash).getMBeanServerConnection();
DomainRuntimeServiceMBean domainRuntimeServiceMBean = (DomainRuntimeServiceMBean)
MBeanServerInvocationHandler.newProxyInstance(conn, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME));
DomainMBean domainBean = domainRuntimeServiceMBean.getDomainConfiguration();

一旦您拥有了DomainMBean,它就很简单:

domainBean.isProductionModeEnabled() 

在此处引用 DomainMBean API:

DomainMBean API

这也可能是一个有用的例子:

Connecting to a server with JMX and listing info

关于java - 如何确定Weblogic服务器处于生产模式还是开发模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24287307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com