public class Fault extends AttributableSupport
Operations or DefaultEventSources just like exceptions may be
declared on Java methods. A fault has a name, which must not be null
and unique within the scope of the surrounding operation/event, and an action URI corresponding to the wsa:Action property of the fault message
within which the fault is sent . The action URI must also not be null and must be
unique within the operation. However, when creating a user-defined Fault, it is
possible to omit specifying the action URI explicitly as the JMEDS framework will provide an
auto-generated one in case it was not set prior to adding the fault to an operation/event.
A Fault can also carry user-defined data, just like exceptions can be designed to
encapsulate additional state within their instance variables. Within the Fault, this
state is described by means of its associated element.
It is important to notice that modifications to a fault are not possible after it has been
added to an operation. Calling any of the setter methods at this time will result in
IllegalStateExceptions being thrown.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ELEM_FAULT
"Fault".
|
attributes| Constructor and Description |
|---|
Fault(java.lang.String name)
Creates a fault with the given
name, which must be unique within the scope of the
surrounding operation. |
Fault(java.lang.String name,
java.lang.String action)
Creates a fault with the given
name (must be unique within the scope of the
surrounding operation). |
| Modifier and Type | Method and Description |
|---|---|
ParameterValue |
createValue()
A shorthand method for creating a suitable data container for this fault's element.
|
ParameterValue |
createValue(Type instanceType)
A shorthand method for creating a suitable data container for this fault's element.
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getAction()
Returns the wsa:Action associated to this fault.
|
Element |
getElement()
Returns the element of this fault, which defines the type and structure of any user-defined
data the fault may contain.
|
java.lang.String |
getName()
Returns the name of this
Fault. |
int |
hashCode() |
void |
setAction(java.lang.String action)
Sets the wsa:Action of this fault.
|
void |
setElement(Element element)
Sets the element of this
Fault. |
java.lang.String |
toString() |
getAttribute, getAttributes, hasAttributes, serializeAttributes, setAttribute, setAttribute, setAttributespublic static final java.lang.String ELEM_FAULT
public Fault(java.lang.String name)
name, which must be unique within the scope of the
surrounding operation. The fault will be assigned an auto-generated action
when it is added to an operation or event.name - the name of this fault; unique within the scope of the surrounding operationpublic Fault(java.lang.String name,
java.lang.String action)
name (must be unique within the scope of the
surrounding operation). The action argument should be a URI representing the
wsa:Action associated to this fault.name - the name of the fault; unique within the scope of the surrounding operationaction - the wsa:Action URI of this faultpublic java.lang.String toString()
toString in class AttributableSupportpublic java.lang.String getAction()
As Faults are always required to have an action URI associated to them, one
will be automatically generated when adding this Fault to an operation or event, if it was not specified explicitly.
public void setAction(java.lang.String action)
Fault is added to an operation or
event.action - the action to setWS4DIllegalStateException - if the fault is currently attached to an operation or an eventpublic Element getElement()
create a suitable ParameterValue container for the actual values when sending messages containing this fault.setElement(Element)public void setElement(Element element)
Fault. The element describes the type and contents of a
user-defined data structure providing additional information about the fault. Calling this
method after having already added this Fault to an operation or
event will result in an IllegalStateException being
thrown.element - the element to setWS4DIllegalStateException - if the fault is currently attached to an operation or an eventpublic java.lang.String getName()
Fault. This name must be unique within the scope of its
surrounding operation or event.public ParameterValue createValue()
ParameterValue.createElementValue(getElement()).getElement()public ParameterValue createValue(Type instanceType)
ParameterValue.createElementValue(getElement(), instanceType) .
It is intended to be used with instanceType being a subtype of the type defined for the fault value.
instanceType - type of the ParameterValue returned by this methodgetElement()public boolean equals(java.lang.Object obj)
equals in class AttributableSupportpublic int hashCode()
hashCode in class AttributableSupport