/*
(non-Javadoc)
@see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer, javax.management.ObjectName)
494998
public ObjectName preRegister(MBeanServer server, ObjectName name)
			throws Exception {
		oname=name;
        mserver=server;
        domain=name.getDomain();
        return name;
	}
274405
public void register(BundleContext bndCtx) {
        final String methodName = "register()";
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, methodName, this);
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put("jmx.objectname", this.obn.toString());

        if (IS_DEBUGGING)
            // Extra Check: Does this MBean exist already?
            MBeanHelper.isMbeanExist(objectName.toString() + "*", className, methodName);

        // Register the MBean
        if (trace && tc.isDebugEnabled())
            Tr.debug(tc, "activateMBean started for " + this.obn.toString());
        this.reg = bndCtx.registerService(JCAConnectionFactoryMBeanImpl.class.getName(), this, props);
        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, methodName, this);
    }
950665
public void unregister(ZKMBeanInfo bean) {
        if(bean==null)
            return;
        String path=mapBean2Path.get(bean);
        try {
            unregister(path,bean);
        }
        catch (InstanceNotFoundException e) {
            LOG.warn("InstanceNotFoundException during unregister usually means more than one Zookeeper server has been running in a single JVM");
            LOG.warn("InstanceNotFoundException during unregister can be safely ignored during automated tests.");
        }
        catch (JMException e) {
            LOG.warn("Error during unregister", e);
        }
        mapBean2Path.remove(bean);
        mapName2Bean.remove(bean.getName());
    }
38830
@Override
  protected void registered(RequestServer.API_VERSION ver) {
    super.registered(ver);
    for (Argument arg : _arguments) {
      if ( arg._name.equals("activation") || arg._name.equals("initial_weight_distribution")
              || arg._name.equals("expert_mode") || arg._name.equals("adaptive_rate")
              || arg._name.equals("replicate_training_data")
              || arg._name.equals("balance_classes")
              || arg._name.equals("n_folds")
              || arg._name.equals("autoencoder")
              || arg._name.equals("checkpoint")) {
        arg.setRefreshOnChange();
      }
    }
  }
1157774
public static void unregisterMbean(ObjectName name) {
        try {
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
        } catch(Exception e) {
            logger.error("Error unregistering mbean", e);
        }
    }
460915
@Override
	protected void configure(ServletRegistration.Dynamic registration) {
		super.configure(registration);
		String[] urlMapping = StringUtils.toStringArray(this.urlMappings);
		if (urlMapping.length == 0 && this.alwaysMapUrl) {
			urlMapping = DEFAULT_MAPPINGS;
		}
		if (!ObjectUtils.isEmpty(urlMapping)) {
			registration.addMapping(urlMapping);
		}
		registration.setLoadOnStartup(this.loadOnStartup);
		if (this.multipartConfig != null) {
			registration.setMultipartConfig(this.multipartConfig);
		}
	}
392079
private static void unregisterMBean(String name) {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        try {
            synchronized (mbs) {
                ObjectName objName = new ObjectName(name);
                if (mbs.isRegistered(objName)) {
                    mbs.unregisterMBean(objName);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
1225958
private static void unregister(ObjectName objectName) {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    try {
      for (ObjectName name : server.queryNames(objectName, null)) {
        server.unregisterMBean(name);
      }
    } catch (MBeanRegistrationException | InstanceNotFoundException e) {
      throw new CacheException("Error unregistering " + objectName, e);
    }
  }
1221614
public static <K, V> void unregisterCacheObject(AbstractJCache<K, V> cache, ObjectNameType objectNameType) {
      Set<ObjectName> registeredObjectNames;
      MBeanServer mBeanServer = cache.getMBeanServer();

      if (mBeanServer != null) {
         ObjectName objectName = calculateObjectName(cache, objectNameType);
         registeredObjectNames = SecurityActions.queryNames(objectName, null, mBeanServer);

         //should just be one
         for (ObjectName registeredObjectName : registeredObjectNames) {
            try {
               SecurityActions.unregisterMBean(registeredObjectName, mBeanServer);
            } catch (Exception e) {
               throw new CacheException("Error unregistering object instance "
                     + registeredObjectName + " . Error was " + e.getMessage(), e);
            }
         }
      }
   }
1237405
public static void registerMbean(Object mbean, ObjectName name) {
        registerMbean(ManagementFactory.getPlatformMBeanServer(),
                      JmxUtils.createModelMBean(mbean),
                      name);
    }
454633
@Override
  public void unregister(Monitor<?> monitor) {
    try {
      List<MonitorMBean> beans = MonitorMBean.createMBeans(name, monitor, mapper);
      for (MonitorMBean bean : beans) {
        try {
          mBeanServer.unregisterMBean(bean.getObjectName());
          locks.remove(bean.getObjectName());
        } catch (InstanceNotFoundException ignored) {
          // ignore errors attempting to unregister a non-registered monitor
          // a common error is to unregister twice
        }
      }
      monitors.remove(monitor.getConfig());
      updatePending.set(true);
    } catch (Exception e) {
      LOG.warn("Unable to un-register Monitor:" + monitor.getConfig(), e);
    }
  }
16978
public String registerMBean(Object bean, String name)
            throws MalformedObjectNameException, NotCompliantMBeanException, MBeanRegistrationException {
        return registerMBean(bean, name, false);
    }
1215990
public static void regMBean(final Object object, final String... parameters) {
		try {
			final String name = buildObjectName(object, parameters);
			final ObjectName objectName = new ObjectName(name);
			if (mbs.isRegistered(objectName))
				return;
			mbs.registerMBean(object, objectName);
		} catch (final MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
			log.error("can't register mbean regMBean("+object+", "+ Arrays.toString(parameters)+ ')', e);
		} catch (final AccessControlException e){
			log.error("Access denied, can no register mbean add permission javax.management.MBeanTrustPermission \"register\"; to java.policy file", e);
		}
	}
18320
private List<ObjectName> registerMBeans(MBeanServer pServer, String pDomain) {
        List<ObjectName> ret = new ArrayList<ObjectName>();
        try {
            // Register my test mbeans
            for (String name : strangeNamesShort) {
                String strangeName = pDomain + ":type=naming/,name=" + name;
                strangeNames.add(strangeName);
                ret.add(registerMBean(pServer, new ObjectNameChecking(strangeName), strangeName));
            }
            for (String name : escapedNamesShort) {
                String escapedName = pDomain + ":type=escape,name=" + ObjectName.quote(name);
                escapedNames.add(escapedName);
                ret.add(registerMBean(pServer, new ObjectNameChecking(escapedName), escapedName));
            }

            // Other MBeans with different names
            for (String name : fullNames) {
                ret.add(registerMBean(pServer, new ObjectNameChecking(name), name));
            }

            // Other MBeans
            boolean isWebsphere = checkForClass("com.ibm.websphere.management.AdminServiceFactory");
            ret.add(registerMBean(pServer,new OperationChecking(JOLOKIA_IT_DOMAIN),isWebsphere ? null : pDomain + ":type=operation"));
            ret.add(registerMBean(pServer, new AttributeChecking(JOLOKIA_IT_DOMAIN), isWebsphere ? null : pDomain + ":type=attribute"));
            // MXBean
            if (hasMxBeanSupport()) {
                ret.add(registerMBean(pServer, new MxBeanSample(), isWebsphere ? null : pDomain + ":type=mxbean"));
            }
            // Tabular Data MBean
            ret.add(registerMBean(pServer, new TabularMBean(), pDomain + ":type=tabularData"));
        } catch (RuntimeException e) {
            throw new RuntimeException("Error",e);
        } catch (Exception exp) {
            throw new RuntimeException("Error",exp);
        }
        return ret;
    }
988906
@Override
    public Future<Void> registerProvider(final String domain,
                                         Object provider,
                                         ProviderQos providerQos,
                                         boolean awaitGlobalRegistration) {
        if (providerQos == null) {
            throw new JoynrRuntimeException("providerQos == null. It must not be null");
        }
        ProviderContainer providerContainer = providerContainerFactory.create(provider);
        String participantId = participantIdStorage.getProviderParticipantId(domain,
                                                                             providerContainer.getInterfaceName(),
                                                                             providerContainer.getMajorVersion());
        String defaultPublicKeyId = "";
        DiscoveryEntry discoveryEntry = new DiscoveryEntry(getVersionFromAnnotation(provider.getClass()),
                                                           domain,
                                                           providerContainer.getInterfaceName(),
                                                           participantId,
                                                           providerQos,
                                                           System.currentTimeMillis(),
                                                           System.currentTimeMillis() + defaultExpiryTimeMs,
                                                           defaultPublicKeyId);
        final boolean isGloballyVisible = (discoveryEntry.getQos().getScope() == ProviderScope.GLOBAL);
        messageRouter.addNextHop(participantId, libjoynrMessagingAddress, isGloballyVisible);
        providerDirectory.add(participantId, providerContainer);

        Callback<Void> callback = new Callback<Void>() {
            @Override
            public void onSuccess(@CheckForNull Void result) {

            }

            @Override
            public void onFailure(JoynrRuntimeException runtimeException) {
                logger.error("Unexpected Error while registering Provider:", runtimeException);

            }
        };
        return localDiscoveryAggregator.add(callback, discoveryEntry, awaitGlobalRegistration);
    }
494896
public static void initializeDomainRegistry(final TransformerRegistry registry) {

        //The chains for transforming will be as follows
        //For JBoss EAP: 8.0.0 -> 5.0.0 -> 4.0.0 -> 1.8.0 -> 1.7.0 -> 1.6.0 -> 1.5.0

        registerRootTransformers(registry);
        registerChainedManagementTransformers(registry);
        registerChainedServerGroupTransformers(registry);
        registerProfileTransformers(registry);
        registerSocketBindingGroupTransformers(registry);
        registerDeploymentTransformers(registry);
    }
1296304
public static void preRegister(Context context) {
        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
            public JavaFileManager make(Context c) {
                return new JavacFileManager(c, true, null);
            }
        });
    }