mmaxaccessstatus.java

来自「httptunnel.jar httptunnel java 源码」· Java 代码 · 共 70 行

JAVA
70
字号
package net.jumperz.app.MGuardian.console;

import net.jumperz.util.*;
import java.awt.Color;
import java.util.*;
import net.jumperz.app.MGuardian.*;

public final class MMaxAccessStatus
extends MAbstractStatus
implements MObserver2
{
int max = 0;
Map ipCountMap = new HashMap();
//--------------------------------------------------------------------------------
public void update( Object eventName, Object source )
{
if( eventName.equals( "getAccessLog" ) )
	{
	String clientRemoteAddr = ( ( MSession )source ).getClientRemoteAddr();
	MCount count;
	synchronized( ipCountMap )
		{
		count = ( MCount )ipCountMap.get( clientRemoteAddr );
		}
	if( count == null )
		{
		synchronized( ipCountMap )
			{
			ipCountMap.put( clientRemoteAddr, new MCount() );
			}
		}
	else
		{
		count.inc();
		int countInt = count.getValue();
		if( countInt > max )
			{
			max = countInt;
			}
		}
	}
}
//--------------------------------------------------------------------------------
public String getStatusName()
{
return "maxAccess";
}
//--------------------------------------------------------------------------------
public String getStatusValue()
{
synchronized( ipCountMap )
	{
	ipCountMap.clear();
	}
String value = Integer.toString( max );
max = 0;
return value;
}
//--------------------------------------------------------------------------------
public String getTitle()
{
return "Max Access";
}
//--------------------------------------------------------------------------------
public Color getAreaColor()
{
return new Color( 0x94, 0x8C, 0xB5 );
}
//--------------------------------------------------------------------------------
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?