/* */ {
/* 182 */ ObjectName regName = name;
/* 183 */ boolean registrationDone = true;
/* 184 */ boolean invokedPreRegister = false;
/* 185 */ String magicToken = null;
/* 186 */ MBeanInvoker invoker = null;
/* */
/* 188 */ if (object == null) {
/* 189 */ throw new RuntimeOperationsException(new IllegalArgumentException("Attempting to register null object"));
/* */ }
/* */
/* 193 */ MBeanCapability mbcap = MBeanCapability.of(object.getClass());
/* */ try
/* */ {
/* 198 */ if (valueMap != null) {
/* 199 */ magicToken = (String)valueMap.get(JMI_DOMAIN);
/* */ }
/* */
/* 202 */ int mbeanType = mbcap.getMBeanType();
/* 203 */ if (mbeanType == 291)
/* */ {
/* 205 */ invoker = new XMBean(object, "StandardMBean");
/* */ }
/* 207 */ else if ((object instanceof MBeanInvoker))
/* */ {
/* 209 */ invoker = (MBeanInvoker)object;
/* */ }
/* 211 */ else if (mbeanType == 801)
/* */ {
/* 213 */ if ((object instanceof RequiredModelMBean))
/* 214 */ invoker = new RequiredModelMBeanInvoker((DynamicMBean)object);
/* */ else {
/* 216 */ invoker = new RawDynamicInvoker((DynamicMBean)object);
/* */ }
/* */ }
/* */
/* 220 */ MBeanEntry entry = new MBeanEntry(regName, invoker, object, valueMap);
/* 221 */ AbstractMBeanInvoker.setMBeanEntry(entry);
/* 222 */ regName = invokePreRegister(invoker, regName, magicToken);
/* 223 */ invokedPreRegister = true;
/* */ try
/* */ {
/* 227 */ MBeanInfo info = invoker.getMBeanInfo();
/* 228 */ verifyMBeanInfo(info, name);
/* 229 */ entry.setResourceClassName(info.getClassName());
/* */
/* 234 */ entry.setObjectName(regName);
/* */
/* 236 */ add(entry);
/* */ try
/* */ {
/* 241 */ if ((object instanceof ClassLoader)) {
/* 242 */ registerClassLoader((ClassLoader)object);
/* */ }
/* */ try
/* */ {
/* 246 */ if (this.delegate != null)
/* 247 */ sendRegistrationNotification(regName);
/* 248 */ else if (serverConfig.getMBeanServerDelegateName().equals(name)) {
/* 249 */ this.delegate = ((MBeanServerDelegate)object);
/* */ }
/* 251 */ ServerObjectInstance serverObjInst = new ServerObjectInstance(regName, entry.getResourceClassName(), this.delegate.getMBeanServerId());
/* */
/* 254 */ persistIfRequired(invoker.getMBeanInfo(), regName);
/* */
/* 256 */ ServerObjectInstance localServerObjectInstance1 = serverObjInst;
/* */
/* 334 */ if (invoker != null)
/* */ {
/* */ try
/* */ {
/* 338 */ invoker.postRegister(new Boolean(registrationDone));
/* */ }
/* */ catch (Exception e)
/* */ {
/* 343 */ if (invokedPreRegister == true)
/* */ {
/* 345 */ if ((e instanceof RuntimeException)) {
/* 346 */ throw new RuntimeMBeanException((RuntimeException)e);
/* */ }
/* 348 */ throw new MBeanRegistrationException(e);
/* */ }
/* */ }
/* */ }
/* 352 */ AbstractMBeanInvoker.setMBeanEntry(null); return localServerObjectInstance1;
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 262 */ if ((object instanceof ClassLoader)) {
/* 263 */ this.loaderRepository.removeClassLoader((ClassLoader)object);
/* */ }
/* 265 */ throw t;
/* */ }
/* */
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 271 */ remove(regName);
/* 272 */ throw t;
/* */ }
/* */
/* */ }
/* */ catch (NotCompliantMBeanException e)
/* */ {
/* 278 */ throw e;
/* */ }
/* */ catch (InstanceAlreadyExistsException e)
/* */ {
/* 283 */ throw e;
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 288 */ log.error("Unexpected Exception:", t);
/* 289 */ throw t;
/* */ }
/* */ }
/* */ catch (NotCompliantMBeanException e)
/* */ {
/* 294 */ registrationDone = false;
/* 295 */ throw e;
/* */ }
/* */ catch (InstanceAlreadyExistsException e)
/* */ {
/* 300 */ registrationDone = false;
/* 301 */ throw e;
/* */ }
/* */ catch (MBeanRegistrationException e)
/* */ {
/* 306 */ registrationDone = false;
/* 307 */ log.warn(e.toString());
/* 308 */ throw e;
/* */ }
/* */ catch (RuntimeOperationsException e)
/* */ {
/* 313 */ registrationDone = false;
/* 314 */ throw e;
/* */ }
/* */ catch (Exception ex)
/* */ {
/* 319 */ registrationDone = false;
/* 320 */ ncex = new NotCompliantMBeanException("Cannot register MBean: " + name);
/* 321 */ ncex.initCause(ex);
/* 322 */ throw ncex;
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 327 */ log.error("Cannot register MBean", t);
/* 328 */ registrationDone = false;
/* 329 */ NotCompliantMBeanException ncex = null;
/* */ return ncex;
/* */ }
/* */ finally
/* */ {
/* 334 */ if (invoker != null)
/* */ {
/* */ try
/* */ {
/* 338 */ invoker.postRegister(new Boolean(registrationDone));
/* */ }
/* */ catch (Exception e)
/* */ {
/* 343 */ if (invokedPreRegister == true)
/* */ {