1 22 package org.jboss.test.jmx.compliance.registration.support; 23 24 import javax.management.MBeanRegistration ; 25 import javax.management.ObjectName ; 26 import javax.management.MBeanServer ; 27 28 public class RegistrationAware implements RegistrationAwareMBean, MBeanRegistration 29 { 30 private String something; 31 32 private boolean preRegisterCalled = false; 33 private boolean preDeRegisterCalled = false; 34 private boolean postRegisterCalled = false; 35 private boolean postDeRegisterCalled = false; 36 private boolean postRegisterRegistrationDone = false; 37 38 private MBeanServer registeredServer = null; 39 private ObjectName registeredObjectName = null; 40 41 private Exception exceptionOnPreRegister = null; 42 private Exception exceptionOnPreDeRegister = null; 43 44 private ObjectName alternateObjectName = null; 45 private boolean returnAlternateObjectName = false; 46 47 public RegistrationAware() 48 { 49 } 50 51 public void setSomething(String something) 52 { 53 this.something = something; 54 } 55 56 public String getSomething() 57 { 58 return something; 59 } 60 61 62 public ObjectName preRegister(MBeanServer server, ObjectName name) 63 throws Exception 64 { 65 preRegisterCalled = true; 66 registeredServer = server; 67 registeredObjectName = name; 68 69 if (null != exceptionOnPreRegister) 70 { 71 exceptionOnPreRegister.fillInStackTrace(); 72 throw exceptionOnPreRegister; 73 } 74 75 if (returnAlternateObjectName) 76 { 77 return alternateObjectName; 78 } 79 80 return name; 81 } 82 83 public void postRegister(Boolean registrationDone) 85 { 86 postRegisterCalled = true; 87 postRegisterRegistrationDone = registrationDone.booleanValue(); 88 } 89 90 public void preDeregister() 91 throws Exception 92 { 93 preDeRegisterCalled = true; 94 95 if (null != exceptionOnPreDeRegister) 96 { 97 exceptionOnPreDeRegister.fillInStackTrace(); 98 throw exceptionOnPreDeRegister; 99 } 100 } 101 102 public void postDeregister() 103 { 104 postDeRegisterCalled = true; 105 } 106 107 public void setExceptionOnPreRegister(Exception exceptionOnPreRegister) 109 { 110 this.exceptionOnPreRegister = exceptionOnPreRegister; 111 } 112 113 public void setExceptionOnPreDeRegister(Exception exceptionOnPreDeRegister) 114 { 115 this.exceptionOnPreDeRegister = exceptionOnPreDeRegister; 116 } 117 118 public void setAlternateObjectName(ObjectName alternateObjectName) 119 { 120 this.returnAlternateObjectName = true; 121 this.alternateObjectName = alternateObjectName; 122 } 123 124 public boolean isPreRegisterCalled() 126 { 127 return preRegisterCalled; 128 } 129 130 public boolean isPreDeRegisterCalled() 131 { 132 return preDeRegisterCalled; 133 } 134 135 public boolean isPostRegisterCalled() 136 { 137 return postRegisterCalled; 138 } 139 140 public boolean isPostDeRegisterCalled() 141 { 142 return postDeRegisterCalled; 143 } 144 145 public boolean isPostRegisterRegistrationDone() 146 { 147 return postRegisterRegistrationDone; 148 } 149 150 public MBeanServer getRegisteredServer() 151 { 152 return registeredServer; 153 } 154 155 public ObjectName getRegisteredObjectName() 156 { 157 return registeredObjectName; 158 } 159 } 160 | Popular Tags |