Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 264D891E1 for ; Tue, 7 Feb 2012 15:19:35 +0000 (UTC) Received: (qmail 52051 invoked by uid 500); 7 Feb 2012 15:19:34 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 51915 invoked by uid 500); 7 Feb 2012 15:19:33 -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 51907 invoked by uid 99); 7 Feb 2012 15:19:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 15:19:33 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simone.tripodi@gmail.com designates 209.85.216.50 as permitted sender) Received: from [209.85.216.50] (HELO mail-qw0-f50.google.com) (209.85.216.50) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 15:19:29 +0000 Received: by qabg27 with SMTP id g27so25879443qab.9 for ; Tue, 07 Feb 2012 07:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=VoeRIvODknuhzSIMQp7DT9R7cc/kw5QqnOo4xgGtFAo=; b=nD6wDDZQCs26k1ps4o1hKObsWPYI4nwq0om1yVpZ1u2T8BvTg3rIaGqFyOieJt0WIf /3e60uu+E8KQuaQcHZ+yzbS0coreOeJl4bOscfy46aGE+fYOKkrlF9y3yv2ri0GyCmaP 0TRqtt6G+o4DF23CvmdpWXpkOAitG/BF70ueU= MIME-Version: 1.0 Received: by 10.224.116.207 with SMTP id n15mr1157098qaq.97.1328627948369; Tue, 07 Feb 2012 07:19:08 -0800 (PST) Sender: simone.tripodi@gmail.com Received: by 10.224.117.139 with HTTP; Tue, 7 Feb 2012 07:19:08 -0800 (PST) In-Reply-To: <4F313999.2000503@systemoutprintln.de> References: <4F2E893C.90008@systemoutprintln.de> <4F313999.2000503@systemoutprintln.de> Date: Tue, 7 Feb 2012 16:19:08 +0100 X-Google-Sender-Auth: IqiEJK_Bv2v_FwOwPgWY3-HIJE0 Message-ID: Subject: Re: [SANDBOX][BeanUtils2] Regarding BeanAccessor.populate() From: Simone Tripodi To: Commons Developers List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hola, > I've read your email twice yesterday evening and again today. Sorry, but = I > honestly do not understand, what you are talking about :-) > I assume, that you are referring to my comment on svn commit r1241124 on > moving Assertions to a new package?! (rather then the behavior of > populate()) yes indeed, I replied to your last message > > If so, I would say, yes you're right when saying, that exposing the minim= al > possible API is a good thing. At least it is a good thing for users. OTOH > for developers it is more complicated to understand the code if everythin= g > is contained in just one package. > :| complicated?!? do you see how small is the actual the codebase? have you never raw Hibernate or Spring2.X source code? :) > > I think we can live with an internal package. Everybody should know, that= it > is not intended to be used outside the library. > A nice thing about OSGi Bundles is that you can explicitly specify which > packages should be visible to other bundles. Looking at the generated > MANIFEST after calling mvn clean test, I can see that the internal packag= e > will be exported to. > Is there any possibility to configure the build, so that it generates a > MANIFEST, that does not export the internal package? > yes, there are few configuration properties that have to be set, see the parent pom if you're interested on providing the patch ;) alles gute! -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Tue, Feb 7, 2012 at 3:47 PM, Benedikt Ritter wrote: > Hi Simo, > > > If so, I would say, yes you're right when saying, that exposing the minim= al > possible API is a good thing. At least it is a good thing for users. OTOH > for developers it is more complicated to understand the code if everythin= g > is contained in just one package. > > I think we can live with an internal package. Everybody should know, that= it > is not intended to be used outside the library. > A nice thing about OSGi Bundles is that you can explicitly specify which > packages should be visible to other bundles. Looking at the generated > MANIFEST after calling mvn clean test, I can see that the internal packag= e > will be exported to. > Is there any possibility to configure the build, so that it generates a > MANIFEST, that does not export the internal package? > > Regards, > Benedikt > > > Am 06.02.2012 21:31, schrieb Simone Tripodi: > >> anyway, just for the record: the reason is just because I introduced a >> new package that needs to access to same methods, otherwise there >> wouldn't have been any reason to expose it. >> do you see a valid motivation? >> -Simo >> >> http://people.apache.org/~simonetripodi/ >> http://simonetripodi.livejournal.com/ >> http://twitter.com/simonetripodi >> http://www.99soft.org/ >> >> >> >> On Sun, Feb 5, 2012 at 9:27 PM, Simone Tripodi >> =C2=A0wrote: >>> >>> Hi Benedikt, >>> >>> let's keep the `skip readonly property` behavior ATM, that is >>> something =C2=A0BeanUtils users are already used to. >>> Same for null key, skip them. >>> >>> Moreover, iterate over properties.entrySet()[1] instead of keySet(). >>> >>> all the best, >>> -Simo >>> >>> [1] >>> http://docs.oracle.com/javase/6/docs/api/java/util/Map.html#entrySet() >>> >>> http://people.apache.org/~simonetripodi/ >>> http://simonetripodi.livejournal.com/ >>> http://twitter.com/simonetripodi >>> http://www.99soft.org/ >>> >>> >>> >>> On Sun, Feb 5, 2012 at 2:50 PM, Benedikt Ritter >>> =C2=A0wrote: >>>> >>>> Hi, >>>> >>>> I'm working on populate and tried to stick to the convention of throwi= ng >>>> exceptions for illegal inputs: >>>> >>>> * passing null will cause NullPointerException >>>> * passing an empty Map will have no effect >>>> * passing a Map with null keys will cause NullPointerException >>>> * passing a Map with null values will set those properties to null >>>> * passing a Map with null values for primitive properties will cause a >>>> IllegalArgumentException >>>> >>>> But this is in contrast to BeanUtils1. Looking at the implementation o= f >>>> BeanUtilsBean.populate() I can see that: >>>> >>>> * passing null does nothing >>>> * passing an empty map does nothing >>>> * Null keys will be ignored >>>> >>>> Now I think, that throwing exceptions is better than just accepting >>>> every >>>> value. Am I right with that? >>>> >>>> Also, I'm wondering how populate should behave if a value for a read >>>> only >>>> property is passed. Looking at BeanUtils1 I've seen that >>>> BeanUtilsBean.populate() just ignores those properties (line 974 in >>>> BeanUtilsBean). >>>> Currently I've a pretty straight forward implementation: >>>> >>>> public void populate( Map =C2=A0properties ) throws >>>> IllegalAccessException, IllegalArgumentException, >>>> InvocationTargetException, >>>> NoSuchMethodException, IntrospectionException >>>> { >>>> =C2=A0 =C2=A0checkNotNull( properties, "Can not populate null!" ); >>>> =C2=A0 =C2=A0for ( String propertyName : properties.keySet() ) >>>> =C2=A0 =C2=A0{ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0checkNotNull( propertyName, "Null is not an= allowed property >>>> key!" ); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0setProperty( propertyName ).withValue( prop= erties.get( >>>> propertyName ) >>>> ); >>>> =C2=A0 =C2=A0} >>>> } >>>> >>>> Calling setProperty will result in a NoSuchMethodException been thrown= , >>>> if >>>> there is no setter method for a given key. I thing that is convenient >>>> looking at the overall design of BeanUtils2. >>>> >>>> To sum this all up: How should populate() behave, if the property for = a >>>> given key is read only? >>>> >>>> Regards, >>>> Benedikt >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>>> For additional commands, e-mail: dev-help@commons.apache.org >>>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org