Java 8 RequiredModelMBean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RequiredModelMBean class.

This code example shows how to use the following methods:setManagedResource
 
    if (mbi == null) {
      return null; 
    } 
 
    RequiredModelMBean mbean = new RequiredModelMBean(mbi);
 
    try { 
      mbean.setManagedResource(obj, "ObjectReference");
    } catch (InvalidTargetObjectTypeException e) {
      throw new JMException(e.getMessage());
    } 
 
    // Allows the managed object to send notifications 
    if (obj instanceof NotificationSenderAware) { 
      ((NotificationSenderAware) obj).setNotificationSender(new NotificationSenderAdapter(mbean));
    } 
 
    return mbean;
  } 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource, setModelMBeanInfo
 
        LOG.trace("Assembled MBeanInfo {}", mbi);
 
        RequiredModelMBean mbean = (RequiredModelMBean) mBeanServer.instantiate(RequiredModelMBean.class.getName());
        mbean.setModelMBeanInfo(mbi);
 
        try { 
            mbean.setManagedResource(obj, "ObjectReference");
        } catch (InvalidTargetObjectTypeException e) {
            throw new JMException(e.getMessage());
        } 
 
        // Allows the managed object to send notifications 
        if (obj instanceof NotificationSenderAware) {
            ((NotificationSenderAware)obj).setNotificationSender(new NotificationSenderAdapter(mbean));
        } 
 
        return mbean;
    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource, setModelMBeanInfo
        boolean sanitize = camelContext.getManagementStrategy().getManagementAgent().getMask() != null && camelContext.getManagementStrategy().getManagementAgent().getMask();
        if (sanitize) {
            mbean = new MaskRequiredModelMBean(mbi, sanitize);
        } else { 
            mbean = (RequiredModelMBean) mBeanServer.instantiate(RequiredModelMBean.class.getName());
            mbean.setModelMBeanInfo(mbi);
        } 
 
        try { 
            mbean.setManagedResource(obj, "ObjectReference");
        } catch (InvalidTargetObjectTypeException e) {
            throw new JMException(e.getMessage());
        } 
 
        // Allows the managed object to send notifications 
        if (obj instanceof NotificationSenderAware) { 
            ((NotificationSenderAware)obj).setNotificationSender(new NotificationSenderAdapter(mbean));
        } 
 
        return mbean;

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource, setModelMBeanInfo
        RequiredModelMBean rtMBean;
         
        rtMBean = (RequiredModelMBean)server.instantiate(
            "javax.management.modelmbean.RequiredModelMBean"); 
                        
        rtMBean.setModelMBeanInfo(mbi);
     
        rtMBean.setManagedResource(ati, "ObjectReference");
                            
        server.registerMBean(rtMBean, ton);
    } 
 
    public MBeanServer getServer() {
        return server;
    } 
     
    //the client get and set the ModelObject and setup the ManagerBean 
    @Test
    public void testRegisterOperations() throws Exception {
        ModelMBeanInfo info = getMBeanInfoFromAssembler();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource
                                      null,  // no constructors 
                                      new ModelMBeanOperationInfo[] {
                                          operationInfo, getCountInfo, setCountInfo
                                      }, 
                                      null); // no notifications 
        ModelMBean mmb = new RequiredModelMBean(mmbi);
        mmb.setManagedResource(resource3, "ObjectReference");
        mbs.registerMBean(mmb, name);
        mbs.invoke(name, "operation", null, null);
        mbs.setAttribute(name, new Attribute("Count", 53));
        if (resource1.operationCount != 1)
            throw new Exception("operationCount: " + resource1.operationCount);
        if (resource2.count != 53)
            throw new Exception("count: " + resource2.count);
        int got = (Integer) mbs.getAttribute(name, "Count");
        if (got != 53)
            throw new Exception("got count: " + got);
 
        JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
        JMXConnectorServer cs =
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource
            new ModelMBeanOperationInfo[] {},
            null); 
 
        // RequiredModelMBean 
 
        ModelMBean mmb = new RequiredModelMBean(mmbi);
        mmb.setManagedResource(resource, "ObjectReference");
        ObjectName mmbName = new ObjectName(":type=ResourceMBean");
        mbs.registerMBean(mmb, mmbName);
 
        // Run tests 
 
        System.out.println("\nTest that we receive ServiceNotFoundException");
        try { 
            Attribute attr = new Attribute("Something", "Some string");
            mbs.setAttribute(mmbName, attr);
            System.out.println("TEST FAILED: Didn't caught exception");
            ok = false;
        } catch(MBeanException mbex) {
            Exception e = mbex.getTargetException();
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource
        try { 
            if (mBeanInfo == null) {
                final Class managementInterface = getManagementInterface(componentInstance.getClass(), management, null);
                return new StandardMBean(componentInstance, managementInterface);
            } else if (mBeanInfo instanceof ModelMBeanInfo) {
                final ModelMBean mBean = new RequiredModelMBean((ModelMBeanInfo)mBeanInfo);
                try { 
                    mBean.setManagedResource(componentInstance, "ObjectReference");
                } catch (final InvalidTargetObjectTypeException e) {
                    // N/A: "ObjectReference" is a valid reference type 
                } catch (final InstanceNotFoundException e) {
                    // N/A: the instance was a valid object 
                } 
                return mBean;
            } else { 
                final Class<?> managementInterface = getManagementInterface(
                        componentInstance.getClass(), management, mBeanInfo);
                return new StandardNanoMBean(componentInstance, managementInterface, mBeanInfo);
            } 
        } catch (final ClassNotFoundException e) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource, setModelMBeanInfo
     
    private void register(Object obj, ObjectName name, ModelMBeanInfo mbi, boolean forceRegistration) 
        throws JMException {                  
        RequiredModelMBean rtMBean = 
            (RequiredModelMBean)mbs.instantiate("javax.management.modelmbean.RequiredModelMBean");
        rtMBean.setModelMBeanInfo(mbi);
        try { 
            rtMBean.setManagedResource(obj, "ObjectReference");
        } catch (InvalidTargetObjectTypeException itotex) {
            throw new JMException(itotex.getMessage());
        } 
        registerMBeanWithServer(rtMBean, persist(name), forceRegistration);
    } 
 
    private void registerMBeanWithServer(Object obj, ObjectName name, boolean forceRegistration) 
        throws JMException {
        ObjectInstance instance = null;
        try { 
            if (LOG.isLoggable(Level.INFO)) {
                LOG.info("registering MBean " + name + ": " + obj);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setManagedResource
				null, //attributes 
				null, //constructors 
				buildModelMBeanOperationInfo(), 
				null //notifications 
				); 
		RequiredModelMBean rmb = new RequiredModelMBean(mmbInfoSupport);
		rmb.setManagedResource(bootstrap, OBJECT_REFERENCE);
		ObjectName objectName = new ObjectName(bootstrap.getMBeanNameSuffix(bootstrap, MBEAN_NAME) != null ? MBEAN_NAME + bootstrap.getMBeanNameSuffix(bootstrap, MBEAN_NAME) : MBEAN_NAME);
		if (this.mbeanServer.isRegistered(objectName)){
			this.mbeanServer.unregisterMBean(objectName);
		} 
		this.mbeanServer.registerMBean(rmb, objectName);
	} 
	 
	/** 
	 * Helper method to construct the MBean opeation info objects 
	 * @return array of ModelMBeanOperationInfo instances for the BootstrapMXBean interface methods 
	 */ 
	private ModelMBeanOperationInfo[] buildModelMBeanOperationInfo() {
		// the start() operation info 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 RequiredModelMBean Methods: