use of com.sun.appserv.management.client.ProxyFactory in project Payara by payara.
the class ProxyFactoryTest method testProxyFactoryDetectsMBeanRemoved.
/**
* Verify that when an MBean is removed, the ProxyFactory
* detects this, and removes any proxy from its cache.
*/
public void testProxyFactoryDetectsMBeanRemoved() throws InstanceNotFoundException {
// use the NotificationServiceMgr as a convenient way of making
// an MBean (a NotificationService) come and go.
final NotificationServiceMgr mgr = getDomainRoot().getNotificationServiceMgr();
final NotificationService ns = mgr.createNotificationService("UserData", 10);
final ObjectName nsObjectName = Util.getObjectName(ns);
assert (ns.getUserData().equals("UserData"));
final ProxyFactory factory = getProxyFactory();
final NotificationService proxy = factory.getProxy(nsObjectName, NotificationService.class, false);
assert (proxy == ns) : "proxies differ: " + ns + "\n" + proxy;
mgr.removeNotificationService(ns.getName());
int iterations = 0;
long sleepMillis = 10;
while (factory.getProxy(nsObjectName, NotificationService.class, false) != null) {
mySleep(sleepMillis);
if (sleepMillis >= 400) {
trace("testProxyFactoryDetectsMBeanRemoved: waiting for proxy to be removed");
}
sleepMillis *= 2;
}
}
use of com.sun.appserv.management.client.ProxyFactory in project Payara by payara.
the class AMXTestBase method getProxy.
protected final AMX getProxy(final ObjectName objectName) {
final ProxyFactory factory = ProxyFactory.getInstance(getConnectionSource(), true);
final AMX proxy = factory.getProxy(objectName, AMX.class);
return (proxy);
}
use of com.sun.appserv.management.client.ProxyFactory in project Payara by payara.
the class TestUtil method asAMXDebugStuff.
public AMXDebugStuff asAMXDebugStuff(final AMX amx) {
final String[] attrNames = Util.getExtra(amx).getAttributeNames();
AMXDebugStuff result = null;
if (GSetUtil.newUnmodifiableStringSet(attrNames).contains("AMXDebug")) {
final ProxyFactory factory = Util.getExtra(amx).getProxyFactory();
try {
final Class amxClass = ClassUtil.getClassFromName(Util.getExtra(amx).getInterfaceName());
final Class[] interfaces = new Class[] { amxClass, AMXDebugStuff.class };
final ObjectName objectName = Util.getObjectName(amx);
return (AMXDebugStuff) factory.newProxyInstance(objectName, interfaces);
} catch (Exception e) {
trace(ExceptionUtil.toString(e));
throw new RuntimeException(e);
}
}
return result;
}
use of com.sun.appserv.management.client.ProxyFactory in project Payara by payara.
the class TestUtil method getAllAMX.
/**
* @return all AMX, sorted by ObjectName
*/
public SortedSet<AMX> getAllAMX() {
final SortedSet<ObjectName> all = getAllObjectNames();
final SortedSet<AMX> allAMX = new TreeSet<AMX>(new AMXComparator<AMX>());
final ProxyFactory proxyFactory = Util.getExtra(mDomainRoot).getProxyFactory();
for (final ObjectName objectName : all) {
try {
final AMX amx = proxyFactory.getProxy(objectName, AMX.class);
allAMX.add(amx);
} catch (Exception e) {
trace(ExceptionUtil.toString(e));
}
}
return allAMX;
}
use of com.sun.appserv.management.client.ProxyFactory in project Payara by payara.
the class ConfigMgrTestBase method testCreateRemove.
public final synchronized void testCreateRemove() throws Exception {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final long start = now();
String name = getProgenyTestName();
final String progenyJ2EEType = getProgenyJ2EEType();
AMXConfig proxy = getProgeny(name);
if (proxy != null) {
final ObjectName objectName = Util.getExtra(proxy).getObjectName();
remove(name);
waitUnregistered(objectName);
assert (!getConnection().isRegistered(objectName));
assert (getProgeny(name) == null);
proxy = null;
}
final Container container = getProgenyContainer();
final CreateRemoveListener listener = new CreateRemoveListener(container, progenyJ2EEType, name);
// create it
try {
proxy = createProgeny(name, null);
} catch (Exception e) {
trace(getStackTrace(ExceptionUtil.getRootCause(e)));
failure("Can't create item of j2eeType=" + progenyJ2EEType + ",name=" + name);
}
assert (proxy.getName().equals(name));
final ObjectName objectName = Util.getObjectName(proxy);
assert (getConnection().isRegistered(objectName));
assert (container.getContainee(progenyJ2EEType, name) != null);
assert (container.getContainee(progenyJ2EEType, name) == proxy);
final AMXConfig progeny = getProgeny(name);
assert (progeny == proxy);
// remove it
final ProxyFactory factory = Util.getExtra(proxy).getProxyFactory();
assert (name.equals(progeny.getName()));
remove(name);
waitUnregistered(objectName);
assert (!getConnection().isRegistered(objectName));
waitProxyGone(factory, objectName);
assert (getProgeny(name) == null);
listener.waitNotifs();
printElapsed("testCreateRemove: created/remove/listen for: " + progenyJ2EEType, start);
}
Aggregations