Return to Video

Explore Project Layout and Configuration - Developing Scalable Apps with Java

  • 0:01 - 0:05
    Now the Hello World project here that you've got, it's
  • 0:05 - 0:09
    a very simple, application that uses end points. What I want
  • 0:09 - 0:12
    to do now is just talk you quickly through the code
  • 0:12 - 0:15
    so that you understand how to define endpoints, so you see
  • 0:15 - 0:17
    how to call them from a web page. So let's
  • 0:17 - 0:19
    take a look at the files in the Hello World end
  • 0:19 - 0:22
    points application. So here, you see here in src > main
  • 0:22 - 0:26
    > java. In the com > google > training > helloworld
  • 0:26 - 0:28
    package, you see the Java files.
  • 0:28 - 0:32
    There are three Java files, Constants.java, HelloClass.java
  • 0:32 - 0:37
    and HelloWorldEndpoints.java. So Constants.java defines some constants,
  • 0:37 - 0:40
    as you might expect. HelloClass.java is a
  • 0:40 - 0:42
    very simple class we'll look at
  • 0:42 - 0:46
    in a minute. And then HelloWorldEndpoints.java defines
  • 0:46 - 0:48
    the endpoints used in the application. So
  • 0:48 - 0:52
    the source dir, contains the main folder,
  • 0:52 - 0:54
    which contains the java and the webapp folders.
  • 0:54 - 0:56
    We just looked at java, but now we're
  • 0:56 - 0:58
    going to look at webapp. So the webapp
  • 0:58 - 1:02
    folder contains the static files, the index.html, other
  • 1:02 - 1:05
    HTML files if you have them, JavaScript files,
  • 1:05 - 1:10
    any static content. It also contains the WEB-I-N-F,
  • 1:10 - 1:13
    or WEB-INF folder. And this folder's common to
  • 1:13 - 1:17
    all web applications, and it's where you configure
  • 1:17 - 1:20
    your application. So for app engine apps, you have
  • 1:20 - 1:25
    to have the appengine-web.xml file, which we already looked at,
  • 1:25 - 1:27
    which is where you configure the things that are specific
  • 1:27 - 1:30
    to your app engine app in, particular, you have to
  • 1:30 - 1:32
    specify the app ID if you want to deploy it
  • 1:32 - 1:36
    to Appspot. Another file in here is web.xml. And let's
  • 1:36 - 1:39
    take a quick look at that. So web.xml is where
  • 1:39 - 1:42
    you'd configure servers if you have them. In your web.xml
  • 1:42 - 1:44
    you should see that you have
  • 1:44 - 1:46
    the SystemsServiceServlet. And
  • 1:46 - 1:51
    it's mapped to com.google.api.server.spi.SystemServiceServlet.
  • 1:51 - 1:57
    And this spi, means end points. So this servlet is crucial to your application,
  • 1:57 - 1:58
    if you want to use end points.
  • 1:58 - 2:03
    Basically you must have com.google.api.server.spi.SystemServiceServlet in your
  • 2:03 - 2:07
    app if you want to use endpoints. Also see we define the welcome file
  • 2:07 - 2:10
    here which is index.html, which is pretty much
  • 2:10 - 2:12
    the default. Another configuration I want to draw your
  • 2:12 - 2:15
    attention to, is this one here for the
  • 2:15 - 2:20
    security constraint, where we specified that all web pages
  • 2:20 - 2:23
    must use HTTPS and this is how we
  • 2:23 - 2:27
    specify it, by setting the transport guarantee confidential. So
  • 2:27 - 2:30
    whenever you see this in your web.xml, it just
  • 2:30 - 2:33
    means that when the app's running on app spot,
  • 2:33 - 2:34
    if the user goes to it without using
  • 2:34 - 2:40
    HTTPS, they'll be redirected to HTTPS. Okay, so back
  • 2:40 - 2:43
    in the webapp dir, you see there's also
  • 2:43 - 2:47
    hello.js. And there's index.html. And these are the two
  • 2:47 - 2:49
    files that this app uses in the web
  • 2:49 - 2:53
    UI, or in the web front-end. Hello.js contains the
  • 2:53 - 2:56
    JavaScript functions used by the app, and index.html
  • 2:56 - 2:59
    is the home page for the app, and it
  • 2:59 - 3:02
    shows the two buttons, and the input field. And
  • 3:02 - 3:05
    here you see the two buttons, and the input failed.
Title:
Explore Project Layout and Configuration - Developing Scalable Apps with Java
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
UD859 - Developing Scalable Apps
Duration:
03:07

English subtitles

Revisions Compare revisions