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

时间:2014-06-18 13:46:45

标签: java weblogic

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

谢谢!

1 个答案:

答案 0 :(得分:2)

我假设您通过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