/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7654321
* @summary Tests to receive notifications for opened and closed connections
ions
* @author sjiang
* @run clean RMINotifTest
* @run build RMINotifTest
* @run main RMINotifTest
* @run main RMINotifTest event
*/
// java imports
//
public class RMINotifTest {
try {
// create a rmi registry
int port = 6666;
while(port++<7000) {
try {
break;
} catch (RemoteException re) {
// no problem
}
}
"the ports from 6666 to 6999 are all occupied.");
}
// create a MBeanServer
// create a notif emitter mbean
// create a rmi server
null);
ObjectInstance ss = server.registerMBean(sServer, new ObjectName("Default:name=RmiConnectorServer"));
// create a rmi client
// add listener at the client side
//ask to send notifs
// waiting ...
synchronized (lock) {
if (receivedNotifs != nb) {
}
}
// check
if (receivedNotifs != nb) {
} else {
}
// remove listener
// more test
// // clean
// client.unregisterMBean(mbean);
// rmiConnection.close();
// Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
//--------------------------
// private classes
//--------------------------
if(++receivedNotifs == nb) {
synchronized(lock) {
}
}
}
}
public static class NotificationEmitter extends NotificationBroadcasterSupport implements NotificationEmitterMBean {
// public NotificationEmitter() {
// super();
// System.out.println("===NotificationEmitter: new instance.");
// }
/**
* Returns a NotificationInfo object containing the name of the Java class of the notification
* and the notification types sent by this notification broadcaster.
*/
"javax.management.Notification",
"Notifications sent by the NotificationEmitter");
return ntfInfoArray;
}
// public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {
// super.addNotificationListener(listener, filter, handback);
// System.out.println("============NotificationEmitter: add new listener");
// }
/**
* Send a Notification object with the specified times.
* The sequence number will be from zero to times-1.
*
* @param nb The number of notifications to send
*/
}
}
}
public interface NotificationEmitterMBean {
}
}