Package org.jivesoftware.smack
Class SynchronizationPoint<E extends java.lang.Exception>
- java.lang.Object
-
- org.jivesoftware.smack.SynchronizationPoint<E>
-
public class SynchronizationPoint<E extends java.lang.Exception> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SynchronizationPoint(AbstractXMPPConnection connection, java.lang.String waitFor)Construct a new synchronization point for the given connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.ExceptioncheckIfSuccessOrWait()Check if this synchronization point is successful or wait the connections reply timeout.voidcheckIfSuccessOrWaitOrThrow()Check if this synchronization point is successful or wait the connections reply timeout.EgetFailureException()voidinit()Initialize (or reset) this synchronization point.booleanisNotInInitialState()voidreportFailure()Deprecated.usereportFailure(Exception)instead.voidreportFailure(E failureException)Report this synchronization point as failed because of the given exception.voidreportGenericFailure(SmackException.SmackWrappedException exception)Report this synchronization point as failed because of the given exception.voidreportSuccess()Report this synchronization point as successful.booleanrequestSent()Check if this synchronization point has its request already sent.voidresetTimeout()java.lang.ExceptionsendAndWaitForResponse(TopLevelStreamElement request)Send the given top level stream element and wait for a response.voidsendAndWaitForResponseOrThrow(Nonza request)Send the given plain stream element and wait for a response.booleanwasSuccessful()Check if this synchronization point was successful.
-
-
-
Constructor Detail
-
SynchronizationPoint
public SynchronizationPoint(AbstractXMPPConnection connection, java.lang.String waitFor)
Construct a new synchronization point for the given connection.- Parameters:
connection- the connection of this synchronization point.waitFor- a description of the event this synchronization point handles.
-
-
Method Detail
-
init
public void init()
Initialize (or reset) this synchronization point.
-
sendAndWaitForResponse
public java.lang.Exception sendAndWaitForResponse(TopLevelStreamElement request) throws SmackException.NoResponseException, SmackException.NotConnectedException, java.lang.InterruptedException
Send the given top level stream element and wait for a response.- Parameters:
request- the plain stream element to send.- Returns:
nullif synchronization point was successful, or the failure Exception.- Throws:
SmackException.NoResponseException- if no response was received.SmackException.NotConnectedException- if the connection is not connected.java.lang.InterruptedException- if the connection is interrupted.
-
sendAndWaitForResponseOrThrow
public void sendAndWaitForResponseOrThrow(Nonza request) throws E extends java.lang.Exception, SmackException.NoResponseException, SmackException.NotConnectedException, java.lang.InterruptedException, SmackException.SmackWrappedException
Send the given plain stream element and wait for a response.- Parameters:
request- the plain stream element to send.- Throws:
E- if an failure was reported.SmackException.NoResponseException- if no response was received.SmackException.NotConnectedException- if the connection is not connected.java.lang.InterruptedException- if the connection is interrupted.SmackException.SmackWrappedException- in case of a wrapped exception;E extends java.lang.Exception
-
checkIfSuccessOrWaitOrThrow
public void checkIfSuccessOrWaitOrThrow() throws SmackException.NoResponseException, E extends java.lang.Exception, java.lang.InterruptedException, SmackException.SmackWrappedExceptionCheck if this synchronization point is successful or wait the connections reply timeout.- Throws:
SmackException.NoResponseException- if there was no response marking the synchronization point as success or failed.E- if there was a failurejava.lang.InterruptedException- if the connection is interrupted.SmackException.SmackWrappedException- in case of a wrapped exception;E extends java.lang.Exception
-
checkIfSuccessOrWait
public java.lang.Exception checkIfSuccessOrWait() throws SmackException.NoResponseException, java.lang.InterruptedExceptionCheck if this synchronization point is successful or wait the connections reply timeout.- Returns:
nullif synchronization point was successful, or the failure Exception.- Throws:
SmackException.NoResponseException- if there was no response marking the synchronization point as success or failed.java.lang.InterruptedException- if the calling thread was interrupted.
-
reportSuccess
public void reportSuccess()
Report this synchronization point as successful.
-
reportFailure
@Deprecated public void reportFailure()
Deprecated.usereportFailure(Exception)instead.Deprecated.
-
reportFailure
public void reportFailure(E failureException)
Report this synchronization point as failed because of the given exception. ThefailureExceptionmust be set.- Parameters:
failureException- the exception causing this synchronization point to fail.
-
reportGenericFailure
public void reportGenericFailure(SmackException.SmackWrappedException exception)
Report this synchronization point as failed because of the given exception. ThefailureExceptionmust be set.- Parameters:
exception- the exception causing this synchronization point to fail.
-
wasSuccessful
public boolean wasSuccessful()
Check if this synchronization point was successful.- Returns:
- true if the synchronization point was successful, false otherwise.
-
isNotInInitialState
public boolean isNotInInitialState()
-
requestSent
public boolean requestSent()
Check if this synchronization point has its request already sent.- Returns:
- true if the request was already sent, false otherwise.
-
getFailureException
public E getFailureException()
-
resetTimeout
public void resetTimeout()
-
-