Skip to main content

Development Environment

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

settings.gradle

pluginManagement {
repositories {
gradlePluginPortal()
}
}

We need the gradle plugin portal in order to get the jPOS APP Gradle Plugin.

build.gradle

plugins {
id 'org.jpos.jposapp' version '0.0.10'
id 'java-library'
}

group = 'org.jpos.jposapp'
version = '0.0.1-SNAPSHOT'

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

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

Here we define a couple plugins:

  • The jposapp plugin that provides the dist, installApp, and other jPOS related tasks.
  • The java-library plugin used to build a Java code.

Then we define a group and version name for this application, and we configure jPOS as a dependency.

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.

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.

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.