You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by Mark Struberg <st...@yahoo.de> on 2012/06/28 08:26:29 UTC

MessageBuilder take3

... and a take 4 will follow I'm sure :)

Hi!

The MessageBuilder is now working a bit better, but I'm still not satisfied.

What I changed so far: 

How it works:

There are 2 big areas in the game

1.) the MessageContext. This contains the core messaging functionality, a fluent API and a configuration section.



2.) the typesafe @MessageBundle + MessageBundleInvocationHandler. There have been lot's of code inside the invocation handler which logically should rather be handled in the MessageContext. I now moved the whole ResourceBundle handling to the MessageContext for example. Prior to that it had not been possible to create a messagebundle text with the fluent api. I'm still not 100% happy with some parts but the functionality works now at least.



It's now also a bit easier to change the default behaviour of the MessageContext.
The configuration consists off 3 parts

a.) the LocaleResolver (resolves en_US, de_AT, ...). We do not inject a final Locale but only the Resolver, because in e.g. JSF this information can be taken from the ViewRoot, the logged in user, etc...

b.) the MessageInterpolator. The default one now uses the String.format which allows lots of tweaks. If someone used the java.text.MessageFormat in his project in the past, then he can simply change this now.

c.) the MessageResolver. This is the location where messages will be taken from the ResourceBundle. I needed to add an 'initialize' method which is slightly 'out of tune' from my gut feeling. Maybe we should give it a way to resolve the other configurations from the MessageContext? Please review!

I'll write another mail about the @DefaultConfiguration...

LieGrue,
strub


Re: MessageBuilder take3

Posted by Jason Porter <li...@gmail.com>.
I'll put it on my todo list and get to it probably after the conference
when my time frees up a bit.

On Thu, Jun 28, 2012 at 2:26 AM, Mark Struberg <st...@yahoo.de> wrote:

> ... and a take 4 will follow I'm sure :)
>
> Hi!
>
> The MessageBuilder is now working a bit better, but I'm still not
> satisfied.
>
> What I changed so far:
>
> How it works:
>
> There are 2 big areas in the game
>
> 1.) the MessageContext. This contains the core messaging functionality, a
> fluent API and a configuration section.
>
>
>
> 2.) the typesafe @MessageBundle + MessageBundleInvocationHandler. There
> have been lot's of code inside the invocation handler which logically
> should rather be handled in the MessageContext. I now moved the whole
> ResourceBundle handling to the MessageContext for example. Prior to that it
> had not been possible to create a messagebundle text with the fluent api.
> I'm still not 100% happy with some parts but the functionality works now at
> least.
>
>
>
> It's now also a bit easier to change the default behaviour of the
> MessageContext.
> The configuration consists off 3 parts
>
> a.) the LocaleResolver (resolves en_US, de_AT, ...). We do not inject a
> final Locale but only the Resolver, because in e.g. JSF this information
> can be taken from the ViewRoot, the logged in user, etc...
>
> b.) the MessageInterpolator. The default one now uses the String.format
> which allows lots of tweaks. If someone used the java.text.MessageFormat in
> his project in the past, then he can simply change this now.
>
> c.) the MessageResolver. This is the location where messages will be taken
> from the ResourceBundle. I needed to add an 'initialize' method which is
> slightly 'out of tune' from my gut feeling. Maybe we should give it a way
> to resolve the other configurations from the MessageContext? Please review!
>
> I'll write another mail about the @DefaultConfiguration...
>
> LieGrue,
> strub
>
>


-- 
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp

Software Engineer
Open Source Advocate
Author of Seam Catch - Next Generation Java Exception Handling

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu