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

This code example shows how to use the following methods:
		assertSame("The 'source' property of the Notification is not being set to the ObjectName of the associated MBean.", objectName, mbean.getActualNotification().getSource());
	} 
 
	public void testSendAttributeChangeNotification() throws Exception {
		StubSpringModelMBean mbean = new StubSpringModelMBean();
		Notification notification = new AttributeChangeNotification(mbean, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
		ObjectName objectName = createObjectName();
 
		NotificationPublisher publisher = new ModelMBeanNotificationPublisher(mbean, objectName, mbean);
		publisher.sendNotification(notification);
 
		assertNotNull(mbean.getActualNotification());
		assertTrue(mbean.getActualNotification() instanceof AttributeChangeNotification);
		assertSame("The exact same Notification is not being passed through from the publisher to the mbean.", notification, mbean.getActualNotification());
		assertSame("The 'source' property of the Notification is not being set to the ObjectName of the associated MBean.", objectName, mbean.getActualNotification().getSource());
	} 
 
	public void testSendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception {
		StubSpringModelMBean mbean = new StubSpringModelMBean();
		Notification notification = new AttributeChangeNotification(this, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
7
CodeRank
This code example shows how to use the following methods:getAttributeName, getAttributeType, getNewValue, getOldValue
 
        if (aNotification instanceof AttributeChangeNotification) {
            AttributeChangeNotification ac = (AttributeChangeNotification) aNotification;
 
            jaxb = mObjectFactory.createAttributeChangeNotification()
                    .withAttributeName(ac.getAttributeName())
                    .withAttributeType(ac.getAttributeType())
                    .withNewValue(ac.getNewValue() == null ? null : String.valueOf(ac.getNewValue()))
                    .withOldValue(ac.getOldValue() == null ? null : String.valueOf(ac.getOldValue()));
        } else if (aNotification instanceof JMXConnectionNotification) {
            jaxb = mObjectFactory.createJMXConnectionNotification()
                    .withConnectionId(((JMXConnectionNotification) aNotification).getConnectionId());
        } else if (aNotification instanceof MBeanServerNotification) {
            jaxb = mObjectFactory.createMBeanServerNotification()
                    .withMBeanName(String.valueOf(((MBeanServerNotification) aNotification).getMBeanName()));
        } else if (aNotification instanceof MonitorNotification) {
            MonitorNotification mn = (MonitorNotification) aNotification;
            jaxb = mObjectFactory.createMonitorNotification()
                    .withDerivedGauge(String.valueOf(mn.getDerivedGauge()))
                    .withObservedAttribute(mn.getObservedAttribute())
7
CodeRank
This code example shows how to use the following methods:getAttributeName, getAttributeType, getNewValue, getOldValue
This code example shows how to use the following methods:
 
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM'T'HH:mm:ss");
        Date date = sdf.parse("2010-07-01T10:30:15");
        long timeStamp = date.getTime();
 
        AttributeChangeNotification acn = new AttributeChangeNotification(
                this, sequence++, timeStamp, "attribute changed", "stringValue", "string", tick - 1, tick);
        sendNotification(acn);
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
 
    public void setStringValue(String aStringValue) {
        String oldValue = getStringValue();
        mStringValue = aStringValue;
 
        AttributeChangeNotification acn = new AttributeChangeNotification(
                this, mSequence++, mTimestamp, "attribute changed", "stringValue", "string", oldValue, mStringValue);
        sendNotification(acn);
    } 
 
    public Integer getMonitorNumber() {
        return mMonitorNumber;
    } 
    public void setMonitorNumber(Integer aNumber) {
        mMonitorNumber = aNumber;
    } 
 
    public Long getLongNumber() {
        return mLongNumber;
    } 
5
CodeRank
This code example shows how to use the following methods:
                 "Notification is null"); 
        if (attributeBroadcaster == null)
            return; // This means there are no registered listeners 
        if( log.isDebugEnabled() )
            log.debug( "AttributeChangeNotification " + notification );
        attributeBroadcaster.sendNotification(notification);
 
    } 
 
 
    /** 
     * Send an <code>AttributeChangeNotification</code> to all registered 
     * listeners. 
     * 
     * @param oldValue The original value of the <code>Attribute</code> 
     * @param newValue The new value of the <code>Attribute</code> 
     * 
     * @exception MBeanException if an object initializer throws an 
     *  exception 
     * @exception RuntimeOperationsException wraps IllegalArgumentException 

5
CodeRank
This code example shows how to use the following methods:
     * attributes of the "SimpleStandard" standard MBean. 
     */ 
    public void reset() { 
        checkSubject(); 
        AttributeChangeNotification acn =
            new AttributeChangeNotification(this,
                                            0, 
                                            0, 
                                            "NbChanges reset", 
                                            "NbChanges", 
                                            "Integer", 
                                            new Integer(nbChanges),
                                            new Integer(0));
        state = "initial state";
        nbChanges = 0;
        nbResets++;
        sendNotification(acn);
    } 
 
    /* 
4
CodeRank
This code example shows how to use the following methods:
		generateNotification("Unregistering ObjectStore MBean"); 
        StoreManagerProxy.registerBean(getMBeanName(), this, false);
	} 
 
	private void generateNotification(String message) {
		AttributeChangeNotification acn = new AttributeChangeNotification(this, 0, 0, message,
			"storeName", "String", "oldValue", "newValue"); 
		sendNotification(acn);
	} 
 
	public MBeanNotificationInfo[] getNotificationInfo() {
		return new MBeanNotificationInfo[] {new MBeanNotificationInfo(
			new String[] { AttributeChangeNotification.ATTRIBUTE_CHANGE },
			AttributeChangeNotification.class.getName(),
			"Generated when the ObjectStore MBean is registered and destroyed") 
		}; 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    public void refresh() { 
        collectAndResetCounters1(); 
        //Notification n = new AttributeChangeNotification(this, notificationSequenceNumber++, System.currentTimeMillis(), "CacheInfo changed", "PerfInfo", newValue.getClass().getName(), null, newValue); 
        Notification n = new AttributeChangeNotification(this, notificationSequenceNumber++, System.currentTimeMillis(), "Info changed", "", null, null, null);
        sendNotification(n);
    } 
 
    protected long getMillisSinceLastCollect() { 
        return System.currentTimeMillis() - lastCollectTime;
    } 
     
    public synchronized int getTimerPeriod() { 
        return timerPeriod;
    } 
 
    public synchronized void setTimerPeriod(int timerPeriod) {
        if (timerPeriod != this.timerPeriod) {
            this.timerPeriod = timerPeriod;
3
CodeRank
This code example shows how to use the following methods:
		Notification n;
		 
		if (AttributeChangeMessage.class.isInstance( message )){
			AttributeChangeMessage attributeChangeMessage = (AttributeChangeMessage) message;
			 
			n = new AttributeChangeNotification(config.getNotificationMBeanName(), sequence.incrementAndGet()
					, System.currentTimeMillis(), attributeChangeMessage.getDescription()
					, attributeChangeMessage.getAttributeName(), attributeChangeMessage.getAttributeType().getSimpleName()
					, attributeChangeMessage.getOldValue(), attributeChangeMessage.getNewValue());
		} 
		else{ 
			n = new Notification(NOTIFICATION_TYPE_GENERIC, config.getNotificationMBeanName(), sequence.incrementAndGet(), System.currentTimeMillis(), demoiselleNotification.getMessage().toString());
		} 
		sendNotification(n);
	} 
} 
3
CodeRank
See Code Examples for Java 8 AttributeChangeNotification Methods: