Author: ron.sigal(a)jboss.com
Date: 2010-02-20 14:52:58 -0500 (Sat, 20 Feb 2010)
New Revision: 5741
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
Log:
JBREM-1179: Now uses reflection to get logger and logs version at DEBUG level.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2010-02-20 19:52:15
UTC (rev 5740)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2010-02-20 19:52:58
UTC (rev 5741)
@@ -22,7 +22,9 @@
package org.jboss.remoting;
+import java.lang.reflect.Method;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@@ -38,7 +40,7 @@
public static final byte VERSION_2 = 2;
public static final byte VERSION_2_2 = 22;
- public static final String VERSION = "2.5.2.SP2 (Flounder)";
+ public static final String VERSION = "2.5.2.SP3-preview (Flounder)";
private static final byte byteVersion = VERSION_2_2;
private static byte defaultByteVersion = byteVersion;
private static boolean performVersioning = true;
@@ -53,7 +55,20 @@
// have a static block to load the user defined version to use
static
{
- System.out.println("Remoting version: " + VERSION);
+ try
+ {
+ ClassLoader cl = getClassLoader();
+ Class c = cl.loadClass("org.jboss.logging.Logger");
+ Method getLogger = c.getMethod("getLogger", new
Class[]{String.class});
+ Object logger = getLogger.invoke(null, new Object[]
{"org.jboss.remoting"});
+ Method debug = c.getMethod("debug", new Class[]{Object.class});
+ debug.invoke(logger, new Object[]{"Remoting version: " + VERSION});
+ }
+ catch (Throwable t)
+ {
+ // ignore
+ }
+
boolean precompatibleFlag = false;
String precompatible = getSystemProperty(PRE_2_0_COMPATIBLE);
@@ -167,4 +182,20 @@
throw (RuntimeException) e.getCause();
}
}
+
+ static private ClassLoader getClassLoader()
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return Version.class.getClassLoader();
+ }
+
+ return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return Version.class.getClassLoader();
+ }
+ });
+ }
}
\ No newline at end of file
Show replies by date