Class JingleSessionState
- java.lang.Object
-
- org.jivesoftware.smackx.jingleold.JingleSessionState
-
- Direct Known Subclasses:
JingleSessionStateActive
,JingleSessionStateEnded
,JingleSessionStatePending
,JingleSessionStateUnknown
public abstract class JingleSessionState extends Object
Implement the Jingle Session state using the State Behavioral pattern. (From the book Design Patterns, AKA GoF.) These classes also employ the Flyweight and Singleton patterns as recommended for the State pattern by GoF. There seems to be three ways to go with the State pattern in Java: interface, abstract class and enums. Most of the accepted models use abstract classes. It wasn't clear to me that any of the three models was superior, so I went with the most common example.
-
-
Constructor Summary
Constructors Constructor Description JingleSessionState()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
enter()
Called when entering the state.abstract void
exit()
Called when exiting the state.static JingleSessionState
getInstance()
Called when entering the state.abstract IQ
processJingle(JingleSession session, Jingle jingle, JingleActionEnum action)
Process an incoming Jingle Packet.String
toString()
For debugging just emit the short name of the class.
-
-
-
Constructor Detail
-
JingleSessionState
public JingleSessionState()
-
-
Method Detail
-
getInstance
public static JingleSessionState getInstance()
Called when entering the state.- Returns:
- the jingle session state.
-
enter
public abstract void enter()
Called when entering the state.
-
exit
public abstract void exit()
Called when exiting the state.
-
processJingle
public abstract IQ processJingle(JingleSession session, Jingle jingle, JingleActionEnum action) throws SmackException, InterruptedException
Process an incoming Jingle Packet. When you look at the GoF State pattern this method roughly corresponds to example on p310: ProcessOctect()- Parameters:
session
- the jingle session.jingle
- the jingle stanza.action
- the jingle action.- Returns:
- the resulting IQ.
- Throws:
SmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
-