01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package test.javax.management.support;
10:
11: import java.util.Set;
12: import javax.management.MBeanRegistration;
13: import javax.management.MBeanServer;
14: import javax.management.ObjectInstance;
15: import javax.management.ObjectName;
16:
17: /**
18: * @version $Revision: 1.3 $
19: */
20: public class PostRegistrationSupport implements
21: PostRegistrationSupportMBean, MBeanRegistration {
22: private MBeanServer server;
23: private ObjectName name;
24:
25: public ObjectName preRegister(MBeanServer server, ObjectName name)
26: throws Exception {
27: this .server = server;
28: this .name = name;
29: return name;
30: }
31:
32: public void postRegister(Boolean registrationDone) {
33: if (registrationDone.booleanValue()) {
34: Set mbeans = server.queryMBeans(name, null);
35: if (mbeans.size() != 1)
36: throw new Error();
37: ObjectInstance instance = (ObjectInstance) mbeans
38: .iterator().next();
39: if (instance == null)
40: throw new Error();
41: }
42: }
43:
44: public void preDeregister() throws Exception {
45: }
46:
47: public void postDeregister() {
48: }
49: }
|