james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Fondermann" <bernd.fonderm...@googlemail.com>
Subject Re: svn commit: r472864 - in /james/server/trunk/src/java/org/apache/james: core/ services/ util/connection/
Date Thu, 16 Nov 2006 10:51:50 GMT
On 11/9/06, norman@apache.org <norman@apache.org> wrote:
> Author: norman
> +    public synchronized void addConnectionPerIP (String ip) {
> +        connectionPerIP.put(ip,Integer.toString(getConnectionPerIP(ip) +1));
> +    }
> +
> +    public synchronized int getConnectionPerIP(String ip) {
> +        int count = 0;
> +        String curCount = null;
> +        Object c = connectionPerIP.get(ip);
> +
> +        if (c != null) {
> +            curCount = c.toString();
> +
> +            if (curCount != null) {
> +                return Integer.parseInt(curCount);
> +            }
> +        }
> +        return count;
> +    }
> +

BTW, while I like that ConnectionPerIpMap is extracted as a separate
class, why is String used as a value type and not Integer? This is
making life harder than it should be with all its casts and
conversions.

Alternatively, to reduce object creation on increment and conversions
even more, something like int[] counter = int[] {0} could be used
internally. arrays are objects if I am not mistaken and can be put
into maps.

  Bernd

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message