tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: fixing reloadable config of JAXRSReloadTest after recent changes on defaults + fixing tomee mojos to support placeholders as ports
Date Mon, 09 Nov 2015 16:47:34 GMT
Repository: tomee
Updated Branches:
  refs/heads/master d52a47e25 -> a81347e4f


fixing reloadable config of JAXRSReloadTest after recent changes on defaults + fixing tomee
mojos to support placeholders as ports


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a81347e4
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a81347e4
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a81347e4

Branch: refs/heads/master
Commit: a81347e4f64f3d196981d238046e9fd4d3f1fda4
Parents: d52a47e
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Mon Nov 9 08:47:20 2015 -0800
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Mon Nov 9 08:47:20 2015 -0800

----------------------------------------------------------------------
 .../org/apache/openejb/config/RemoteServer.java |  2 +-
 .../openejb/maven/plugin/AbstractTomEEMojo.java | 58 ++++++++------------
 .../maven/plugin/test/JAXRSReloadTest.java      |  5 +-
 3 files changed, 26 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/a81347e4/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
index f024610..2fd2d48 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
@@ -171,7 +171,7 @@ public class RemoteServer {
 
     private void cmd(final List<String> additionalArgs, final String cmd, final boolean
checkPortAvailable) {
         boolean ok = true;
-        final int port = START.equals(cmd) ? portStartup : portShutdown;
+        final int port = START.equals(cmd) && portStartup > 0 ? portStartup :
portShutdown;
 
         if (checkPortAvailable) {
             ok = !connect(port, 1);

http://git-wip-us.apache.org/repos/asf/tomee/blob/a81347e4/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
index 02444f6..2175a3b 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
@@ -886,22 +886,22 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo
{
 
             // ensure connector is not commented
             value = value.replace("<Service name=\"Catalina\">", "<Service name=\"Catalina\">\n"
-                    + "    <Connector port=\"" + this.getTomeeHttpsPortChecked() + "\"
protocol=\"HTTP/1.1\" SSLEnabled=\"true\"\n" +
+                    + "    <Connector port=\"" + tomeeHttpsPort + "\" protocol=\"HTTP/1.1\"
SSLEnabled=\"true\"\n" +
                     "                scheme=\"https\" secure=\"true\"\n" +
                     "                clientAuth=\"false\" sslProtocol=\"TLS\" keystoreFile=\""
+ keystorePath + "\" />\n");
         }
 
         if (tomeeHttpPort != null) {
-            value = value.replace("\"" + parser.http() + "\"", "\"" + this.getTomeeHttpPortChecked()
+ "\"");
+            value = value.replace("\"" + parser.http() + "\"", "\"" + tomeeHttpPort + "\"");
         }
         if (tomeeHttpsPort != null) {
-            value = value.replace("\"" + parser.https() + "\"", "\"" + this.getTomeeHttpsPortChecked()
+ "\"");
+            value = value.replace("\"" + parser.https() + "\"", "\"" + tomeeHttpsPort + "\"");
         }
         if (tomeeAjpPort != null) {
             value = value.replace("\"" + parser.ajp() + "\"", "\"" + tomeeAjpPort + "\"");
         }
         if (tomeeShutdownPort != null) {
-            value = value.replace("\"" + parser.stop() + "\"", "\"" + this.getTomeeShutdownPortChecked()
+ "\"");
+            value = value.replace("\"" + parser.stop() + "\"", "\"" + tomeeShutdownPort +
"\"");
         }
         if (webappDir != null) {
             value = value.replace("\"" + parser.value("app-base", "webapps") + "\"", "\""
+ webappDir + "\"");
@@ -993,6 +993,12 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
             classpaths = new ArrayList<>();
         }
 
+        // init ports if needed
+        tomeeHttpPort = getOrInitPort(tomeeHttpPort);
+        tomeeHttpsPort = getOrInitPort(tomeeHttpsPort);
+        tomeeAjpPort = getOrInitPort(tomeeAjpPort);
+        tomeeShutdownPort = getOrInitPort(tomeeShutdownPort);
+
         final List<String> strings = generateJVMArgs();
 
         // init env for RemoteServer
@@ -1001,7 +1007,7 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo
{
             System.setProperty("openejb.server.debug", "true");
             System.setProperty("server.debug.port", Integer.toString(debugPort));
         }
-        System.setProperty("server.shutdown.port", String.valueOf(this.getTomeeShutdownPortChecked()));
+        System.setProperty("server.shutdown.port", String.valueOf(tomeeShutdownPort));
         System.setProperty("server.shutdown.command", tomeeShutdownCommand);
 
         server = new RemoteServer(getConnectAttempts(), debug);
@@ -1010,8 +1016,11 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo
{
         addShutdownHooks(server); // some shutdown hooks are always added (see UpdatableTomEEMojo)
 
         if (TOM_EE.equals(container)) {
-
-            server.setPortStartup(tomeeHttpPort == null ? this.getTomeeHttpsPortChecked()
: this.getTomeeHttpPortChecked());
+            try {
+                server.setPortStartup(Integer.parseInt(tomeeHttpPort == null ? tomeeHttpsPort
: tomeeHttpPort));
+            } catch (final NumberFormatException nfe) {
+                // no-op
+            }
 
             getLog().info("Running '" + getClass().getName().replace("TomEEMojo", "").toLowerCase(Locale.ENGLISH)
                     + "'. Configured TomEE in plugin is " + tomeeHost + ":" + server.getPortStartup()
@@ -1068,34 +1077,15 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo
{
         }
     }
 
-    private synchronized int getTomeeHttpPortChecked() {
-        int port = Integer.parseInt(this.tomeeHttpPort);
-
-        if (port <= 0) {
-            port = NetworkUtil.getNextAvailablePort();
-            this.tomeeHttpPort = String.valueOf(port);
-        }
-        return port;
-    }
-
-    private synchronized int getTomeeHttpsPortChecked() {
-        int port = Integer.parseInt(this.tomeeHttpsPort);
-
-        if (port <= 0) {
-            port = NetworkUtil.getNextAvailablePort();
-            this.tomeeHttpsPort = String.valueOf(port);
-        }
-        return port;
-    }
-
-    private synchronized int getTomeeShutdownPortChecked() {
-        int port = Integer.parseInt(this.tomeeShutdownPort);
-
-        if (port <= 0) {
-            port = NetworkUtil.getNextAvailablePort();
-            this.tomeeShutdownPort = String.valueOf(port);
+    private static String getOrInitPort(final String raw) {
+        try {
+            if (Integer.parseInt(raw) <= 0) {
+                return Integer.toString(NetworkUtil.getNextAvailablePort());
+            }
+        } catch (final NumberFormatException nfe) {
+            // no-op, surely a placeholder
         }
-        return port;
+        return raw;
     }
 
     private String getNextLine(final Scanner reader) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/a81347e4/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
index b921b25..eed1bb8 100644
--- a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
+++ b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
@@ -70,16 +70,13 @@ public class JAXRSReloadTest {
     protected boolean forceReloadable = true;
 
     @Config
-    protected boolean deployOpenEjbApplication = true;
-
-    @Config
     private File catalinaBase = JAXRS_APP.getParentFile().getParentFile();
 
     @Config
     private File deployedFile = JAXRS_APP;
 
     @Config
-    private String args = "-Dopenejb.classloader.forced-load=" + Endpoint.class.getPackage().getName();
+    private String args = "-Dtomee.remote.support=true -Dopenejb.classloader.forced-load="
+ Endpoint.class.getPackage().getName();
 
     @Test
     public void simpleStart() throws Exception {


Mime
View raw message