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

This code example shows how to use the following methods:
	} 
 
	@Test
	public void testSetAttribute() throws Exception {
		ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
		getServer().setAttribute(objectName, new Attribute(NAME_ATTRIBUTE, "Rob Harrop"));
		IJmxTestBean bean = (IJmxTestBean) getContext().getBean("testBean");
		assertEquals("Rob Harrop", bean.getName());
	} 
 
	@Test
	public void testGetAttribute() throws Exception {
		ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
		getBean().setName("John Smith"); 
		Object val = getServer().getAttribute(objectName, NAME_ATTRIBUTE);
		assertEquals("Incorrect result", "John Smith", val); 
	} 
 
	@Test
	public void testOperationInvocation() throws Exception{
6
CodeRank
This code example shows how to use the following methods:
	@Override 
	public Void action() throws ManageActionException {
		try { 
			MBeanServer mBeanServer = getMBeanServer();
 
			mBeanServer.setAttribute(_objectName, new Attribute(_name, _value));
 
			return null; 
		} 
		catch (Exception e) {
			throw new ManageActionException(e);
		} 
	} 
 
	private final String _name;
	private final ObjectName _objectName;
	private final Object _value; 
 
} 
6
CodeRank
This code example shows how to use the following methods:getName, getValue
		throw new ReflectionException(new NoSuchMethodException(name));	
	} 
 
	@Override 
	public synchronized void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
		String name = attr.getName();
		if(name != null)
			_propMap.put(name, attr.getValue());
	} 
 
	@Override 
	public synchronized AttributeList setAttributes(AttributeList list) {
		Attribute[] attrs = (Attribute[]) list.toArray(new Attribute[0]);
		AttributeList retList = new AttributeList();
        for (Attribute attr : attrs) {
            String name = attr.getName();
            Object value = attr.getValue();
            _propMap.put(name, value);
            retList.add(new Attribute(name, value));
        }  
6
CodeRank
This code example shows how to use the following methods:
        Assert.assertEquals(0L, mbeanServer.getAttribute(objectName, "Count"));
        Assert.assertEquals("Welcome", mbeanServer.getAttribute(objectName, "WelcomeMessage"));
        Assert.assertEquals("Welcome 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"));
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:sleep
      assertNull(stm0.getCacheTopology().getPendingCH());
      assertEquals(Arrays.asList(address(0), address(1)), stm0.getCacheTopology().getCurrentCH().getMembers());
 
      // Re-enable rebalancing 
      log.debugf("Rebalancing with nodes %s %s %s %s", address(0), address(1), address(2), address(3)); 
      mBeanServer.setAttribute(ltmName0, new Attribute("RebalancingEnabled", true));
      assertTrue((Boolean) mBeanServer.getAttribute(ltmName0, "RebalancingEnabled"));
      // Duplicate request to enable rebalancing - should be ignored 
      mBeanServer.setAttribute(ltmName0, new Attribute("RebalancingEnabled", true));
 
      // Check that the cache now has 4 nodes, and the CH is balanced 
      TestingUtil.waitForRehashToComplete(cache(0), cache(1), cache(2), cache(3)); 
      assertNull(stm0.getCacheTopology().getPendingCH());
      ConsistentHash ch = stm0.getCacheTopology().getCurrentCH();
      assertEquals(Arrays.asList(address(0), address(1), address(2), address(3)), ch.getMembers());
      for (int i = 0; i < ch.getNumSegments(); i++) {
         assertEquals(2, ch.locateOwnersForSegment(i).size());
      } 
 
      // Suspend rebalancing again 

6
CodeRank
This code example shows how to use the following methods:
        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"));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
        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"));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getName, getValue
 
        // Validate the input parameters 
        if (attribute == null)
            throw new RuntimeOperationsException(new IllegalArgumentException(
                    "Attribute is null"), "Attribute is null"); 
        String name = attribute.getName();
        Object value = attribute.getValue();
        if (name == null)
            throw new RuntimeOperationsException(new IllegalArgumentException(
                    "Attribute name is null"), "Attribute name is null"); 
 
        try { 
            Connector connector = (Connector) getManagedResource();
            IntrospectionUtils.setProperty(connector, name, String.valueOf(value));
        } catch (InstanceNotFoundException e) {
            throw new MBeanException(e);
        } catch (InvalidTargetObjectTypeException e) {
            throw new MBeanException(e);
        } 
   
6
CodeRank
This code example shows how to use the following methods:getName, getValue
        if (attribute == null)
            throw new RuntimeOperationsException
                (new IllegalArgumentException("Attribute is null"),
                 "Attribute is null"); 
         
        String name = attribute.getName();
        Object value = attribute.getValue();
        if (name == null)
            throw new RuntimeOperationsException
                (new IllegalArgumentException("Attribute name is null"),
                 "Attribute name is null");  
          
        ContextResourceLink crl = null;
        try { 
            crl = (ContextResourceLink) getManagedResource();
        } catch (InstanceNotFoundException e) {
            throw new MBeanException(e);
        } catch (InvalidTargetObjectTypeException e) {
             throw new MBeanException(e);
        } 
6
CodeRank
This code example shows how to use the following methods:
	 */ 
	public void setAttribute(final String mbeanName, final String attributeName, final Object value) {
		assertConnected(); 
		try { 
			ObjectName objectName = buildObjectName(mbeanName);
			Attribute attribute = new Attribute(attributeName, value);
			mbsc.setAttribute(objectName, attribute);
		} catch (Exception ex) {
			throw new IllegalStateException(ex);
		} 
	} 
 
	/** 
	 * Invokes bean method. 
	 */ 
	public void invoke(final String mbeanName, final String methodName) {
		invoke(mbeanName, methodName, new Object[]{}, new String[]{});
	} 
 
	/** 
6
CodeRank
See Code Examples for Java 8 Attribute Methods: