Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 32868 invoked from network); 20 Sep 2010 22:27:34 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Sep 2010 22:27:34 -0000 Received: (qmail 83857 invoked by uid 500); 20 Sep 2010 22:27:31 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 83368 invoked by uid 500); 20 Sep 2010 22:27:30 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 83360 invoked by uid 99); 20 Sep 2010 22:27:30 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Sep 2010 22:27:30 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.171] (HELO mail-wy0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Sep 2010 22:27:07 +0000 Received: by wyb35 with SMTP id 35so4160569wyb.30 for ; Mon, 20 Sep 2010 15:26:47 -0700 (PDT) Received: by 10.227.208.7 with SMTP id ga7mr2479798wbb.126.1285021607266; Mon, 20 Sep 2010 15:26:47 -0700 (PDT) MIME-Version: 1.0 Sender: jcarman@carmanconsulting.com Received: by 10.227.144.13 with HTTP; Mon, 20 Sep 2010 15:26:26 -0700 (PDT) In-Reply-To: <29E08A68-B784-42FB-95D4-7CE12C293AF8@gmail.com> References: <29E08A68-B784-42FB-95D4-7CE12C293AF8@gmail.com> From: James Carman Date: Mon, 20 Sep 2010 18:26:26 -0400 X-Google-Sender-Auth: WZJF5_fcQZeLCVhEWkhR8LBiJPI Message-ID: Subject: Re: [proxy] suppression of equals/hashCode To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Sep 20, 2010 at 6:16 PM, Matt Benson wrote: > Hi all, > =A0By default, [proxy]'s provided ProxyFactory implementations all force = their generated proxies to implement hashCode via System.identityHashCode()= and equals via reference equality. =A0I will leave it to the original auth= or to explain the reasons behind this design decision if he chooses, but I = would propose that it would not be out of order to provide a means of allow= ing a user to implement these methods as any other. =A0If anyone has any op= inions to contribute on the matter, please make them known. > As the original author, I do not recall the exact reasoning behind this decision at this time. However, I would assume that it has something to do with the fact that you may have two different proxies with the same "target" object. One of these proxies could have interceptors on it (for security, logging, whatever) and the other might not. If you let the "target" respond to equals/hashCode, then these two proxies would be considered equal, when they clearly should not. I agree that it would be nice to allow the user to override this behavior, but I think the general case should be to just use Object's implementation of these two methods. I don't want to muddy up ProxyFactory's API to do this, though. I'd rather figure out some other way to do this. Perhaps we could make every proxy object implement some interface (ProxyObject perhaps). That interface could have a "setter" on it to allow the user to override the "thing" that implements the equals/hashCode methods: public interface Equalizer { public boolean equals(T source, T target); public int hashCode(T source); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org