Java – get the instance name of the websphere application server

My web service will run on JBoss app server or websphere application server For both of them, I need to know the instance name. For JBoss, I can use system Getproperty ("JBoss. Server. Name"), but it can be used in WebSphere? I can't use WebSphere specific methods. I need to call system properties

thank you

Solution

To keep the platform uninterrupted, you can set the variable to the JVM parameter of the WebSphere server (one for each node if it is clustered) For WebSphere 7, you will find the following in the administrative console:

Servers > Server Types > Websphere application servers > [your cluster node] >
  >  Java and Process Management  > Process DeFinition > Java Virtual Machine >
    > Generic JVM arguments

And add such a variable

-DServerName=serverNodeA

You can then access the values in the code as

String serverName = System.getproperty("ServerName");

This technique can be used with all application servers as long as you have access to add parameters to the JVM I determined that there must be a WebSphere specific API to query the node name, and then you enter the code into the server, which makes unit testing difficult and non portable I like this method

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>