Checks, is mbean required to be registered as producer
@param mBean mbean to check requirements
@return true  - mbean need to be registered
false - no
545944
private static boolean isMBeanRequired(final ObjectInstance mBean) {

        final String domain = mBean.getObjectName().getDomain();
        final String className = mBean.getClassName();

        return !domain.startsWith("moskito.") // we have to skip all the moskito internal MBeans
                && conf.isMBeanRequired(domain, className);

    }
161388
@Override
    public JMSProducer createProducer() {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createProducer");

        JMSProducer jmsProducer = null;
        try {
            // Create messageproducer first, since we reuse most in jmsproducer
            // destination is passed as null because during send,destination is passed
            // jmssession.createproducer() is not used becuase it stores the list of producers
            // which is not required for simplified API's
            MessageProducer msgProducer = jmsSession.instantiateProducer(null);
            jmsProducer = new JmsJMSProducerImpl(msgProducer);
        } catch (JMSException e) {
            // should never have got here because we pass destination as null so there is no chance 
            // that instantiateProducer() will throw any exception

            FFDCFilter.processException(e,
                                        JmsJMSContextImpl.class.toString() + ".createProducer",
                                        "598", this);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createProducer");

        return jmsProducer;

    }
120602
private static boolean isProducer(Annotated annotated) {
        boolean isProducer = false;

        Produces produces = annotated.getAnnotation(Produces.class);

        if (produces != null) {
            isProducer = true;
        }

        return isProducer;
    }
1206392
public boolean isProducerQOSOverrideEnabled()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "isProducerQOSOverrideEnabled");    
    boolean allowed = aliasDest.isOverrideOfQOSByProducerAllowed();    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "isProducerQOSOverrideEnabled", new Boolean(allowed));   
    return allowed;
  }
1123461
public <T> Producer<T> createProducer(final Bean<X> declaringBean, final Bean<T> bean, DisposalMethod<X, T> disposalMethod) {
        EnhancedAnnotatedMethod<T, X> enhancedMethod = getManager().getServices().get(MemberTransformer.class).loadEnhancedMember(method, getManager().getId());
        return new ProducerMethodProducer<X, T>(enhancedMethod, disposalMethod) {

            @Override
            public AnnotatedMethod<X> getAnnotated() {
                return method;
            }

            @Override
            public BeanManagerImpl getBeanManager() {
                return getManager();
            }

            @Override
            public Bean<X> getDeclaringBean() {
                return declaringBean;
            }

            @Override
            public Bean<T> getBean() {
                return bean;
            }
        };
    }
1211953
public static void unregisterJMXBean(ServletContext servletContext, String resourceType, String mBeanPrefix) {

		try {

			MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

			if (mbs != null) {

				ObjectName jawrConfigMgrObjName = JmxUtils.getMBeanObjectName(servletContext, resourceType,
						mBeanPrefix);

				// register the jawrApplicationConfigManager if it's not already
				// done
				ObjectName appJawrMgrObjectName = JmxUtils.getAppJawrConfigMBeanObjectName(servletContext, mBeanPrefix);
				if (mbs.isRegistered(appJawrMgrObjectName)) {
					mbs.unregisterMBean(appJawrMgrObjectName);
				}

				if (mbs.isRegistered(jawrConfigMgrObjName)) {
					mbs.unregisterMBean(jawrConfigMgrObjName);
				}
			}

		} catch (InstanceNotFoundException | MBeanRegistrationException e) {
			LOGGER.error("Unable to unregister the Jawr MBean for resource type '" + resourceType + "'", e);
		}
	}
82919
@Override
	public final void register( ObjectName name , Object mBean ) throws JMSException
	{
		log.debug("Registering object " + name);
		try
		{
			this.mBeanServer.registerMBean(mBean, name);
		}
		catch (Exception e)
		{
			throw new FFMQException("Cannot register MBean", "JMX_ERROR", e);
		}
	}
1355580
public static void buildProducers() {

        // Registering decorator for mbean stats
        DecoratorRegistryFactory.getDecoratorRegistry().addDecorator(
                MBeanStats.class,
                new GeneralMBeanDecorator()
        );

        for (MBeanServer server : MBeanServerFactory.findMBeanServer(null))
            for (final ObjectInstance mBean : server.queryMBeans(null, null))
                if(isMBeanRequired(mBean)) {

                    SimpleStatsProducer<MBeanStats> producer = buildProducer(server, mBean);

                    if (producer != null) {
                        producerRegistry.registerProducer(producer);
                        log.debug("Registered new producer for " + mBean.getObjectName().getCanonicalName() + "mbean");
                    }

                }

    }
34840
public boolean isTracingEnabledForProducer(String producerId){
		//check if tracing is completely disabled.
		if (!MoskitoConfigurationHolder.getConfiguration().getTracingConfig().isTracingEnabled())
			return false;

		Tracer tracer = tracers.get(producerId);
		return tracer != null && tracer.isEnabled();

	}
924266
@Override
    public boolean offer(final E e)
    {
        if (null == e)
        {
            throw new NullPointerException();
        }
        // local load of field to avoid repeated loads after volatile reads
        final E[] buffer = this.buffer;
        final long mask = this.mask;
        final long producerIndex = this.lpProducerIndex();

        if (producerIndex >= producerLimit &&
            !offerSlowPath(buffer, mask, producerIndex))
        {
            return false;
        }
        final long offset = calcElementOffset(producerIndex, mask);

        soElement(buffer, offset, e); // StoreStore
        soProducerIndex(producerIndex + 1); // ordered store -> atomic and ordered for size()
        return true;
    }
