diff --git a/build-and-deploy.ps1 b/build-and-deploy.ps1
index 8335ecd..26c5a63 100644
--- a/build-and-deploy.ps1
+++ b/build-and-deploy.ps1
@@ -1,17 +1,20 @@
# PowerShell script for building and deploying arm_am-pom to JBoss EAP 7.4
-# Configuration
-$JBOSS_HOME = "C:\Dev2012\BUILDERS\jboss-eap-7.4"
-$PROJECT_DIR = "C:\Dev2012\source\WindSurf\adv\arm_am-pom"
-$DEPLOYMENT_DIR = "$JBOSS_HOME\standalone\deployments"
-$MAVEN_PROFILE = "adv360-DEV" # Default development profile
-$JAVA_HOME = "C:\Dev2012\BUILDERS\java\jdk1.8.0_291" # Path to Java 8
+# Load configuration from JSON file
+$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
+
+# Configuration variables from JSON
+$JBOSS_HOME = $config.jbossHome
+$PROJECT_DIR = $config.ear.projectDir
+$DEPLOYMENT_DIR = $config.deploymentDir
+$MAVEN_PROFILE = $config.ear.mavenProfile
+$JAVA_HOME = $config.javaHome
# Store the original directory
$originalDirectory = Get-Location
# Function to check if JBoss is running
-function Is-JBossRunning {
+function Test-JBossRunning {
$jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" |
Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" }
return $null -ne $jbossProcess
@@ -54,7 +57,7 @@ Write-Host "Current directory: $(Get-Location)" -ForegroundColor Yellow
# First build the parent and modules with debug output
Write-Host "Building parent POM..." -ForegroundColor Yellow
& "$env:JAVA_HOME\bin\java" -version
-mvn clean install -N -P$MAVEN_PROFILE -X
+mvn clean install -N -P$MAVEN_PROFILE
if ($LASTEXITCODE -ne 0) {
Write-Host "Maven parent build failed!" -ForegroundColor Red
Set-Location $originalDirectory # Restore original directory
@@ -64,7 +67,7 @@ if ($LASTEXITCODE -ne 0) {
# Build the EJB module first with debug output
Write-Host "Building EJB module..." -ForegroundColor Yellow
Set-Location "$PROJECT_DIR\arm_am-ejb"
-mvn clean install -DskipTests -P$MAVEN_PROFILE -X
+mvn clean install -DskipTests -P$MAVEN_PROFILE
if ($LASTEXITCODE -ne 0) {
Write-Host "Maven EJB module build failed!" -ForegroundColor Red
Set-Location $originalDirectory # Restore original directory
@@ -74,7 +77,7 @@ if ($LASTEXITCODE -ne 0) {
# Build the WAR module with debug output
Write-Host "Building WAR module..." -ForegroundColor Yellow
Set-Location "$PROJECT_DIR\arm_am"
-mvn clean install -DskipTests -P$MAVEN_PROFILE -X
+mvn clean install -DskipTests -P$MAVEN_PROFILE
if ($LASTEXITCODE -ne 0) {
Write-Host "Maven WAR module build failed!" -ForegroundColor Red
Set-Location $originalDirectory # Restore original directory
@@ -84,7 +87,7 @@ if ($LASTEXITCODE -ne 0) {
# Finally build the EAR module with debug output
Write-Host "Building EAR module..." -ForegroundColor Yellow
Set-Location "$PROJECT_DIR\arm_am-ear"
-mvn clean package -DskipTests -P$MAVEN_PROFILE -X
+mvn clean package -DskipTests -P$MAVEN_PROFILE
if ($LASTEXITCODE -ne 0) {
Write-Host "Maven EAR module build failed!" -ForegroundColor Red
Set-Location $originalDirectory # Restore original directory
@@ -113,7 +116,7 @@ Write-Host "Copying to: $DEPLOYMENT_DIR" -ForegroundColor Yellow
Copy-Item $earFile.FullName $DEPLOYMENT_DIR
# Check if JBoss is running
-if (Is-JBossRunning) {
+if (Test-JBossRunning) {
Write-Host "JBoss is running - deployment will be automatically picked up" -ForegroundColor Green
} else {
Write-Host "Note: JBoss is not running. Start JBoss to complete deployment" -ForegroundColor Yellow
diff --git a/build-and-run-asset-gui.ps1 b/build-and-run-asset-gui.ps1
index ca496ad..a22501e 100644
--- a/build-and-run-asset-gui.ps1
+++ b/build-and-run-asset-gui.ps1
@@ -1,7 +1,10 @@
# PowerShell script to build and run asset-gui
-$projectDir = ".\asset-gui"
-$targetDir = ".\arm_am-pom\arm_am\WebContent\adv"
+# Load configuration from JSON file
+$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
+
+$projectDir = $config.assetGui.projectDir
+$targetDir = $config.assetGui.targetDir
Write-Host "Building asset-gui project..." -ForegroundColor Green
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..8519d49
--- /dev/null
+++ b/config.json
@@ -0,0 +1,27 @@
+{
+ "jbossHome": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4",
+ "deploymentDir": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4\\standalone\\deployments",
+ "javaHome": "C:\\Dev2012\\BUILDERS\\java\\jdk1.8.0_291",
+ "jboss": {
+ "configFile": "standalone\\configuration\\standalone-ADVC-full.xml",
+ "modules": {
+ "logmanager": "modules\\system\\layers\\base\\org\\jboss\\logmanager\\main"
+ }
+ },
+ "customFormatter": {
+ "src": "src",
+ "build": "build",
+ "classes": "build/classes",
+ "jar": "custom-formatter.jar"
+ },
+ "ear": {
+ "projectDir": "C:\\Dev2012\\source\\WindSurf\\adv\\arm_am-pom",
+ "mavenProfile": "adv360-DEV",
+ "deployedFile": "adv360-ear.ear",
+ "unpackDir": ".\\arm_am-unpacked"
+ },
+ "assetGui": {
+ "projectDir": ".\\asset-gui",
+ "targetDir": ".\\arm_am-pom\\arm_am\\WebContent\\adv"
+ }
+}
diff --git a/modules/com/armundia/advc360/bes/startup/main/build.xml b/modules/com/armundia/advc360/bes/startup/main/build.xml
new file mode 100644
index 0000000..16656d2
--- /dev/null
+++ b/modules/com/armundia/advc360/bes/startup/main/build.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/com/armundia/advc360/bes/startup/main/build/classes/com/armundia/adv360/bes/startup/CustomLogFormatter.class b/modules/com/armundia/advc360/bes/startup/main/build/classes/com/armundia/adv360/bes/startup/CustomLogFormatter.class
new file mode 100644
index 0000000..c94c3a2
Binary files /dev/null and b/modules/com/armundia/advc360/bes/startup/main/build/classes/com/armundia/adv360/bes/startup/CustomLogFormatter.class differ
diff --git a/modules/com/armundia/advc360/bes/startup/main/custom-formatter.jar b/modules/com/armundia/advc360/bes/startup/main/custom-formatter.jar
new file mode 100644
index 0000000..52dc0b3
Binary files /dev/null and b/modules/com/armundia/advc360/bes/startup/main/custom-formatter.jar differ
diff --git a/modules/com/armundia/advc360/bes/startup/main/module.xml b/modules/com/armundia/advc360/bes/startup/main/module.xml
new file mode 100644
index 0000000..6b2693f
--- /dev/null
+++ b/modules/com/armundia/advc360/bes/startup/main/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/com/armundia/advc360/bes/startup/main/src/com/armundia/adv360/bes/startup/CustomLogFormatter.java b/modules/com/armundia/advc360/bes/startup/main/src/com/armundia/adv360/bes/startup/CustomLogFormatter.java
new file mode 100644
index 0000000..9c476ef
--- /dev/null
+++ b/modules/com/armundia/advc360/bes/startup/main/src/com/armundia/adv360/bes/startup/CustomLogFormatter.java
@@ -0,0 +1,58 @@
+package com.armundia.adv360.bes.startup;
+
+import java.util.logging.Formatter;
+import java.util.logging.LogRecord;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class CustomLogFormatter extends Formatter {
+
+ private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS");
+
+ private String stripXMLTags(String input) {
+ if (input == null || input.isEmpty()) {
+ return input;
+ }
+ return input.replaceAll("<[^>]*>", "");
+ }
+
+ @Override
+ public String format(LogRecord record) {
+ StringBuilder sb = new StringBuilder();
+
+ // Data e ora
+ sb.append(ZonedDateTime.now().format(dateFormatter))
+ .append(" ");
+
+ // Livello log padded a 5 caratteri
+ String level = record.getLevel().toString();
+ sb.append(String.format("%-5s", level));
+
+ // Nome classe
+ sb.append("[")
+ .append(record.getSourceClassName())
+ .append("] ");
+
+ // Thread
+ sb.append("(")
+ .append(Thread.currentThread().getName())
+ .append(") ");
+
+ // Messaggio
+ String message = formatMessage(record);
+ sb.append(stripXMLTags(message));
+
+ // Stack trace se presente
+ if (record.getThrown() != null) {
+ sb.append("\n");
+ for (StackTraceElement element : record.getThrown().getStackTrace()) {
+ sb.append("\tat ")
+ .append(element.toString())
+ .append("\n");
+ }
+ }
+
+ sb.append("\n");
+ return sb.toString();
+ }
+}
diff --git a/start-jboss.ps1 b/start-jboss.ps1
index a121fcf..fae6756 100644
--- a/start-jboss.ps1
+++ b/start-jboss.ps1
@@ -1,11 +1,14 @@
# PowerShell script to start JBoss EAP 7.4
-# Configuration
-$JBOSS_HOME = "C:\Dev2012\BUILDERS\jboss-eap-7.4"
-$JAVA_HOME = "C:\Dev2012\BUILDERS\java\jdk1.8.0_291"
+# Load configuration from JSON file
+$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
+
+# Configuration variables from JSON
+$JBOSS_HOME = $config.jbossHome
+$JAVA_HOME = $config.javaHome
# Function to check if JBoss is already running
-function Is-JBossRunning {
+function Test-JBossRunning {
$jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" |
Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" }
return $null -ne $jbossProcess
@@ -24,7 +27,7 @@ if (-not (Test-Path $JBOSS_HOME)) {
}
# Check if configuration file exists
-$configFile = "$JBOSS_HOME\standalone\configuration\standalone-ADVCsvil-full.xml"
+$configFile = Join-Path $JBOSS_HOME $config.jboss.configFile
if (-not (Test-Path $configFile)) {
Write-Host "Error: Configuration file not found at $configFile" -ForegroundColor Red
exit 1
@@ -39,7 +42,7 @@ $env:NOPAUSE = "true"
# $env:LAUNCH_JBOSS_IN_BACKGROUND = "true"
# Check if JBoss is already running
-if (Is-JBossRunning) {
+if (Test-JBossRunning) {
Write-Host "JBoss is already running!" -ForegroundColor Yellow
exit 0
}
@@ -47,10 +50,10 @@ if (Is-JBossRunning) {
Write-Host "Starting JBoss EAP 7.4..." -ForegroundColor Green
Write-Host "Using Java from: $JAVA_HOME" -ForegroundColor Yellow
Write-Host "JBoss Home: $JBOSS_HOME" -ForegroundColor Yellow
-Write-Host "Using configuration: standalone-ADVCsvil-full.xml" -ForegroundColor Yellow
+Write-Host "Using configuration: $($config.jboss.configFile)" -ForegroundColor Yellow
# Start JBoss in standalone mode
-$startScript = "$JBOSS_HOME\bin\standalone.bat"
+$startScript = Join-Path $JBOSS_HOME "bin\standalone.bat"
$jvmOptions = @(
"-DIDServer=GS",
"-Dbtf.PathToParse=C:\Dev2012\advc0\in",
@@ -71,16 +74,16 @@ Write-Host "JVM Options: $env:JAVA_OPTS" -ForegroundColor Yellow
Write-Host "Remote debugging enabled on port 8787" -ForegroundColor Cyan
# Create the command line arguments
-$cmdArgs = "-c standalone-ADVCsvil-full.xml --debug -b 0.0.0.0 -bmanagement 0.0.0.0"
+$cmdArgs = "-c $($config.jboss.configFile) --debug -b 0.0.0.0 -bmanagement 0.0.0.0"
# Start JBoss - Modified to use Start-Process with RedirectStandardOutput
-$logFile = "$JBOSS_HOME\standalone\log\server.log"
+$logFile = Join-Path $JBOSS_HOME "standalone\log\server.log"
$processStartInfo = @{
FilePath = $startScript
ArgumentList = $cmdArgs
RedirectStandardOutput = $logFile
- RedirectStandardError = "$JBOSS_HOME\standalone\log\server_error.log"
- WorkingDirectory = "$JBOSS_HOME\bin"
+ RedirectStandardError = Join-Path $JBOSS_HOME "standalone\log\server_error.log"
+ WorkingDirectory = Join-Path $JBOSS_HOME "bin"
NoNewWindow = $true
PassThru = $true
}
@@ -91,7 +94,7 @@ $jbossProcess = Start-Process @processStartInfo
# Wait a few seconds to check if the process started successfully
Start-Sleep -Seconds 10
-if (Is-JBossRunning) {
+if (Test-JBossRunning) {
Write-Host "JBoss started successfully!" -ForegroundColor Green
Write-Host "Admin console will be available at: http://localhost:9990" -ForegroundColor Yellow
Write-Host "Remote debugging is enabled on port 8787" -ForegroundColor Cyan
diff --git a/stop-jboss.ps1 b/stop-jboss.ps1
index 0b3c4eb..db2bfe2 100644
--- a/stop-jboss.ps1
+++ b/stop-jboss.ps1
@@ -1,7 +1,10 @@
# PowerShell script to stop JBoss EAP 7.4
-# Configuration
-$JBOSS_HOME = "C:\Dev2012\BUILDERS\jboss-eap-7.4"
+# Load configuration from JSON file
+$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
+
+# Configuration variables from JSON
+$JBOSS_HOME = $config.jbossHome
Write-Host "Stopping JBoss EAP 7.4..." -ForegroundColor Yellow
diff --git a/unpack_ear.ps1 b/unpack_ear.ps1
new file mode 100644
index 0000000..51c2312
--- /dev/null
+++ b/unpack_ear.ps1
@@ -0,0 +1,56 @@
+# Load configuration from JSON file
+$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
+
+# Set paths from configuration
+$sourceFile = Join-Path $config.deploymentDir $config.ear.deployedFile
+$destinationPath = $config.ear.unpackDir
+
+# Remove destination directory if it exists
+if (Test-Path -Path $destinationPath) {
+ Remove-Item -Path $destinationPath -Recurse -Force
+ Write-Host "Removed existing directory: $destinationPath"
+}
+
+# Create destination directory
+if (-not (Test-Path -Path $destinationPath)) {
+ New-Item -ItemType Directory -Path $destinationPath -Force
+}
+
+# Rename .ear to .zip temporarily to use Expand-Archive
+$tempZipPath = $sourceFile -replace '\.ear$', '.zip'
+Copy-Item -Path $sourceFile -Destination $tempZipPath
+
+# Extract the EAR contents
+Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force
+
+# Clean up temporary zip file
+Remove-Item -Path $tempZipPath
+
+Write-Host "EAR file extracted to $destinationPath"
+
+# Function to unpack archive files (war/ejb)
+function Expand-JavaArchive {
+ param (
+ [string]$archivePath,
+ [string]$destinationPath
+ )
+
+ $tempZipPath = $archivePath -replace '\.(war|jar)$', '.zip'
+ Copy-Item -Path $archivePath -Destination $tempZipPath
+
+ # Create extraction directory
+ if (-not (Test-Path -Path $destinationPath)) {
+ New-Item -ItemType Directory -Path $destinationPath -Force
+ }
+
+ # Extract contents
+ Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force
+ Remove-Item -Path $tempZipPath
+ Write-Host "Extracted $archivePath to $destinationPath"
+}
+
+# Find and extract WAR and EJB files
+Get-ChildItem -Path $destinationPath -Recurse -Include "*.war", "*-ejbx.jar" | ForEach-Object {
+ $extractPath = Join-Path (Split-Path -Parent $_.FullName) ($_.BaseName + "_unpacked")
+ Expand-JavaArchive -archivePath $_.FullName -destinationPath $extractPath
+}