我在检测(从应用程序的代码)服务器是否在生产或开发模式下运行时遇到问题,因为它需要不同的行为。该链接看起来很有希望: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