1043856
public final boolean registerMBean(final Class<?> clazz) {
		if (this.mbs != null && clazz != null) {
			try {
				final String fqnName = clazz.getCanonicalName();
				final String domain = fqnName.substring(0, fqnName.lastIndexOf('.'));
				final String type = fqnName.substring(fqnName.lastIndexOf('.') + 1);

				final ObjectName objectName = new ObjectName(String.format(
						beanNameFormat, domain, type));
				if (!mbs.isRegistered(objectName)) {
					LaunchingMessageKind.IJMX0004.format(objectName);
					mbs.registerMBean(clazz.newInstance(), objectName);
					LaunchingMessageKind.IJMX0005.format(objectName);
				}
				this.beanNames.add(objectName);
			} catch (Exception e) {
				LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
				return false;
			}
		} else {
			LaunchingMessageKind.EJMX0002.format();
			return false;
		}
		return true;
	}
403272
public static void registerStandardMXBeans(Registry registry) {
    for (MemoryPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class)) {
      registry.register(new MemoryPoolMeter(registry, mbean));
    }

    for (BufferPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) {
      registry.register(new BufferPoolMeter(registry, mbean));
    }
  }
293782
void registerMBean(final String storageId) {
    // We wrap to bypass standard mbean naming convetion.
    // This wraping can be removed in java 6 as it is more flexible in
    // package naming for mbeans and their impl.
    StandardMBean bean;
    String storageName;
    if (storageId == null || storageId.equals("")) {// Temp fix for the uninitialized storage
      storageName = "UndefinedStorageId" + rand.nextInt();
    } else {
      storageName = storageId;
    }
    try {
      bean = new StandardMBean(this,FSDatasetMBean.class);
      mbeanName = MBeanUtil.registerMBean("DataNode", "FSDatasetState-" + storageName, bean);
      versionBeanName = VersionInfo.registerJMX("DataNode");
    } catch (NotCompliantMBeanException e) {
      e.printStackTrace();
    }

    DataNode.LOG.info("Registered FSDatasetStatusMBean");
  }
180185
public synchronized ObjectName register(PublishAllBeanWrapper wrapper) throws JMException {
		ReflectionMbean mbean;
		try {
			mbean = new ReflectionMbean(wrapper);
		} catch (Exception e) {
			throw createJmException("Could not build mbean object for publish-all bean: " + wrapper.getTarget(), e);
		}
		ObjectName objectName = ObjectNameUtil.makeObjectName(wrapper.getJmxResourceInfo());
		doRegister(objectName, mbean);
		return objectName;
	}
1239831
protected void checkJsonBeanValidator() {
        final Class<?> returnType = executeMethod.getReturnType();
        if (!JsonResponse.class.isAssignableFrom(returnType)) {
            return;
        }
        final Type genericReturnType = executeMethod.getGenericReturnType();
        if (genericReturnType == null || !(genericReturnType instanceof ParameterizedType)) { // just in case
            return;
        }
        final Class<?> jsonBeanType = DfReflectionUtil.getGenericFirstClass(genericReturnType);
        if (jsonBeanType == null) { // just in case
            return;
        }
        if (Collection.class.isAssignableFrom(jsonBeanType)) { // e.g. JsonResponse<List<SeaBean>>
            final Type[] resopnseArgTypes = DfReflectionUtil.getGenericParameterTypes(genericReturnType);
            if (resopnseArgTypes.length > 0) { // just in case
                final Class<?> elementBeanType = DfReflectionUtil.getGenericFirstClass(resopnseArgTypes[0]);
                if (elementBeanType != null && mayBeJsonBeanType(elementBeanType)) { // just in case
                    doCheckJsonBeanValidator(elementBeanType, Collections.emptyMap()); // can check JsonResponse<List<SeaBean>>
                }
            }
        } else if (mayBeJsonBeanType(jsonBeanType)) { // e.g. JsonResponse<SeaBean>, JsonResponse<WholeBean<SeaBean>>
            doCheckJsonBeanValidator(jsonBeanType, prepareJsonBeanGenericMap(genericReturnType, jsonBeanType));
        }
    }
259517
@Bean
	public boolean adminToolMbeansExported(MBeanServer server, BeanFactory beanFactory, List<AdminToolConfig> configs) throws MalformedObjectNameException {
		MBeanExporter mbeanExporter = new MBeanExporter();
		mbeanExporter.setServer(server);
		mbeanExporter.setBeanFactory(beanFactory);
		SimpleReflectiveMBeanInfoAssembler assembler = new SimpleReflectiveMBeanInfoAssembler();
		mbeanExporter.setAssembler(assembler);
		mbeanExporter.setAutodetect(true);
		LOGGER.info("registering %s managed admintool config resources", configs.size());
		for (AdminToolConfig adminToolConfig : configs) {
			LOGGER.info("registering managed resource: %s", adminToolConfig.getClass().getName());
			ObjectName name = new ObjectName(String.format("de.chandre.admintool:type=Config,name=%s", adminToolConfig.getClass().getSimpleName()));
			mbeanExporter.registerManagedResource(adminToolConfig, name);
		}
		return true;
	}
175515
protected boolean isProducerTypeCheck() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "isProducerTypeCheck");
        boolean checking = true;

        // We can carry out checking if there is no FRP, or the FRP has 0 size.
        StringArrayWrapper frp = (StringArrayWrapper) properties.get(FORWARD_ROUTING_PATH);
        if (frp != null) {
            List totalPath = frp.getMsgForwardRoutingPath();
            if ((totalPath != null) && (totalPath.size() > 0))
                checking = false;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "isProducerTypeCheck", checking);
        return checking;
    }