User: user57
Date: 02/02/06 16:05:56
Modified: src/main/org/jboss/system Info.java InfoMBean.java
Server.java ServerMBean.java
Log:
o moved getHostName() + getHostAddress() to Info (from Server). Don't really
like haveing to split up this information, but since Server is part of the
core boot, *fluffy* informatin (like this) should be put into Info to keep
the core footprint from growing.
Revision Changes Path
1.8 +49 -3 jboss/src/main/org/jboss/system/Info.java
Index: Info.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/Info.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Info.java 2002/01/03 04:01:00 1.7
+++ Info.java 2002/02/07 00:05:56 1.8
@@ -19,14 +19,15 @@
import org.jboss.logging.Logger;
/**
- * A simple mbean that dumps out info like the system properties, etc.
- *
+ * An MBean that provides a rich view of system information for the JBoss
+ * server in which it is deployed.
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class Info
implements InfoMBean, MBeanRegistration
@@ -34,6 +35,17 @@
/** Class logger. */
private static final Logger log = Logger.getLogger(Info.class);
+ /** The cached host name for the server. */
+ private String hostName;
+
+ /** The cached host address for the server. */
+ private String hostAddress;
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // JMX Hooks //
+ ///////////////////////////////////////////////////////////////////////////
+
public ObjectName preRegister(MBeanServer server, ObjectName name)
throws Exception
{
@@ -78,6 +90,39 @@
// empty
}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Server Information //
+ ///////////////////////////////////////////////////////////////////////////
+
+ public String getHostName() {
+ if (hostName == null) {
+ try {
+ hostName = java.net.InetAddress.getLocalHost().getHostName();
+ }
+ catch (java.net.UnknownHostException e) {
+ log.error("Error looking up local hostname", e);
+ hostName = "<unknown>";
+ }
+ }
+
+ return hostName;
+ }
+
+ public String getHostAddress() {
+ if (hostAddress == null) {
+ try {
+ hostAddress = java.net.InetAddress.getLocalHost().getHostAddress();
+ }
+ catch (java.net.UnknownHostException e) {
+ log.error("Error looking up local address", e);
+ hostAddress = "<unknown>";
+ }
+ }
+
+ return hostAddress;
+ }
+
private String getThreadGroupInfo(ThreadGroup group) {
StringBuffer rc = new StringBuffer();
@@ -119,6 +164,7 @@
// I'm not sure why what gets reported is off by +1,
// but I'm adjusting so that it is consistent with the display
int activeThreads = root.activeCount()-1;
+
// I'm not sure why what gets reported is off by -1
// but I'm adjusting so that it is consistent with the display
int activeGroups = root.activeGroupCount()+1;
1.4 +5 -36 jboss/src/main/org/jboss/system/InfoMBean.java
Index: InfoMBean.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/InfoMBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InfoMBean.java 2002/01/03 04:01:00 1.3
+++ InfoMBean.java 2002/02/07 00:05:56 1.4
@@ -16,48 +16,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface InfoMBean
{
String OBJECT_NAME = ":service=Info";
+ String getHostName();
+
+ String getHostAddress();
+
Map showProperties();
String showThreads();
-
- /**
- * Returns the installation URL.
- *
- * can be local in a file: or remote with http:
- * tells where the jboss.system was loaded from
- * By default it is the systemHome. In case of an http install the system
- * will be the local file system where the run is and the install will be
- * an http based install with centralized configuration for the farms.
- */
- // String getInstallationURL();
-
- /**
- * Returns the configuration directory.
- *
- * relative to the installation you can reference different install
- * directories so you can configure farms from an http base with different
- * profiles. The webserver will need the subdirectory at the
- * installationURL.
- *
- * <p>
- * ex: a install refering to -n http://www.jboss.org/world -c acme-inc
- * will download a profile from www.jboss.org that is acme-inc only on the
- * www.jboss.org we need to have conf/acme-inc under the base directory of
- * JBoss installs.
- */
- //String getConfigurationDirectoryURL();
-
- /**
- * Returns the library directory.
- *
- * Where to find basic libraries in this system.
- * This is an absoluteURL
- */
- //String getLibraryDirectoryURL();
}
1.10 +1 -21 jboss/src/main/org/jboss/system/Server.java
Index: Server.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/Server.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Server.java 2002/02/06 02:20:48 1.9
+++ Server.java 2002/02/07 00:05:56 1.10
@@ -32,7 +32,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class Server
implements ServerMBean
@@ -397,26 +397,6 @@
return started;
}
- public String getHostName() {
- try {
- return java.net.InetAddress.getLocalHost().getHostName();
- }
- catch (java.net.UnknownHostException e) {
- log.error("Error looking up local hostname", e);
- return "<unknown>";
- }
- }
-
- public String getHostAddress() {
- try {
- return java.net.InetAddress.getLocalHost().getHostAddress();
- }
- catch (java.net.UnknownHostException e) {
- log.error("Error looking up local address", e);
- return "<unknown>";
- }
- }
-
public Long getTotalMemory() {
return new Long(Runtime.getRuntime().totalMemory());
}
1.5 +1 -5 jboss/src/main/org/jboss/system/ServerMBean.java
Index: ServerMBean.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServerMBean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerMBean.java 2002/02/06 02:20:48 1.4
+++ ServerMBean.java 2002/02/07 00:05:56 1.5
@@ -14,7 +14,7 @@
* The JMX MBean interface for the <tt>Server</tt> component.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public interface ServerMBean
{
@@ -100,10 +100,6 @@
Date getStarted();
- String getHostName();
-
- String getHostAddress();
-
Long getTotalMemory();
Long getFreeMemory();
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development