[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.51,0:00:04.29,Default,,0000,0000,0000,,So I'm running my app now on localhost. And Dialogue: 0,0:00:04.29,0:00:07.06,Default,,0000,0000,0000,,you'll see, if you look in the APIs Explorer, Dialogue: 0,0:00:07.06,0:00:08.63,Default,,0000,0000,0000,,and drill down in to the functions in the Dialogue: 0,0:00:08.63,0:00:13.44,Default,,0000,0000,0000,,conference API, that the set announcement method is not here. Dialogue: 0,0:00:13.44,0:00:15.81,Default,,0000,0000,0000,,That's because we didn't expose it as an endpoints Dialogue: 0,0:00:15.81,0:00:18.54,Default,,0000,0000,0000,,function. Instead, we defined it as a servlet on Dialogue: 0,0:00:18.54,0:00:21.92,Default,,0000,0000,0000,,purpose, to keep it internal to the application. So Dialogue: 0,0:00:21.92,0:00:25.57,Default,,0000,0000,0000,,the APIs Explorer let's you explore endpoint functions, but it Dialogue: 0,0:00:25.57,0:00:28.84,Default,,0000,0000,0000,,doesn't let you explore your servlets. Since we're going to Dialogue: 0,0:00:28.84,0:00:31.73,Default,,0000,0000,0000,,put things into memcache, I've deployed my app to app Dialogue: 0,0:00:31.73,0:00:34.97,Default,,0000,0000,0000,,spot so I can use the memcache viewer. First, I'll Dialogue: 0,0:00:34.97,0:00:37.41,Default,,0000,0000,0000,,make sure I have some conferences that are nearly sold out. Dialogue: 0,0:00:38.73,0:00:41.30,Default,,0000,0000,0000,,Okay, this one's pretty close to being sold out. Only Dialogue: 0,0:00:41.30,0:00:45.72,Default,,0000,0000,0000,,three seats left. This one's only got one seat left. Okay, Dialogue: 0,0:00:45.72,0:00:47.79,Default,,0000,0000,0000,,so I've got a couple of conferences that only have Dialogue: 0,0:00:47.79,0:00:51.03,Default,,0000,0000,0000,,a couple of seats left. To test the new set announcement Dialogue: 0,0:00:51.03,0:00:53.46,Default,,0000,0000,0000,,function, you can use the browser to go to the Dialogue: 0,0:00:53.46,0:00:57.16,Default,,0000,0000,0000,,URL mapped to the servlet. However, you do have to be Dialogue: 0,0:00:57.16,0:01:00.25,Default,,0000,0000,0000,,logged in as a developer on the application or you'll Dialogue: 0,0:01:00.25,0:01:03.33,Default,,0000,0000,0000,,get an error that you're not in the required role. And Dialogue: 0,0:01:03.33,0:01:06.10,Default,,0000,0000,0000,,that's because we don't want just any old person coming Dialogue: 0,0:01:06.10,0:01:08.98,Default,,0000,0000,0000,,along, setting the announcements by going to the URL in the Dialogue: 0,0:01:08.98,0:01:13.30,Default,,0000,0000,0000,,browser. So to trigger the set announcement function, we go Dialogue: 0,0:01:13.30,0:01:16.66,Default,,0000,0000,0000,,to the URL that we mapped it to in the servlet, Dialogue: 0,0:01:16.66,0:01:20.81,Default,,0000,0000,0000,,in this case which is crons/set_announcment. So we Dialogue: 0,0:01:20.81,0:01:25.52,Default,,0000,0000,0000,,go to the URL. Crons_\set announcement. Nothing seems to Dialogue: 0,0:01:25.52,0:01:29.60,Default,,0000,0000,0000,,happen. But actually that's expected. Remember that the servlet Dialogue: 0,0:01:29.60,0:01:31.85,Default,,0000,0000,0000,,doesn't set a response so nothing happens in the Dialogue: 0,0:01:31.85,0:01:36.41,Default,,0000,0000,0000,,page, and if you've got to the place where it asks you to log in and you Dialogue: 0,0:01:36.41,0:01:38.45,Default,,0000,0000,0000,,go ahead and log in you're going to remain on Dialogue: 0,0:01:38.45,0:01:42.28,Default,,0000,0000,0000,,the log in page even when the URL executes. Dialogue: 0,0:01:42.28,0:01:44.49,Default,,0000,0000,0000,,However, we can use a memcache viewer to check Dialogue: 0,0:01:44.49,0:01:47.99,Default,,0000,0000,0000,,that the announcement got set. So here in the memcache Dialogue: 0,0:01:47.99,0:01:50.90,Default,,0000,0000,0000,,viewer we do see that we have one item. We Dialogue: 0,0:01:50.90,0:01:53.78,Default,,0000,0000,0000,,can use the content lookup section to look to see Dialogue: 0,0:01:53.78,0:01:56.19,Default,,0000,0000,0000,,if it is our announcement. The key we use Dialogue: 0,0:01:56.19,0:02:00.74,Default,,0000,0000,0000,,with recent announcements is a Java String, so let's display Dialogue: 0,0:02:00.74,0:02:03.75,Default,,0000,0000,0000,,it, see if we have an announcement. And yes, we Dialogue: 0,0:02:03.75,0:02:07.34,Default,,0000,0000,0000,,do. So the announcement about the conferences that have been Dialogue: 0,0:02:07.34,0:02:11.04,Default,,0000,0000,0000,,nearly sold out has been created and saved in memcache. Dialogue: 0,0:02:11.04,0:02:13.19,Default,,0000,0000,0000,,So now, we can save values in memcache and we Dialogue: 0,0:02:13.19,0:02:16.96,Default,,0000,0000,0000,,can use a memcache viewer to get those values back. Dialogue: 0,0:02:16.96,0:02:19.94,Default,,0000,0000,0000,,We're going to want to show this announcement to other people, not Dialogue: 0,0:02:19.94,0:02:22.75,Default,,0000,0000,0000,,to the developers of the application. Let's go ahead and Dialogue: 0,0:02:22.75,0:02:26.39,Default,,0000,0000,0000,,create an endpoint function to get the announcement out of Memcache Dialogue: 0,0:02:26.39,0:02:28.97,Default,,0000,0000,0000,,so we can show it to other people. So another Dialogue: 0,0:02:28.97,0:02:32.54,Default,,0000,0000,0000,,thing I want to mention is that in the constants class, Dialogue: 0,0:02:32.54,0:02:37.61,Default,,0000,0000,0000,,constants.java, we define the key for the Dialogue: 0,0:02:37.61,0:02:39.94,Default,,0000,0000,0000,,announcements, and this is where we get the Dialogue: 0,0:02:39.94,0:02:43.38,Default,,0000,0000,0000,,recent announcements key from. So in the conference Dialogue: 0,0:02:43.38,0:02:46.15,Default,,0000,0000,0000,,API class you can define the get announcement Dialogue: 0,0:02:46.15,0:02:50.53,Default,,0000,0000,0000,,function. This is going to be an end points function so this is a fairly simple Dialogue: 0,0:02:50.53,0:02:55.54,Default,,0000,0000,0000,,function. Basically get some memcache service, and then Dialogue: 0,0:02:55.54,0:02:58.18,Default,,0000,0000,0000,,calls the get method on the memcache service, Dialogue: 0,0:02:58.18,0:03:02.92,Default,,0000,0000,0000,,passing in the announcement key. We check if the value is null. So long as it's Dialogue: 0,0:03:02.92,0:03:05.44,Default,,0000,0000,0000,,not null, we create a new announcement object, Dialogue: 0,0:03:05.44,0:03:09.13,Default,,0000,0000,0000,,and we set the message property to the announcement Dialogue: 0,0:03:09.13,0:03:11.59,Default,,0000,0000,0000,,that we got out of memcache. And again, Dialogue: 0,0:03:11.59,0:03:13.70,Default,,0000,0000,0000,,we have to return an announcement, rather than Dialogue: 0,0:03:13.70,0:03:15.95,Default,,0000,0000,0000,,just a string, because this is an endpoint Dialogue: 0,0:03:15.95,0:03:19.74,Default,,0000,0000,0000,,function. And end point functions can't return just strings.