This is a simple Apache Causeway application, structured so that it can be used as a starting point for developing your own applications.
It consists of:
-
a single module, which you can refactor for your own domain, or take a copy of in order to ensure that your application is properly modular
-
configuration to bring in some of the more commonly used extensions: secman, command log, audit trail, execution log, session logger, flyway,quartz and excel download.
You can easily remove these extensions (or add others) in the AppManifest
.
Tip
|
If all you want is get a feel for what the framework is all about, then take a look at the HelloWorld starter app, which has the bare minimum of configuration. |
-
install prereqs:
-
Java 11 LTS (eg Adopt OpenJDK distribution)
-
Maven 3.6 or later (download)
-
-
download and unzip
APP=simpleapp BRANCH=master REPO=causeway-app-$APP curl "https://codeload.github.com/apache/$REPO/zip/$BRANCH" | jar xv mv $REPO-$BRANCH $REPO cd $REPO
-
Build using Maven:
mvn clean install
-
Download the
spring-instrument.jar
for load-time weaving (discussed in more detail below):mvn dependency:get -DgroupId=org.springframework -DartifactId=spring-instrument -Dversion=XXX
Change "XXX" to the value that
${spring-framework.version}
resolves to in the webapppom.xml
-
Run using Maven:
mvn -pl webapp spring-boot:run
-
Browse to http://localhost:8080.
-
Login using:
-
either the secman superuser:
-
username:
secman-admin
-
password:
pass
-
-
or as a regular user:
-
username:
sven
-
password:
pass
-
The app runs with H2 running in-memory, with sample data set up using fixture scripts.
-
-
Build a Docker image
export REVISION=... #(1) export DOCKER_REGISTRY_USERNAME #(2) export DOCKER_REGISTRY_PASSWORD #(3) mvn -pl webapp -Ddocker jib:build
-
used as the image tag
-
Docker Hub registry username
-
Docker Hub registry password
To push to another container registry, change the
<image>
tag in the pom.xml
-
The following table explains the contents of each of the directories:
Directory | Description | ||
---|---|---|---|
|
Holds the "simple" module, consisting of the
|
||
|
Holds the unit- and integration tests for |
||
|
Holds the bootstrapping classes, along with application-level scoped services and home page. The |
||
|
Contains application-wide integration tests. |
It’s more common for tests to reside within the same module, but we moved them into their own Maven modules because it makes them easier to be temporarily excluded, eg during initial explorations/prototyping.
This version of the application uses EclipseLink JPA as its ORM, configured with load-time weaving. This requires that the application be run with a Java agent.
The spring-boot plugin is configured to run with this agent already. If you want to run from an IDE:
-
first, you might wish to copy the file locally:
cp ~/.m2/repository/org/springframework/spring-instrument/XXX/spring-instrument-XXX.jar lib/spring-instrument.jar
Change "XXX" to the value that
${spring-framework.version}
resolves to in the webapppom.xml
-
Then specify the agent as a VM option:
-javaagent:lib/spring-instrument.jar
The application has both unit tests and integration tests.
Test type | Report | Phase | Skip using |
---|---|---|---|
Unit test |
|
|
|
Integ test |
|
|
|
These outputs can for example be processed within/published by a continuous pipeline.
Apache Causeway supports i18n using GNU .po files.
The WEB-INF/translations.po
is the fallback (an empty value means that the key is used "as-is"), while WEB-INF/translations-XX.po
files provide translations for each "XX" locale.
Translations are required for all domain classes and all members (actions, properties and collections) of all classes.
This information is available from the metamodel, and so a new template translations.po
is generated as a side effect of running the integration tests (through a log4j2 logger).
A good integration test to run is ValidateDomainModel_IntegTest
.
In addition, translations are required for any validation messages triggered by the test.
Running an integration tests that trigger validations will result in these messages being captured as keys, for example Smoke_IntegTest
.
The generated file should be merged with any existing translations in WEB-INF/translations.po
, and translations obtained for any new keys (there are numerous online services that support the format).
The application also demonstrates how to use Flyway to migrate the database schema.
By default the app runs using an in-memory database. The Flyway example is activated using the "SQLSERVER" Spring Boot profile, eg:
mvn -Dspring.profiles.active=SQLSERVER -pl webapp install
mvn -Dspring.profiles.active=SQLSERVER -pl webapp spring-boot:run
This causes the properties defined in config/application-SQLSERVER.properties
file to be used in preference to those in the default config/application.properties
file.
It defines the following:
-
spring.flyway.url
,spring.flyway.user
andspring.flyway.password
The presence of these is enough to enable the Flyway integration
-
spring.flyway.enabled
This is explicitly set to
true
, to override the value in the defaultconfig/application.properties
. -
causeway.persistence.jdo-datanucleus.impl.datanucleus.schema.autoCreateAll
This is set to
false
, also overriding the value in the defaultconfig/application.properties
. It instructs the JDO/DataNucleus object store not to automatically create any tables etc.
The Spring Boot profile is also used to add the dependency to the SQL Server driver is included (it is hidden behind a Maven profile).
The prerequisites to try this out are a SQL Server database running on localhost
and with the credentials as specified in config/application-SQLSERVER.properties
; adjust as necessary.