com.github.fge.msgsimple.provider
Class LoadingMessageSourceProvider.Builder

java.lang.Object
  extended by com.github.fge.msgsimple.provider.LoadingMessageSourceProvider.Builder
Enclosing class:
LoadingMessageSourceProvider

public static final class LoadingMessageSourceProvider.Builder
extends Object

Builder class for a LoadingMessageSourceProvider


Method Summary
 MessageSourceProvider build()
          Build the provider
 LoadingMessageSourceProvider.Builder neverExpires()
          Set this loading provider so that entries never expire
 LoadingMessageSourceProvider.Builder setDefaultSource(MessageSource defaultSource)
          Set the default message source if the loader fails to load
 LoadingMessageSourceProvider.Builder setExpiryTime(long duration, TimeUnit unit)
          Set the source expiry time (10 minutes by default)
 LoadingMessageSourceProvider.Builder setLoader(MessageSourceLoader loader)
          Set the message source loader
 LoadingMessageSourceProvider.Builder setLoadTimeout(long duration, TimeUnit unit)
          Set the load timeout (1 second by default)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLoader

public LoadingMessageSourceProvider.Builder setLoader(MessageSourceLoader loader)
Set the message source loader

Parameters:
loader - the loader
Returns:
this
Throws:
NullPointerException - loader is null

setDefaultSource

public LoadingMessageSourceProvider.Builder setDefaultSource(MessageSource defaultSource)
Set the default message source if the loader fails to load

Parameters:
defaultSource - the default source
Returns:
this
Throws:
NullPointerException - source is null

setLoadTimeout

public LoadingMessageSourceProvider.Builder setLoadTimeout(long duration,
                                                           TimeUnit unit)
Set the load timeout (1 second by default)

If the loader passed as an argument fails to load a message source after the specified timeout is elapsed, then the default messagesource will be returned (if any).

Parameters:
duration - number of units
unit - the time unit
Returns:
this
Throws:
IllegalArgumentException - duration is negative or zero
NullPointerException - unit is null
See Also:
setLoader(MessageSourceLoader), setDefaultSource(MessageSource)

setExpiryTime

public LoadingMessageSourceProvider.Builder setExpiryTime(long duration,
                                                          TimeUnit unit)
Set the source expiry time (10 minutes by default)

Do not use this method if you want no expiry at all; use neverExpires() instead.

Parameters:
duration - number of units
unit - the time unit
Returns:
this
Throws:
IllegalArgumentException - duration is negative or zero
NullPointerException - unit is null
Since:
0.5

neverExpires

public LoadingMessageSourceProvider.Builder neverExpires()
Set this loading provider so that entries never expire

Returns:
this
Since:
0.5

build

public MessageSourceProvider build()
Build the provider

Returns:
a LoadingMessageSourceProvider
Throws:
IllegalArgumentException - no loader has been provided