KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > support > PostRegistrationSupport


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.support;
10
11 import java.util.Set JavaDoc;
12 import javax.management.MBeanRegistration JavaDoc;
13 import javax.management.MBeanServer JavaDoc;
14 import javax.management.ObjectInstance JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16
17 /**
18  * @version $Revision: 1.3 $
19  */

20 public class PostRegistrationSupport implements PostRegistrationSupportMBean, MBeanRegistration JavaDoc
21 {
22    private MBeanServer JavaDoc server;
23    private ObjectName JavaDoc name;
24
25    public ObjectName JavaDoc preRegister(MBeanServer JavaDoc server, ObjectName JavaDoc name) throws Exception JavaDoc
26    {
27       this.server = server;
28       this.name = name;
29       return name;
30    }
31
32    public void postRegister(Boolean JavaDoc registrationDone)
33    {
34       if (registrationDone.booleanValue())
35       {
36          Set JavaDoc mbeans = server.queryMBeans(name, null);
37          if (mbeans.size() != 1) throw new Error JavaDoc();
38          ObjectInstance JavaDoc instance = (ObjectInstance JavaDoc)mbeans.iterator().next();
39          if (instance == null) throw new Error JavaDoc();
40       }
41    }
42
43    public void preDeregister() throws Exception JavaDoc
44    {
45    }
46
47    public void postDeregister()
48    {
49    }
50 }
51
Popular Tags