public class SmsBuilder extends Object implements MessagingSenderBuilder<ConditionalSender>
Specialized builder for SMS sender.
There exists several implementations to send an SMS:
This builder provides a MultiImplementationSender
. The aim of the
MultiImplementationSender
is to choose the best implementation for
sending the SMS according to the runtime environment (detection of libraries
in the classpath, availability of a particular property, ...).
This builder lets you the possibility to register any new implementation. It allows you to enable or not templating support and automatic filling of message values (like sender address for example).
SmsSender
,
OvhSmsSender
,
CloudhopperSMPPSender
,
TemplateBuilder
,
ContentTranslatorBuilder
,
MessageFillerBuilder
Constructor and Description |
---|
SmsBuilder() |
Modifier and Type | Method and Description |
---|---|
ConditionalSender |
build()
Build the object
|
SmsBuilder |
enableSmsTemplateKeys()
Calling this method will enable different location for SMS templates from
default one.
|
ContentTranslatorBuilder |
getContentTranslatorBuilder()
Get the builder used transform the content of the message.
|
MessageFillerBuilder |
getMessageFillerBuilder()
Get the builder used for filling messages.
|
PhoneNumberTranslatorBuilder |
getRecipientNumberTranslatorBuilder()
Get the builder for transformation of recipient phone numbers.
|
PhoneNumberTranslatorBuilder |
getSenderNumberTranslatorBuilder()
Get the builder for transformation of sender phone numbers.
|
TemplateBuilder |
getTemplateBuilder()
Shortcut to directly access template builder for fine tuning templating
mechanism.
|
SmsBuilder |
registerDefaultImplementations()
Register all default implementations:
OVH HTTP API implementation
Configuration values come from system properties.
|
SmsBuilder |
registerDefaultImplementations(Properties properties)
Register all default implementations:
OVH HTTP API implementation
smsgloabl REST API implementation
Cloudhopper SMPP implementation
Configuration values come from provided properties.
|
SmsBuilder |
registerImplementation(Condition<Message> condition,
Builder<? extends MessageSender> builder)
Register a new implementation for sending SMS.
|
SmsBuilder |
registerImplementation(Condition<Message> condition,
MessageSender implementation)
Register a new implementation for sending SMS.
|
SmsBuilder |
setTemplateExtensionKey(String extensionKey)
Calling this method will enable different location for SMS templates from
default one.
|
SmsBuilder |
setTemplateParentPathKey(String parentPathKey)
Calling this method will enable different location for SMS templates from
default one.
|
SmsBuilder |
useDefaults()
Tells the builder to use all default behaviors and values:
Registers OVH HTTP API implementation
Enables automatic filling of message based on configuration
properties
Enables templating support
Configuration values come from system properties.
|
SmsBuilder |
useDefaults(Properties properties)
Tells the builder to use all default behaviors and values:
Registers OVH HTTP API implementation
Enables automatic filling of message based on configuration
properties
Enables templating support
Configuration values come from provided properties.
|
SmsBuilder |
withAutoFilling()
Enables filling of SMS with values that comes from system configuration
properties.
|
SmsBuilder |
withAutoFilling(MessageFillerBuilder builder)
Enables automatic filling of SMS with values that come from multiple
sources.
|
SmsBuilder |
withAutoFilling(Properties props)
Enables filling of SMS with values that comes from provided configuration
properties.
|
SmsBuilder |
withAutoFilling(Properties props,
String... baseKeys)
Enables filling of SMS with values that comes from provided configuration
properties.
|
SmsBuilder |
withCloudhopper(Properties properties)
Enable Cloudhoppder SMPP implementation.
|
SmsBuilder |
withoutTemplate()
Disable templating support.
|
SmsBuilder |
withOvhHttpApi(Properties properties)
Enable OVH HTTP API implementation.
|
SmsBuilder |
withPhoneNumberTranslation()
Enables Addressing strategy using all default behaviors and values.
|
SmsBuilder |
withPhoneNumberTranslation(PhoneNumberTranslatorBuilder senderBuilder,
PhoneNumberTranslatorBuilder recipientBuilder)
Enables Addressing strategy using the provided
SenderPhoneNumberTranslatorBuilder and
RecipientPhoneNumberTranslatorBuilder . |
SmsBuilder |
withReceiverPhoneNumberTranslation(PhoneNumberTranslatorBuilder builder)
Enables Addressing strategy using the provided
RecipientPhoneNumberTranslatorBuilder . |
SmsBuilder |
withSenderPhoneNumberTranslation(PhoneNumberTranslatorBuilder builder)
Enables Addressing strategy using the provided
SenderPhoneNumberTranslatorBuilder . |
SmsBuilder |
withSmsglobalRestApi(Properties properties)
Enable smsglobal REST API implementation.
|
SmsBuilder |
withTemplate()
Enables templating support using all default behaviors and values.
|
SmsBuilder |
withTemplate(ContentTranslatorBuilder builder)
Enables templating support using the provided
ContentTranslatorBuilder . |
public ConditionalSender build() throws BuildException
Builder
build
in interface Builder<ConditionalSender>
BuildException
- when the object couldn't be constructedpublic SmsBuilder useDefaults()
Configuration values come from system properties.
public SmsBuilder useDefaults(Properties properties)
Configuration values come from provided properties.
properties
- the properties to use instead of default onespublic SmsBuilder registerImplementation(Condition<Message> condition, MessageSender implementation)
condition
- the condition that indicates at runtime if the implementation
can be used or notimplementation
- the implementation to registerpublic SmsBuilder registerImplementation(Condition<Message> condition, Builder<? extends MessageSender> builder)
condition
- the condition that indicates at runtime if the implementation
can be used or notbuilder
- the builder for the implementation to registerpublic SmsBuilder registerDefaultImplementations()
Configuration values come from system properties.
Automatically called by useDefaults()
and
useDefaults(Properties)
public SmsBuilder registerDefaultImplementations(Properties properties)
Configuration values come from provided properties.
Automatically called by useDefaults()
and
useDefaults(Properties)
properties
- the properties to usepublic SmsBuilder withSmsglobalRestApi(Properties properties)
ogham.sms.smsglobal.api.key
is setproperties
- the properties to use for checking if property existspublic SmsBuilder withOvhHttpApi(Properties properties)
ogham.sms.ovh.account
is setogham.sms.ovh.login
is setogham.sms.ovh.password
is setproperties
- the properties to use for checking if property existspublic SmsBuilder withCloudhopper(Properties properties)
ogham.sms.smpp.host
is setogham.sms.smpp.port
is setcom.cloudhopper.smpp.SmppClient
is available
in the classpathproperties
- the properties to use for checking if property existspublic SmsBuilder withAutoFilling(MessageFillerBuilder builder)
builder
- the builder for constructing the message fillerpublic SmsBuilder withAutoFilling(Properties props, String... baseKeys)
Automatically called by useDefaults()
and
useDefaults(Properties)
props
- the properties that contains the values to set on the SMSbaseKeys
- the prefix(es) for the keys used for filling the messagepublic SmsBuilder withAutoFilling(Properties props)
Automatically called by useDefaults()
and
useDefaults(Properties)
props
- the properties that contains the values to set on the SMSpublic SmsBuilder withAutoFilling()
Automatically called by useDefaults()
and
useDefaults(Properties)
public SmsBuilder withTemplate()
ContentTranslatorBuilder.useDefaults()
for more information.
Automatically called by useDefaults()
and
useDefaults(Properties)
public SmsBuilder withTemplate(ContentTranslatorBuilder builder)
ContentTranslatorBuilder
. It decorates the SMS sender with a
ContentTranslatorSender
.builder
- the builder to use to build the ContentTranslator
instead of using the default onepublic SmsBuilder withoutTemplate()
public SmsBuilder enableSmsTemplateKeys()
Calling this method will enable different location for SMS templates from default one. The location will be specified by different property keys for parent path and extension.
By default default properties are:TemplateConstants.PREFIX_PROPERTY
)
TemplateConstants.SUFFIX_PROPERTY
SmsConstants.TemplateConstants.PREFIX_PROPERTY
SmsConstants.TemplateConstants.SUFFIX_PROPERTY
public SmsBuilder setTemplateParentPathKey(String parentPathKey)
Calling this method will enable different location for SMS templates from default one. The location will be specified by a different property key for parent path.
By default default property key is ogham.template.prefix (see
TemplateConstants.PREFIX_PROPERTY
)
Calling this method will change the property key to the provided key.
parentPathKey
- the new key for the SMS template parent pathpublic SmsBuilder setTemplateExtensionKey(String extensionKey)
Calling this method will enable different location for SMS templates from default one. The location will be specified by a different property key for extension.
By default default property key is ogham.template.suffix (see
TemplateConstants.SUFFIX_PROPERTY
)
Calling this method will change the property key to the provided key.
extensionKey
- the new key for the SMS template extensionpublic SmsBuilder withPhoneNumberTranslation()
SenderPhoneNumberTranslatorBuilder
and
RecipientPhoneNumberTranslatorBuilder
.
Automatically called by useDefaults()
and
useDefaults(Properties)
public SmsBuilder withPhoneNumberTranslation(PhoneNumberTranslatorBuilder senderBuilder, PhoneNumberTranslatorBuilder recipientBuilder)
SenderPhoneNumberTranslatorBuilder
and
RecipientPhoneNumberTranslatorBuilder
. It decorates the SMS
sender with a PhoneNumberTranslatorSender
senderBuilder
- the builder to use to build the PhoneNumberTranslator
for sender instead of using the default onerecipientBuilder
- the builder to use to build the PhoneNumberTranslator
for sender instead of using the default onepublic SmsBuilder withReceiverPhoneNumberTranslation(PhoneNumberTranslatorBuilder builder)
RecipientPhoneNumberTranslatorBuilder
. It decorates the SMS
sender with a PhoneNumberTranslatorSender
builder
- the builder to use to build the PhoneNumberTranslator
instead of using the default onepublic SmsBuilder withSenderPhoneNumberTranslation(PhoneNumberTranslatorBuilder builder)
SenderPhoneNumberTranslatorBuilder
. It decorates the SMS sender
with a PhoneNumberTranslatorSender
builder
- the builder to use to build the PhoneNumberTranslator
instead of using the default onepublic MessageFillerBuilder getMessageFillerBuilder()
Get the builder used for filling messages.
Access this builder if you want to:public ContentTranslatorBuilder getContentTranslatorBuilder()
Get the builder used transform the content of the message. It may be useful to fine tune templating mechanism, resource inlining and messages with with several contents.
Access this builder if you want to:getTemplateBuilder()
)public TemplateBuilder getTemplateBuilder()
Shortcut to directly access template builder for fine tuning templating mechanism.
Access this builder if you want to:public PhoneNumberTranslatorBuilder getRecipientNumberTranslatorBuilder()
Get the builder for transformation of recipient phone numbers.
Access to this builder if you want to:public PhoneNumberTranslatorBuilder getSenderNumberTranslatorBuilder()
Get the builder for transformation of sender phone numbers.
Access to this builder if you want to:Copyright © 2017. All rights reserved.