|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ws4d.java.types.AttributableSupport org.ws4d.java.service.OperationCommons org.ws4d.java.service.DefaultEventSource
public class DefaultEventSource
Events are the source of server-side notifications to which interested
clients may subscribe. Services exposing events create instances of this
class and call its fire(ParameterValue, int)
method each time a
notification is sent to subscribers.
The DPWS framework supports two types of WSDL 1.1 and WS-Eventing compliant
events: notifications and solicit-response
operations. Whilst the first ones represent one-way messages sent from the
event source to its subscribers, the later additionally includes response
messages sent back from the subscribers to the source. Those responses are
delivered to the callback method
solicitResponseReceived(ParameterValue, int, ServiceSubscription)
.
Means to identify the particular subscriber responding as well as the
original event to which the response belongs are also provided, see
documentation for methods fire(ParameterValue, int)
and
solicitResponseReceived(ParameterValue, int, ServiceSubscription)
.
Clients willing to receive notifications from this event source can simply
subscribe
to it. A
subscription can be set up to expire after a certain amount of time (
duration) or it may last "forever", i.e. until either the
event source or the subscriber explicitly cancels it or it terminates due to
shutdown or to lack of network reachability.
name
is not required
to be unique within the scope of its containing port type in order to support
overloading. However, when overloading operations, the combination of each
one's name
, input name
and
output name
must be unique in order to avoid name
clashes.
Constructor Summary | |
---|---|
DefaultEventSource(java.lang.String name,
QName portType)
Creates a new event source instance with the given local name and portType . |
|
DefaultEventSource(WSDLOperation operation)
|
Method Summary | |
---|---|
void |
fire(ParameterValue paramValue,
int eventNumber)
Fires this event source. |
int |
getType()
Returns the transmission type of this event source according
to WSDL 1.1 specification. |
boolean |
isNotification()
Returns true , if the transmission type of this event source
is WSDLOperation.TYPE_NOTIFICATION . |
boolean |
isSolicitResponse()
Returns true , if the transmission type of this event source
is WSDLOperation.TYPE_SOLICIT_RESPONSE . |
void |
solicitResponseReceived(ParameterValue paramValue,
int eventNumber,
ServiceSubscription subscription)
Callback method for receiving responses to sent events if they are from type solicit-response . |
ClientSubscription |
subscribe(EventListener client,
long duration)
Allows a client to subscribe to this event source. |
ClientSubscription |
subscribe(EventListener client,
long duration,
DataStructure bindings)
Allows a listener to subscribe to this event source. |
Methods inherited from class org.ws4d.java.types.AttributableSupport |
---|
getAttribute, getAttributes, hasAttributes, serializeAttributes, setAttribute, setAttribute, setAttributes |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.ws4d.java.service.OperationDescription |
---|
createFaultValue, createInputValue, createOutputValue, getFault, getFaultCount, getFaults, getInput, getInputAction, getInputName, getName, getOutput, getOutputAction, getOutputName, getPortType, getService |
Constructor Detail |
---|
public DefaultEventSource(java.lang.String name, QName portType)
name
and portType
.
name
- the name of the event source; see here
for a short description of uniqueness requirements
regarding event source namesportType
- the qualified port type of the event sourcepublic DefaultEventSource(WSDLOperation operation)
operation
- Method Detail |
---|
public void fire(ParameterValue paramValue, int eventNumber)
paramValue
.
In case this event source represents a solicit-response
operation (in the sense of WSDL 1.1 Specification), the value
of argument eventNumber
can be used by callers to correlate
incoming responses with this particular event source. It will be passed
as the second argument to
solicitResponseReceived(ParameterValue, int, ServiceSubscription)
. It is recommended to increment the supplied value whenever calling this
method, but this is not checked for, so other means of providing reliable
correlation based on this value can also be used.
paramValue
- the parameters to be sent to all subscribers with this
event notificationeventNumber
- a number identifying this event notification and
allowing correlation to possible
responses
from subscriberspublic final int getType()
transmission type
of this event source according
to WSDL 1.1 specification. The
value returned is one of WSDLOperation.TYPE_NOTIFICATION
or
WSDLOperation.TYPE_SOLICIT_RESPONSE
.
getType
in interface OperationDescription
getType
in class OperationCommons
public final boolean isNotification()
true
, if the transmission type of this event source
is WSDLOperation.TYPE_NOTIFICATION
. Returns false
in
any other case.
isNotification
in interface EventSource
notification
event sourcepublic final boolean isSolicitResponse()
true
, if the transmission type of this event source
is WSDLOperation.TYPE_SOLICIT_RESPONSE
. Returns
false
in any other case.
isSolicitResponse
in interface EventSource
solicit-response
event sourcepublic ClientSubscription subscribe(EventListener client, long duration) throws EventingException, TimeoutException
EventSource
duration
milliseconds or it will not expire at all
when the value of duration
is 0
.
This method will generate auto-bindings when subscribing to an event
source which belongs to a remotely deployed DPWS service.
This/These binding(s) will be used to open a local event
sink
and listen for incoming notifications.
This method returns a ClientSubscription
instance, which can be
used to explore and manage the state of the subscription (e.g. renew or
unsubscribe, etc.).
subscribe
in interface EventSource
client
- the client to which notification messages from this event
source are to be sentduration
- time until subscription expires in milliseconds;
0
means subscription never expires
EventingException
- if an error occurs during subscription
TimeoutException
- if this event source belongs to a remote service
and sending the subscription to it timed outpublic ClientSubscription subscribe(EventListener client, long duration, DataStructure bindings) throws EventingException, TimeoutException
EventSource
duration
milliseconds or it will not expire at
all, in case the value of duration
is 0
.
When subscribing to an event source, which belongs to a remotely
deployed DPWS service, it is important to include at least one
CommunicationBinding
within the argument bindings
.
This/These binding(s) will be used to open a local event
sink
and listen for incoming notifications.
This method returns a ClientSubscription
instance, which can be
used to explore and manage the state of the subscription (e.g. renew or
unsubscribe, etc.).
subscribe
in interface EventSource
client
- the listener to which notification messages from
this event source are to be sentduration
- time until subscription expires in milliseconds;
0
means subscription never expiresbindings
- a data structure consisting of one or more
CommunicationBinding
instances; those are used to bind
a local event sink
to and allow it to listen
for event notifications from a remote service
EventingException
- if an error occurs during subscription
TimeoutException
- if this event source belongs to a remote service
and sending the subscription to it timed outpublic void solicitResponseReceived(ParameterValue paramValue, int eventNumber, ServiceSubscription subscription)
type
solicit-response
. A
call to this method is made by the DPWS framework each time a subscribed
client responds to a fired event source (see
fire(ParameterValue, int)
. The parameters sent by the client
within its response are contained within argument paramValue
. The value of eventNumber
corresponds to the value passed
to fire(ParameterValue, int)
when creating the notification to
which this response belongs. Finally, argument subscription
contains information allowing identification of the subscriber sending
the response, as well as further details about its subscription (such as
expiration time, filter, etc.).
paramValue
- parameter value from the response receivedeventNumber
- number allowing for correlation between sent
notifications (solicit requests) and their corresponding
responsessubscription
- provides information about the subscriber who sent
the response
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |