Return object name with which will be register in {@link MBeanServer}.

@param object     provided object
@param parameters additional parameters
@return object name
197465
private static String buildObjectName(final Object object, final String... parameters) {
		final StringBuilder objectName = new StringBuilder();
		objectName.append(object.getClass().getPackage().getName());
		objectName.append(":type=");
		objectName.append(object.getClass().getName());
		if (parameters.length > 0) {
			objectName.append('(');
			for (final String parameter : parameters)
				objectName.append(parameter).append(',');
			objectName.deleteCharAt(objectName.length() - 1);
			objectName.append(')');
		}
		return objectName.toString();
	}

	/**
	 * Private constructor.
	 */
	private MBeanRegisterUtil() {
		throw new IllegalAccessError("Can't instantiate.");
	}
}
1346973
public static ObjectName getAppJawrConfigMBeanObjectName(ServletContext servletContext, String mBeanPrefix) {

		return getMBeanObjectName(getContextPath(servletContext), JAWR_APP_CONFIG_MANAGER_TYPE, mBeanPrefix, null);
	}
553104
public static <T> T parameterizeObject(T object) {
      if (object == null) {
         return null;
      }

      BeanMap beanMap = new BeanMap(object);
      List<Class<?>> list = ReflectionUtils.getAncestorClasses(object);
      Collections.reverse(list);
      for (Class<?> clazz : list) {
         doParametrization(beanMap, clazz.getName());
      }

      return object;
   }
1035522
public static String getClassName(final Object object) {

    return object != null ? object.getClass().getName() : NULL_STRING;
  }
484618
private static ObjectNameMapper getObjectNameMapper(Properties props) {
    ObjectNameMapper mapper = ObjectNameMapper.DEFAULT;
    final String jmxNameMapperClass = props.getProperty(REGISTRY_JMX_NAME_PROP);
    if (jmxNameMapperClass != null) {
      try {
        Class<?> mapperClazz = Class.forName(jmxNameMapperClass);
        mapper = (ObjectNameMapper) mapperClazz.newInstance();
      } catch (Throwable t) {
        LOG.error(
            "failed to create the JMX ObjectNameMapper instance of class "
                + jmxNameMapperClass
                + ", using the default naming scheme",
            t);
      }
    }

    return mapper;
  }
1263628
public static String[] getNames(Object object) {
		if (object == null) {
			return null;
		}
		Class<? extends Object> klass = object.getClass();
		Field[] fields = klass.getFields();
		int length = fields.length;
		if (length == 0) {
			return null;
		}
		String[] names = new String[length];
		for (int i = 0; i < length; i += 1) {
			names[i] = fields[i].getName();
		}
		return names;
	}
374795
public static MBeanServer getMBeanServer(String domain)
   {
      try
      {
         ArrayList<MBeanServer> l = MBeanServerFactory.findMBeanServer(null);

         if (l != null)
         {
            for (MBeanServer ms : l)
            {
               String[] domains = ms.getDomains();

               if (domains != null)
               {
                  for (String d : domains)
                  {
                     if (domain.equals(d))
                     {
                        return ms;
                     }
                  }
               }
            }
         }
      }
      catch (SecurityException se)
      {
         // Ignore
      }

      return null;
   }
47698
public static Function<Object,Object> obj(final String methodName, final Object... optionalParameters) {
        return methodForObject(methodName, optionalParameters);
    }
1345165
static MBeanServer registerJolokiaMBeanServerHolderMBean(MBeanServer pServer) {
        JolokiaMBeanServerHolder holder = new JolokiaMBeanServerHolder();
        ObjectName holderName = createObjectName(JolokiaMBeanServerHolderMBean.OBJECT_NAME);
        MBeanServer jolokiaMBeanServer;
        try {
            pServer.registerMBean(holder,holderName);
            jolokiaMBeanServer = holder.getJolokiaMBeanServer();
        } catch (InstanceAlreadyExistsException e) {
            // If the instance already exist, we look it up and fetch the MBeanServerHolder from there.
            // Might happen in race conditions.
            try {
                jolokiaMBeanServer = (MBeanServer) pServer.getAttribute(holderName,JOLOKIA_MBEAN_SERVER_ATTRIBUTE);
            } catch (JMException e1) {
                throw new IllegalStateException("Internal: Cannot get JolokiaMBean server in fallback JMX lookup " +
                                                "while trying to register the holder MBean: " + e1,e1);
            }
        } catch (JMException e) {
            throw new IllegalStateException("Internal: JolokiaMBeanHolder cannot be registered to JMX: " + e,e);
        }
        return jolokiaMBeanServer;
    }
1000348
public static ObjectName createApplicationObjectName(String name, String serverName) {
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put(TYPE_SERVER, serverName);
        return createObjectName(TYPE_APPLICATION, name, props);
    }
426713
private String getParameterName(AnnotatedParameter<?> parameter) {
        Parameter[] parameters = ((Method) parameter.getDeclaringCallable().getJavaMember()).getParameters();
        Parameter param = parameters[parameter.getPosition()];
        if (param.isNamePresent()) {
            return param.getName();
        }
        else {
            throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], activate the -parameters compiler argument or annotate the injected parameter with the @Metric annotation");
        }
    }
899253
public static Type parameterizedType(Object object) {
    if (object != null) {
      Type type = object.getClass().getGenericSuperclass();
      if (type instanceof ParameterizedType) {
        return ((ParameterizedType) type).getActualTypeArguments()[0];
      }
    }
    return Object.class;
  }
93403
private String isSpecialMBean(ObjectName nameObject) {
        String domain = nameObject.getDomain();
        if ("org.apache.activemq".equals(domain)) {
            String destinationType = nameObject.getKeyProperty("destinationType");
            // see: org.apache.activemq.command.ActiveMQDestination.getDestinationTypeAsString()
            if ("Queue".equals(destinationType)) {
                return "activemq:queue";
            }
            if ("TempQueue".equals(destinationType)) {
                return "activemq:tempqueue";
            }
            if ("Topic".equals(destinationType)) {
                return "activemq:topic";
            }
            if ("TempTopic".equals(destinationType)) {
                return "activemq:temptopic";
            }
        } else if ("org.apache.camel".equals(domain)) {
            String type = nameObject.getKeyProperty("type");
            // TODO: verify: "type" attribute is not enough - we have to know real class of MBean
            return null;
        }

        return null;
    }
257797
public String getParameterName(Integer position) {
        String name = null;

        if (this.sqlParameterNames != null) {
            name = this.sqlParameterNames.get(position);
        }

        return name;
    }
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);
		}
	}
532057
public synchronized ObjectName register(Object obj) throws JMException {
		if (mbeanServer == null) {
			throw new JMException("JmxServer has not be started");
		}
		ObjectName objectName = ObjectNameUtil.makeObjectName(obj);
		ReflectionMbean mbean;
		try {
			mbean = new ReflectionMbean(obj, getObjectDescription(obj));
		} catch (Exception e) {
			throw createJmException("Could not build MBean object for: " + obj, e);
		}
		doRegister(objectName, mbean);
		return objectName;
	}
548481
private <T> ServiceRegistration<T> registerMBean(ObjectName on, Class<T> type, T o) {
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("jmx.objectname", on.toString());
        return context.registerService(type, o, props);
    }