KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > monitor > test > MonitorTCListener


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19 package org.apache.avalon.excalibur.monitor.test;
20
21 import java.beans.PropertyChangeEvent JavaDoc;
22 import java.beans.PropertyChangeListener JavaDoc;
23
24 import org.apache.avalon.framework.logger.AbstractLogEnabled;
25
26 /*
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  */

29 class MonitorTCListener
30     extends AbstractLogEnabled
31     implements PropertyChangeListener JavaDoc
32 {
33     private volatile boolean m_hasChanged = false;
34
35     public boolean hasBeenModified()
36     {
37         return m_hasChanged;
38     }
39
40     public void reset()
41     {
42         m_hasChanged = false;
43     }
44
45     public void propertyChange( final PropertyChangeEvent JavaDoc propertyChangeEvent )
46     {
47         m_hasChanged = true;
48
49         if( getLogger().isInfoEnabled() )
50         {
51             getLogger().info( "NOTIFICATION LATENCY: " + ( System.currentTimeMillis() -
52                                                            ( (Long JavaDoc)propertyChangeEvent.getNewValue() ).longValue() ) +
53                               "ms" );
54             getLogger().info( "Received notification for " +
55                               ( (MockResource)propertyChangeEvent.getSource() ).getResourceKey() );
56             getLogger().info( propertyChangeEvent.getPropertyName() +
57                               "\n IS::" + (Long JavaDoc)propertyChangeEvent.getNewValue() +
58                               "\n WAS::" + (Long JavaDoc)propertyChangeEvent.getOldValue() +
59                               "\n TIME SINCE LAST MOD::" +
60                               ( ( (Long JavaDoc)propertyChangeEvent.getNewValue() ).longValue() -
61                                 ( (Long JavaDoc)propertyChangeEvent.getOldValue() ).longValue() ) );
62         }
63     }
64 }
65
Popular Tags