forked from pheaber/OJUG-February-2012-Restlet
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
78 additions
and
33 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,49 @@ | ||
package stutter.client; | ||
|
||
import java.util.List; | ||
|
||
import org.restlet.resource.ClientResource; | ||
|
||
import stutter.Mumble; | ||
import stutter.User; | ||
import stutter.common.MumbleListManager; | ||
import stutter.common.UserListManager; | ||
import stutter.common.UserManager; | ||
|
||
public class StutterClient { | ||
|
||
public static void main(String[] args) { | ||
UserManager userManagerClient = ClientResource.create("http://localhost:8182/users/farmBoy", UserManager.class); | ||
|
||
// how cool is this, we get an instance of our interface and Restlet does the HTTP magic?!? | ||
User got = userManagerClient.getUser(); | ||
System.out.println("Got a user: " + got); | ||
private static final String BASE = "http://localhost:8182"; | ||
|
||
MumbleListManager mumbleManagerClient = ClientResource.create("http://localhost:8182/mumbles", | ||
MumbleListManager.class); | ||
public static void main(String[] args) { | ||
// how cool is this? we get an instance of our interface and Restlet does the HTTP magic!! | ||
UserListManager userListManagerClient = ClientResource.create(BASE + "/users", UserListManager.class); | ||
User westley = new User("farmBoy", "westley@asyouwish.fl"); | ||
userListManagerClient.addUser(westley); | ||
|
||
// TODO: why are these strings and not Users? | ||
// Collection<User> users = userListManagerClient.listAll(); | ||
// for (User user : users) { | ||
// System.out.println("Got a user: " + user); | ||
// } | ||
|
||
UserManager userManagerClient = ClientResource.create(BASE + "/users/farmBoy", UserManager.class); | ||
User beforeUpdate = userManagerClient.getUser(); | ||
System.out.println("Got a user: " + beforeUpdate); | ||
|
||
westley.setName("Westley"); | ||
userManagerClient.updateUser(westley); | ||
User afterUpdate = userManagerClient.getUser(); | ||
System.out.println("Got an updated user: " + afterUpdate); | ||
|
||
MumbleListManager mumbleManagerClient = ClientResource.create(BASE + "/mumbles", MumbleListManager.class); | ||
Mumble newMessage = new Mumble(afterUpdate.getUsername(), "As you wish."); | ||
mumbleManagerClient.newMumble(newMessage); | ||
|
||
// TODO: why are these strings and not Mumbles? | ||
List<Mumble> mumbles = mumbleManagerClient.listAll(); | ||
System.out.println("Got some mumbles: " + mumbles); | ||
// List<Mumble> mumbles = mumbleManagerClient.listAll(); | ||
// for (Mumble mumble : mumbles) { | ||
// System.out.println("Got a mumble: " + mumble); | ||
// } | ||
|
||
mumbleManagerClient.newMumble(got.getUsername(), "As you wish again."); | ||
userManagerClient.removeUser(); | ||
} | ||
|
||
} |
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
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
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
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
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
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
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