0:00:00.510,0:00:04.290 So I'm running my app now on localhost. And 0:00:04.290,0:00:07.060 you'll see, if you look in the APIs Explorer, 0:00:07.060,0:00:08.632 and drill down in to the functions in the 0:00:08.632,0:00:13.440 conference API, that the set announcement method is not here. 0:00:13.440,0:00:15.810 That's because we didn't expose it as an endpoints 0:00:15.810,0:00:18.540 function. Instead, we defined it as a servlet on 0:00:18.540,0:00:21.920 purpose, to keep it internal to the application. So 0:00:21.920,0:00:25.570 the APIs Explorer let's you explore endpoint functions, but it 0:00:25.570,0:00:28.840 doesn't let you explore your servlets. Since we're going to 0:00:28.840,0:00:31.730 put things into memcache, I've deployed my app to app 0:00:31.730,0:00:34.970 spot so I can use the memcache viewer. First, I'll 0:00:34.970,0:00:37.410 make sure I have some conferences that are nearly sold out. 0:00:38.730,0:00:41.300 Okay, this one's pretty close to being sold out. Only 0:00:41.300,0:00:45.720 three seats left. This one's only got one seat left. Okay, 0:00:45.720,0:00:47.790 so I've got a couple of conferences that only have 0:00:47.790,0:00:51.030 a couple of seats left. To test the new set announcement 0:00:51.030,0:00:53.460 function, you can use the browser to go to the 0:00:53.460,0:00:57.160 URL mapped to the servlet. However, you do have to be 0:00:57.160,0:01:00.250 logged in as a developer on the application or you'll 0:01:00.250,0:01:03.333 get an error that you're not in the required role. And 0:01:03.333,0:01:06.098 that's because we don't want just any old person coming 0:01:06.098,0:01:08.978 along, setting the announcements by going to the URL in the 0:01:08.978,0:01:13.303 browser. So to trigger the set announcement function, we go 0:01:13.303,0:01:16.656 to the URL that we mapped it to in the servlet, 0:01:16.656,0:01:20.814 in this case which is crons/set_announcment. So we 0:01:20.814,0:01:25.520 go to the URL. Crons_\set announcement. Nothing seems to 0:01:25.520,0:01:29.600 happen. But actually that's expected. Remember that the servlet 0:01:29.600,0:01:31.850 doesn't set a response so nothing happens in the 0:01:31.850,0:01:36.410 page, and if you've got to the place where it asks you to log in and you 0:01:36.410,0:01:38.450 go ahead and log in you're going to remain on 0:01:38.450,0:01:42.280 the log in page even when the URL executes. 0:01:42.280,0:01:44.490 However, we can use a memcache viewer to check 0:01:44.490,0:01:47.990 that the announcement got set. So here in the memcache 0:01:47.990,0:01:50.900 viewer we do see that we have one item. We 0:01:50.900,0:01:53.780 can use the content lookup section to look to see 0:01:53.780,0:01:56.190 if it is our announcement. The key we use 0:01:56.190,0:02:00.740 with recent announcements is a Java String, so let's display 0:02:00.740,0:02:03.750 it, see if we have an announcement. And yes, we 0:02:03.750,0:02:07.340 do. So the announcement about the conferences that have been 0:02:07.340,0:02:11.038 nearly sold out has been created and saved in memcache. 0:02:11.038,0:02:13.190 So now, we can save values in memcache and we 0:02:13.190,0:02:16.960 can use a memcache viewer to get those values back. 0:02:16.960,0:02:19.940 We're going to want to show this announcement to other people, not 0:02:19.940,0:02:22.750 to the developers of the application. Let's go ahead and 0:02:22.750,0:02:26.390 create an endpoint function to get the announcement out of Memcache 0:02:26.390,0:02:28.970 so we can show it to other people. So another 0:02:28.970,0:02:32.544 thing I want to mention is that in the constants class, 0:02:32.544,0:02:37.610 constants.java, we define the key for the 0:02:37.610,0:02:39.940 announcements, and this is where we get the 0:02:39.940,0:02:43.380 recent announcements key from. So in the conference 0:02:43.380,0:02:46.150 API class you can define the get announcement 0:02:46.150,0:02:50.530 function. This is going to be an end points function so this is a fairly simple 0:02:50.530,0:02:55.540 function. Basically get some memcache service, and then 0:02:55.540,0:02:58.180 calls the get method on the memcache service, 0:02:58.180,0:03:02.920 passing in the announcement key. We check if the value is null. So long as it's 0:03:02.920,0:03:05.440 not null, we create a new announcement object, 0:03:05.440,0:03:09.130 and we set the message property to the announcement 0:03:09.130,0:03:11.590 that we got out of memcache. And again, 0:03:11.590,0:03:13.700 we have to return an announcement, rather than 0:03:13.700,0:03:15.950 just a string, because this is an endpoint 0:03:15.950,0:03:19.740 function. And end point functions can't return just strings.