KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > Observer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.management;
24
25 import java.util.Set JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28
29 import com.sun.appserv.management.DomainRoot;
30 import com.sun.appserv.management.base.Util;
31 import com.sun.appserv.management.client.ConnectionSource;
32
33
34 /**
35     Observes various things as tests are run.
36  */

37 public final class Observer
38 {
39     private static Observer INSTANCE = null;
40     
41     private final RegistrationListener mListener;
42     
43     private final DomainRoot mDomainRoot;
44     
45         private
46     Observer( final DomainRoot domainRoot )
47     {
48         mDomainRoot = domainRoot;
49         
50         final ConnectionSource connSource =
51             Util.getExtra(domainRoot).getConnectionSource();
52         
53         try
54         {
55             mListener = new RegistrationListener(
56                 connSource.getExistingMBeanServerConnection() );
57         }
58         catch ( Exception JavaDoc e )
59         {
60             throw new RuntimeException JavaDoc( e );
61         }
62     }
63     
64         public static synchronized Observer
65     create( final DomainRoot domainRoot )
66     {
67         if ( INSTANCE == null )
68         {
69             INSTANCE = new Observer( domainRoot );
70         }
71         else
72         {
73             throw new IllegalArgumentException JavaDoc();
74         }
75         return INSTANCE;
76     }
77     
78         public static Observer
79     getInstance()
80     {
81         return INSTANCE;
82     }
83     
84         public RegistrationListener
85     getRegistrationListener()
86     {
87         return mListener;
88     }
89     
90         public Set JavaDoc<ObjectName JavaDoc>
91     getCurrentlyRegisteredAMX()
92     {
93         return mListener.getCurrentlyRegistered();
94     }
95     
96         public void
97     notifsLost()
98     {
99         mListener.notifsLost();
100     }
101     
102 }
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Popular Tags