diff --git a/README.md b/README.md
index 2850867f20..6a9a90ac4f 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ A versatile and lightweight **API Gateway** for **REST** and **legacy SOAP Web S
- Open a terminal in the extracted directory.
- Run the appropriate command for your operating system:
- **Linux/Mac:** `./service-proxy.sh`
- - **Windows:** `service-proxy.bat`
+ - **Windows:** `service-proxy.ps1`
3. **Access the Gateway**
- Open your browser and navigate to [http://localhost:2000](http://localhost:2000).
diff --git a/core/.factorypath b/core/.factorypath
index 9dcf3a81b2..e01b84bc25 100644
--- a/core/.factorypath
+++ b/core/.factorypath
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/core/src/main/java/com/predic8/membrane/core/interceptor/InterceptorUtil.java b/core/src/main/java/com/predic8/membrane/core/interceptor/InterceptorUtil.java
index 9c6096bd52..00f9b84fb9 100644
--- a/core/src/main/java/com/predic8/membrane/core/interceptor/InterceptorUtil.java
+++ b/core/src/main/java/com/predic8/membrane/core/interceptor/InterceptorUtil.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.interceptor;
import java.util.*;
diff --git a/core/src/main/java/com/predic8/membrane/core/interceptor/lang/Polyglot.java b/core/src/main/java/com/predic8/membrane/core/interceptor/lang/Polyglot.java
index a7016905d7..66bfe45898 100644
--- a/core/src/main/java/com/predic8/membrane/core/interceptor/lang/Polyglot.java
+++ b/core/src/main/java/com/predic8/membrane/core/interceptor/lang/Polyglot.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.interceptor.lang;
import com.predic8.membrane.core.lang.*;
diff --git a/core/src/main/java/com/predic8/membrane/core/interceptor/shutdown/ShutdownInterceptor.java b/core/src/main/java/com/predic8/membrane/core/interceptor/shutdown/ShutdownInterceptor.java
index 268f02aa8e..f01126b724 100644
--- a/core/src/main/java/com/predic8/membrane/core/interceptor/shutdown/ShutdownInterceptor.java
+++ b/core/src/main/java/com/predic8/membrane/core/interceptor/shutdown/ShutdownInterceptor.java
@@ -29,7 +29,7 @@
*
*
* Has undefined behavior when Membrane is not started from command line
- * (=via the RouterCLI class, which service-proxy.bat/service-proxy.sh
+ * (=via the RouterCLI class, which service-proxy.ps1/service-proxy.sh
* do use).
*
*
diff --git a/core/src/main/java/com/predic8/membrane/core/util/ExceptionUtil.java b/core/src/main/java/com/predic8/membrane/core/util/ExceptionUtil.java
index a0e60abb59..71dd4b53b6 100644
--- a/core/src/main/java/com/predic8/membrane/core/util/ExceptionUtil.java
+++ b/core/src/main/java/com/predic8/membrane/core/util/ExceptionUtil.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.util;
public class ExceptionUtil {
diff --git a/core/src/test/java/com/predic8/membrane/core/interceptor/ThrowablePrintStackTraceTest.java b/core/src/test/java/com/predic8/membrane/core/interceptor/ThrowablePrintStackTraceTest.java
index 0316e537cf..01ef171a8d 100644
--- a/core/src/test/java/com/predic8/membrane/core/interceptor/ThrowablePrintStackTraceTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/interceptor/ThrowablePrintStackTraceTest.java
@@ -1,4 +1,17 @@
-package com.predic8.membrane.core;
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+package com.predic8.membrane.core.interceptor;
import com.tngtech.archunit.core.domain.*;
import com.tngtech.archunit.junit.AnalyzeClasses;
diff --git a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxySpringConfigurationTest.java b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxySpringConfigurationTest.java
index 2feb48b066..cca4a3bdcb 100644
--- a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxySpringConfigurationTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxySpringConfigurationTest.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.openapi.serviceproxy;
import com.predic8.membrane.core.*;
diff --git a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxyTest.java b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxyTest.java
index b7c90e456f..d9149cfd88 100644
--- a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxyTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxyTest.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.openapi.serviceproxy;
import org.junit.jupiter.api.*;
diff --git a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/AbstractProxySpringConfigurationTest.java b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/AbstractProxySpringConfigurationTest.java
index 3828261f06..414eff8745 100644
--- a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/AbstractProxySpringConfigurationTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/AbstractProxySpringConfigurationTest.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.openapi.serviceproxy;
import com.predic8.membrane.core.*;
diff --git a/core/src/test/java/com/predic8/membrane/core/proxies/AbstractProxyTest.java b/core/src/test/java/com/predic8/membrane/core/proxies/AbstractProxyTest.java
index dcaa847d07..3d47fe4f62 100644
--- a/core/src/test/java/com/predic8/membrane/core/proxies/AbstractProxyTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/proxies/AbstractProxyTest.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.proxies;
import org.junit.jupiter.api.*;
diff --git a/core/src/test/java/com/predic8/membrane/core/util/ExceptionUtilTest.java b/core/src/test/java/com/predic8/membrane/core/util/ExceptionUtilTest.java
index f68d018ed6..4edb28d25b 100644
--- a/core/src/test/java/com/predic8/membrane/core/util/ExceptionUtilTest.java
+++ b/core/src/test/java/com/predic8/membrane/core/util/ExceptionUtilTest.java
@@ -1,3 +1,16 @@
+/* Copyright 2025 predic8 GmbH, www.predic8.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
package com.predic8.membrane.core.util;
import org.junit.jupiter.api.Test;
diff --git a/distribution/examples/acl/README.md b/distribution/examples/acl/README.md
index c791c869fa..bf412aba53 100644
--- a/distribution/examples/acl/README.md
+++ b/distribution/examples/acl/README.md
@@ -13,7 +13,7 @@ To run the example execute the following steps:
1. Go to the `examples/acl` directory.
-2. Execute `service-proxy.bat`
+2. Execute `service-proxy.ps1`
3. Open the URL http://localhost:2000/ in your browser.
The predic8.de website will be displayed in your browser.
diff --git a/distribution/examples/acl/service-proxy.bat b/distribution/examples/acl/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/acl/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/acl/service-proxy.ps1 b/distribution/examples/acl/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/acl/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/apikey/store/service-proxy.bat b/distribution/examples/apikey/store/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/apikey/store/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/apikey/store/service-proxy.ps1 b/distribution/examples/apikey/store/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/apikey/store/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/basic-xml-interceptor/README.md b/distribution/examples/basic-xml-interceptor/README.md
index d78cbd152d..ee4354bbbd 100644
--- a/distribution/examples/basic-xml-interceptor/README.md
+++ b/distribution/examples/basic-xml-interceptor/README.md
@@ -21,7 +21,7 @@ To run the example execute the following steps:
mvn package
```
-3. Execute service-proxy.bat or service-proxy.sh
+3. Execute service-proxy.ps1 or service-proxy.sh
4. Open a second terminal
5. Run below command
diff --git a/distribution/examples/basic-xml-interceptor/pom.xml b/distribution/examples/basic-xml-interceptor/pom.xml
index 438950fb4c..f9638633d6 100644
--- a/distribution/examples/basic-xml-interceptor/pom.xml
+++ b/distribution/examples/basic-xml-interceptor/pom.xml
@@ -18,7 +18,7 @@
org.membrane-soa
service-proxy-core
- 5.8.1-SNAPSHOT
+ 6.0.0-SNAPSHOT
diff --git a/distribution/examples/basic-xml-interceptor/service-proxy.bat b/distribution/examples/basic-xml-interceptor/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/basic-xml-interceptor/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/basic-xml-interceptor/service-proxy.ps1 b/distribution/examples/basic-xml-interceptor/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/basic-xml-interceptor/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/cbr/README.md b/distribution/examples/cbr/README.md
index 5e30703b1e..6031ec8412 100644
--- a/distribution/examples/cbr/README.md
+++ b/distribution/examples/cbr/README.md
@@ -17,7 +17,7 @@ To run the example execute the following steps:
2. Start Membrane:
`service-proxy.sh` or
-`service-proxy.bat`
+`service-proxy.ps1`
3. Send an order XML document to the API:
diff --git a/distribution/examples/cbr/proxies.xml b/distribution/examples/cbr/proxies.xml
index 242875cc76..27e18829f8 100644
--- a/distribution/examples/cbr/proxies.xml
+++ b/distribution/examples/cbr/proxies.xml
@@ -27,15 +27,15 @@
-
+
Normal order received.
-
+
-
+
Express order received.
-
+
diff --git a/distribution/examples/cbr/service-proxy.bat b/distribution/examples/cbr/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/cbr/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/cbr/service-proxy.ps1 b/distribution/examples/cbr/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/cbr/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/custom-interceptor/README.md b/distribution/examples/custom-interceptor/README.md
index 45502490b1..c460b73d2a 100644
--- a/distribution/examples/custom-interceptor/README.md
+++ b/distribution/examples/custom-interceptor/README.md
@@ -17,7 +17,7 @@ To run the example execute the following steps:
mvn package
```
-3. Execute service-proxy.bat or service-proxy.sh
+3. Execute service-proxy.ps1 or service-proxy.sh
4. Open http://localhost:2000/ using a browser
diff --git a/distribution/examples/custom-interceptor/pom.xml b/distribution/examples/custom-interceptor/pom.xml
index 52fc447cfc..228a6107e9 100644
--- a/distribution/examples/custom-interceptor/pom.xml
+++ b/distribution/examples/custom-interceptor/pom.xml
@@ -25,7 +25,7 @@
org.membrane-soa
service-proxy-core
- 5.8.1-SNAPSHOT
+ 6.0.0-SNAPSHOT
diff --git a/distribution/examples/custom-interceptor/service-proxy.bat b/distribution/examples/custom-interceptor/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/custom-interceptor/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/custom-interceptor/service-proxy.ps1 b/distribution/examples/custom-interceptor/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/custom-interceptor/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.bat b/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.ps1 b/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/custom-websocket-interceptor/standalone/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/embedding-java/pom.xml b/distribution/examples/embedding-java/pom.xml
index 07391754b4..ac996567ab 100644
--- a/distribution/examples/embedding-java/pom.xml
+++ b/distribution/examples/embedding-java/pom.xml
@@ -29,7 +29,7 @@
org.membrane-soa
service-proxy-core
- 5.8.1-SNAPSHOT
+ 6.0.0-SNAPSHOT
org.projectlombok
diff --git a/distribution/examples/error-handling/custom-error-messages/service-proxy.bat b/distribution/examples/error-handling/custom-error-messages/service-proxy.bat
deleted file mode 100644
index eaca1a4098..0000000000
--- a/distribution/examples/error-handling/custom-error-messages/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/error-handling/service-proxy.ps1 b/distribution/examples/error-handling/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/error-handling/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/file-exchangestore/README.md b/distribution/examples/file-exchangestore/README.md
index 148afec776..d5eabceea4 100644
--- a/distribution/examples/file-exchangestore/README.md
+++ b/distribution/examples/file-exchangestore/README.md
@@ -11,7 +11,7 @@ To run the example execute the following steps:
1. Have a look at `file-exchangestore-beans.xml`
-2. Execute `examples/file-exchangestore/service-proxy.bat`
+2. Execute `examples/file-exchangestore/service-proxy.ps1`
3. Open http://localhost:2000/ in your browser.
diff --git a/distribution/examples/file-exchangestore/service-proxy.bat b/distribution/examples/file-exchangestore/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/file-exchangestore/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/file-exchangestore/service-proxy.ps1 b/distribution/examples/file-exchangestore/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/file-exchangestore/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/greasing/README.md b/distribution/examples/greasing/README.md
index ca385fc51b..711d85cabe 100644
--- a/distribution/examples/greasing/README.md
+++ b/distribution/examples/greasing/README.md
@@ -6,7 +6,7 @@ Modify JSON documents by injecting random fields or shuffling field order withou
***Note:*** *The request is also available in the requests.http file.*
1. **Navigate** to the `examples/greasing` directory.
-2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3. **Access** the greased API:
```
curl -v http://localhost:2000 \
diff --git a/distribution/examples/greasing/service-proxy.bat b/distribution/examples/greasing/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/greasing/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/greasing/service-proxy.ps1 b/distribution/examples/greasing/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/greasing/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/groovy/README.md b/distribution/examples/groovy/README.md
index b64e1826eb..0488da31b8 100644
--- a/distribution/examples/groovy/README.md
+++ b/distribution/examples/groovy/README.md
@@ -8,7 +8,7 @@ Using the `groovy` element you can run Groovy scripts to manipulate or monitor m
1. Take a look at [proxies.xml](proxies.xml). There you'll find the APIs with Groovy scripts.
2. Open a commandline session or a terminal.
-3. Run `service-proxy.bat` or `./service-proxy.sh` in this folder
+3. Run `service-proxy.ps1` or `./service-proxy.sh` in this folder
4. Open a second terminal and run the commands:
**Create JSON with Groovy:**
diff --git a/distribution/examples/groovy/service-proxy.bat b/distribution/examples/groovy/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/groovy/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/groovy/service-proxy.ps1 b/distribution/examples/groovy/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/groovy/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/if/service-proxy.bat b/distribution/examples/if/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/if/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/if/service-proxy.ps1 b/distribution/examples/if/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/if/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/internalproxy/README.md b/distribution/examples/internalproxy/README.md
index bebb22689b..a5e2210db1 100644
--- a/distribution/examples/internalproxy/README.md
+++ b/distribution/examples/internalproxy/README.md
@@ -7,7 +7,7 @@ Route requests to internal proxies for reusable functionality across multiple AP
***Note:*** *You can test these requests using the provided HTTP file or cURL snippets.*
1. **Navigate** to the `examples/internalproxy` directory.
-2. **Start** Membrane by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** Membrane by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3. **Execute the following requests** (alternatively, use the `requests.http` file):
- **Normal Processing**:
```bash
diff --git a/distribution/examples/internalproxy/service-proxy.bat b/distribution/examples/internalproxy/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/internalproxy/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/internalproxy/service-proxy.ps1 b/distribution/examples/internalproxy/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/internalproxy/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/javascript/README.md b/distribution/examples/javascript/README.md
index e2a7e96730..d813dd5cb3 100644
--- a/distribution/examples/javascript/README.md
+++ b/distribution/examples/javascript/README.md
@@ -8,7 +8,7 @@ JavaScript is a powerful tool for manipulating messages and customizing the beha
1. Review the [proxies.xml](proxies.xml) file to see how the APIs are configured with the `javascript` plugin.
2. Open a command-line session or terminal.
-3. Run `service-proxy.bat` (Windows) or `./service-proxy.sh` (Linux/Mac) in this folder.
+3. Run `service-proxy.ps1` (Windows) or `./service-proxy.sh` (Linux/Mac) in this folder.
4. Open a second terminal and execute the following commands:
### Create JSON with JavaScript
@@ -53,7 +53,7 @@ curl http://localhost:2020 -v
Greatings from Javascript
```
-The response should include an `X-Javascript` header. Additionally, the console output of `service-proxy.sh` or `service-proxy.bat` will display the request header fields logged by the script:
+The response should include an `X-Javascript` header. Additionally, the console output of `service-proxy.sh` or `service-proxy.ps1` will display the request header fields logged by the script:
```
Request headers:
diff --git a/distribution/examples/javascript/service-proxy.bat b/distribution/examples/javascript/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/javascript/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/javascript/service-proxy.ps1 b/distribution/examples/javascript/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/javascript/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/1-static/README.md b/distribution/examples/loadbalancing/1-static/README.md
index 54d5fd3438..bdd647c163 100644
--- a/distribution/examples/loadbalancing/1-static/README.md
+++ b/distribution/examples/loadbalancing/1-static/README.md
@@ -13,7 +13,7 @@ This example sets up a loadbalancer to distribute requests to 3 different nodes.
Execute the following steps:
1. Go to the `examples/loadbalancing/1-static` directory.
-2. Run `service-proxy.sh` or `service-proxy.bat` in a terminal.
+2. Run `service-proxy.sh` or `service-proxy.ps1` in a terminal.
3. Open the URL:
```
diff --git a/distribution/examples/loadbalancing/1-static/service-proxy.bat b/distribution/examples/loadbalancing/1-static/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/loadbalancing/1-static/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/1-static/service-proxy.ps1 b/distribution/examples/loadbalancing/1-static/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/loadbalancing/1-static/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/2-dynamic/README.md b/distribution/examples/loadbalancing/2-dynamic/README.md
index 7ae81dae6b..3d8253dc05 100644
--- a/distribution/examples/loadbalancing/2-dynamic/README.md
+++ b/distribution/examples/loadbalancing/2-dynamic/README.md
@@ -13,7 +13,7 @@ In this example we will distribute requests to 3 different nodes.
To run the example execute the following steps:
1. Go to the `examples/loadbalancing/2-dynamic` directory.
-2. Execute `service-proxy.bat` or `service-proxy.sh`
+2. Execute `service-proxy.ps1` or `service-proxy.sh`
3. Open the URL http://localhost:4000 in your browser.
You will see a simple web app that counts how often it was called. There are 2 more web apps of the same kind
listening at port `4001` and `4002`.
diff --git a/distribution/examples/loadbalancing/2-dynamic/service-proxy.bat b/distribution/examples/loadbalancing/2-dynamic/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/loadbalancing/2-dynamic/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/2-dynamic/service-proxy.ps1 b/distribution/examples/loadbalancing/2-dynamic/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/loadbalancing/2-dynamic/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/3-client/README.md b/distribution/examples/loadbalancing/3-client/README.md
index 945098ea47..3434be17e9 100644
--- a/distribution/examples/loadbalancing/3-client/README.md
+++ b/distribution/examples/loadbalancing/3-client/README.md
@@ -12,7 +12,7 @@ To run the example execute the following steps:
1. Go to the `examples/loadbalancing/3-node-api` directory.
-2. Run `service-proxy.bat` or `service-proxy.sh`
+2. Run `service-proxy.ps1` or `service-proxy.sh`
This will start three nodes, the loadbalancer and the node management API.
diff --git a/distribution/examples/loadbalancing/3-client/lbclient.bat b/distribution/examples/loadbalancing/3-client/lbclient.bat
deleted file mode 100644
index d5097855a9..0000000000
--- a/distribution/examples/loadbalancing/3-client/lbclient.bat
+++ /dev/null
@@ -1,19 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:javaHomeMissing
-echo Please set the JAVA_HOME environment variable.
-exit
-
-:homeOk
-if not exist "%JAVA_HOME%" goto javaHomeMissing
-java -cp "%JAVA_HOME%\jre\lib\ext\*;%MEMBRANE_HOME%\lib\*;%MEMBRANE_HOME%\conf\*" com.predic8.membrane.balancer.client.LBNotificationClient %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/distribution/examples/loadbalancing/3-client/lbclient.ps1 b/distribution/examples/loadbalancing/3-client/lbclient.ps1
new file mode 100644
index 0000000000..877fa8e8a5
--- /dev/null
+++ b/distribution/examples/loadbalancing/3-client/lbclient.ps1
@@ -0,0 +1,30 @@
+$MEMBRANE_HOME = Join-Path $PWD "..\..\.."
+if (-not $env:MEMBRANE_HOME) {
+ $env:MEMBRANE_HOME = $MEMBRANE_HOME
+}
+Write-Output $env:MEMBRANE_HOME
+
+function Check-MembraneHome {
+ if (Test-Path "$env:MEMBRANE_HOME\service-proxy.ps1") {
+ return $true
+ }
+ Write-Output "Please set the MEMBRANE_HOME environment variable to point to"
+ Write-Output "the directory where you have extracted the Membrane software."
+ exit
+}
+
+function Check-JavaHome {
+ if (-not (Test-Path $env:JAVA_HOME)) {
+ Write-Output "Please set the JAVA_HOME environment variable."
+ exit
+ }
+}
+
+if (-not (Check-MembraneHome)) {
+ exit
+}
+
+Check-JavaHome
+
+$classpath = "$env:JAVA_HOME\jre\lib\ext\*;$env:MEMBRANE_HOME\lib\*;$env:MEMBRANE_HOME\conf\*"
+& java -cp $classpath com.predic8.membrane.balancer.client.LBNotificationClient $args
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/3-client/service-proxy-secured.bat b/distribution/examples/loadbalancing/3-client/service-proxy-secured.bat
deleted file mode 100644
index 309ec1110a..0000000000
--- a/distribution/examples/loadbalancing/3-client/service-proxy-secured.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c lb-client-secured.proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/3-client/service-proxy-secured.ps1 b/distribution/examples/loadbalancing/3-client/service-proxy-secured.ps1
new file mode 100644
index 0000000000..844d1fe9b0
--- /dev/null
+++ b/distribution/examples/loadbalancing/3-client/service-proxy-secured.ps1
@@ -0,0 +1,68 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c lb-client-secured.proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
diff --git a/distribution/examples/loadbalancing/3-client/service-proxy.bat b/distribution/examples/loadbalancing/3-client/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/loadbalancing/3-client/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/3-client/service-proxy.ps1 b/distribution/examples/loadbalancing/3-client/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/loadbalancing/3-client/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/4-xml-session/README.md b/distribution/examples/loadbalancing/4-xml-session/README.md
index 2faf393229..39834a7410 100644
--- a/distribution/examples/loadbalancing/4-xml-session/README.md
+++ b/distribution/examples/loadbalancing/4-xml-session/README.md
@@ -22,7 +22,7 @@ To run the example execute the following steps:
3. Execute
- `service-proxy.bat`
+ `service-proxy.ps1`
This will initialize the `LoadBalancingInterceptor` and associate it with a rule.
diff --git a/distribution/examples/loadbalancing/4-xml-session/service-proxy.bat b/distribution/examples/loadbalancing/4-xml-session/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/loadbalancing/4-xml-session/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/4-xml-session/service-proxy.ps1 b/distribution/examples/loadbalancing/4-xml-session/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/loadbalancing/4-xml-session/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/5-multiple/README.md b/distribution/examples/loadbalancing/5-multiple/README.md
index 83b0359d27..ef365ef266 100644
--- a/distribution/examples/loadbalancing/5-multiple/README.md
+++ b/distribution/examples/loadbalancing/5-multiple/README.md
@@ -24,7 +24,7 @@ To run the example execute the following steps:
1. Go to the `examples/loadbalancer-multiple-4` directory.
-2. Execute `service-proxy.bat`
+2. Execute `service-proxy.ps1`
3. Open the URL http://localhost:8080/service in your browser and repeatedly refresh (F5). Observe that the response alternates
between Mock Node 1 and 2.
diff --git a/distribution/examples/loadbalancing/5-multiple/service-proxy.bat b/distribution/examples/loadbalancing/5-multiple/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/loadbalancing/5-multiple/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/loadbalancing/5-multiple/service-proxy.ps1 b/distribution/examples/loadbalancing/5-multiple/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/loadbalancing/5-multiple/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/logging/access/service-proxy.bat b/distribution/examples/logging/access/service-proxy.bat
deleted file mode 100644
index eaca1a4098..0000000000
--- a/distribution/examples/logging/access/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/logging/access/service-proxy.ps1 b/distribution/examples/logging/access/service-proxy.ps1
new file mode 100644
index 0000000000..5180b8070e
--- /dev/null
+++ b/distribution/examples/logging/access/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java "-Dlog4j.configurationFile=$(pwd)/log4j2_access.xml" -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/logging/access/service-proxy.sh b/distribution/examples/logging/access/service-proxy.sh
index 2ac562b116..95b2dbdf2e 100755
--- a/distribution/examples/logging/access/service-proxy.sh
+++ b/distribution/examples/logging/access/service-proxy.sh
@@ -6,7 +6,7 @@ start() {
membrane_home="$1"
export CLASSPATH="$membrane_home/conf:$membrane_home/lib/*"
echo "Starting: $membrane_home CL: $CLASSPATH"
- java -Dlog4j.configurationFile=$(pwd)/log4j2_access.xml -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+ java "-Dlog4j.configurationFile=$(pwd)/log4j2_access.xml" -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
}
find_membrane_directory() {
diff --git a/distribution/examples/logging/console/README.md b/distribution/examples/logging/console/README.md
index a407216e90..f025ce0096 100644
--- a/distribution/examples/logging/console/README.md
+++ b/distribution/examples/logging/console/README.md
@@ -8,7 +8,7 @@ Membrane can log the access to APIs to a CSV file. The fields will be separated
To run the example execute the following steps:
1. Go to the `examples/logging-csv` directory.
-2. Run `service-proxy.sh` or `service-proxy.bat`
+2. Run `service-proxy.sh` or `service-proxy.ps1`
4. Route a request through Membrane:
```
diff --git a/distribution/examples/logging/console/service-proxy.bat b/distribution/examples/logging/console/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/logging/console/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/logging/console/service-proxy.ps1 b/distribution/examples/logging/console/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/logging/console/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/logging/csv/README.md b/distribution/examples/logging/csv/README.md
index eed955d868..d2283595e6 100644
--- a/distribution/examples/logging/csv/README.md
+++ b/distribution/examples/logging/csv/README.md
@@ -11,7 +11,7 @@ To run the example execute the following steps:
1. Go to the `examples/logging-csv` directory.
-2. Execute `service-proxy.sh` or service-proxy.bat`
+2. Execute `service-proxy.sh` or service-proxy.ps1`
3. Open the URL http://localhost:2000 in your browser.
diff --git a/distribution/examples/logging/csv/service-proxy.bat b/distribution/examples/logging/csv/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/logging/csv/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/logging/csv/service-proxy.ps1 b/distribution/examples/logging/csv/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/logging/csv/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/logging/jdbc-database/README.md b/distribution/examples/logging/jdbc-database/README.md
index 8ba7d297d5..6b8c10ec75 100644
--- a/distribution/examples/logging/jdbc-database/README.md
+++ b/distribution/examples/logging/jdbc-database/README.md
@@ -21,7 +21,7 @@ To run the example execute the following steps:
```
start DERBY_HOME/bin/startNetworkServer.bat
```
-6. Execute `service-proxy.bat` or `service-proxy.sh`
+6. Execute `service-proxy.ps1` or `service-proxy.sh`
7. Open the URL http://localhost:2000/ in your browser.
diff --git a/distribution/examples/logging/jdbc-database/service-proxy.bat b/distribution/examples/logging/jdbc-database/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/logging/jdbc-database/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/logging/jdbc-database/service-proxy.ps1 b/distribution/examples/logging/jdbc-database/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/logging/jdbc-database/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/logging/json/service-proxy.bat b/distribution/examples/logging/json/service-proxy.bat
deleted file mode 100644
index eaca1a4098..0000000000
--- a/distribution/examples/logging/json/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/logging/json/service-proxy.ps1 b/distribution/examples/logging/json/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/logging/json/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/login/README.md b/distribution/examples/login/README.md
index 9e893f2193..d7a43f4be7 100644
--- a/distribution/examples/login/README.md
+++ b/distribution/examples/login/README.md
@@ -11,7 +11,7 @@ To run the example execute the following steps:
1. Go to the `examples/login` directory.
-2. Execute `service-proxy.bat`
+2. Execute `service-proxy.ps1`
3. Open the URL http://localhost:2000/ in your browser.
diff --git a/distribution/examples/login/service-proxy.bat b/distribution/examples/login/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/login/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/login/service-proxy.ps1 b/distribution/examples/login/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/login/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/json2xml/README.md b/distribution/examples/message-transformation/json2xml/README.md
index 54c6244877..d4840fb1a9 100644
--- a/distribution/examples/message-transformation/json2xml/README.md
+++ b/distribution/examples/message-transformation/json2xml/README.md
@@ -9,7 +9,7 @@ To run the example, execute the following steps:
1. Go to the examples/message-transformation/json2xml directory
-2. Run `service-proxy.sh` or `service-proxy.bat` to start the API Gateway.
+2. Run `service-proxy.sh` or `service-proxy.ps1` to start the API Gateway.
3. Run the command below in a second console from the same directory:
diff --git a/distribution/examples/message-transformation/json2xml/requests.http b/distribution/examples/message-transformation/json2xml/requests.http
index b7c3af27e8..4aa9b672e1 100644
--- a/distribution/examples/message-transformation/json2xml/requests.http
+++ b/distribution/examples/message-transformation/json2xml/requests.http
@@ -1,6 +1,6 @@
# Sample Requests
#
-# 1. Start service-proxy.bat or service-proxy.sh
+# 1. Start service-proxy.ps1 or service-proxy.sh
# 2. Execute the requests in this document using:
# - IntelliJ (Plugin: https://plugins.jetbrains.com/plugin/13121-http-client) or
# - Visual Studio Code (Plugin https://marketplace.visualstudio.com/items?itemName=humao.rest-client)
diff --git a/distribution/examples/message-transformation/json2xml/service-proxy.bat b/distribution/examples/message-transformation/json2xml/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/message-transformation/json2xml/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/json2xml/service-proxy.ps1 b/distribution/examples/message-transformation/json2xml/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/message-transformation/json2xml/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/replace/README.md b/distribution/examples/message-transformation/replace/README.md
index 161d5eec3b..83221c7223 100644
--- a/distribution/examples/message-transformation/replace/README.md
+++ b/distribution/examples/message-transformation/replace/README.md
@@ -3,7 +3,7 @@
The `Replace`plugin allows you to modify values in your JSON by using a `jsonPath` expression to target specific fields for replacement.
## Running the Example
-1. Run `service-proxy.bat` or `service-proxy.sh`
+1. Run `service-proxy.ps1` or `service-proxy.sh`
2. Send a request using `curl`:
```shell
diff --git a/distribution/examples/message-transformation/replace/service-proxy.bat b/distribution/examples/message-transformation/replace/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/message-transformation/replace/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/replace/service-proxy.ps1 b/distribution/examples/message-transformation/replace/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/message-transformation/replace/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/transformation-using-javascript/README.md b/distribution/examples/message-transformation/transformation-using-javascript/README.md
index 0ae1924832..909396cf8e 100644
--- a/distribution/examples/message-transformation/transformation-using-javascript/README.md
+++ b/distribution/examples/message-transformation/transformation-using-javascript/README.md
@@ -7,7 +7,7 @@ Transforming JSON into documents with a different format. Using Javascript you c
Execute the following steps in the `$MEMBRANE_HOME/examples/message-transformation/json2json-with-javascript` folder:
-1. Run `service-proxy.sh` or `service-proxy.bat` to start the API Gateway.
+1. Run `service-proxy.sh` or `service-proxy.ps1` to start the API Gateway.
2. Execute the following curls:
diff --git a/distribution/examples/message-transformation/transformation-using-javascript/requests.http b/distribution/examples/message-transformation/transformation-using-javascript/requests.http
index d6333bf9d7..d9e270ee31 100644
--- a/distribution/examples/message-transformation/transformation-using-javascript/requests.http
+++ b/distribution/examples/message-transformation/transformation-using-javascript/requests.http
@@ -1,6 +1,6 @@
# Sample Requests
#
-# 1. Start service-proxy.bat or service-proxy.sh
+# 1. Start service-proxy.ps1 or service-proxy.sh
# 2. Execute the requests in this document using:
# - IntelliJ (Plugin: https://plugins.jetbrains.com/plugin/13121-http-client) or
# - Visual Studio Code (Plugin https://marketplace.visualstudio.com/items?itemName=humao.rest-client)
diff --git a/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.bat b/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.ps1 b/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/message-transformation/transformation-using-javascript/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/xml2json/service-proxy.bat b/distribution/examples/message-transformation/xml2json/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/message-transformation/xml2json/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/message-transformation/xml2json/service-proxy.ps1 b/distribution/examples/message-transformation/xml2json/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/message-transformation/xml2json/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/ntlm/service-proxy.bat b/distribution/examples/ntlm/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/ntlm/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/ntlm/service-proxy.ps1 b/distribution/examples/ntlm/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/ntlm/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/api/README.md b/distribution/examples/oauth2/api/README.md
index 40bea2a529..3bbc960c10 100644
--- a/distribution/examples/oauth2/api/README.md
+++ b/distribution/examples/oauth2/api/README.md
@@ -15,7 +15,7 @@ In this example, Membrane acts as a pre-configured OAuth2 authorization server.
Steps to start the authorization server:
1. Open the `authorization_server` subfolder in a terminal.
-2. Run `service-proxy.bat` or `service-proxy.sh`.
+2. Run `service-proxy.ps1` or `service-proxy.sh`.
3. Verify the server is running by visiting [http://localhost:9000/admin](http://localhost:9000/admin).
### 2. Start the Server with the Protected Resource
@@ -24,7 +24,7 @@ The `token_validator` folder contains a Membrane setup that validates tokens and
Steps to start the token validator:
1. Open the `token_validator` folder in a terminal.
-2. Run `service-proxy.bat` or `service-proxy.sh` there.
+2. Run `service-proxy.ps1` or `service-proxy.sh` there.
3. Verify the resource side is running at [http://localhost:9001/admin](http://localhost:9001/admin).
### 3. Get a Token and Access the Protected Resource
diff --git a/distribution/examples/oauth2/api/authorization_server/service-proxy.bat b/distribution/examples/oauth2/api/authorization_server/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/api/authorization_server/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/api/authorization_server/service-proxy.ps1 b/distribution/examples/oauth2/api/authorization_server/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/api/authorization_server/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/api/token_validator/service-proxy.bat b/distribution/examples/oauth2/api/token_validator/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/api/token_validator/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/api/token_validator/service-proxy.ps1 b/distribution/examples/oauth2/api/token_validator/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/api/token_validator/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/azure-ad-with-jwts/README.md b/distribution/examples/oauth2/azure-ad-with-jwts/README.md
index b135a39d15..7be07a1813 100644
--- a/distribution/examples/oauth2/azure-ad-with-jwts/README.md
+++ b/distribution/examples/oauth2/azure-ad-with-jwts/README.md
@@ -102,7 +102,7 @@ Look at the file ``token.json`` and extract the token (Format should be similar
3. Replace ``2axxxx16-xxxx-xxxx-xxxx-faxxxxxxxxf0`` by your backend's Application ID URI (see section 1.)
4. Open a console in the same directory.
-5. Execute ``service-proxy.bat`` in the console and keep it running.
+5. Execute ``service-proxy.ps1`` in the console and keep it running.
## Token Validation
diff --git a/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.bat b/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.ps1 b/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/azure-ad-with-jwts/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/credentials/authorization_server/service-proxy.bat b/distribution/examples/oauth2/credentials/authorization_server/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/credentials/authorization_server/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/credentials/authorization_server/service-proxy.ps1 b/distribution/examples/oauth2/credentials/authorization_server/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/credentials/authorization_server/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/credentials/token_validator/service-proxy.bat b/distribution/examples/oauth2/credentials/token_validator/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/credentials/token_validator/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/credentials/token_validator/service-proxy.ps1 b/distribution/examples/oauth2/credentials/token_validator/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/credentials/token_validator/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/github/service-proxy.bat b/distribution/examples/oauth2/github/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/oauth2/github/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/github/service-proxy.ps1 b/distribution/examples/oauth2/github/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/github/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/github/service-proxySSL.bat b/distribution/examples/oauth2/github/service-proxySSL.bat
deleted file mode 100644
index 594e8e320a..0000000000
--- a/distribution/examples/oauth2/github/service-proxySSL.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxiesSSL.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/github/service-proxySSL.ps1 b/distribution/examples/oauth2/github/service-proxySSL.ps1
new file mode 100644
index 0000000000..ae3c6f9b26
--- /dev/null
+++ b/distribution/examples/oauth2/github/service-proxySSL.ps1
@@ -0,0 +1,68 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxiesSSL.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
diff --git a/distribution/examples/oauth2/google/service-proxy.bat b/distribution/examples/oauth2/google/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/oauth2/google/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/google/service-proxy.ps1 b/distribution/examples/oauth2/google/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/google/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/google/service-proxySSL.bat b/distribution/examples/oauth2/google/service-proxySSL.bat
deleted file mode 100644
index 594e8e320a..0000000000
--- a/distribution/examples/oauth2/google/service-proxySSL.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxiesSSL.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/google/service-proxySSL.ps1 b/distribution/examples/oauth2/google/service-proxySSL.ps1
new file mode 100644
index 0000000000..ae3c6f9b26
--- /dev/null
+++ b/distribution/examples/oauth2/google/service-proxySSL.ps1
@@ -0,0 +1,68 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxiesSSL.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
diff --git a/distribution/examples/oauth2/implicit/authorization_server/service-proxy.bat b/distribution/examples/oauth2/implicit/authorization_server/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/implicit/authorization_server/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/implicit/authorization_server/service-proxy.ps1 b/distribution/examples/oauth2/implicit/authorization_server/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/implicit/authorization_server/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/implicit/webserver/service-proxy.bat b/distribution/examples/oauth2/implicit/webserver/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/implicit/webserver/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/implicit/webserver/service-proxy.ps1 b/distribution/examples/oauth2/implicit/webserver/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/implicit/webserver/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/membrane/authorization_server/service-proxy.bat b/distribution/examples/oauth2/membrane/authorization_server/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/membrane/authorization_server/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/membrane/authorization_server/service-proxy.ps1 b/distribution/examples/oauth2/membrane/authorization_server/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/membrane/authorization_server/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/membrane/client/service-proxy.bat b/distribution/examples/oauth2/membrane/client/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/oauth2/membrane/client/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/membrane/client/service-proxy.ps1 b/distribution/examples/oauth2/membrane/client/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/membrane/client/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/oauth2/openid/service-proxy.bat b/distribution/examples/oauth2/openid/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/oauth2/openid/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/oauth2/openid/service-proxy.ps1 b/distribution/examples/oauth2/openid/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/oauth2/openid/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/openapi/openapi-proxy/service-proxy.bat b/distribution/examples/openapi/openapi-proxy/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/openapi/openapi-proxy/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/openapi/openapi-proxy/service-proxy.ps1 b/distribution/examples/openapi/openapi-proxy/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/openapi/openapi-proxy/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation-security/service-proxy.bat b/distribution/examples/openapi/validation-security/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/openapi/validation-security/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation-security/service-proxy.ps1 b/distribution/examples/openapi/validation-security/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/openapi/validation-security/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation-simple/service-proxy.bat b/distribution/examples/openapi/validation-simple/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/openapi/validation-simple/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation-simple/service-proxy.ps1 b/distribution/examples/openapi/validation-simple/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/openapi/validation-simple/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation/service-proxy.bat b/distribution/examples/openapi/validation/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/openapi/validation/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/openapi/validation/service-proxy.ps1 b/distribution/examples/openapi/validation/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/openapi/validation/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/opentelemetry/README.md b/distribution/examples/opentelemetry/README.md
index a60236b0d8..41e0da9f5b 100644
--- a/distribution/examples/opentelemetry/README.md
+++ b/distribution/examples/opentelemetry/README.md
@@ -14,7 +14,7 @@ To instrument an API add the `opentelemetry` plugin to it.
docker run -d --name jaeger -e COLLECTOR_OTLP_ENABLED=true -p 16686:16686 -p 4317:4317 -p 4318:4318 jaegertracing/all-in-one:latest
```
-2. Run `service-proxy.bat` or `./service-proxy.sh` to start Membrane.
+2. Run `service-proxy.ps1` or `./service-proxy.sh` to start Membrane.
3. Call the first endpoint in the telemetry chain:
diff --git a/distribution/examples/opentelemetry/service-proxy.bat b/distribution/examples/opentelemetry/service-proxy.bat
deleted file mode 100644
index f52742878e..0000000000
--- a/distribution/examples/opentelemetry/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/opentelemetry/service-proxy.ps1 b/distribution/examples/opentelemetry/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/opentelemetry/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/rateLimiter/README.md b/distribution/examples/rateLimiter/README.md
index 70f7ae8001..ca194d0c84 100644
--- a/distribution/examples/rateLimiter/README.md
+++ b/distribution/examples/rateLimiter/README.md
@@ -11,7 +11,7 @@ In this example we will send 4 requests to the service with a rate limit of 3 re
2. Go to the `examples/rateLimiter` directory.
-3. Execute `service-proxy.bat`
+3. Execute `service-proxy.ps1`
4. Run the command line
diff --git a/distribution/examples/rateLimiter/service-proxy.bat b/distribution/examples/rateLimiter/service-proxy.bat
deleted file mode 100644
index 57a0fde463..0000000000
--- a/distribution/examples/rateLimiter/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/rateLimiter/service-proxy.ps1 b/distribution/examples/rateLimiter/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/rateLimiter/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/rest2soap-json/README.md b/distribution/examples/rest2soap-json/README.md
index 5de1d7e3d8..6566c40a6b 100644
--- a/distribution/examples/rest2soap-json/README.md
+++ b/distribution/examples/rest2soap-json/README.md
@@ -20,7 +20,7 @@ To test the router we will use the command line tool curl that can transfer data
To run the example execute the following steps:
-1. Execute `service-proxy.bat` or `service-proxy.sh`.
+1. Execute `service-proxy.ps1` or `service-proxy.sh`.
2. Open a new console and execute `curl --header "Accept: application/json" http://localhost:2000/bank/37050198`
diff --git a/distribution/examples/rest2soap-json/service-proxy.bat b/distribution/examples/rest2soap-json/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/rest2soap-json/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/rest2soap-json/service-proxy.ps1 b/distribution/examples/rest2soap-json/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/rest2soap-json/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/rest2soap/README.md b/distribution/examples/rest2soap/README.md
index ccfdc2f1a5..dc5c6caf66 100644
--- a/distribution/examples/rest2soap/README.md
+++ b/distribution/examples/rest2soap/README.md
@@ -15,7 +15,7 @@ To run the example execute the following steps:
1. Go to the `examples/rest2soap` directory.
-2. Execute `service-proxy.bat` or `service-proxy.sh`
+2. Execute `service-proxy.ps1` or `service-proxy.sh`
3. Open the URL http://localhost:2000/bank/37050198 in your browser.
diff --git a/distribution/examples/rest2soap/service-proxy.bat b/distribution/examples/rest2soap/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/rest2soap/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/rest2soap/service-proxy.ps1 b/distribution/examples/rest2soap/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/rest2soap/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/rewriter/openapi/README.md b/distribution/examples/rewriter/openapi/README.md
index 01fbf3c729..bc1f0af89e 100644
--- a/distribution/examples/rewriter/openapi/README.md
+++ b/distribution/examples/rewriter/openapi/README.md
@@ -11,7 +11,7 @@ Using the rewriter in the [OpenAPI](../../openapi) element, you can rewrite the
servers:
- url: http://localhost:2000/demo-api/v1/
```
-3. Execute `service-proxy.sh` or `service-proxy.bat`.
+3. Execute `service-proxy.sh` or `service-proxy.ps1`.
4. Review the [proxies.xml](./proxies.xml) configuration.
```xml
diff --git a/distribution/examples/rewriter/openapi/service-proxy.bat b/distribution/examples/rewriter/openapi/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/rewriter/openapi/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/rewriter/openapi/service-proxy.ps1 b/distribution/examples/rewriter/openapi/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/rewriter/openapi/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/rewriter/regex/README.md b/distribution/examples/rewriter/regex/README.md
index aa958c3b5d..5da6b2c9bd 100644
--- a/distribution/examples/rewriter/regex/README.md
+++ b/distribution/examples/rewriter/regex/README.md
@@ -12,7 +12,7 @@ We want to access this API with the path `store/products/`. To do this we have t
1. Go to the `examples/rewriter/regex` directory.
-2. Execute `service-proxy.bat`
+2. Execute `service-proxy.ps1`
3. Open the URL http://localhost:2000/store/products/ in your browser.
---
diff --git a/distribution/examples/rewriter/regex/service-proxy.bat b/distribution/examples/rewriter/regex/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/rewriter/regex/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/rewriter/regex/service-proxy.ps1 b/distribution/examples/rewriter/regex/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/rewriter/regex/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/api-key/apikey-openapi/README.md b/distribution/examples/security/api-key/apikey-openapi/README.md
index 5162ac6f57..88f39190c8 100644
--- a/distribution/examples/security/api-key/apikey-openapi/README.md
+++ b/distribution/examples/security/api-key/apikey-openapi/README.md
@@ -4,7 +4,7 @@ This example shows how to use API keys with role-based access control (RBAC). An
## 1. Accessing the API
1. **Navigate** to the `examples/security/api-key/apikey-openapi` directory.
-2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3. Open `http://localhost:2000/api-docs`.
4. Click on `Fruit Shop API`
5. Expand 'GET /products', click on `Try it out` and then on `execute`.
diff --git a/distribution/examples/security/api-key/apikey-openapi/service-proxy.bat b/distribution/examples/security/api-key/apikey-openapi/service-proxy.bat
deleted file mode 100644
index a9ff5b820d..0000000000
--- a/distribution/examples/security/api-key/apikey-openapi/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/security/api-key/apikey-openapi/service-proxy.ps1 b/distribution/examples/security/api-key/apikey-openapi/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/api-key/apikey-openapi/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/api-key/rbac/README.md b/distribution/examples/security/api-key/rbac/README.md
index 995eef59c9..1dc6fa8e68 100644
--- a/distribution/examples/security/api-key/rbac/README.md
+++ b/distribution/examples/security/api-key/rbac/README.md
@@ -6,7 +6,7 @@ Secure endpoints using API keys combined with role-based access control (RBAC).
***Note:*** *The requests are also available in the requests.http file.*
1. **Navigate** to the `examples/security/api-key/rbac` directory.
-2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3**Test Optional API Key with RBAC**:
- Access with a non-admin scope key to receive limited access:
```
diff --git a/distribution/examples/security/api-key/rbac/service-proxy.bat b/distribution/examples/security/api-key/rbac/service-proxy.bat
deleted file mode 100644
index a9ff5b820d..0000000000
--- a/distribution/examples/security/api-key/rbac/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/security/api-key/rbac/service-proxy.ps1 b/distribution/examples/security/api-key/rbac/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/api-key/rbac/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/api-key/simple/README.md b/distribution/examples/security/api-key/simple/README.md
index 10a253f528..d184f44b25 100644
--- a/distribution/examples/security/api-key/simple/README.md
+++ b/distribution/examples/security/api-key/simple/README.md
@@ -6,7 +6,7 @@ Secure endpoints using API keys.
***Note:*** *The requests are also available in the requests.http file.*
1. **Navigate** to the `examples/security/api-key/simple` directory.
-2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3. **Test Mandatory API Key Authentication**:
- Send a request without an API key to see access denial:
```
diff --git a/distribution/examples/security/api-key/simple/service-proxy.bat b/distribution/examples/security/api-key/simple/service-proxy.bat
deleted file mode 100644
index a9ff5b820d..0000000000
--- a/distribution/examples/security/api-key/simple/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/security/api-key/simple/service-proxy.ps1 b/distribution/examples/security/api-key/simple/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/api-key/simple/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/basic-auth/database/README.md b/distribution/examples/security/basic-auth/database/README.md
index a66344023d..139c319e6a 100644
--- a/distribution/examples/security/basic-auth/database/README.md
+++ b/distribution/examples/security/basic-auth/database/README.md
@@ -27,7 +27,7 @@ This example walks you through setting up **HTTP Basic Authentication** for an A
VALUES ('johnsmith123', 'pass123'), ('membrane', 'proxy');
```
-5. Execute `service-proxy.bat` or `service-proxy.sh`.
+5. Execute `service-proxy.ps1` or `service-proxy.sh`.
6. Open the URL http://localhost:2000 in your browser.
diff --git a/distribution/examples/security/basic-auth/database/service-proxy.bat b/distribution/examples/security/basic-auth/database/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/security/basic-auth/database/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/security/basic-auth/database/service-proxy.ps1 b/distribution/examples/security/basic-auth/database/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/basic-auth/database/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/basic-auth/simple/README.md b/distribution/examples/security/basic-auth/simple/README.md
index a0131a8071..ff2372ff11 100644
--- a/distribution/examples/security/basic-auth/simple/README.md
+++ b/distribution/examples/security/basic-auth/simple/README.md
@@ -8,7 +8,7 @@ This example explains how to protect an API or a Web application using __HTTP Ba
1. Go to the `examples/security/basic-auth/simple` directory.
-2. Execute `service-proxy.bat` or `service-proxy.sh`
+2. Execute `service-proxy.ps1` or `service-proxy.sh`
3. Open the URL http://localhost:2000 in your browser.
diff --git a/distribution/examples/security/basic-auth/simple/service-proxy.bat b/distribution/examples/security/basic-auth/simple/service-proxy.bat
deleted file mode 100644
index 7f906b97ce..0000000000
--- a/distribution/examples/security/basic-auth/simple/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/security/basic-auth/simple/service-proxy.ps1 b/distribution/examples/security/basic-auth/simple/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/basic-auth/simple/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/json-protection/README.md b/distribution/examples/security/json-protection/README.md
index ad1a143ae3..27d4ee1ddf 100644
--- a/distribution/examples/security/json-protection/README.md
+++ b/distribution/examples/security/json-protection/README.md
@@ -17,7 +17,7 @@ Membrane can identify misuse in JSON documents such as duplicate fields, unusual
**Windows**:
```shell
cd examples/security/json-protection
- service-proxy.bat
+ service-proxy.ps1
```
2. Send a message violating the configuration. Depth is set to a maximum of 3.
diff --git a/distribution/examples/security/json-protection/service-proxy.bat b/distribution/examples/security/json-protection/service-proxy.bat
deleted file mode 100644
index 1798a43dbd..0000000000
--- a/distribution/examples/security/json-protection/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/security/json-protection/service-proxy.ps1 b/distribution/examples/security/json-protection/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/json-protection/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/security/padding-header/README.md b/distribution/examples/security/padding-header/README.md
index 814e7f4595..4a9f412f95 100644
--- a/distribution/examples/security/padding-header/README.md
+++ b/distribution/examples/security/padding-header/README.md
@@ -5,7 +5,7 @@ The Padding Header is utilized to protect against [breach attacks](https://nvd.n
## Running the Sample
1. Go to the `examples/security/padding-header` directory.
-2. Run `service-proxy.sh` or `service-proxy.bat` to start the API Gateway.
+2. Run `service-proxy.sh` or `service-proxy.ps1` to start the API Gateway.
3. Send a request to http://localhost:2000:
```
curl http://localhost:2000 -v
diff --git a/distribution/examples/security/padding-header/service-proxy.bat b/distribution/examples/security/padding-header/service-proxy.bat
deleted file mode 100644
index 1798a43dbd..0000000000
--- a/distribution/examples/security/padding-header/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
diff --git a/distribution/examples/security/padding-header/service-proxy.ps1 b/distribution/examples/security/padding-header/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/security/padding-header/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.bat b/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.ps1 b/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/service-discovery-with-etcd/configurator/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.bat b/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.ps1 b/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/service-discovery-with-etcd/publisher/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/shadowing/README.md b/distribution/examples/shadowing/README.md
index 8834a872a5..6fe5af6101 100644
--- a/distribution/examples/shadowing/README.md
+++ b/distribution/examples/shadowing/README.md
@@ -4,7 +4,7 @@ This example demonstrates how to send requests to multiple shadow hosts. A reque
## Running the Example
-1. Run `service-proxy.bat` or `service-proxy.sh`
+1. Run `service-proxy.ps1` or `service-proxy.sh`
2. Open [localhost:2000](http://localhost:2000) in your browser or use `curl`:
```
diff --git a/distribution/examples/shadowing/service-proxy.bat b/distribution/examples/shadowing/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/shadowing/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/shadowing/service-proxy.ps1 b/distribution/examples/shadowing/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/shadowing/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/soap/add-soap-header/README.md b/distribution/examples/soap/add-soap-header/README.md
index d800003df1..681eac3bd9 100644
--- a/distribution/examples/soap/add-soap-header/README.md
+++ b/distribution/examples/soap/add-soap-header/README.md
@@ -59,7 +59,7 @@ Run the appropriate command based on your operating system:
./service-proxy.sh
# For Windows
- service-proxy.bat
+ service-proxy.ps1
```
### Step 5: Test the Service
diff --git a/distribution/examples/soap/add-soap-header/pom.xml b/distribution/examples/soap/add-soap-header/pom.xml
index 92be9fc27f..bdee32672e 100644
--- a/distribution/examples/soap/add-soap-header/pom.xml
+++ b/distribution/examples/soap/add-soap-header/pom.xml
@@ -18,7 +18,7 @@
org.membrane-soa
service-proxy-core
- 5.8.1-SNAPSHOT
+ 6.0.0-SNAPSHOT
diff --git a/distribution/examples/soap/add-soap-header/service-proxy.bat b/distribution/examples/soap/add-soap-header/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/soap/add-soap-header/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/soap/add-soap-header/service-proxy.ps1 b/distribution/examples/soap/add-soap-header/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/soap/add-soap-header/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/soap/add-soap-header/src/main/java/com/predic8/AddSoapHeaderInterceptor.java b/distribution/examples/soap/add-soap-header/src/main/java/com/predic8/AddSoapHeaderInterceptor.java
index bcf87d4831..a0909f2487 100644
--- a/distribution/examples/soap/add-soap-header/src/main/java/com/predic8/AddSoapHeaderInterceptor.java
+++ b/distribution/examples/soap/add-soap-header/src/main/java/com/predic8/AddSoapHeaderInterceptor.java
@@ -14,7 +14,6 @@
package com.predic8;
-import com.predic8.membrane.annot.MCElement;
import com.predic8.membrane.core.exchange.Exchange;
import com.predic8.membrane.core.http.Message;
import com.predic8.membrane.core.interceptor.AbstractInterceptor;
@@ -23,9 +22,11 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
@@ -36,20 +37,24 @@
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
-public class AddSoapHeaderInterceptor extends AbstractInterceptor{
+public class AddSoapHeaderInterceptor extends AbstractInterceptor {
@Override
- public Outcome handleRequest(Exchange exc) throws Exception {
+ public Outcome handleRequest(Exchange exc) {
if(!exc.getRequest().isXML()){
return Outcome.CONTINUE;
}
- this.addHeaderNode(exc.getRequest());
+ try {
+ this.addHeaderNode(exc.getRequest());
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
return Outcome.CONTINUE;
}
- private void addHeaderNode(Message res){
+ private void addHeaderNode(Message res) throws XMLStreamException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
@@ -89,7 +94,6 @@ private void addHeaderNode(Message res){
} catch (ParserConfigurationException | SAXException | IOException | TransformerException e) {
e.printStackTrace();
}
-
}
private String docToString(Document doc) throws TransformerException {
diff --git a/distribution/examples/soap/sample-soap-service/README.md b/distribution/examples/soap/sample-soap-service/README.md
index 7ab7cd010e..8cbc89d4a6 100644
--- a/distribution/examples/soap/sample-soap-service/README.md
+++ b/distribution/examples/soap/sample-soap-service/README.md
@@ -5,7 +5,7 @@ This plugin offers a sample SOAP service that can be used in tutorials and for t
## Starting the Service
1. Go to the `examples/soap/sample-soap-service` directory.
-2. Run `service-proxy.sh` or `service-proxy.bat` to start the API Gateway.
+2. Run `service-proxy.sh` or `service-proxy.ps1` to start the API Gateway.
## Using the Service
### Get the WSDL
diff --git a/distribution/examples/soap/sample-soap-service/service-proxy.bat b/distribution/examples/soap/sample-soap-service/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/soap/sample-soap-service/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/soap/sample-soap-service/service-proxy.ps1 b/distribution/examples/soap/sample-soap-service/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/soap/sample-soap-service/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/spel/README.md b/distribution/examples/spel/README.md
index 980afb77bb..6b7fac3eca 100644
--- a/distribution/examples/spel/README.md
+++ b/distribution/examples/spel/README.md
@@ -13,7 +13,7 @@ In this example we will visit a website and take a look at the logs in the conso
2. Look at file `proxies.xml` ( maybe change some properties )
-3. Execute `service-proxy.bat`
+3. Execute `service-proxy.ps1`
4. Open the URL [http://localhost:${LISTEN_PORT}/](http://localhost:${LISTEN_PORT}/) in your browser. Where LISTEN_PORT is value defined in `proxies.xml`
diff --git a/distribution/examples/spel/service-proxy.bat b/distribution/examples/spel/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/spel/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/spel/service-proxy.ps1 b/distribution/examples/spel/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/spel/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/ssl/api-with-tls-pem/README.md b/distribution/examples/ssl/api-with-tls-pem/README.md
index d1e01fab45..5fdcac4802 100644
--- a/distribution/examples/ssl/api-with-tls-pem/README.md
+++ b/distribution/examples/ssl/api-with-tls-pem/README.md
@@ -5,7 +5,7 @@ This example describes how to secure an API with SSL/TLS using PEM formatted fil
## Running the Example
-1. Run `service-proxy.bat` or `service-proxy.sh`
+1. Run `service-proxy.ps1` or `service-proxy.sh`
2. Open the following URL in your browser. Please do not forget to use `https` instead of `http`.
`https://localhost/`
diff --git a/distribution/examples/ssl/api-with-tls-pem/service-proxy.bat b/distribution/examples/ssl/api-with-tls-pem/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/ssl/api-with-tls-pem/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/ssl/api-with-tls-pem/service-proxy.ps1 b/distribution/examples/ssl/api-with-tls-pem/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/ssl/api-with-tls-pem/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/ssl/api-with-tls-pkcs12/README.md b/distribution/examples/ssl/api-with-tls-pkcs12/README.md
index fca467442f..cf1713059f 100644
--- a/distribution/examples/ssl/api-with-tls-pkcs12/README.md
+++ b/distribution/examples/ssl/api-with-tls-pkcs12/README.md
@@ -5,7 +5,7 @@ This example describes how to secure an API with SSL/TLS using a keystore in the
## Running the Example
-1. Run `service-proxy.bat` or `service-proxy.sh`
+1. Run `service-proxy.ps1` or `service-proxy.sh`
2. Open the following URL in your browser. Please do not forget to use `https` instead of `http`.
`https://localhost/`
diff --git a/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.bat b/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.ps1 b/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/ssl/api-with-tls-pkcs12/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/ssl/to-backend/README.md b/distribution/examples/ssl/to-backend/README.md
index 6b0eb7c654..82137d3225 100644
--- a/distribution/examples/ssl/to-backend/README.md
+++ b/distribution/examples/ssl/to-backend/README.md
@@ -5,7 +5,7 @@
In the example we will route to an SSL protected API.
-1. Execute `service-proxy.sh` or `service-proxy.bat`
+1. Execute `service-proxy.sh` or `service-proxy.ps1`
2. Open the URL http://localhost:2000 in your browser.
diff --git a/distribution/examples/ssl/to-backend/service-proxy.bat b/distribution/examples/ssl/to-backend/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/ssl/to-backend/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/ssl/to-backend/service-proxy.ps1 b/distribution/examples/ssl/to-backend/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/ssl/to-backend/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/stax-interceptor/README.md b/distribution/examples/stax-interceptor/README.md
index a347111ceb..d39ca44261 100644
--- a/distribution/examples/stax-interceptor/README.md
+++ b/distribution/examples/stax-interceptor/README.md
@@ -53,7 +53,7 @@ Run the Membrane service proxy:
./service-proxy.sh
# For Windows
-service-proxy.bat
+service-proxy.ps1
```
### Step 4: Test the Transformation
diff --git a/distribution/examples/stax-interceptor/pom.xml b/distribution/examples/stax-interceptor/pom.xml
index 52272e9a6c..843952231e 100644
--- a/distribution/examples/stax-interceptor/pom.xml
+++ b/distribution/examples/stax-interceptor/pom.xml
@@ -19,7 +19,7 @@
org.membrane-soa
service-proxy-core
- 5.8.1-SNAPSHOT
+ 6.0.0-SNAPSHOT
diff --git a/distribution/examples/stax-interceptor/service-proxy.bat b/distribution/examples/stax-interceptor/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/stax-interceptor/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/stax-interceptor/service-proxy.ps1 b/distribution/examples/stax-interceptor/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/stax-interceptor/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/stax-interceptor/src/main/java/com/predic8/StaxConverterInterceptor.java b/distribution/examples/stax-interceptor/src/main/java/com/predic8/StaxConverterInterceptor.java
index 8df3e5df2d..fb38fb7368 100644
--- a/distribution/examples/stax-interceptor/src/main/java/com/predic8/StaxConverterInterceptor.java
+++ b/distribution/examples/stax-interceptor/src/main/java/com/predic8/StaxConverterInterceptor.java
@@ -43,20 +43,25 @@ public class StaxConverterInterceptor extends AbstractInterceptor implements XML
@Override
- public Outcome handleRequest(Exchange exc) throws Exception {
+ public Outcome handleRequest(Exchange exc) {
return handleInternal(exc.getRequest());
}
@Override
- public Outcome handleResponse(Exchange exc) throws Exception {
+ public Outcome handleResponse(Exchange exc) {
return handleInternal(exc.getResponse());
}
- private Outcome handleInternal(Message msg) throws Exception {
+ private Outcome handleInternal(Message msg) {
if(!msg.isXML()){
return CONTINUE;
}
- replaceTag(msg);
+
+ try {
+ replaceTag(msg);
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
return CONTINUE;
}
diff --git a/distribution/examples/stomp-over-websocket-intercepting/service-proxy.bat b/distribution/examples/stomp-over-websocket-intercepting/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/stomp-over-websocket-intercepting/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/stomp-over-websocket-intercepting/service-proxy.ps1 b/distribution/examples/stomp-over-websocket-intercepting/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/stomp-over-websocket-intercepting/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/template/json/service-proxy.ps1 b/distribution/examples/template/json/service-proxy.ps1
index 800b7eee16..d21fb44423 100644
--- a/distribution/examples/template/json/service-proxy.ps1
+++ b/distribution/examples/template/json/service-proxy.ps1
@@ -3,6 +3,7 @@ $required_version = "21"
function Start-MembraneService {
param([string]$membrane_home)
+ $env:MEMBRANE_HOME = $membrane_home
$CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
Write-Host "Starting: $membrane_home CL: $CLASSPATH"
& java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
@@ -65,4 +66,4 @@ try {
} catch {
Write-Host "Error checking Java version: $_"
exit 1
-}
+}
\ No newline at end of file
diff --git a/distribution/examples/template/text/README.md b/distribution/examples/template/text/README.md
index 24c1279e70..ec7ae08c71 100644
--- a/distribution/examples/template/text/README.md
+++ b/distribution/examples/template/text/README.md
@@ -12,7 +12,7 @@ Execute the following steps:
2. Have a look at `proxies.xml`.
-2. Open a commandline and execute `service-proxy.sh` or `service-proxy.bat`
+2. Open a commandline and execute `service-proxy.sh` or `service-proxy.ps1`
3. Run this command from a second commandline:
diff --git a/distribution/examples/template/text/service-proxy.bat b/distribution/examples/template/text/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/template/text/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/template/text/service-proxy.ps1 b/distribution/examples/template/text/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/template/text/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/template/xml/README.md b/distribution/examples/template/xml/README.md
index 4804b420b8..0789fddeb2 100644
--- a/distribution/examples/template/xml/README.md
+++ b/distribution/examples/template/xml/README.md
@@ -12,7 +12,7 @@ Execute the following steps:
2. Have a look at `proxies.xml`.
-3. Open a commandline and execute `service-proxy.sh` or `service-proxy.bat`
+3. Open a commandline and execute `service-proxy.sh` or `service-proxy.ps1`
4. Run this command from a second commandline:
diff --git a/distribution/examples/template/xml/service-proxy.bat b/distribution/examples/template/xml/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/template/xml/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/template/xml/service-proxy.ps1 b/distribution/examples/template/xml/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/template/xml/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/throttle/service-proxy.bat b/distribution/examples/throttle/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/throttle/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/throttle/service-proxy.ps1 b/distribution/examples/throttle/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/throttle/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/validation/form/service-proxy.bat b/distribution/examples/validation/form/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/validation/form/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/validation/form/service-proxy.ps1 b/distribution/examples/validation/form/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/validation/form/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/validation/graphql/README.md b/distribution/examples/validation/graphql/README.md
index 37090b5791..6f39a7996e 100644
--- a/distribution/examples/validation/graphql/README.md
+++ b/distribution/examples/validation/graphql/README.md
@@ -6,7 +6,7 @@ Check GraphQL-over-HTTP requests, enforcing several limits and restrictions to m
## Running the Example
1. **Navigate** to the `examples/validation/graphql` directory in a terminal.
-2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.bat` (Windows).
+2. **Start** the API Gateway by executing `service-proxy.sh` (Linux/Mac) or `service-proxy.ps1` (Windows).
3. **Query** the protected API by opening the `requests.http` file in VS Code or IntelliJ IDEA to execute the querries.
## How it works
diff --git a/distribution/examples/validation/graphql/service-proxy.bat b/distribution/examples/validation/graphql/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/validation/graphql/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/validation/graphql/service-proxy.ps1 b/distribution/examples/validation/graphql/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/validation/graphql/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/validation/json-schema/README.md b/distribution/examples/validation/json-schema/README.md
index 5d9015f52b..537903b891 100644
--- a/distribution/examples/validation/json-schema/README.md
+++ b/distribution/examples/validation/json-schema/README.md
@@ -7,7 +7,7 @@ This sample explains how to set up and use the `validator` plugin, utilizing JSO
1. Go to the directory `/examples/validation/json-schema`.
-2. Start `service-proxy.bat` or `service-proxy.sh`.
+2. Start `service-proxy.ps1` or `service-proxy.sh`.
3. Look at `schema2000.json` and compare the schema to `good2000.json` and `bad2000.json`.
diff --git a/distribution/examples/validation/json-schema/service-proxy.bat b/distribution/examples/validation/json-schema/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/validation/json-schema/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/validation/json-schema/service-proxy.ps1 b/distribution/examples/validation/json-schema/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/validation/json-schema/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/validation/soap-Proxy/README.md b/distribution/examples/validation/soap-Proxy/README.md
index ab701f7f5e..c08ea40def 100644
--- a/distribution/examples/validation/soap-Proxy/README.md
+++ b/distribution/examples/validation/soap-Proxy/README.md
@@ -8,7 +8,7 @@ This sample explains how to set up and use the `validator` plugin within a `soap
1. Go to `/examples/validation/soap-Proxy`
-2. Start `service-proxy.bat` or `service-proxy.sh`
+2. Start `service-proxy.ps1` or `service-proxy.sh`
3. Run the following command, observe a successful response:
diff --git a/distribution/examples/validation/soap-Proxy/service-proxy.bat b/distribution/examples/validation/soap-Proxy/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/validation/soap-Proxy/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/validation/soap-Proxy/service-proxy.ps1 b/distribution/examples/validation/soap-Proxy/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/validation/soap-Proxy/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/validation/xml/README.md b/distribution/examples/validation/xml/README.md
index 4cfc9dfd46..31ebb06a69 100644
--- a/distribution/examples/validation/xml/README.md
+++ b/distribution/examples/validation/xml/README.md
@@ -8,7 +8,7 @@ This sample explains how to set up and use the `validator` plugin, utilizing XML
1. Go to the directory `/examples/validation/xml`.
-2. Start `service-proxy.bat` or `service-proxy.sh`.
+2. Start `service-proxy.ps1` or `service-proxy.sh`.
3. Run `curl -d @year.xml http://localhost:2000/`. Observe that you get a successful response.
diff --git a/distribution/examples/validation/xml/service-proxy.bat b/distribution/examples/validation/xml/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/validation/xml/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/validation/xml/service-proxy.ps1 b/distribution/examples/validation/xml/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/validation/xml/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/versioning/soap-xslt/README.md b/distribution/examples/versioning/soap-xslt/README.md
index f7b3348668..2e7f532eae 100644
--- a/distribution/examples/versioning/soap-xslt/README.md
+++ b/distribution/examples/versioning/soap-xslt/README.md
@@ -20,7 +20,7 @@ In many enterprise environments, services evolve over time, resulting in differe
./service-proxy.sh
# For Windows
- service-proxy.bat
+ service-proxy.ps1
```
3. **Send a SOAP Request (New Version)**
diff --git a/distribution/examples/versioning/soap-xslt/service-proxy.bat b/distribution/examples/versioning/soap-xslt/service-proxy.bat
deleted file mode 100644
index 6742f74b41..0000000000
--- a/distribution/examples/versioning/soap-xslt/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/versioning/soap-xslt/service-proxy.ps1 b/distribution/examples/versioning/soap-xslt/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/versioning/soap-xslt/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/websocket-intercepting/service-proxy.bat b/distribution/examples/websocket-intercepting/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/websocket-intercepting/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/websocket-intercepting/service-proxy.ps1 b/distribution/examples/websocket-intercepting/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/websocket-intercepting/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/websocket-intercepting/startWebsocket.bat b/distribution/examples/websocket-intercepting/startWebsocket.bat
deleted file mode 100644
index 2f9afa9022..0000000000
--- a/distribution/examples/websocket-intercepting/startWebsocket.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-echo please wait
-call npm install
-call npm start
\ No newline at end of file
diff --git a/distribution/examples/websocket-intercepting/startWebsocket.ps1 b/distribution/examples/websocket-intercepting/startWebsocket.ps1
new file mode 100644
index 0000000000..772888c967
--- /dev/null
+++ b/distribution/examples/websocket-intercepting/startWebsocket.ps1
@@ -0,0 +1,3 @@
+echo "please wait"
+npm install
+npm start
\ No newline at end of file
diff --git a/distribution/examples/websocket-stomp/README.md b/distribution/examples/websocket-stomp/README.md
index 3a61e73fc4..9c142adb54 100644
--- a/distribution/examples/websocket-stomp/README.md
+++ b/distribution/examples/websocket-stomp/README.md
@@ -25,7 +25,7 @@ the Running instructions.
3. Go to the `examples/websocket-stomp directory`.
-4. Execute `service-proxy.sh` / `service-proxy.bat`
+4. Execute `service-proxy.sh` / `service-proxy.ps1`
5. Open the URL http://localhost:8161/admin/queues.jsp in your browser.
diff --git a/distribution/examples/websocket-stomp/service-proxy.bat b/distribution/examples/websocket-stomp/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/websocket-stomp/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/websocket-stomp/service-proxy.ps1 b/distribution/examples/websocket-stomp/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/websocket-stomp/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/examples/xslt/README.md b/distribution/examples/xslt/README.md
index 1818faebe9..fee1f2c4dc 100644
--- a/distribution/examples/xslt/README.md
+++ b/distribution/examples/xslt/README.md
@@ -9,7 +9,7 @@ Execute the following steps:
1. Go to the `examples/xslt` directory.
-2. Execute `service-proxy.bat` or `service-proxy.sh`
+2. Execute `service-proxy.ps1` or `service-proxy.sh`
2. Open the URL https://api.predic8.de/restnames/name.groovy?name=Pia in your browser.
diff --git a/distribution/examples/xslt/service-proxy.bat b/distribution/examples/xslt/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/examples/xslt/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/examples/xslt/service-proxy.ps1 b/distribution/examples/xslt/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/examples/xslt/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/router/README.txt b/distribution/router/README.txt
index 2da672d171..8ad3b3b9e0 100644
--- a/distribution/router/README.txt
+++ b/distribution/router/README.txt
@@ -8,7 +8,7 @@ Running API Gateway
Make sure you have installed Java 17 or higher. Then do the following:
* Starting the Service Proxy (Windows)
- Execute service-proxy.bat
+ Execute service-proxy.ps1
* Starting the Service Proxy (Linux)
Execute service-proxy.sh
diff --git a/distribution/router/conf/proxies-offline.xml b/distribution/router/conf/proxies-offline.xml
index 3999270e3d..eb3834d3ba 100644
--- a/distribution/router/conf/proxies-offline.xml
+++ b/distribution/router/conf/proxies-offline.xml
@@ -4,7 +4,7 @@
Start Membrane with:
./service-proxy.sh -c conf/proxies-offline.xml
or
- service-proxy.bat -c conf/proxies-offline.xml
+ service-proxy.ps1 -c conf/proxies-offline.xml
-->
&1 | ForEach-Object {
- if ($_ -match "version") {
- $version_line = $_
- }
-}
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
-if (-not $version_line) {
- Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
- if (-not $env:MEMBRANE_HOME) {
- $env:MEMBRANE_HOME = Resolve-MembraneHome $PSCommandPath
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
}
- Start-MembraneRouter $env:MEMBRANE_HOME $args
- exit 0
-}
-$full_version = [regex]::Match($version_line, '"([^"]+)"').Groups[1].Value
-$current_version = [int]($full_version.Split('.')[0])
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
-if ($current_version -ge $required_version) {
- Write-Host $env:MEMBRANE_HOME
- if (-not $env:MEMBRANE_HOME) {
- $env:MEMBRANE_HOME = Resolve-MembraneHome $PSCommandPath
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
}
- Start-MembraneRouter $env:MEMBRANE_HOME $args
- exit 0
-} else {
- Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+} catch {
+ Write-Host "Error checking Java version: $_"
exit 1
}
diff --git a/distribution/router/service-proxy.sh b/distribution/router/service-proxy.sh
index 9e668c1b1e..2ef17db3ea 100644
--- a/distribution/router/service-proxy.sh
+++ b/distribution/router/service-proxy.sh
@@ -4,39 +4,38 @@ required_version="21"
start() {
membrane_home="$1"
- shift
- CLASSPATH="$membrane_home/conf:$membrane_home/lib/*"
- echo "Membrane Router running..."
- exec java $JAVA_OPTS -classpath "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI "$@"
+ export CLASSPATH="$membrane_home/conf:$membrane_home/lib/*"
+ echo "Starting: $membrane_home CL: $CLASSPATH"
+ java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI
}
-resolve_membrane_home() {
- PRG="$1"
+find_membrane_directory() {
+ current="$1"
- # Resolve symlinks
- while [ -h "$PRG" ]; do
- ls=$(ls -ld "$PRG")
- link=$(expr "$ls" : '.*-> \(.*\)$')
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="$(dirname "$PRG")/$link"
+ while [ "$current" != "/" ]; do
+ if [ -d "$current/conf" ] && [ -d "$current/lib" ]; then
+ echo "$current"
+ return 0
fi
+ current=$(dirname "$current")
done
- saveddir=$(pwd)
- MEMBRANE_HOME=$(dirname "$PRG")
- MEMBRANE_HOME=$(cd "$MEMBRANE_HOME" && pwd)
- cd "$saveddir"
+ return 1
+}
- echo "$MEMBRANE_HOME"
+start_membrane() {
+ membrane_home=$(find_membrane_directory "$(pwd)")
+ if [ $? -eq 0 ]; then
+ start "$membrane_home"
+ else
+ echo "Could not start Membrane. Ensure the directory structure is correct."
+ fi
}
if ! ( _test=test && _="${_test#t}" ) >/dev/null 2>&1; then
echo "WARNING: Shell does not support parameter expansion. Java version check disabled!" >&2
echo " Please ensure Java $required_version is installed." >&2
- MEMBRANE_HOME=$(resolve_membrane_home "$0")
- start "$MEMBRANE_HOME" "$@"
+ start_membrane
exit 0
fi
@@ -49,8 +48,7 @@ version_line=$(java -version 2>&1 | grep "version" | head -n 1)
if [ -z "$version_line" ]; then
echo "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
- MEMBRANE_HOME=$(resolve_membrane_home "$0")
- start "$MEMBRANE_HOME" "$@"
+ start_membrane
exit 0
fi
@@ -61,15 +59,13 @@ current_version=${full_version%%.*}
case "$current_version" in
''|*[!0-9]*)
echo "WARNING: Could not parse Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
- MEMBRANE_HOME=$(resolve_membrane_home "$0")
- start "$MEMBRANE_HOME" "$@"
+ start_membrane
exit 0
;;
esac
if [ "$current_version" -ge "$required_version" ]; then
- MEMBRANE_HOME=$(resolve_membrane_home "$0")
- start "$MEMBRANE_HOME" "$@"
+ start_membrane
exit 0
else
echo "Java version mismatch: Required=$required_version, Installed=$full_version"
diff --git a/distribution/src/test/java/com/predic8/membrane/examples/env/JavaLicenseInfoTest.java b/distribution/src/test/java/com/predic8/membrane/examples/env/JavaLicenseInfoTest.java
index a9ef20ec4f..34bee2544a 100644
--- a/distribution/src/test/java/com/predic8/membrane/examples/env/JavaLicenseInfoTest.java
+++ b/distribution/src/test/java/com/predic8/membrane/examples/env/JavaLicenseInfoTest.java
@@ -61,7 +61,10 @@ private List findJavaFiles(File startLocation) {
private static boolean containsLicense(File file) {
try {
String content = readFileToString(file, UTF_8);
- return content.contains("Apache License") || content.contains("Copyright (c) 2013, Oracle and/or its affiliates");
+ return content.contains("Apache License")
+ || content.contains("Copyright (c) 2013, Oracle and/or its affiliates")
+ || content.contains("MIT license")
+ || content.contains("Copyright 2015 Google Inc. All Rights Reserved.");
} catch (Exception e) {
return false;
}
diff --git a/distribution/src/test/java/com/predic8/membrane/examples/tests/loadbalancing/BalancerClientScriptUtil.java b/distribution/src/test/java/com/predic8/membrane/examples/tests/loadbalancing/BalancerClientScriptUtil.java
index bbade50d1b..bf0fa8b022 100644
--- a/distribution/src/test/java/com/predic8/membrane/examples/tests/loadbalancing/BalancerClientScriptUtil.java
+++ b/distribution/src/test/java/com/predic8/membrane/examples/tests/loadbalancing/BalancerClientScriptUtil.java
@@ -48,7 +48,7 @@ public static void controlNodeViaScript(int expectedReturnCode, File base, Stri
public static String getClientStartCommand(String command, String nodeHost, int nodePort) {
if (isWindows())
- return "cmd /c lbclient.bat " + command + " " + nodeHost + " " + nodePort;
+ return "PowerShell -ExecutionPolicy Bypass -File \"lbclient.ps1\" " + command + " " + nodeHost + " " + nodePort;
return "bash lbclient.sh " + command + " " + nodeHost + " " + nodePort;
}
diff --git a/distribution/src/test/java/com/predic8/membrane/examples/util/DistributionExtractingTestcase.java b/distribution/src/test/java/com/predic8/membrane/examples/util/DistributionExtractingTestcase.java
index f0b856b54b..64ef745b88 100644
--- a/distribution/src/test/java/com/predic8/membrane/examples/util/DistributionExtractingTestcase.java
+++ b/distribution/src/test/java/com/predic8/membrane/examples/util/DistributionExtractingTestcase.java
@@ -21,6 +21,7 @@
import org.slf4j.LoggerFactory;
import java.io.*;
+import java.nio.file.Files;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -151,8 +152,11 @@ private static void recursiveDelete(File file) {
//noinspection ConstantConditions
for (File child : file.listFiles())
recursiveDelete(child);
- if (!file.delete())
- throw new RuntimeException("could not delete " + file.getAbsolutePath());
+ try {
+ Files.delete(file.toPath());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
public static void unzip(File zip, File target) throws IOException {
diff --git a/distribution/src/test/java/com/predic8/membrane/examples/util/Process2.java b/distribution/src/test/java/com/predic8/membrane/examples/util/Process2.java
index ae1084ae97..a8d6dc1133 100644
--- a/distribution/src/test/java/com/predic8/membrane/examples/util/Process2.java
+++ b/distribution/src/test/java/com/predic8/membrane/examples/util/Process2.java
@@ -75,7 +75,7 @@ public Builder script(String script) {
if (id != null)
throw new IllegalStateException("executable or script is already set.");
id = script;
- line = isWindows() ? "cmd /c " + script + ".bat" : "bash " + script + ".sh";
+ line = isWindows() ? "PowerShell -ExecutionPolicy Bypass -File " + script + ".ps1" : "bash " + script + ".sh";
return this;
}
diff --git a/distribution/tutorials/rest/service-proxy.bat b/distribution/tutorials/rest/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/tutorials/rest/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/tutorials/rest/service-proxy.ps1 b/distribution/tutorials/rest/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/tutorials/rest/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/distribution/tutorials/soap/service-proxy.bat b/distribution/tutorials/soap/service-proxy.bat
deleted file mode 100644
index d2dec51288..0000000000
--- a/distribution/tutorials/soap/service-proxy.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if not "%MEMBRANE_HOME%" == "" goto homeSet
-set "MEMBRANE_HOME=%cd%\..\.."
-echo "%MEMBRANE_HOME%"
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-
-:homeSet
-if exist "%MEMBRANE_HOME%\service-proxy.bat" goto homeOk
-echo Please set the MEMBRANE_HOME environment variable to point to
-echo the directory where you have extracted the Membrane software.
-exit
-
-:homeOk
-set "CLASSPATH=%MEMBRANE_HOME%"
-set "CLASSPATH=%MEMBRANE_HOME%/conf"
-set "CLASSPATH=%CLASSPATH%;%MEMBRANE_HOME%/starter.jar"
-echo Membrane Router running...
-java -classpath "%CLASSPATH%" com.predic8.membrane.core.Starter -c proxies.xml
\ No newline at end of file
diff --git a/distribution/tutorials/soap/service-proxy.ps1 b/distribution/tutorials/soap/service-proxy.ps1
new file mode 100644
index 0000000000..d21fb44423
--- /dev/null
+++ b/distribution/tutorials/soap/service-proxy.ps1
@@ -0,0 +1,69 @@
+$required_version = "21"
+
+function Start-MembraneService {
+ param([string]$membrane_home)
+
+ $env:MEMBRANE_HOME = $membrane_home
+ $CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
+ Write-Host "Starting: $membrane_home CL: $CLASSPATH"
+ & java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
+}
+
+function Find-MembraneDirectory {
+ param([string]$current)
+
+ while ($current -ne "") {
+ if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
+ return $current
+ }
+ $current = Split-Path -Parent $current
+ }
+ return $null
+}
+
+function Start-Membrane {
+ $membrane_home = Find-MembraneDirectory (Get-Location).Path
+ if ($membrane_home) {
+ Start-MembraneService $membrane_home
+ } else {
+ Write-Host "Could not start Membrane. Ensure the directory structure is correct."
+ }
+}
+
+try {
+ $null = Get-Command java -ErrorAction Stop
+} catch {
+ Write-Host "Java is not installed. Membrane needs at least Java $required_version."
+ exit 1
+}
+
+try {
+ $version_output = & java -version 2>&1
+ $version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
+
+ if (-not $version_line) {
+ Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+
+ $full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
+ $current_version = $full_version -replace '\..*$', ''
+
+ if ($current_version -match '^\d+$') {
+ if ([int]$current_version -ge [int]$required_version) {
+ Start-Membrane
+ exit 0
+ } else {
+ Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
+ exit 1
+ }
+ } else {
+ Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
+ Start-Membrane
+ exit 0
+ }
+} catch {
+ Write-Host "Error checking Java version: $_"
+ exit 1
+}
\ No newline at end of file
diff --git a/membrane.spec b/membrane.spec
index 3ad56c48cd..19e7ca659a 100644
--- a/membrane.spec
+++ b/membrane.spec
@@ -131,7 +131,7 @@ exit 0
%{__rm} -rf %{buildroot}%{homedir}/examples
%{__rm} -rf %{buildroot}%{homedir}/tutorials
-%{__rm} -f %{buildroot}%{homedir}/service-proxy.bat
+%{__rm} -f %{buildroot}%{homedir}/service-proxy.ps1
%{__rm} -f %{buildroot}%{homedir}/CHANGELOG.txt
%{__rm} -f %{buildroot}%{homedir}/INSTALL_TANUKI.txt
%{__rm} -f %{buildroot}%{homedir}/README.txt
diff --git a/war/.factorypath b/war/.factorypath
index 9dcf3a81b2..e01b84bc25 100644
--- a/war/.factorypath
+++ b/war/.factorypath
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file