So in the next few weeks I am going to be designing and writing an application that requires Web Services, Integration, Database access and Scaling.
I have chosen a well known problem domain and will use Apache Camel as the foundation of the solution
Problem Statement:
You are tasked to design an insurance comperative rating platform.
It will have a web interface, a database backend and integration with multiple partners.
When a user enters their information online, the system will collect that information and send it to many different partner systems.
The partner systems will return back some information with different policies and prices the user may qualify to buy.
After a user buys a plan, the information will be sent to the partner as well as being stored in the local system storage.
The system must be lively, robust and crash resilient
Well, this is no easy task given the challenge. This in some way is in the same problem space as HealthCare.gov, albeit in a limited way. So the problems I will try to solve will be a microcosm of that problem space.
So here is my proposed solution at this time:
Solution:
We will use the following core technologies:
We will use Java 8, ActivemQ, Mongo DB, Web Services and REST
We will use the following frameworks:
Akka, Camel, CXF, Spring and Play Framework
Conceptual Design:
Rather than write a formal requirements document, we will simply
narate them in plain English, and add diagrams s they are needed.
We will call our product ExcellentRater
After a user has entered their information into the web page form, it is submitted to ExcellentRater.
This is where our solution begins, though we will provide a web page form to enter some information for demo purposes.
ExcellentRater will take that information and submit it a Camel pipe line.
Each pipeline will be dedicated to a single partner. Note that a partner may be serviced by zero or more pipelines.
Inside the Camel pipeline, processors will transform the data into a fomat that the partner system understands.
The processor will then connect to the partner system, transfer the policy application data in the partner format.
It will get a response in the partner format. It will transform the response into a format ExcellentRater understands (i.e, Domain Model or specialised DTO).
After processing the results will be aggregated by Camel and passed to a processor to save to the ExcellentRater database so that the user can review them at will.
The system objects need to be location transparent so that the system can be scaped at any layer (web, application, data storage).
Here is the initial class diagram of our domain.
And here is the initial Schema of our domain model (DTO, btw).
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://rater.exellent.com/1.0" xmlns:rater="http://rater.exellent.com/1.0">
<xsd:include schemaLocation="country-code.xsd" />
<xsd:simpleType name="UserStatus">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="ACTIVE" />
<xsd:enumeration value="NOT_ACTIVE" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ApprovalStatus">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="APPROVED" />
<xsd:enumeration value="DENIED" />
<xsd:enumeration value="PENDING" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Gender">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="MALE" />
<xsd:enumeration value="FEMALE" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="CoverageTerm">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="SIX_MONTHS" />
<xsd:enumeration value="TWELVE_MONTHS" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="CoverageType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="COMPREHENSIVE" />
<xsd:enumeration value="THIRD_PARTY_ONLY" />
<xsd:enumeration value="THIRD_PARTY_AND_PROPERTY" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="AuthUser">
<xsd:sequence>
<xsd:element name="email" type="xsd:string" />
<xsd:element name="password" type="xsd:string" />
<xsd:element name="status" type="rater:UserStatus" />
<xsd:element name="dateCreated" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="User">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string" />
<xsd:element name="lastName" type="xsd:string" />
<xsd:element name="address1" type="xsd:string" />
<xsd:element name="address2" type="xsd:string" />
<xsd:element name="address3" type="xsd:string" />
<xsd:element name="city" type="xsd:string" />
<xsd:element name="province" type="xsd:string" />
<xsd:element name="postCode" type="xsd:string" />
<xsd:element name="country" type="rater:CountryCode" />
<xsd:element name="dateofBirth" type="xsd:date" />
<xsd:element name="dateOfLicense" type="xsd:date" />
<xsd:element name="points" type="xsd:int" />
<xsd:element name="authUser" type="rater:AuthUser" />
<xsd:element name="dateCreated" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Vehicle">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="make" type="xsd:string" />
<xsd:element name="model" type="xsd:string" />
<xsd:element name="color" type="xsd:string" />
<xsd:element name="year" type="xsd:int" />
<xsd:element name="vin" type="xsd:string" />
<xsd:element name="numberOfDoors" type="xsd:string" />
<xsd:element name="numberOfSeats" type="xsd:string" />
<xsd:element name="dateCreated" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Policy">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="rater:User" />
<xsd:element name="coverageTerm" type="rater:CoverageTerm" />
<xsd:element ref="rater:Vehicle" />
<xsd:element name="coverageType" type="rater:CoverageType" />
<xsd:element name="coverageStartDate" type="xsd:date" />
<xsd:element name="dateCreated" type="xsd:date" />
<xsd:element name="termPrice" type="xsd:double" />
<xsd:element name="approvalStatus" type="rater:ApprovalStatus" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
and the Country Codes Schema
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://rater.exellent.com/1.0" xmlns:rater="http://rater.exellent.com/1.0">
<xs:annotation>
<xs:documentation>
Copyright (C) 2006-2007 Code Synthesis Tools CC
Redistribution and use with or without modification are permitted
under the terms of the new BSD license. See the accompanying LICENSE
file.
</xs:documentation>
</xs:annotation>
<xs:simpleType name="CountryCode">
<xs:annotation>
<xs:documentation>
Two-letter (alpha-2) ISO 3166-1 code for one of the 243 countries.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="AF"/> <!-- AFGHANISTAN -->
<xs:enumeration value="AX"/> <!-- ÅLAND ISLANDS -->
<xs:enumeration value="AL"/> <!-- ALBANIA -->
<xs:enumeration value="DZ"/> <!-- ALGERIA -->
<xs:enumeration value="AS"/> <!-- AMERICAN SAMOA -->
<xs:enumeration value="AD"/> <!-- ANDORRA -->
<xs:enumeration value="AO"/> <!-- ANGOLA -->
<xs:enumeration value="AI"/> <!-- ANGUILLA -->
<xs:enumeration value="AQ"/> <!-- ANTARCTICA -->
<xs:enumeration value="AG"/> <!-- ANTIGUA AND BARBUDA -->
<xs:enumeration value="AR"/> <!-- ARGENTINA -->
<xs:enumeration value="AM"/> <!-- ARMENIA -->
<xs:enumeration value="AW"/> <!-- ARUBA -->
<xs:enumeration value="AU"/> <!-- AUSTRALIA -->
<xs:enumeration value="AT"/> <!-- AUSTRIA -->
<xs:enumeration value="AZ"/> <!-- AZERBAIJAN -->
<xs:enumeration value="BS"/> <!-- BAHAMAS -->
<xs:enumeration value="BH"/> <!-- BAHRAIN -->
<xs:enumeration value="BD"/> <!-- BANGLADESH -->
<xs:enumeration value="BB"/> <!-- BARBADOS -->
<xs:enumeration value="BY"/> <!-- BELARUS -->
<xs:enumeration value="BE"/> <!-- BELGIUM -->
<xs:enumeration value="BZ"/> <!-- BELIZE -->
<xs:enumeration value="BJ"/> <!-- BENIN -->
<xs:enumeration value="BM"/> <!-- BERMUDA -->
<xs:enumeration value="BT"/> <!-- BHUTAN -->
<xs:enumeration value="BO"/> <!-- BOLIVIA -->
<xs:enumeration value="BA"/> <!-- BOSNIA AND HERZEGOVINA -->
<xs:enumeration value="BW"/> <!-- BOTSWANA -->
<xs:enumeration value="BV"/> <!-- BOUVET ISLAND -->
<xs:enumeration value="BR"/> <!-- BRAZIL -->
<xs:enumeration value="IO"/> <!-- BRITISH INDIAN OCEAN TERRITORY -->
<xs:enumeration value="BN"/> <!-- BRUNEI DARUSSALAM -->
<xs:enumeration value="BG"/> <!-- BULGARIA -->
<xs:enumeration value="BF"/> <!-- BURKINA FASO -->
<xs:enumeration value="BI"/> <!-- BURUNDI -->
<xs:enumeration value="KH"/> <!-- CAMBODIA -->
<xs:enumeration value="CM"/> <!-- CAMEROON -->
<xs:enumeration value="CA"/> <!-- CANADA -->
<xs:enumeration value="CV"/> <!-- CAPE VERDE -->
<xs:enumeration value="KY"/> <!-- CAYMAN ISLANDS -->
<xs:enumeration value="CF"/> <!-- CENTRAL AFRICAN REPUBLIC -->
<xs:enumeration value="TD"/> <!-- CHAD -->
<xs:enumeration value="CL"/> <!-- CHILE -->
<xs:enumeration value="CN"/> <!-- CHINA -->
<xs:enumeration value="CX"/> <!-- CHRISTMAS ISLAND -->
<xs:enumeration value="CC"/> <!-- COCOS (KEELING) ISLANDS -->
<xs:enumeration value="CO"/> <!-- COLOMBIA -->
<xs:enumeration value="KM"/> <!-- COMOROS -->
<xs:enumeration value="CG"/> <!-- CONGO -->
<xs:enumeration value="CD"/> <!-- CONGO, THE DEMOCRATIC REPUBLIC OF THE -->
<xs:enumeration value="CK"/> <!-- COOK ISLANDS -->
<xs:enumeration value="CR"/> <!-- COSTA RICA -->
<xs:enumeration value="CI"/> <!-- COTE D'IVOIRE -->
<xs:enumeration value="HR"/> <!-- CROATIA -->
<xs:enumeration value="CU"/> <!-- CUBA -->
<xs:enumeration value="CY"/> <!-- CYPRUS -->
<xs:enumeration value="CZ"/> <!-- CZECH REPUBLIC -->
<xs:enumeration value="DK"/> <!-- DENMARK -->
<xs:enumeration value="DJ"/> <!-- DJIBOUTI -->
<xs:enumeration value="DM"/> <!-- DOMINICA -->
<xs:enumeration value="DO"/> <!-- DOMINICAN REPUBLIC -->
<xs:enumeration value="EC"/> <!-- ECUADOR -->
<xs:enumeration value="EG"/> <!-- EGYPT -->
<xs:enumeration value="SV"/> <!-- EL SALVADOR -->
<xs:enumeration value="GQ"/> <!-- EQUATORIAL GUINEA -->
<xs:enumeration value="ER"/> <!-- ERITREA -->
<xs:enumeration value="EE"/> <!-- ESTONIA -->
<xs:enumeration value="ET"/> <!-- ETHIOPIA -->
<xs:enumeration value="FK"/> <!-- FALKLAND ISLANDS (MALVINAS) -->
<xs:enumeration value="FO"/> <!-- FAROE ISLANDS -->
<xs:enumeration value="FJ"/> <!-- FIJI -->
<xs:enumeration value="FI"/> <!-- FINLAND -->
<xs:enumeration value="FR"/> <!-- FRANCE -->
<xs:enumeration value="GF"/> <!-- FRENCH GUIANA -->
<xs:enumeration value="PF"/> <!-- FRENCH POLYNESIA -->
<xs:enumeration value="TF"/> <!-- FRENCH SOUTHERN TERRITORIES -->
<xs:enumeration value="GA"/> <!-- GABON -->
<xs:enumeration value="GM"/> <!-- GAMBIA -->
<xs:enumeration value="GE"/> <!-- GEORGIA -->
<xs:enumeration value="DE"/> <!-- GERMANY -->
<xs:enumeration value="GH"/> <!-- GHANA -->
<xs:enumeration value="GI"/> <!-- GIBRALTAR -->
<xs:enumeration value="GR"/> <!-- GREECE -->
<xs:enumeration value="GL"/> <!-- GREENLAND -->
<xs:enumeration value="GD"/> <!-- GRENADA -->
<xs:enumeration value="GP"/> <!-- GUADELOUPE -->
<xs:enumeration value="GU"/> <!-- GUAM -->
<xs:enumeration value="GT"/> <!-- GUATEMALA -->
<xs:enumeration value="GG"/> <!-- GUERNSEY -->
<xs:enumeration value="GN"/> <!-- GUINEA -->
<xs:enumeration value="GW"/> <!-- GUINEA-BISSAU -->
<xs:enumeration value="GY"/> <!-- GUYANA -->
<xs:enumeration value="HT"/> <!-- HAITI -->
<xs:enumeration value="HM"/> <!-- HEARD ISLAND AND MCDONALD ISLANDS -->
<xs:enumeration value="VA"/> <!-- HOLY SEE (VATICAN CITY STATE) -->
<xs:enumeration value="HN"/> <!-- HONDURAS -->
<xs:enumeration value="HK"/> <!-- HONG KONG -->
<xs:enumeration value="HU"/> <!-- HUNGARY -->
<xs:enumeration value="IS"/> <!-- ICELAND -->
<xs:enumeration value="IN"/> <!-- INDIA -->
<xs:enumeration value="ID"/> <!-- INDONESIA -->
<xs:enumeration value="IR"/> <!-- IRAN, ISLAMIC REPUBLIC OF -->
<xs:enumeration value="IQ"/> <!-- IRAQ -->
<xs:enumeration value="IE"/> <!-- IRELAND -->
<xs:enumeration value="IM"/> <!-- ISLE OF MAN -->
<xs:enumeration value="IL"/> <!-- ISRAEL -->
<xs:enumeration value="IT"/> <!-- ITALY -->
<xs:enumeration value="JM"/> <!-- JAMAICA -->
<xs:enumeration value="JP"/> <!-- JAPAN -->
<xs:enumeration value="JE"/> <!-- JERSEY -->
<xs:enumeration value="JO"/> <!-- JORDAN -->
<xs:enumeration value="KZ"/> <!-- KAZAKHSTAN -->
<xs:enumeration value="KE"/> <!-- KENYA -->
<xs:enumeration value="KI"/> <!-- KIRIBATI -->
<xs:enumeration value="KP"/> <!-- KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF -->
<xs:enumeration value="KR"/> <!-- KOREA, REPUBLIC OF -->
<xs:enumeration value="KW"/> <!-- KUWAIT -->
<xs:enumeration value="KG"/> <!-- KYRGYZSTAN -->
<xs:enumeration value="LA"/> <!-- LAO PEOPLE'S DEMOCRATIC REPUBLIC -->
<xs:enumeration value="LV"/> <!-- LATVIA -->
<xs:enumeration value="LB"/> <!-- LEBANON -->
<xs:enumeration value="LS"/> <!-- LESOTHO -->
<xs:enumeration value="LR"/> <!-- LIBERIA -->
<xs:enumeration value="LY"/> <!-- LIBYAN ARAB JAMAHIRIYA -->
<xs:enumeration value="LI"/> <!-- LIECHTENSTEIN -->
<xs:enumeration value="LT"/> <!-- LITHUANIA -->
<xs:enumeration value="LU"/> <!-- LUXEMBOURG -->
<xs:enumeration value="MO"/> <!-- MACAO -->
<xs:enumeration value="MK"/> <!-- MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF -->
<xs:enumeration value="MG"/> <!-- MADAGASCAR -->
<xs:enumeration value="MW"/> <!-- MALAWI -->
<xs:enumeration value="MY"/> <!-- MALAYSIA -->
<xs:enumeration value="MV"/> <!-- MALDIVES -->
<xs:enumeration value="ML"/> <!-- MALI -->
<xs:enumeration value="MT"/> <!-- MALTA -->
<xs:enumeration value="MH"/> <!-- MARSHALL ISLANDS -->
<xs:enumeration value="MQ"/> <!-- MARTINIQUE -->
<xs:enumeration value="MR"/> <!-- MAURITANIA -->
<xs:enumeration value="MU"/> <!-- MAURITIUS -->
<xs:enumeration value="YT"/> <!-- MAYOTTE -->
<xs:enumeration value="MX"/> <!-- MEXICO -->
<xs:enumeration value="FM"/> <!-- MICRONESIA, FEDERATED STATES OF -->
<xs:enumeration value="MD"/> <!-- MOLDOVA, REPUBLIC OF -->
<xs:enumeration value="MC"/> <!-- MONACO -->
<xs:enumeration value="MN"/> <!-- MONGOLIA -->
<xs:enumeration value="MS"/> <!-- MONTSERRAT -->
<xs:enumeration value="MA"/> <!-- MOROCCO -->
<xs:enumeration value="MZ"/> <!-- MOZAMBIQUE -->
<xs:enumeration value="MM"/> <!-- MYANMAR -->
<xs:enumeration value="NA"/> <!-- NAMIBIA -->
<xs:enumeration value="NR"/> <!-- NAURU -->
<xs:enumeration value="NP"/> <!-- NEPAL -->
<xs:enumeration value="NL"/> <!-- NETHERLANDS -->
<xs:enumeration value="AN"/> <!-- NETHERLANDS ANTILLES -->
<xs:enumeration value="NC"/> <!-- NEW CALEDONIA -->
<xs:enumeration value="NZ"/> <!-- NEW ZEALAND -->
<xs:enumeration value="NI"/> <!-- NICARAGUA -->
<xs:enumeration value="NE"/> <!-- NIGER -->
<xs:enumeration value="NG"/> <!-- NIGERIA -->
<xs:enumeration value="NU"/> <!-- NIUE -->
<xs:enumeration value="NF"/> <!-- NORFOLK ISLAND -->
<xs:enumeration value="MP"/> <!-- NORTHERN MARIANA ISLANDS -->
<xs:enumeration value="NO"/> <!-- NORWAY -->
<xs:enumeration value="OM"/> <!-- OMAN -->
<xs:enumeration value="PK"/> <!-- PAKISTAN -->
<xs:enumeration value="PW"/> <!-- PALAU -->
<xs:enumeration value="PS"/> <!-- PALESTINIAN TERRITORY, OCCUPIED -->
<xs:enumeration value="PA"/> <!-- PANAMA -->
<xs:enumeration value="PG"/> <!-- PAPUA NEW GUINEA -->
<xs:enumeration value="PY"/> <!-- PARAGUAY -->
<xs:enumeration value="PE"/> <!-- PERU -->
<xs:enumeration value="PH"/> <!-- PHILIPPINES -->
<xs:enumeration value="PN"/> <!-- PITCAIRN -->
<xs:enumeration value="PL"/> <!-- POLAND -->
<xs:enumeration value="PT"/> <!-- PORTUGAL -->
<xs:enumeration value="PR"/> <!-- PUERTO RICO -->
<xs:enumeration value="QA"/> <!-- QATAR -->
<xs:enumeration value="RE"/> <!-- REUNION -->
<xs:enumeration value="RO"/> <!-- ROMANIA -->
<xs:enumeration value="RU"/> <!-- RUSSIAN FEDERATION -->
<xs:enumeration value="RW"/> <!-- RWANDA -->
<xs:enumeration value="SH"/> <!-- SAINT HELENA -->
<xs:enumeration value="KN"/> <!-- SAINT KITTS AND NEVIS -->
<xs:enumeration value="LC"/> <!-- SAINT LUCIA -->
<xs:enumeration value="PM"/> <!-- SAINT PIERRE AND MIQUELON -->
<xs:enumeration value="VC"/> <!-- SAINT VINCENT AND THE GRENADINES -->
<xs:enumeration value="WS"/> <!-- SAMOA -->
<xs:enumeration value="SM"/> <!-- SAN MARINO -->
<xs:enumeration value="ST"/> <!-- SAO TOME AND PRINCIPE -->
<xs:enumeration value="SA"/> <!-- SAUDI ARABIA -->
<xs:enumeration value="SN"/> <!-- SENEGAL -->
<xs:enumeration value="CS"/> <!-- SERBIA AND MONTENEGRO -->
<xs:enumeration value="SC"/> <!-- SEYCHELLES -->
<xs:enumeration value="SL"/> <!-- SIERRA LEONE -->
<xs:enumeration value="SG"/> <!-- SINGAPORE -->
<xs:enumeration value="SK"/> <!-- SLOVAKIA -->
<xs:enumeration value="SI"/> <!-- SLOVENIA -->
<xs:enumeration value="SB"/> <!-- SOLOMON ISLANDS -->
<xs:enumeration value="SO"/> <!-- SOMALIA -->
<xs:enumeration value="ZA"/> <!-- SOUTH AFRICA -->
<xs:enumeration value="GS"/> <!-- SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS -->
<xs:enumeration value="ES"/> <!-- SPAIN -->
<xs:enumeration value="LK"/> <!-- SRI LANKA -->
<xs:enumeration value="SD"/> <!-- SUDAN -->
<xs:enumeration value="SR"/> <!-- SURINAME -->
<xs:enumeration value="SJ"/> <!-- SVALBARD AND JAN MAYEN -->
<xs:enumeration value="SZ"/> <!-- SWAZILAND -->
<xs:enumeration value="SE"/> <!-- SWEDEN -->
<xs:enumeration value="CH"/> <!-- SWITZERLAND -->
<xs:enumeration value="SY"/> <!-- SYRIAN ARAB REPUBLIC -->
<xs:enumeration value="TW"/> <!-- TAIWAN, PROVINCE OF CHINA -->
<xs:enumeration value="TJ"/> <!-- TAJIKISTAN -->
<xs:enumeration value="TZ"/> <!-- TANZANIA, UNITED REPUBLIC OF -->
<xs:enumeration value="TH"/> <!-- THAILAND -->
<xs:enumeration value="TL"/> <!-- TIMOR-LESTE -->
<xs:enumeration value="TG"/> <!-- TOGO -->
<xs:enumeration value="TK"/> <!-- TOKELAU -->
<xs:enumeration value="TO"/> <!-- TONGA -->
<xs:enumeration value="TT"/> <!-- TRINIDAD AND TOBAGO -->
<xs:enumeration value="TN"/> <!-- TUNISIA -->
<xs:enumeration value="TR"/> <!-- TURKEY -->
<xs:enumeration value="TM"/> <!-- TURKMENISTAN -->
<xs:enumeration value="TC"/> <!-- TURKS AND CAICOS ISLANDS -->
<xs:enumeration value="TV"/> <!-- TUVALU -->
<xs:enumeration value="UG"/> <!-- UGANDA -->
<xs:enumeration value="UA"/> <!-- UKRAINE -->
<xs:enumeration value="AE"/> <!-- UNITED ARAB EMIRATES -->
<xs:enumeration value="GB"/> <!-- UNITED KINGDOM -->
<xs:enumeration value="US"/> <!-- UNITED STATES -->
<xs:enumeration value="UM"/> <!-- UNITED STATES MINOR OUTLYING ISLANDS -->
<xs:enumeration value="UY"/> <!-- URUGUAY -->
<xs:enumeration value="UZ"/> <!-- UZBEKISTAN -->
<xs:enumeration value="VU"/> <!-- VANUATU -->
<xs:enumeration value="VE"/> <!-- VENEZUELA -->
<xs:enumeration value="VN"/> <!-- VIET NAM -->
<xs:enumeration value="VG"/> <!-- VIRGIN ISLANDS, BRITISH -->
<xs:enumeration value="VI"/> <!-- VIRGIN ISLANDS, U.S. -->
<xs:enumeration value="WF"/> <!-- WALLIS AND FUTUNA -->
<xs:enumeration value="EH"/> <!-- WESTERN SAHARA -->
<xs:enumeration value="YE"/> <!-- YEMEN -->
<xs:enumeration value="ZM"/> <!-- ZAMBIA -->
<xs:enumeration value="ZW"/> <!-- ZIMBABWE -->
</xs:restriction>
</xs:simpleType>
</xs:schema>
Our Project will have this layout:
rater-modules
rater-protocol (DTOs and Value Objects)
rater-web-app (HTML/Javascript Web Application)
rater-services (Utility Library for business logic) rater-domain (Objects used to store and fetch data from backend storage)
We will use maven for building.
And here is the initial parent pom:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.exellent.rater</groupId>
<artifactId>rater-modules</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>rater-modules</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.0.5.RELEASE</spring.version>
<camel.version>2.9.1</camel.version>
<servlet.version>2.5</servlet.version>
<activemq.version>5.5.1</activemq.version>
<jackson.version>1.8.6</jackson.version>
</properties>
<modules>
<module>rater-protocol</module>
<module>rater-domain</module>
<module>rater-web-app</module>
<module>rater-android-app</module>
<module>rater-services</module>
</modules>
</project>
Initially, we will build the DTO using JAXB, generating the classes using the CXF code generation plugin.
Here is the configuration in rater-protocol/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.exellent.rater</groupId>
<artifactId>rater-protocol</artifactId>
<packaging>jar</packaging>
<name>Excellent Rater Protocol API</name>
<parent>
<groupId>com.exellent.rater</groupId>
<artifactId>rater-modules</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>2.3.0</version>
<configuration>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension>
</extensions>
</configuration>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<xsdOptions>
<xsdOption>
<xsd>${basedir}/src/main/schema/rater-protocol.xsd</xsd>
<bindingFile>${basedir}/src/main/schema/rater-protocol.xjb</bindingFile>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
This says to take the schema in src/main/schema/rater-protocol.xsd folder, use the rules in src/main/schema/rater-protocol.xjb, and generate the Java classes that match the schema file.
We end up with the following DTO classes:
@XmlType(name = "Gender")
@XmlEnum
public enum Gender {
MALE,
FEMALE;
public String value() {
return name();
}
public static Gender fromValue(String v) {
return valueOf(v);
}
}
@XmlType(name = "UserStatus")
@XmlEnum
public enum UserStatus {
ACTIVE,
NOT_ACTIVE;
public String value() {
return name();
}
public static UserStatus fromValue(String v) {
return valueOf(v);
}
}
@XmlType(name = "CoverageType")
@XmlEnum
public enum CoverageType {
COMPREHENSIVE,
THIRD_PARTY_ONLY,
THIRD_PARTY_AND_PROPERTY;
public String value() {
return name();
}
public static CoverageType fromValue(String v) {
return valueOf(v);
}
}
@XmlType(name = "CoverageTerm")
@XmlEnum
public enum CoverageTerm {
SIX_MONTHS,
TWELVE_MONTHS;
public String value() {
return name();
}
public static CoverageTerm fromValue(String v) {
return valueOf(v);
}
}
@XmlType(name = "ApprovalStatus")
@XmlEnum
public enum ApprovalStatus {
APPROVED,
DENIED,
PENDING;
public String value() {
return name();
}
public static ApprovalStatus fromValue(String v) {
return valueOf(v);
}
}
@XmlRootElement(name = "User")
public class User
implements Serializable
{
private final static long serialVersionUID = 12343L;
@XmlElement(required = true)
protected String firstName;
@XmlElement(required = true)
protected String lastName;
@XmlElement(required = true)
protected String address1;
@XmlElement(required = true)
protected String address2;
@XmlElement(required = true)
protected String address3;
@XmlElement(required = true)
protected String city;
@XmlElement(required = true)
protected String province;
@XmlElement(required = true)
protected String postCode;
@XmlElement(required = true)
protected CountryCode country;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateofBirth;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateOfLicense;
protected int points;
@XmlElement(required = true)
protected AuthUser authUser;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateCreated;
/**
* Gets the value of the firstName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFirstName() {
return firstName;
}
....
....
...
@XmlRootElement(name = "Policy")
public class Policy
implements Serializable
{
private final static long serialVersionUID = 12343L;
@XmlElement(name = "User", namespace = "http://rater.exellent.com/1.0", required = true)
protected User user;
@XmlElement(required = true)
protected CoverageTerm coverageTerm;
@XmlElement(name = "Vehicle", namespace = "http://rater.exellent.com/1.0", required = true)
protected Vehicle vehicle;
@XmlElement(required = true)
protected CoverageType coverageType;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar coverageStartDate;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateCreated;
protected double termPrice;
@XmlElement(required = true)
protected ApprovalStatus approvalStatus;
...
...
...
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AuthUser", propOrder = {
"email",
"password",
"status",
"dateCreated"
})
public class AuthUser
implements Serializable
{
private final static long serialVersionUID = 12343L;
@XmlElement(required = true)
protected String email;
@XmlElement(required = true)
protected String password;
@XmlElement(required = true)
protected UserStatus status;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateCreated;
...
...
...
@XmlRootElement(name = "Vehicle")
public class Vehicle
implements Serializable
{
private final static long serialVersionUID = 12343L;
@XmlElement(required = true)
protected String make;
@XmlElement(required = true)
protected String model;
@XmlElement(required = true)
protected String color;
protected int year;
@XmlElement(required = true)
protected String vin;
@XmlElement(required = true)
protected String numberOfDoors;
@XmlElement(required = true)
protected String numberOfSeats;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateCreated;
...
...
...
Next, we will write the domain model and then the services layer. Stay tuned.
You can download the code for this project so far from here:
github.com:exellent-rater
Thursday, 1 May 2014
Subscribe to:
Posts (Atom)

