Skip to main content

Development Environment

After cloning the tutorial repository, you'll find a few files:

note

Each lesson lives under tutorials/{lesson}. The snippets below refer to files in the module you’re working on (for example tutorials/qbean-primer).

settings.gradle

pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven { url = uri('https://jpos.org/maven') }
}
}

rootProject.name = 'jpos-tutorials'

include 'tutorials:qbean-primer'
include 'tutorials:qbean-support'
include 'tutorials:qserver'

We declare the plugin repositories (Gradle Portal plus the jPOS maven repo) and, at the bottom, include each lesson module under tutorials/{lesson}.

build.gradle

plugins {
id 'org.jpos.jposapp' version '0.0.16' apply false
id 'idea'
}

group = 'org.jpos.tutorials'
version = '3.0.1-SNAPSHOT'

subprojects {
apply plugin: 'java-library'
apply plugin: 'org.jpos.jposapp'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}

group = rootProject.group
version = rootProject.version

repositories {
mavenCentral()
maven { url = uri('https://jpos.org/maven') }
mavenLocal()
}

dependencies {
implementation 'org.jpos:jpos:3.0.1-SNAPSHOT'
}

jpos {
distDir.set('src/dist')
}
}

We apply the jposapp plugin inside every subproject, along with the standard java-library plugin, and configure Java 25 toolchains plus the shared group/version. The subprojects { ... } block also wires up the repositories and jPOS dependency once so each module inherits it.

note

The jPOS Gradle Plugin is available in Gradle's Plugin Portal allowing for easy integration into your build process. The source code is available on GitHub at https://github.com/jpos/jpos-gradle-plugin.

tutorials/{lesson}/src/dist/deploy/00_logger.xml

<logger name="Q2">
<property name="redirect" value="stdout, stderr" />
<log-listener class="org.jpos.util.SimpleLogListener" />

<log-listener class="org.jpos.util.RotateLogListener">
<property name="file" value="log/q2.log" />
<property name="window" value="86400" />
<property name="copies" value="90" />
<property name="maxsize" value="100000000" />
</log-listener>
</logger>

Later in the tutorial, we'll delve deeply into logger configuration. For now, we present an example configuration to illustrate what it entails.

In this setup, a logger named Q2 is defined, accompanied by specific configurations. One such configuration is the 'redirect' property, which directs both stdout and stderr to the logger. Additionally, there are a couple of listeners configured: the SimpleLogListener directs log output to stdout, while the second listener maintains a log history, retaining up to 90 days of logs with each file capped at 100MB.

tutorials/{lesson}/src/dist/deploy/99_sysmon.xml

<sysmon logger="Q2">
<attr name="sleepTime" type="java.lang.Long">3600000</attr>
<attr name="detailRequired" type="java.lang.Boolean">true</attr>
</sysmon>

If you started Q2 in the previous exercise, you might have noticed a log entry like this (output may vary as we transition to Structured Audit Logs).

<log realm="org.jpos.q2.qbean.SystemMonitor" at="2023-11-13T12:57:11.005240">
<info>
OS: Mac OS X (13.5.1)
Java: 21.0.1 (Oracle Corporation) AES-secure
environment: default
process name: 65998@apr-2.local
user name: jpos
host: jpos.local/127.0.0.1
cwd: /opt/local/jpos/tutorial
free space: 396.7 GiB
version: 3.0.0-SNAPSHOT (9565627)
instance: cb6e2224-da4c-47c0-9897-fd6be13fb03f
uptime: 00:00:00.652 (2.780762)
processors: 16
drift : 0
memory(t/u/f): 258/31/226
encoding: UTF-8
timezone: America/Montevideo (Uruguay Time) -03:00
watch service: sun.nio.fs.PollingWatchService
metrics dir: log
clock: 1699891031 2023-11-13T15:57:10.911673Z
thread count: 11
peak threads: 11
user threads: 6
Thread[#9,Reference Handler,10,system]
Thread[#10,Finalizer,8,system]
Thread[#11,Signal Dispatcher,9,system]
Thread[#26,Notification Thread,9,system]
Thread[#27,Common-Cleaner,8,InnocuousThreadGroup]
Thread[#28,pool-1-thread-1,5,main]
Thread[#29,Q2-cb6e2224-da4c-47c0-9897-fd6be13fb03f,5,main]
Thread[#30,DestroyJavaVM,5,main]
Thread[#31,FileSystemWatcher,5,main]
Thread[#33,Timer-0,5,main]
Thread[#40,SystemMonitor,5,main]
name-registrar:
Q2: org.jpos.q2.Q2
logger.Q2: org.jpos.util.Logger
</info>
</log>

While the specific content currently discussed may not be pertinent yet, it serves as an illustrative example of how a jPOS QBean can be utilized for self-monitoring purposes.