test/java/rmi/reliability/juicer/AppleUserImpl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 2008, 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) 2003, 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.
*** 57,88 ****
* @library ../../testlibrary
*
* @build Apple AppleEvent AppleImpl AppleUserImpl
* @build Orange OrangeEcho OrangeEchoImpl OrangeImpl
* @build ApplicationServer
*
* @run main/othervm/policy=security.policy AppleUserImpl -seconds 30
*
* @author Peter Jones, Nigel Daley
*/
- import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException;
! import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.util.Random;
- import java.util.logging.Logger;
import java.util.logging.Level;
/**
* The AppleUserImpl class implements the behavior of the remote
* "apple user" objects exported by the server. The application server
* passes each of its remote "apple" objects to an apple user, and an
* AppleUserThread is created for each apple.
*/
public class AppleUserImpl extends UnicastRemoteObject implements AppleUser {
!
private static final Logger logger =
Logger.getLogger("reliability.appleuser");
private static int threadNum = 0;
private static long testDuration = 0;
private static int maxLevel = 7;
--- 57,90 ----
* @library ../../testlibrary
*
* @build Apple AppleEvent AppleImpl AppleUserImpl
* @build Orange OrangeEcho OrangeEchoImpl OrangeImpl
* @build ApplicationServer
+ * @build TestLibrary
*
* @run main/othervm/policy=security.policy AppleUserImpl -seconds 30
*
* @author Peter Jones, Nigel Daley
*/
import java.rmi.NoSuchObjectException;
! import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
+ import java.rmi.registry.Registry;
+ import java.rmi.server.UnicastRemoteObject;
import java.util.Random;
import java.util.logging.Level;
+ import java.util.logging.Logger;
/**
* The AppleUserImpl class implements the behavior of the remote
* "apple user" objects exported by the server. The application server
* passes each of its remote "apple" objects to an apple user, and an
* AppleUserThread is created for each apple.
*/
public class AppleUserImpl extends UnicastRemoteObject implements AppleUser {
! private static int registryPort = -1;
private static final Logger logger =
Logger.getLogger("reliability.appleuser");
private static int threadNum = 0;
private static long testDuration = 0;
private static int maxLevel = 7;
*** 306,326 ****
try {
user = new AppleUserImpl();
synchronized (user) {
// create new registry and bind new AppleUserImpl in registry
! LocateRegistry.createRegistry(2006);
! LocateRegistry.getRegistry(2006).rebind("AppleUser",user);
// start the other server if applicable
if (othervm) {
// the other server must be running in a separate process
logger.log(Level.INFO, "Application server must be " +
"started in separate process");
} else {
Class app = Class.forName("ApplicationServer");
! server = new Thread((Runnable) app.newInstance());
logger.log(Level.INFO, "Starting application server " +
"in same process");
server.start();
}
--- 308,332 ----
try {
user = new AppleUserImpl();
synchronized (user) {
// create new registry and bind new AppleUserImpl in registry
! Registry registry = TestLibrary.createRegistryOnUnusedPort();
! registryPort = TestLibrary.getRegistryPort(registry);
! LocateRegistry.getRegistry(registryPort).rebind("AppleUser",
! user);
// start the other server if applicable
if (othervm) {
// the other server must be running in a separate process
logger.log(Level.INFO, "Application server must be " +
"started in separate process");
} else {
Class app = Class.forName("ApplicationServer");
! java.lang.reflect.Constructor appConstructor =
! app.getDeclaredConstructor(new Class[] {Integer.TYPE});
! server = new Thread((Runnable) appConstructor.newInstance(registryPort));
logger.log(Level.INFO, "Starting application server " +
"in same process");
server.start();
}