Basically in the API area we have something called, ConfigurationProvider. We might rename that to something more general (which it basically also is, since it also provides ConfigurationContext). The factory method for the builder then could be added there. As a side effect we also would be able to model the builder as interface and let it be implemented by the RI (via the ConfigurationProviderSpi -> must be adapted from name perspective, when we rename ConfigurationProvider, of course). So I try to list some proposals:
ConfigurationManager ConfigManager Configurations ConfigurationSystem ConfigSystem Tamaya I agree with Romain on minimizing the entry points. In the money JSR e.g. we have basically one entry point per functional area (MonetaryCurrencies, MonetaryAmounts, MonetaryFormats and MonetaryConversions). All start with "Monetary", so working with them in an IDE is damn simple and intuitive ;) We could try to to something similar that we provide for each area a singleton entry point starting with "Config", thus resulting in ConfigManager ConfigResources (resource module) ConfigResolver (resolver module) ConfigFormats (formats module) Adding the builder to this central place would consequently mean to move its API to the API package as well. I am fine with that. If we keep it separate, we must have some alternate entry point. Given that the builder module can also have logic for building other artifacts, e.g. a PropertySource, we might create an entry point named: ConfigBuilders WDYT? 2015-03-20 11:05 GMT+01:00 Romain Manni-Bucau <[email protected]>: > yes, jsonp API is quite smooth. > > agree that technically we can put the factory in the builder but actually I > like having a product/spec entry point (Json, Validation, > Persistence,....). It makes the API discovery super smooth compared to have > to know N entry points. > > > Romain Manni-Bucau > @rmannibucau <https://twitter.com/rmannibucau> | Blog > <http://rmannibucau.wordpress.com> | Github < > https://github.com/rmannibucau> | > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber > <http://www.tomitribe.com> > > 2015-03-20 11:01 GMT+01:00 Werner Keil <[email protected]>: > > > Hi, > > > > Being a member of the JSON-P 1.1 EG I also came across its builders and > how > > they're constructed. > > http://docs.oracle.com/javaee/7/api/javax/json/package-summary.html > > shows relevant parts of the API. > > > > It's as simple as > > JsonObject object = Json.createObjectBuilder().build(); > > > > So whatever we might call a similar factory for the builder, > Configurations > > or just Tamaya, doing something like > > Configuration config = Tamaya.createConfigurationBuilder.build(); > > sounds appealing. > > > > Of course a static create() method could also be on the > > ConfigurationBuilder itself (in Java 8 even interfaces, for Java 7 we > might > > have to find a workaround;-) > > > > Werner > > > > > > > > On Thu, Mar 19, 2015 at 3:36 PM, Werner Keil <[email protected]> > > wrote: > > > > > That's why I say a properly named useful static accessor makes sense. > I'd > > > be equally fine with the (completely hiding the constructor) way > Typesafe > > > does it, though IMHO the variants like defaultApp() and so on you'll > find > > > beside load() feel a bit cluttered and confusing. > > > > > > Werner Keil | JCP Executive Committee Member, JSR 363 Co Spec Lead | > > > Eclipse UOMo Lead, Babel Language Champion | Apache Committer | > Advisory > > > Board Member, Java Track Chair, DWX '15 > > > > > > Twitter @wernerkeil | @UnitAPI | @JSR377 | @JSR354 | @AgoravaProj | > > #EclipseUOMo > > > | #DeviceMap | #DevOps > > > Skype werner.keil | Google+ gplus.to/wernerkeil > > > > > > On Thu, Mar 19, 2015 at 3:28 PM, Romain Manni-Bucau < > > [email protected] > > > > wrote: > > > > > >> well that's to build a config, do you expect it to do it for each > > request? > > >> > > >> > > >> Romain Manni-Bucau > > >> @rmannibucau <https://twitter.com/rmannibucau> | Blog > > >> <http://rmannibucau.wordpress.com> | Github < > > >> https://github.com/rmannibucau> | > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber > > >> <http://www.tomitribe.com> > > >> > > >> 2015-03-19 15:18 GMT+01:00 Werner Keil <[email protected]>: > > >> > > >> > Just a question of preference, some (or several) projects tend to > hide > > >> the > > >> > constructor, others accept it and yet other ones offer even both > > ways;-D > > >> > > > >> > Configuration conf = new ConfigurationBuilder().build(); > > >> > int bar1 = conf.getInteger("foo.bar"); > > >> > > > >> > From my earlier example for simplicity would be equally fine. > > >> > > > >> > One has to add, the static factory allows optimization especially > for > > a > > >> > default case to cache something if it won't change for the lifetime > of > > >> an > > >> > app/VM. > > >> > If you call new ConfigurationBuilder() you always need to > instantiate > > a > > >> new > > >> > object, only the underlying JDK may help you save resources if it > can. > > >> > > > >> > Werner > > >> > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> > On Thu, Mar 19, 2015 at 3:06 PM, Oliver B. Fischer < > > >> > [email protected] > > >> > > wrote: > > >> > > > >> > > Hi, > > >> > > > > >> > > I don't see the value of the whole discussion. > > >> > > > > >> > > Why can I not simply say > > >> > > > > >> > > new ConfigurationBuilder(); > > >> > > > > >> > > What is wrong about it? > > >> > > > > >> > > Viele Grüße > > >> > > > > >> > > Oliver > > >> > > > > >> > > > > >> > > Am 19.03.15 um 14:59 schrieb Werner Keil: > > >> > > > > >> > >> Why would you get a builder FROM a configuration? I'd expect a > > >> > >> configuration from a builder;-) > > >> > >> So it'll be a builder "for" a particular configuration. > > >> > >> > > >> > >> valueOf() and getInstance() have been the two most common static > > >> > factories > > >> > >> and till Java 5 or even 6 they were the only ones used at all, > not > > >> just > > >> > by > > >> > >> JDK. > > >> > >> While Josh Bloch started "playing" with of() in a single place > > >> (EnumSet) > > >> > >> it > > >> > >> also got probably even more frequent in the .NET world. > > >> > >> Dim xyz As Nullable(Of Date) > > >> > >> > > >> > >> is the way to use Nullable in VB.net. C# has a shortcut via "?". > > Both > > >> > are > > >> > >> vaguely comparable to the new Optional class in Java 8. Where > of() > > is > > >> > also > > >> > >> used. Mostly new types or elements of Java 8 start getting it, so > > you > > >> > may > > >> > >> call it less "common" for the rest of the platform. > > >> > >> > > >> > >> > > >> > >> If you prefer valueOf(), that would be just as good. from() or > to() > > >> only > > >> > >> apply to conversions, they just make no sense in other cases. > > >> > >> > > >> > >> The new Lambda packages of Java 8 are full with of() and even > > >> classes or > > >> > >> inner types called Of*, etc. > > >> > >> > > >> > >> Most of its builders are static inner .Builder types btw, see > > >> > >> static <T> Stream.Builder > > >> > >> <http://docs.oracle.com/javase/8/docs/api/java/util/ > > >> > >> stream/Stream.Builder.html> > > >> > >> <T>builder > > >> > >> <http://docs.oracle.com/javase/8/docs/api/java/util/ > > >> > >> stream/Stream.html#builder--> > > >> > >> () > > >> > >> Returns a builder *for *a Stream. > > >> > >> > > >> > >> Aside from any particular names it should be as easy as > Typesafe > > >> > Config: > > >> > >> > > >> > >> Config conf = ConfigFactory.load(); > > >> > >> int bar1 = conf.getInt("foo.bar"); > > >> > >> Config foo = conf.getConfig("foo"); > > >> > >> int bar2 = foo.getInt("bar"); > > >> > >> > > >> > >> but if you prefer the term Builder, it should be equally > > >> > straightforward. > > >> > >> > > >> > >> Configuration conf = ConfigurationBuilder.getInstance().build(); > > >> > >> int bar1 = conf.getInteger("foo.bar"); > > >> > >> > > >> > >> would require auto-boxing but compile a comparable Tamay > example. > > >> > >> Assuming > > >> > >> ConfigurationBuilder needs to instanciate first. > > >> > >> > > >> > >> Typesafe's factory is a simple static class that takes various > > >> > arguments. > > >> > >> > > >> > >> Oh btw, mostly used by Eclipse and OSGi, but there you see > default > > >> no-op > > >> > >> factory methods called *getDefault*() almost everywhere. But then > > >> > calling > > >> > >> interfaces ISomething is also nearly unknown outside .NET or > > >> Eclipse;-) > > >> > >> > > >> > >> Werner > > >> > >> > > >> > >> > > >> > >> > > >> > >> > > >> > >> > > >> > >> On Thu, Mar 19, 2015 at 2:29 PM, Romain Manni-Bucau < > > >> > >> [email protected]> > > >> > >> wrote: > > >> > >> > > >> > >> 2015-03-19 14:19 GMT+01:00 Werner Keil <[email protected]>: > > >> > >>> > > >> > >>> well let say common is subjective since it is as common to not > use > > >> it. > > >> > >>> > > >> > >>> here semantically it is wrong since you dont get the builder of > a > > >> > >>> configuration but you get a builder from a configuration. > > >> > >>> > > >> > >>> more root semantic would be unwrap or something like that - we > can > > >> > still > > >> > >>> use but istoo technical IMO. > > >> > >>> > > >> > >>> > > >> > >>> using the constructor just makes this topic closed IMO. The > static > > >> > method > > >> > >>> really brings nothing here. > > >> > >>> > > >> > >>> > > >> > >>> [email protected] > > >> > >>> since > > >> > >>> me;-) > > >> > >>> [email protected]> > > >> > >>> also > > >> > >>> other > > >> > >>> a > > >> > >>> (in > > >> > >>> using > > >> > >>> a > > >> > >>> to > > >> > >>> given > > >> > >>> to > > >> > >>> input, > > >> > >>> don't > > >> > >>> can > > >> > >>> the > > >> > >>> ebove > > >> > >>> we > > >> > >>> the > > >> > >>> > > >> > >> > > >> > > -- > > >> > > N Oliver B. Fischer > > >> > > A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany > > >> > > P +49 30 44793251 > > >> > > M +49 178 7903538 > > >> > > E [email protected] > > >> > > S oliver.b.fischer > > >> > > J [email protected] > > >> > > X http://xing.to/obf > > >> > > > > >> > > > > >> > > > >> > > > > > > > > > -- *Anatole Tresch* Java Engineer & Architect, JSR Spec Lead Glärnischweg 10 CH - 8620 Wetzikon *Switzerland, Europe Zurich, GMT+1* *Twitter: @atsticks* *Blogs: **http://javaremarkables.blogspot.ch/ <http://javaremarkables.blogspot.ch/>* *Google: atsticksMobile +41-76 344 62 79*
