1 23 package com.sun.enterprise.management; 24 25 import java.util.Set ; 26 27 import javax.management.ObjectName ; 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 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 e ) 59 { 60 throw new RuntimeException ( 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 (); 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 <ObjectName > 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 |