15.5. Putting Things Together

The project can be compiled by ant (http://jakarta.apache.org), it but must be modified slightly to use other JDO implementations. A build.xml file can be found in the top-level directory.

15.5.1. XML metadata

The model.jdo metadata file is located in the src/com/corejdo/casestudy directory and follows the JDO 1.0 naming convention.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects
Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
<jdo>
    <package name="com.corejdo.casestudy.model">
      <class name="Book">
      </class>
      <class name="CD">
      </class>
      <class name="Copy">
      </class>
      <class name="Library">
      </class>
      <class name="Publication">
      </class>
      <class name="Rights">
      </class>
      <class name="Song">
      </class>
      <class name="User">
      </class>
    </package>
</jdo>

15.5.2. Running in command-line mode

The command-line application can also be started by an ant target.

$ ant run

Use case [ListBooks]: Type name of use case here!
Start at [0]:
Count [10]:

Result:
1: Title:  Travel Guide: Sweden
   Author: Joseph, Bert
   ISBN:   7-7333-4727-6
   (C):    O'Renny
...

The datastore can be filled with random data by the FillDatabase command. For some operations, you have to log in. The initial user name is “su,” and the password is “su.” Here is how to add new users:

Use case [ListBooks]: Login
UserId []: su
Password []: su
Use case [Login]: EditUser
Find User Id [hb]: smith
User not found.
Add [false]: true
First name: John
Last name: Smith
Password: js
May borrow [false]: true
May manage publications [false]: true
May manage users [false]: true
Use case [EditUser]: _

15.5.3. Running the Servlets

Figure 15-4: A running Servlet shows a screenshot of a Web page that is generated from the ListBooks.jsp code. Again, ant can be used to start the tomcat Web server. The pages are compiled on demand. Please make sure that the Java SDK is set in the classpath; it is needed by the tomcat JSP engine.

Figure 15-4. A running Servlet.


$ ant servlet starts the server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset