Java 8 ObjectName - 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 ObjectName class.

This code example shows how to use the following methods:
		assertEquals("Age is incorrect", 100, bean.getAge());
	} 
 
	@Test
	public void testPropertiesCorrectInJmx() throws Exception {
		ObjectName oname = new ObjectName("bean:name=proxyTestBean1");
		Object name = getServer().getAttribute(oname, "Name");
		Integer age = (Integer) getServer().getAttribute(oname, "Age");
 
		assertEquals("Name is incorrect in JMX", "Rob Harrop", name); 
		assertEquals("Age is incorrect in JMX", 100, age.intValue());
	} 
 
} 
 
7
CodeRank
This code example shows how to use the following methods:
7
CodeRank
This code example shows how to use the following methods:
	} 
 
	@Test
	public void testDatesInJmx() throws Exception {
		// System.out.println(getServer().getClass().getName()); 
		ObjectName oname = new ObjectName("bean:name=dateRange");
 
		Date startJmx = (Date) getServer().getAttribute(oname, "StartDate");
		Date endJmx = (Date) getServer().getAttribute(oname, "EndDate");
 
		assertEquals("startDate ", getStartDate(), startJmx);
		assertEquals("endDate ", getEndDate(), endJmx);
	} 
 
	@Test
	public void testGetDates() throws Exception {
		DateRange dr = (DateRange) getContext().getBean("dateRange");
 
		assertEquals("startDate ", getStartDate(), dr.getStartDate());
		assertEquals("endDate ", getEndDate(), dr.getEndDate());
7
CodeRank
This code example shows how to use the following methods:getDomain, getKeyPropertyListString
		try { 
			ObjectName objectName = _mBean.getObjectName();
 
			MBeanServer mBeanServer = getMBeanServer();
 
			MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
 
			return new MBean(objectName, mBeanInfo);
		} 
		catch (Exception e) {
			throw new ManageActionException(e);
		} 
	} 
 
	private final MBean _mBean;
 
} 

7
CodeRank
This code example shows how to use the following methods:
        monitorName = generateMonitorName(monitorName);
 
        if (!monitors.containsKey(monitorName)) {
            NodeDiscoveryMonitorMBean mbean;
            try { 
                ObjectName oName = new ObjectName(monitorName);
                mbean = new NodeDiscoveryMonitor(discovery);
                monitors.put(monitorName, mbean);
                mbs.registerMBean(mbean, oName);
 
            } 
            catch (Exception e) {
                monitors.remove(monitorName);
            } 
        } 
    } 
 
    public synchronized void unregisterMonitor(String monitorName, NodeDiscovery discovery) {
        monitorName = generateMonitorName(monitorName);
        monitors.remove(monitorName);
7
CodeRank
This code example shows how to use the following methods:
   
  @Override 
  public void start() { 
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try { 
      ObjectName on = new ObjectName(domain+":Name="+getName());
      StandardMBean mbean = new StandardMBean(accessStatsImpl, StatisticalView.class);
      if (mbs.isRegistered(on)) {
          mbs.unregisterMBean(on);
      } 
      mbs.registerMBean(mbean, on);
      super.start(); 
    } catch (Exception e) {
      addError("Failed to create mbean", e);
    } 
  } 
   
  @Override 
  public void stop() { 
    super.stop(); 
7
CodeRank
This code example shows how to use the following methods:isPattern
     * Add a object name pattern 
     * 
     * @param pObjectName pattern to add 
     */ 
    void addPattern(ObjectName pObjectName) {
        patterns.add(pObjectName);
    } 
 
    /** 
     * Add for a given MBean a set of read/write attributes and operations 
     * 
     * @param pOName MBean name (which should not be pattern) 
     * @param pReadAttributes read attributes 
     * @param pWriteAttributes write attributes 
     * @param pOperations operations 
     */ 
    void addValues(ObjectName pOName, Set<String> pReadAttributes, Set<String> pWriteAttributes, Set<String> pOperations) {
        readAttributes.put(pOName,pReadAttributes);
        writeAttributes.put(pOName,pWriteAttributes);
        operations.put(pOName,pOperations);

7
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Test
    public void testHello() throws Exception {
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        ObjectName objectName = new ObjectName("quickstarts", "type", AnnotatedComponentHelloWorld.class.getSimpleName());
        MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
        Assert.assertNotNull(mbeanInfo);
        Assert.assertEquals(0L,mbeanServer.getAttribute(objectName, "Count"));
        Assert.assertEquals("Hello",mbeanServer.getAttribute(objectName, "WelcomeMessage"));
        Assert.assertEquals("Hello jer!",mbeanServer.invoke(objectName, "sayHello", new Object[] {"jer"}, new String[] {"java.lang.String"}));
        Assert.assertEquals(1L,mbeanServer.getAttribute(objectName, "Count"));
        mbeanServer.setAttribute(objectName, new Attribute("WelcomeMessage","Hi"));
        Assert.assertEquals("Hi jer!",mbeanServer.invoke(objectName, "sayHello", new Object[] {"jer"}, new String[] {"java.lang.String"}));
        Assert.assertEquals(2L,mbeanServer.getAttribute(objectName, "Count"));
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
 
        if (!monitors.containsKey(monitorName)) {
            JmxConnectionPoolMonitorMBean mbean;
            try { 
                LOG.info("Registering mbean: " + monitorName);
                ObjectName oName = new ObjectName(monitorName);
                mbean = new JmxConnectionPoolMonitor(pool);
                monitors.put(monitorName, mbean);
                mbs.registerMBean(mbean, oName);
 
            } 
            catch (Exception e) {
                LOG.error(e.getMessage());
                monitors.remove(monitorName);
            } 
        } 
    } 
 
    public synchronized void unregisterMonitor(String name, ConnectionPool<?> pool) {
        String monitorName = generateMonitorName(name);
7
CodeRank
This code example shows how to use the following methods:
 
  public void unregister(ObjectName oName)
  { 
    try 
    { 
      if (_server.isRegistered(oName))
      { 
        _server.unregisterMBean(oName);
      } 
      _registeredNames.remove(oName);
      _log.info("Unregistered MBean {}", oName);
    } 
    catch (Exception e)
    { 
      _log.warn("Failed to unregister MBean " + oName, e);
    } 
  } 
 
  public ObjectName getName(String name) throws MalformedObjectNameException

7
CodeRank
See Code Examples for Java 8 ObjectName Methods: