Created
May 27, 2013 13:59
-
-
Save sergiosvieira/5657210 to your computer and use it in GitHub Desktop.
design patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface XMPPActions | |
{ | |
public abstract void sendMessageWithBody(String text, String jid); | |
} | |
public class XMPPNormalActions implements XMPPActions | |
{ | |
- void sendMessageWithBody(String text, String jid) | |
{ | |
/** código relacionado ao envio de mensagem usando chat normal **/ | |
System.out.println("Chat Normal"); | |
} | |
} | |
public class XMPPMUCActions implements XMPPActions | |
{ | |
void sendMessageWithBody(String text, String jid) | |
{ | |
/** código relacionado ao envio de mensagem usando MUC **/ | |
System.out.println("MUC Chat"); | |
} | |
} | |
public class XMPPCore | |
{ | |
void sendMessageWithBody(String text, String jid, XMPPActions action) | |
{ | |
action.sendMessageWithBody(text, jid); | |
} | |
} | |
class ChatNormal { | |
public static void main(String[] args) { | |
XMPPCore core = new XMPPCore(); | |
XMPPNormalActions action = new XMPPNormalActions(); | |
core.sendMessageWithBody("aí dentro", "[email protected]", action); | |
} | |
} | |
class MUCChat { | |
public static void main(String[] args) { | |
XMPPCore core = new XMPPCore(); | |
XMPPMUCActions action = new XMPPMUCActions(); | |
core.sendMessageWithBody("aí dentro", "[email protected]", action); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment