wrapper 

Commit MetaInfo

Revision174 (tree)
Time2012-02-21 16:42:44
Authormortenson

Log Message

Remove all remaining Java 1.2.x support code.

Change Summary

Diff

--- trunk/wrapper/doc/revisions.txt (revision 173)
+++ trunk/wrapper/doc/revisions.txt (revision 174)
@@ -9,6 +9,8 @@
99 for users who tried to pass other parameters to the JVM.
1010 * Correct a couple log messages in the WrapperManager class which were missing
1111 the correct prefix identifying where they originated.
12+* Remove some old reflection code needed for Java 1.2.x support as we have
13+ required Java 1.4 since version 3.4.0.
1214
1315 3.5.14
1416 * Fix a problem in the AppCommand.bat.in file where a parenthesis in the
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java (revision 173)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperManager.java (revision 174)
@@ -3111,7 +3111,7 @@
31113111 if ( m_debug )
31123112 {
31133113 m_outDebug.println( getRes().getString(
3114- "WrapperManager.stop({0}) called by thread: {1}" ,
3114+ "WrapperManager.stop({0}) called by thread: {1}",
31153115 new Integer( exitCode ), Thread.currentThread().getName() ) );
31163116 }
31173117
@@ -3237,58 +3237,7 @@
32373237
32383238 signalStopped( exitCode );
32393239
3240- // Execute runtime.halt(0) using reflection so this class will
3241- // compile on 1.2.x versions of Java.
3242- Method haltMethod;
3243- try
3244- {
3245- haltMethod =
3246- Runtime.class.getMethod( "halt", new Class[] { Integer.TYPE } );
3247- }
3248- catch ( NoSuchMethodException e )
3249- {
3250- m_outError.println( getRes().getString( "halt not supported by current JVM." ) );
3251- haltMethod = null;
3252- }
3253-
3254- if ( haltMethod != null )
3255- {
3256- Runtime runtime = Runtime.getRuntime();
3257- try
3258- {
3259- haltMethod.invoke( runtime, new Object[] { new Integer( exitCode ) } );
3260- }
3261- catch ( IllegalAccessException e )
3262- {
3263- m_outError.println( getRes().getString( "Unable to call runtime.halt: {0}" , e ) );
3264- }
3265- catch ( InvocationTargetException e )
3266- {
3267- Throwable t = e.getTargetException();
3268- if ( t == null )
3269- {
3270- t = e;
3271- }
3272-
3273- m_outError.println(getRes().getString( "Unable to call runtime.halt: {0}" , t ) );
3274- }
3275- }
3276- else
3277- {
3278- // Shutdown normally
3279-
3280- // This is safe because we are already checking for the privilege to stop the JVM
3281- // above. If we get this far then we want the Wrapper to be able to do everything
3282- // necessary to stop the JVM.
3283- AccessController.doPrivileged(
3284- new PrivilegedAction() {
3285- public Object run() {
3286- privilegedStopInner( exitCode );
3287- return null;
3288- }
3289- }
3290- );
3291- }
3240+ Runtime.getRuntime().halt( exitCode );
32923241 }
32933242
32943243 /**
@@ -3881,16 +3830,23 @@
38813830 // Always send the stop command
38823831 sendCommand( WRAPPER_MSG_STOP, Integer.toString( exitCode ) );
38833832
3884- // Give the Wrapper a chance to register the stop command before stopping.
3885- // This avoids any errors thrown by the Wrapper because the JVM died before
3886- // it was expected to.
3887- try
3833+ if ( delay > 0 )
38883834 {
3889- Thread.sleep( delay );
3835+ // Give the Wrapper a chance to register the stop command before stopping.
3836+ // This avoids any errors thrown by the Wrapper because the JVM died before
3837+ // it was expected to.
3838+ if ( m_debug )
3839+ {
3840+ m_outDebug.println( getRes().getString( "Pausing for {0}ms to allow a clean shutdown...", new Integer( delay ) ) );
3841+ }
3842+ try
3843+ {
3844+ Thread.sleep( delay );
3845+ }
3846+ catch ( InterruptedException e )
3847+ {
3848+ }
38903849 }
3891- catch ( InterruptedException e )
3892- {
3893- }
38943850 }
38953851 }
38963852
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/test/AbstractActionApp.java (revision 173)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/test/AbstractActionApp.java (revision 174)
@@ -32,8 +32,6 @@
3232 import java.io.BufferedReader;
3333 import java.io.InputStreamReader;
3434 import java.io.IOException;
35-import java.lang.reflect.InvocationTargetException;
36-import java.lang.reflect.Method;
3735 import java.util.Enumeration;
3836 import java.util.Properties;
3937
@@ -212,67 +210,11 @@
212210 }
213211 else if ( action.equals( "halt0" ) )
214212 {
215- // Execute runtime.halt(0) using reflection so this class will
216- // compile on 1.2.x versions of Java.
217- Method haltMethod;
218- try
219- {
220- haltMethod = Runtime.class.getMethod( "halt", new Class[] { Integer.TYPE } );
221- }
222- catch ( NoSuchMethodException e )
223- {
224- System.out.println( Main.getRes().getString( "halt not supported by current JVM." ) );
225- haltMethod = null;
226- }
227-
228- if ( haltMethod != null )
229- {
230- Runtime runtime = Runtime.getRuntime();
231- try
232- {
233- haltMethod.invoke( runtime, new Object[] { new Integer( 0 ) } );
234- }
235- catch ( IllegalAccessException e )
236- {
237- System.out.println( Main.getRes().getString( "Unable to call runtime.halt: {0}", e.getMessage() ) );
238- }
239- catch ( InvocationTargetException e )
240- {
241- System.out.println( Main.getRes().getString( "Unable to call runtime.halt: {0}", e.getMessage() ) );
242- }
243- }
213+ Runtime.getRuntime().halt( 0 );
244214 }
245215 else if ( action.equals( "halt1" ) )
246216 {
247- // Execute runtime.halt(1) using reflection so this class will
248- // compile on 1.2.x versions of Java.
249- Method haltMethod;
250- try
251- {
252- haltMethod = Runtime.class.getMethod( "halt", new Class[] { Integer.TYPE } );
253- }
254- catch ( NoSuchMethodException e )
255- {
256- System.out.println( Main.getRes().getString( "halt not supported by current JVM." ) );
257- haltMethod = null;
258- }
259-
260- if ( haltMethod != null )
261- {
262- Runtime runtime = Runtime.getRuntime();
263- try
264- {
265- haltMethod.invoke( runtime, new Object[] { new Integer( 1 ) } );
266- }
267- catch ( IllegalAccessException e )
268- {
269- System.out.println( Main.getRes().getString( "Unable to call runtime.halt: {0}", e.getMessage() ) );
270- }
271- catch ( InvocationTargetException e )
272- {
273- System.out.println( Main.getRes().getString( "Unable to call runtime.halt: {0}", e.getMessage() ) );
274- }
275- }
217+ Runtime.getRuntime().halt( 1 );
276218 }
277219 else if ( action.equals( "restart" ) )
278220 {
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/test/ShutdownHook.java (revision 173)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/test/ShutdownHook.java (revision 174)
@@ -29,9 +29,6 @@
2929 * included in all copies or substantial portions of the Software.
3030 */
3131
32-import java.lang.reflect.InvocationTargetException;
33-import java.lang.reflect.Method;
34-
3532 /**
3633 *
3734 *
@@ -42,50 +39,32 @@
4239 * Main Method
4340 *-------------------------------------------------------------*/
4441 public static void main(String[] args) {
45- // Locate the add and remove shutdown hook methods using reflection so
46- // that this class can be compiled on 1.2.x versions of java.
47- Method addShutdownHookMethod;
48- try {
49- addShutdownHookMethod =
50- Runtime.class.getMethod("addShutdownHook", new Class[] {Thread.class});
51- } catch (NoSuchMethodException e) {
52- System.out.println( Main.getRes().getString( "Shutdown hooks not supported by current JVM.") );
53- return;
54- }
55-
5642 System.out.println( Main.getRes().getString( "This application registers a shutdown hook which") );
5743 System.out.println( Main.getRes().getString( "should be executed after the JVM has told the Wrapper") );
5844 System.out.println( Main.getRes().getString( "it is exiting." ) );
5945 System.out.println( Main.getRes().getString( "This is to test the wrapper.jvm_exit.timeout property" ) );
6046
61- Runtime runtime = Runtime.getRuntime();
62- Thread hook = new Thread() {
63- public void run() {
64- System.out.println( Main.getRes().getString( "Starting shutdown hook. Loop for 25 seconds.") );
65- System.out.println( Main.getRes().getString( "Should timeout unless this property is set: wrapper.jvm_exit.timeout=30" ) );
47+ Runtime.getRuntime().addShutdownHook( new Thread()
48+ {
49+ public void run() {
50+ System.out.println( Main.getRes().getString( "Starting shutdown hook. Loop for 25 seconds.") );
51+ System.out.println( Main.getRes().getString( "Should timeout unless this property is set: wrapper.jvm_exit.timeout=30" ) );
6652
67- long start = System.currentTimeMillis();
68- while(System.currentTimeMillis() - start < 25000)
53+ long start = System.currentTimeMillis();
54+ while(System.currentTimeMillis() - start < 25000)
55+ {
56+ try
6957 {
70- try
71- {
72- Thread.sleep( 250 );
73- }
74- catch ( InterruptedException e )
75- {
76- // Ignore
77- }
58+ Thread.sleep( 250 );
7859 }
79- System.out.println( Main.getRes().getString( "Shutdown hook complete. Should exit now." ) );
60+ catch ( InterruptedException e )
61+ {
62+ // Ignore
63+ }
8064 }
81- };
82- try {
83- addShutdownHookMethod.invoke(runtime, new Object[] {hook});
84- } catch (IllegalAccessException e) {
85- System.out.println( Main.getRes().getString( "Unable to register shutdown hook: {0}", e.getMessage() ) );
86- } catch (InvocationTargetException e) {
87- System.out.println( Main.getRes().getString( "Unable to register shutdown hook: {0}", e.getMessage() ) );
88- }
65+ System.out.println( Main.getRes().getString( "Shutdown hook complete. Should exit now." ) );
66+ }
67+ } );
8968
9069 System.out.println( Main.getRes().getString( "Application complete. Wrapper should stop, invoking the shutdown hooks." ) );
9170 System.out.println();
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperActionServer.java (revision 173)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperActionServer.java (revision 174)
@@ -13,8 +13,6 @@
1313
1414 import java.io.IOException;
1515 import java.io.InterruptedIOException;
16-import java.lang.reflect.InvocationTargetException;
17-import java.lang.reflect.Method;
1816 import java.net.InetAddress;
1917 import java.net.Socket;
2018 import java.net.SocketException;
@@ -447,38 +445,7 @@
447445 {
448446 public void run()
449447 {
450- // Execute runtime.halt(0) using reflection so this class will
451- // compile on 1.2.x versions of Java.
452- Method haltMethod;
453- try
454- {
455- haltMethod =
456- Runtime.class.getMethod( "halt", new Class[] { Integer.TYPE } );
457- }
458- catch ( NoSuchMethodException e )
459- {
460- m_out.println( WrapperManager.getRes().getString( "halt not supported by current JVM." ) );
461- haltMethod = null;
462- }
463-
464- if ( haltMethod != null )
465- {
466- Runtime runtime = Runtime.getRuntime();
467- try
468- {
469- haltMethod.invoke( runtime, new Object[] { new Integer( 0 ) } );
470- }
471- catch ( IllegalAccessException e )
472- {
473- m_out.println( WrapperManager.getRes().getString(
474- "Unable to call runitme.halt: {0}", e.getMessage() ) );
475- }
476- catch ( InvocationTargetException e )
477- {
478- m_out.println( WrapperManager.getRes().getString(
479- "Unable to call runitme.halt: {0}", e.getMessage() ) );
480- }
481- }
448+ Runtime.getRuntime().halt( 0 );
482449 }
483450 } );
484451 }
--- trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperUser.java (revision 173)
+++ trunk/wrapper/src/java/org/tanukisoftware/wrapper/WrapperUser.java (revision 174)
@@ -11,7 +11,8 @@
1111 * http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html
1212 */
1313
14-import java.util.Vector;
14+import java.util.ArrayList;
15+import java.util.List;
1516
1617 /**
1718 * A WrapperUser contains information about a user account on the platform
@@ -25,9 +26,8 @@
2526 /* The name of the user. */
2627 private String m_user;
2728
28- /** A list of the groups that this user is registered with.
29- * This uses a Vector to be compatable with 1.2.x JVMs. */
30- private Vector m_groups = new Vector();
29+ /** A list of the groups that this user is registered with. */
30+ private List m_groups = new ArrayList();
3131
3232 /*---------------------------------------------------------------
3333 * Constructors
@@ -58,7 +58,7 @@
5858 */
5959 void addGroup( WrapperGroup group )
6060 {
61- m_groups.addElement( group );
61+ m_groups.add( group );
6262 }
6363
6464 /**
旧リポジトリブラウザで表示