Advertisement
Guest User

Untitled

a guest
Sep 28th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. interface Session {
  2.    public void submit(Command cmd);
  3. }
  4.  
  5. interface Queryable {
  6.    public void executeQuery(String query);
  7. }
  8.  
  9. interface Command {
  10.    public void execute(Queryable queryable);
  11. }
  12.  
  13. class SessionImpl implements Session, Queryable {
  14.    public void executeQuery(String query) { // execute query in the current session }
  15.  
  16.    public void submit(Command cmd) {
  17.       cmd.execute(this);
  18.    }
  19. }
  20.  
  21. class CommandImpl implements Command {
  22.   public void execute(Queryable queryable) {
  23.      queryable.executeQuery("Hello world!");
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement