In this section we will try out the PeopleService using a simple console application.
<!-- ==================================================================
Runs the MDA component
================================================================== -->
<goal name="mda">
<maven:maven
descriptor="mda/project.xml"
goals="pom:install"/>
</goal>
<!-- ==================================================================
Builds the Console component
================================================================== -->
<goal name="ttconsole">
<maven:maven
descriptor="console/project.xml"
goals="jar:install"/>
</goal>
<!-- ==================================================================
Runs the Console component
================================================================== -->
<goal name="run">
<maven:maven
descriptor="console/project.xml"
goals="run"/>
</goal>
public static void main(String[] args) {
// Get services
serviceLocator = ServiceLocator.instance();
peopleService = serviceLocator.getPeopleService();
// Create people
PersonVO naresh = createPerson("nbhatia", "Naresh", "Bhatia");
PersonVO louis = createPerson("lcoude", "Louis", "Coude");
PersonVO john = createPerson("jsmith", "John", "Smith");
// Fetch and show all objects created above
PersonVO[] people = peopleService.getAllPeople();
showPeople(people);
}
private static PersonVO createPerson(String username, String firstName, String lastName) {
PersonVO person = new PersonVO(null, username, firstName, lastName);
person.setId(peopleService.createPerson(person));
System.out.println("Person " + person.getId() + " created - " + person.getUsername());
return person;
}
C:/timetracker>maven -o run
...
[java] Person 1 created - nbhatia
[java] Person 2 created - lcoude
[java] Person 3 created - jsmith
[java] People:
[java] 1: nbhatia - Naresh Bhatia
[java] 2: lcoude - Louis Coude
[java] 3: jsmith - John Smith
[java]
BUILD SUCCESSFUL
Total time: 8 seconds
Finished at: Mon Jan 30 01:41:58 EST 2006
C:/timetracker>
Now that we have a running console application with 1 entity, 1 value object and 1 service, we are ready to implement more TimeTracker functionality. Click here to add a Timecard object to TimeTracker and learn how to model associations in AndroMDA. application.