public interface WebContext
Allows a Rest or WebSocket Service to communicate with NetSwitch.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Name used withServletContext#getAttribute(String)
to retrieve an instance ofWebContext
. -
Method Summary
Modifier and TypeMethodDescription<T> T
executeSQL
(String poolName, SQLExecutor<T> executor) Allocates a connection from the specified pool and then executes the supplied SQL executor.Returns an unmodifiable map with all the properties of this WebContext.getProperty
(String name, String defval) Returns the value of the property indexed by specified name.void
Sends a mail message using the specified SMTP mail session.void
sendMulticast
(String name, Serializable data) Sends an multicast message built using the suppliedname
anddata
.sendRequest
(String destination, Serializable data, int timeout) Sends a request message to adestination
and then blocks waiting for the reply message for at mosttimeout
milliseconds.
-
Field Details
-
ATTRIBUTE_NAME
Name used withServletContext#getAttribute(String)
to retrieve an instance ofWebContext
.- See Also:
-
-
Method Details
-
getProperties
Returns an unmodifiable map with all the properties of this WebContext.- Returns:
- an unmodifiable map with all the properties of this WebContext.
-
getProperty
Returns the value of the property indexed by specified name. If the property is not defined, it returns the supplied default value.- Parameters:
name
- the name of the required property.defval
- value returned if property is not defined (can be null).- Returns:
- the value of the property or default value
defval
. - Throws:
NullPointerException
- ifname
isnull
.
-
sendMail
Sends a mail message using the specified SMTP mail session.- Parameters:
sessionName
- the name of the mail session.subject
- the subject of the mail message.text
- the text of the mail message.- Throws:
NullPointerException
- if an argument isnull
.Exception
- if another error occurs.
-
sendMulticast
Sends an multicast message built using the suppliedname
anddata
. The message will be dispatched to all client and/or server applications that have enabled the reception of multicast messages with the specifiedname
.- Parameters:
name
- the name of the multicast message.data
- data to include in the multicast message (can be null).- Throws:
NullPointerException
- ifname
isnull
.Exception
- if another error occurs.
-
sendRequest
Sends a request message to adestination
and then blocks waiting for the reply message for at mosttimeout
milliseconds. The value ofdestination
must have the following format:[SwitchName:]ServerName[.ServiceName]
where optional items are shown within"["
and"]"
brackets, and the characters":"
and"."
stand for themselves. If the optionalSwitchName
is not specified, the message is sent to the connected switch.ServerName
is the name of a server, a listener or a connector. The optionalServiceName
is the name of a service provided by the server, or the name of a channel of a listener. The following are examples of valid destinations:POS_DEVICE NETSWITCH.LOG_ERROR HUB:IMSER.ADD_CONTACT
Argumenttimeout
specifies the amount of time to wait for the synchronous reply message. Iftimeout
is zero (0), the call waits forever for the reply message.- Parameters:
destination
- the request destinationswitch:server.service
.data
- the data to include in the request message (can be null).timeout
- the maximum time to wait for a reply (in milliseconds).- Returns:
- the reply message returned from the switch server.
- Throws:
NullPointerException
- ifdestination
isnull
.IllegalArgumentException
- iftimeout
is negative.IllegalStateException
- if already waiting for a reply message.SocketTimeoutException
- iftimeout
expired while waiting for reply.Exception
- if another error occurs.
-
executeSQL
Allocates a connection from the specified pool and then executes the supplied SQL executor. If the SQL executor returns normally, the connection is committed. If the SQL executor throws an exception, the connection is rollback. In any event, the connection is returned to the pool.- Type Parameters:
T
- the type of the value returned by theexecutor
.- Parameters:
poolName
- the name of the connection pool.executor
- an SQL statement executor.- Returns:
- the value returned by the
executor
. - Throws:
NullPointerException
- if an argument isnull
.SQLException
- if an SQL error occurs.Exception
- if another error occurs.
-