sql >> Base de Datos >  >> RDS >> Oracle

Recuperar la URL del proveedor del servidor actual en tiempo de ejecución en weblogic (forma no obsoleta)

Puede buscar el tiempo de ejecución JMX, que es el mismo para todas las aplicaciones. No es necesario ingresar dirección, usuario o contraseña.

1) Busque el MBeanServer

InitialContext ctx = new InitialContext();
MBeanServer mBeanServer = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");

2) Luego, debe recuperar el nombre del servidor que ejecuta la aplicación. Aquí hay dos formas (quizás más).

La más sencilla

String serverName = System.getProperty("weblogic.Name");

Pero no sé si es una forma fiable.

La otra forma de obtener el nombre del servidor es buscarlo en los atributos del servicio de tiempo de ejecución.

ObjectName serviceObjectName = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
String serverName = (String) mBeanServer.getAttribute(serviceObjectName, "ServerName");

3) Ahora podemos crear el servidor de tiempo de ejecución ObjectName ...

ObjectName serverRuntime = new ObjectName("com.bea:Name="+serverName+",Type=ServerRuntime");

4) ... y obtener los atributos que necesitamos

String listenAddress = mBeanServer.getAttribute(serverRuntime, "ListenAddress");
Integer listenPort = mBeanServer.getAttribute(serverRuntime, "ListenPort");

rem:listenAddress tiene el formato hostname /IP , tienes que manipularlo para obtener solo IP o host

Desde ahí puedes acceder a mucha información; como la dirección del servidor de administración que administra el servidor de tiempo de ejecución, el clúster de tiempo de ejecución, ... .

Aquí hay una lista que obtuve de la consola WLST (WL12.2.1), no probé si tenemos acceso a todos los atributos/MBean.

dr--   ApplicationRuntimes
dr--   AsyncReplicationRuntime
dr--   BatchJobRepositoryRuntime
dr--   ClassLoaderRuntime
dr--   ClusterRuntime
dr--   ConcurrentManagedObjectsRuntime
dr--   ConnectorServiceRuntime
dr--   DefaultExecuteQueueRuntime
dr--   EntityCacheCumulativeRuntime
dr--   EntityCacheCurrentStateRuntime
dr--   EntityCacheHistoricalRuntime
dr--   ExecuteQueueRuntimes
dr--   JDBCServiceRuntime
dr--   JMSRuntime
dr--   JTARuntime
dr--   JVMRuntime
dr--   JoltRuntime
dr--   LibraryRuntimes
dr--   LogBroadcasterRuntime
dr--   LogRuntime
dr--   MANAsyncReplicationRuntime
dr--   MANReplicationRuntime
dr--   MailSessionRuntimes
dr--   MaxThreadsConstraintRuntimes
dr--   MessagingBridgeRuntime
dr--   MessagingBridgeRuntimes
dr--   MinThreadsConstraintRuntimes
dr--   PartitionRuntimes
dr--   PathServiceRuntime
dr--   PathServiceRuntimes
dr--   PersistentStoreRuntimes
dr--   RequestClassRuntimes
dr--   SAFRuntime
dr--   SNMPAgentRuntime
dr--   ServerChannelRuntimes
dr--   ServerLogRuntime
dr--   ServerSecurityRuntime
dr--   ServerServices
dr--   SingleSignOnServicesRuntime
dr--   ThreadPoolRuntime
dr--   TimerRuntime
dr--   WANReplicationRuntime
dr--   WLDFRuntime
dr--   WTCRuntime
dr--   WebServerRuntimes
dr--   WorkManagerRuntimes
dr--   WseeClusterFrontEndRuntime
dr--   WseeWsrmRuntime

-r--   ActivationTime                               
-r--   AdminServer                                  
-r--   AdminServerHost                              
-r--   AdminServerListenPort                        
-r--   AdminServerListenPortSecure                  
-r--   AdministrationPort                           
-r--   AdministrationPortEnabled                    
-r--   AdministrationURL                            
-r--   AsyncReplicationRuntime                      
-r--   ClusterRuntime                               
-r--   CurrentDirectory                             
-rw-   CurrentMachine
-r--   DefaultExecuteQueueRuntime                   
-r--   DefaultURL                                   
-r--   EntityCacheCumulativeRuntime                 
-r--   EntityCacheCurrentStateRuntime               
-r--   EntityCacheHistoricalRuntime                 
-r--   HealthState                                  
-r--   HealthStateJMX                               
-r--   JoltRuntime                                  
-r--   ListenAddress                                
-r--   ListenPort                                   
-r--   ListenPortEnabled                            
-r--   MANAsyncReplicationRuntime                   
-r--   MANReplicationRuntime                        
-r--   MessagingBridgeRuntime                       
-r--   MiddlewareHome                               
-r--   Name                                         
-r--   OpenSocketsCurrentCount                      
-r--   OracleHome                                   
-r--   OverallHealthState                           
-r--   OverallHealthStateJMX                        
-rw-   Parent                                       
-r--   PathServiceRuntime                           
-r--   RestartRequired                              
-r--   RestartsTotalCount                           
-r--   SSLListenAddress                             
-r--   SSLListenPort                                
-r--   SSLListenPortEnabled                         
-r--   ServerClasspath                              
-r--   SocketsOpenedTotalCount                      
-r--   State                                        
-r--   StateVal                                     
-r--   Type                                         
-r--   WANReplicationRuntime                        
-r--   WeblogicHome                                 
-r--   WeblogicVersion                              
-r--   WseeClusterFrontEndRuntime