public class CloudhopperBuilder extends AbstractParent<SmsBuilder> implements Builder<CloudhopperSMPPSender>
To send Sms
using Cloudhopper, you need to register this builder into
a MessagingBuilder
like this:
MessagingBuilder msgBuilder = ...
msgBuilder.sms()
.sender(CloudhopperBuilder.class) // registers the builder and accesses to that builder for configuring it
Once the builder is registered, sending sms through Cloudhopper requires at
least host of the SMPP server. You can define it using:
msgBuilder.sms()
.sender(CloudhopperBuilder.class) // registers the builder and accesses to that builder for configuring it
.host("localhost")
Or you can also use property keys (using interpolation):
msgBuilder
.environment()
.properties()
.set("custom.property.for.host", "localhost")
.and()
.and()
.sms()
.sender(CloudhopperBuilder.class) // registers the builder and accesses to that builder for configuring it
.host()
.properties("${custom.property.for.host}")
You can do the same with port of the SMPP server.
SMPP server may require authentication. In most cases, authentication is done using system_id/password. You can use this builder to quickly provide your system_id and password:
.sender(CloudhopperBuilder.class)
.systemId("foo")
.password("bar")
parent
Constructor and Description |
---|
CloudhopperBuilder()
Default constructor when using without all Ogham work.
|
CloudhopperBuilder(SmsBuilder parent,
BuildContext buildContext)
Constructor that is called when using Ogham builder:
|
Modifier and Type | Method and Description |
---|---|
CloudhopperBuilder |
addressRange(com.cloudhopper.smpp.type.Address range)
The address_range parameter is used in the bind_receiver and
bind_transceiver command to specify a set of SME addresses serviced by
the ESME client.
|
ConfigurationValueBuilder<CloudhopperBuilder,com.cloudhopper.smpp.SmppBindType> |
bindType()
The bind command type (see
SmppBindType ). |
CloudhopperBuilder |
bindType(com.cloudhopper.smpp.SmppBindType bindType)
The bind command type (see
SmppBindType ). |
CloudhopperSMPPSender |
build()
Instantiate and configures the instance.
|
CloudhopperBuilder |
clientSupplier(SmppClientSupplier supplier)
By default,
CloudhopperSMPPSender uses DefaultSmppClient
client. |
DataCodingSchemeBuilder |
dataCodingScheme()
Data Coding Scheme is a one-octet field in Short Messages (SM) and Cell
Broadcast Messages (CB) which carries a basic information how the
recipient handset should process the received message.
|
EncoderBuilder |
encoder()
Configures how Cloudhopper will encode SMS messages.
|
ConfigurationValueBuilder<CloudhopperBuilder,String> |
host()
The SMPP server host (IP or address).
|
CloudhopperBuilder |
host(String host)
The SMPP server host (IP or address).
|
ConfigurationValueBuilder<CloudhopperBuilder,InterfaceVersion> |
interfaceVersion()
The SMPP protocol version (one of
InterfaceVersion.VERSION_3_3 ,
InterfaceVersion.VERSION_3_4 ,
InterfaceVersion.VERSION_5_0 ). |
CloudhopperBuilder |
interfaceVersion(Byte version)
The SMPP protocol version (one of
SmppConstants.VERSION_3_3 ,
SmppConstants.VERSION_3_4 , SmppConstants.VERSION_5_0 ). |
CloudhopperBuilder |
interfaceVersion(InterfaceVersion version)
The SMPP protocol version (one of
InterfaceVersion.VERSION_3_3 ,
InterfaceVersion.VERSION_3_4 ,
InterfaceVersion.VERSION_5_0 ). |
LoggingBuilder |
logging()
Configure logs:
Enable/disable log of
Pdu s
Enable/disable log of bytes
|
CloudhopperBuilder |
messagePreparator(MessagePreparator preparator)
|
ConfigurationValueBuilder<CloudhopperBuilder,String> |
password()
The password parameter is used by the SMSC to authenticate the identity
of the binding ESME.
|
CloudhopperBuilder |
password(String password)
The password parameter is used by the SMSC to authenticate the identity
of the binding ESME.
|
ConfigurationValueBuilder<CloudhopperBuilder,Integer> |
port()
Set the SMPP server port.
|
CloudhopperBuilder |
port(Integer port)
Set the SMPP server port.
|
SessionBuilder |
session()
Configures Cloudhopper session management (timeouts, retry, session
name...).
|
CloudhopperBuilder |
session(ExtendedSmppSessionConfiguration session)
Overrides any previously defined Cloudhopper parameters to use the
provided session.
|
CloudhopperBuilder |
smppSessionHandlerSupplier(SmppSessionHandlerSupplier supplier)
By default,
CloudhopperSMPPSender uses
DefaultSmppSessionHandler . |
MessageSplitterBuilder |
splitter()
Configures how Cloudhopper will split messages.
|
SslBuilder |
ssl()
Enable or disable SSL configuration and configure how SSL is handled.
|
ConfigurationValueBuilder<CloudhopperBuilder,String> |
systemId()
The system_id parameter is used to identify an ESME ( External Short
Message Entity) or an SMSC (Short Message Service Centre) at bind time.
|
CloudhopperBuilder |
systemId(String systemId)
The system_id parameter is used to identify an ESME ( External Short
Message Entity) or an SMSC (Short Message Service Centre) at bind time.
|
ConfigurationValueBuilder<CloudhopperBuilder,String> |
systemType()
The system_type parameter is used to categorize the type of ESME that is
binding to the SMSC.
|
CloudhopperBuilder |
systemType(String systemType)
The system_type parameter is used to categorize the type of ESME that is
binding to the SMSC.
|
UserDataBuilder |
userData()
SMS message (named "User Data" in SMPP specification) can be transmitted
using:
Either
short_message field (standard field for "User
Data").
Or message_payload optional parameter.
|
and
public CloudhopperBuilder()
public CloudhopperBuilder(SmsBuilder parent, BuildContext buildContext)
MessagingBuilder msgBuilder = ... msgBuilder .sms() .sender(CloudhopperBuilder.class)
parent
- the parent builder instance for fluent chainingbuildContext
- for registering instances and property evaluationpublic CloudhopperBuilder systemId(String systemId)
The value set using this method takes precedence over any property and
default value configured using systemId()
.
.systemId("my-system-id") .systemId() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-id")
.systemId("my-system-id") .systemId() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-id")In both cases,
systemId("my-system-id")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
systemId
- the system_id valuepublic ConfigurationValueBuilder<CloudhopperBuilder,String> systemId()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.systemId() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-id")
Non-null value set using systemId(String)
takes precedence over
property values and default value.
.systemId("my-system-id") .systemId() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-id")The value
"my-system-id"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder systemType(String systemType)
The value set using this method takes precedence over any property and
default value configured using systemType()
.
.systemType("my-system-type") .systemType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-type")
.systemType("my-system-type") .systemType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-system-type")In both cases,
systemType("my-system-type")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
systemType
- the system type valuepublic ConfigurationValueBuilder<CloudhopperBuilder,String> systemType()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.systemType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("defaut-system-type")
Non-null value set using systemType(String)
takes precedence
over property values and default value.
.systemType("my-system-type") .systemType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("defaut-system-type")The value
"my-system-type"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder password(String password)
The value set using this method takes precedence over any property and
default value configured using password()
.
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")In both cases,
password("my-password")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
password
- the password used to authenticatepublic ConfigurationValueBuilder<CloudhopperBuilder,String> password()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")
Non-null value set using password(String)
takes precedence over
property values and default value.
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")The value
"my-password"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder host(String host)
The value set using this method takes precedence over any property and
default value configured using host()
.
.host("localhost") .host() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-host")
.host("localhost") .host() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-host")In both cases,
host("localhost")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
host
- the host addresspublic ConfigurationValueBuilder<CloudhopperBuilder,String> host()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.host() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-host")
Non-null value set using host(String)
takes precedence over
property values and default value.
.host("localhost") .host() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-host")The value
"localhost"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder port(Integer port)
The value set using this method takes precedence over any property and
default value configured using port()
.
.port(2775) .port() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(1775)
.port(2775) .port() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(1775)In both cases,
port(2775)
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
port
- the SMPP server portpublic ConfigurationValueBuilder<CloudhopperBuilder,Integer> port()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.port() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(1775)
Non-null value set using port(Integer)
takes precedence over
property values and default value.
.port(2775) .port() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(1775)The value
2775
is used regardless of the value of the properties
and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder interfaceVersion(InterfaceVersion version)
InterfaceVersion.VERSION_3_3
,
InterfaceVersion.VERSION_3_4
,
InterfaceVersion.VERSION_5_0
).
The value set using this method takes precedence over any property and
default value configured using interfaceVersion()
.
.interfaceVersion(InterfaceVersion.VERSION_5_0) .interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(InterfaceVersion.VERSION_3_4)
.interfaceVersion(InterfaceVersion.VERSION_5_0) .interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(InterfaceVersion.VERSION_3_4)In both cases,
interfaceVersion(InterfaceVersion.VERSION_5_0)
is
used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
version
- the version of the SMPP protocolpublic CloudhopperBuilder interfaceVersion(Byte version)
SmppConstants.VERSION_3_3
,
SmppConstants.VERSION_3_4
, SmppConstants.VERSION_5_0
).
The value set using this method takes precedence over any property and
default value configured using interfaceVersion()
.
.interfaceVersion(SmppConstants.VERSION_5_0) .interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppConstants.VERSION_3_4)
.interfaceVersion(SmppConstants.VERSION_5_0) .interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppConstants.VERSION_3_4)In both cases,
interfaceVersion(SmppConstants.VERSION_5_0)
is
used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
version
- the version of the SMPP protocolpublic ConfigurationValueBuilder<CloudhopperBuilder,InterfaceVersion> interfaceVersion()
InterfaceVersion.VERSION_3_3
,
InterfaceVersion.VERSION_3_4
,
InterfaceVersion.VERSION_5_0
).
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(InterfaceVersion.VERSION_3_4)
Non-null value set using interfaceVersion(InterfaceVersion)
takes precedence over property values and default value.
.interfaceVersion(InterfaceVersion.VERSION_5_0) .interfaceVersion() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(InterfaceVersion.VERSION_3_4)The value
InterfaceVersion.VERSION_5_0
is used regardless of the
value of the properties and default value.
See ConfigurationValueBuilder
for more information.
public CloudhopperBuilder bindType(com.cloudhopper.smpp.SmppBindType bindType)
SmppBindType
).
The value set using this method takes precedence over any property and
default value configured using bindType()
.
.bindType(SmppBindType.TRANSCEIVER) .bindType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppBindType.RECEIVER)
.bindType(SmppBindType.TRANSCEIVER) .bindType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppBindType.RECEIVER)In both cases,
bindType(SmppBindType.TRANSCEIVER)
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
bindType
- the bind typepublic ConfigurationValueBuilder<CloudhopperBuilder,com.cloudhopper.smpp.SmppBindType> bindType()
SmppBindType
).
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.bindType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppBindType.RECEIVER)
Non-null value set using bindType(SmppBindType)
takes precedence
over property values and default value.
.bindType(SmppBindType.TRANSCEIVER) .bindType() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(SmppBindType.RECEIVER)The value
SmppBindType.TRANSCEIVER
is used regardless of the
value of the properties and default value.
See ConfigurationValueBuilder
for more information.
public EncoderBuilder encoder()
The encoder will be used to transform Java String
into a byte
array that is understandable by SMPP servers.
This builder configures encoders for both messages that are split and message that are not split.
This builder allows to configure:
Charset
Encoder
s
.encoder()
.gsm7()
.properties("${ogham.sms.cloudhopper.encoder.gsm7bit-packed.priority}", "${ogham.sms.smpp.encoder.gsm7bit-packed.priority}")
.defaultValue(100000)
.and()
.gsm8()
.properties("${ogham.sms.cloudhopper.encoder.gsm8bit.priority}", "${ogham.sms.smpp.encoder.gsm8bit.priority}")
.defaultValue(99000)
.and()
.ucs2()
.properties("${ogham.sms.cloudhopper.encoder.ucs2.priority}", "${ogham.sms.smpp.encoder.ucs2.priority}")
.defaultValue(98000)
.and()
.autoGuess()
.properties("${ogham.sms.cloudhopper.encoder.auto-guess.enable}", "${ogham.sms.smpp.encoder.auto-guess.enable}")
.defaultValue(true)
.and()
.fallback()
.properties("${ogham.sms.cloudhopper.encoder.default-charset}", "${ogham.sms.smpp.encoder.default-charset}")
.defaultValue(CharsetUtil.NAME_GSM)
.and()
.customEncoder(new MyCustomEncoder(), 50000)
public MessageSplitterBuilder splitter()
The splitter will check if the whole message can fit in a single segment. If not the splitter will split the whole message in several segments with a header to indicate splitting information such as number of segments, reference number and current segment number.
Encoder
configured using encoder()
is used to encode
each segment.
If automatic guessing of best standard encoder is enabled for
Encoder
(using encoder().autoGuess(true)
), and message
splitting is enabled, then standard message splitting is configured such
as:
GsmMessageSplitter
is used
to split messages that support this encoding. If whole message can fit in
a single segment of 160 characters. Longer message is split into segments
of either 153 characters or 152 characters (depending on reference number
generation, see ReferenceNumberGenerator
)GsmMessageSplitter
is used
to split messages that support this encoding. If whole message can fit in
a single segment of 140 characters. Longer message is split into segments
of either 134 characters or 133 characters (depending on reference number
generation, see ReferenceNumberGenerator
)GsmMessageSplitter
is used to
split messages that support this encoding. If whole message can fit in a
single segment of 70 characters. Longer message is split into segments of
either 67 characters or 66 characters (depending on reference number
generation, see ReferenceNumberGenerator
)Encoder
.
If you don't want standard message splitting based on supported
Encoder
s, you can either disable message splitting or provide a
custom splitter with higher priority.
This builder allows to configure:
Examples of usage:
.splitter()
.enable()
.properties("${ogham.sms.cloudhopper.split.enable}", "${ogham.sms.smpp.split.enable}", "${ogham.sms.split.enable}")
.defaultValue(true)
.and()
.customSplitter(new MyCustomSplitter(), 100000)
.referenceNumber()
.random()
.random(new Random())
.generator(new MyCustomReferenceNumberGenerator())
public SessionBuilder session()
public CloudhopperBuilder session(ExtendedSmppSessionConfiguration session)
If this method is called several times, only the last session is used.
session
- the Cloudhopper session to usepublic CloudhopperBuilder addressRange(com.cloudhopper.smpp.type.Address range)
null
.
Note: For IP addresses, it is only possible to specify a single IP
address. A range of IP addresses are not allowed. IP version 6.0 is not
currently supported in this version of the protocol.
Note: It is likely that the addr_range field is not supported or
deliberately ignored on most Message Centres. The reason for this is that
most carriers will not allow an ESME control the message routing as this
can carry the risk of mis-routing messages. In such circumstances, the
ESME will be requested to set the field to NULL.range
- the address rangepublic SslBuilder ssl()
public LoggingBuilder logging()
Pdu
spublic CloudhopperBuilder clientSupplier(SmppClientSupplier supplier)
CloudhopperSMPPSender
uses DefaultSmppClient
client. This option provides a way to use another SmppClient
.supplier
- an implementation that provides an instance of a
SmppClient
public CloudhopperBuilder smppSessionHandlerSupplier(SmppSessionHandlerSupplier supplier)
CloudhopperSMPPSender
uses
DefaultSmppSessionHandler
. This option provides a way to use
another SmppSessionHandler
.supplier
- an implementation that provides an instance of a
SmppSessionHandler
public CloudhopperBuilder messagePreparator(MessagePreparator preparator)
Sms
message is converted to SubmitSm
(s) using a
MessagePreparator
.
You can provide a custom MessagePreparator
instance if the
default behavior doesn't fit your needs.
If a custom MessagePreparator
is set, any other preparator (using
userData()
) is not used.
If this method is called several times, only the last value is used.
If null
value is provided, then custom MessagePreparator
is disabled. Other configured preparators are used (using
userData()
).
preparator
- the custom preprator instanceuserData()
public UserDataBuilder userData()
short_message
field (standard field for "User
Data").message_payload
optional parameter.This builder allow to configure which strategy to use for sending message:
short_message
fieldmessage_payload
field
The result of userData()
configuration affects the message
preparation strategy.
Examples of usage:
.userData()
.useShortMessage()
.properties("${ogham.sms.cloudhopper.user-data.use-short-message}", "${ogham.sms.smpp.user-data.use-short-message}")
.defaultValue(true)
.and()
.useTlvMessagePayload()
.properties("${ogham.sms.cloudhopper.user-data.use-tlv-message-payload}", "${ogham.sms.smpp.user-data.use-tlv-message-payload}")
.defaultValue(false)
If any of ogham.sms.cloudhopper.user-data.use-short-message
property or ogham.sms.user-data.use-short-message
property is set
to true, it uses short_message
field.
If any of ogham.sms.cloudhopper.user-data.use-tlv-message-payload
property or ogham.sms.user-data.use-tlv-message-payload
property
is set to true, it uses message_payload
field.
If none of the above properties is set, it uses short_message
field is used (last value of shortMessage
is set to
"true"
).
If userData()
is not configured at all, then default behavior is
used (short_message
field is used).
public DataCodingSchemeBuilder dataCodingScheme()
data_coding
values (see
Short
Message Peer to Peer).
This builder allows to configure how Data Coding Scheme value is determined:
interfaceVersion(InterfaceVersion)
and
interfaceVersion(Byte)
) and charset encoding (see
encoder()
) used to encode the message ("User Data")Examples of usage:
.dataCodingScheme()
.auto("${ogham.sms.cloudhopper.data-coding-scheme.auto.enable}", "${ogham.sms.smpp.data-coding-scheme.auto.enable}")
.value("${ogham.sms.cloudhopper.data-coding-scheme.value}", "${ogham.sms.smpp.data-coding-scheme.value}")
.custom(new MyCustomDataCodingProvider())
See DataCodingSchemeBuilder.auto(Boolean)
,
DataCodingSchemeBuilder.value(Byte)
and
DataCodingSchemeBuilder.custom(DataCodingProvider)
for more
information.public CloudhopperSMPPSender build()
Builder
build
in interface Builder<CloudhopperSMPPSender>
Copyright © 2021. All rights reserved.