test/java/rmi/testlibrary/RMID.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 26,36 ****
*/
import java.io.*;
import java.rmi.*;
import java.rmi.activation.*;
- import java.util.Properties;
/**
* Utility class that creates an instance of rmid with a policy
* file of name <code>TestParams.defaultPolicy</code>.
*
--- 26,35 ----
*** 131,141 ****
public static RMID createRMID(OutputStream out, OutputStream err,
boolean debugExec)
{
return createRMID(out, err, debugExec, true,
! TestLibrary.RMID_PORT);
}
public static RMID createRMID(OutputStream out, OutputStream err,
boolean debugExec, boolean includePortArg,
int port)
--- 130,140 ----
public static RMID createRMID(OutputStream out, OutputStream err,
boolean debugExec)
{
return createRMID(out, err, debugExec, true,
! TestLibrary.getUnusedRandomPort());
}
public static RMID createRMID(OutputStream out, OutputStream err,
boolean debugExec, boolean includePortArg,
int port)
*** 206,216 ****
if (getVM() != null) return;
// if rmid is already running, then the test will fail with
// a well recognized exception (port already in use...).
! mesg("starting rmid...");
super.start();
int slopFactor = 1;
try {
slopFactor = Integer.valueOf(
--- 205,215 ----
if (getVM() != null) return;
// if rmid is already running, then the test will fail with
// a well recognized exception (port already in use...).
! mesg("starting rmid on port #" + port + "...");
super.start();
int slopFactor = 1;
try {
slopFactor = Integer.valueOf(
*** 233,242 ****
--- 232,249 ----
}
waitTime -= rmidStartSleepTime;
// Checking if rmid is present
if (ActivationLibrary.rmidRunning(port)) {
+ /**
+ * We need to set the java.rmi.activation.port value as the
+ * activation system will use the property to determine the
+ * port #. The activation system will use this value if set.
+ * If it isn't set, the activation system will set it to an
+ * incorrect value.
+ */
+ System.setProperty("java.rmi.activation.port", Integer.toString(port));
mesg("finished starting rmid.");
return;
}
else {
mesg("rmid still not started");
*** 257,270 ****
* at time of shutdown invocation.
*
* Shutdown does not nullify possible references to the rmid
* process object (destroy does though).
*/
- public static void shutdown() {
- shutdown(TestLibrary.RMID_PORT);
- }
-
public static void shutdown(int port) {
try {
ActivationSystem system = null;
--- 264,273 ----
*** 299,311 ****
* Ask rmid to shutdown gracefully but then destroy the rmid
* process if it does not exit by itself. This method only works
* if rmid is a child process of the current VM.
*/
public void destroy() {
!
! // attempt graceful shutdown of the activation system on
! // TestLibrary.RMID_PORT
shutdown(port);
if (vm != null) {
try {
/* Waiting for distant RMID process to shutdown.
--- 302,312 ----
* Ask rmid to shutdown gracefully but then destroy the rmid
* process if it does not exit by itself. This method only works
* if rmid is a child process of the current VM.
*/
public void destroy() {
! // attempt graceful shutdown of the activation system
shutdown(port);
if (vm != null) {
try {
/* Waiting for distant RMID process to shutdown.
*** 355,360 ****
--- 356,363 ----
// rmid will not restart if its process is not null
vm = null;
}
}
+
+ public int getPort() {return port;}
}