tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1630 withEjbRemote flag for tomee embedded*
Date Sun, 13 Sep 2015 00:19:54 GMT
Repository: tomee
Updated Branches:
  refs/heads/master e158fb678 -> 88ae9197c


TOMEE-1630 withEjbRemote flag for tomee embedded*


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

Branch: refs/heads/master
Commit: 88ae9197cf2cb4561c072256f207df6bc5f9b246
Parents: e158fb6
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Sat Sep 12 17:19:37 2015 -0700
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Sat Sep 12 17:19:37 2015 -0700

----------------------------------------------------------------------
 .../embedded/EmbeddedTomEEConfiguration.java    |  9 +++
 .../embedded/EmbeddedTomEEContainer.java        |  1 +
 .../maven/plugins/TomEEEmbeddedMojo.java        |  3 +
 .../apache/tomee/embedded/Configuration.java    | 14 +++++
 .../org/apache/tomee/embedded/Container.java    |  5 ++
 .../apache/tomee/embedded/RemoteEjbTest.java    | 66 ++++++++++++++++++++
 6 files changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
index 1e3deb4..d09a85f 100644
--- a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
+++ b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
@@ -35,6 +35,7 @@ import java.util.Properties;
 public class EmbeddedTomEEConfiguration extends TomEEConfiguration {
     private int httpsPort = 8443;
     private boolean ssl;
+    private boolean withEjbRemote;
     private String keystoreFile;
     private String keystorePass;
     private String keystoreType = "JKS";
@@ -44,6 +45,14 @@ public class EmbeddedTomEEConfiguration extends TomEEConfiguration {
     private String users;
     private String roles;
 
+    public boolean isWithEjbRemote() {
+        return withEjbRemote;
+    }
+
+    public void setWithEjbRemote(final boolean withEjbRemote) {
+        this.withEjbRemote = withEjbRemote;
+    }
+
     public int getHttpsPort() {
         return httpsPort;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
index 4428d1e..e19ae3b 100644
--- a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
+++ b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
@@ -96,6 +96,7 @@ public class EmbeddedTomEEContainer extends TomEEContainer<EmbeddedTomEEConfigur
         configuration.setClientAuth(tomeeConfiguration.getClientAuth());
         configuration.setKeyAlias(tomeeConfiguration.getKeyAlias());
         configuration.setSslProtocol(tomeeConfiguration.getSslProtocol());
+        configuration.setWithEjbRemote(tomeeConfiguration.isWithEjbRemote());
 
         if (tomeeConfiguration.getRoles() != null) {
             configuration.setRoles(new HashMap<String, String>(Map.class.cast(tomeeConfiguration.getRolesAsProperties())));

http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
index a0688dc..f688854 100644
--- a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
+++ b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
@@ -111,6 +111,9 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
     @Parameter(property = "tomee-embedded-plugin.ssl", defaultValue = "false")
     protected boolean ssl;
 
+    @Parameter(property = "tomee-embedded-plugin.withEjbRemote", defaultValue = "false")
+    protected boolean withEjbRemote;
+
     @Parameter(property = "tomee-embedded-plugin.quickSession", defaultValue = "true")
     protected boolean quickSession;
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Configuration.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Configuration.java
b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Configuration.java
index cfc5ee7..fc40b03 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Configuration.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Configuration.java
@@ -43,6 +43,7 @@ public class Configuration {
 
     private int httpsPort = 8443;
     private boolean ssl;
+    private boolean withEjbRemote;
     private String keystoreFile;
     private String keystorePass;
     private String keystoreType = "JKS";
@@ -96,6 +97,19 @@ public class Configuration {
         return this;
     }
 
+    public boolean isWithEjbRemote() {
+        return withEjbRemote;
+    }
+
+    public Configuration withEjbRemote(final boolean withEjbRemote) {
+        setWithEjbRemote(withEjbRemote);
+        return this;
+    }
+
+    public void setWithEjbRemote(final boolean withEjbRemote) {
+        this.withEjbRemote = withEjbRemote;
+    }
+
     public void setDir(final String dir) {
         this.dir = dir;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
index a685f66..0f09858 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
@@ -71,6 +71,7 @@ import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.tomee.catalina.TomEERuntimeException;
 import org.apache.tomee.catalina.TomcatLoader;
+import org.apache.tomee.catalina.remote.TomEERemoteWebapp;
 import org.apache.tomee.catalina.session.QuickSessionManager;
 import org.apache.tomee.embedded.internal.StandardContextCustomizer;
 import org.apache.tomee.util.QuickServerXmlParser;
@@ -592,6 +593,10 @@ public class Container implements AutoCloseable {
 
         assembler = SystemInstance.get().getComponent(Assembler.class);
         configurationFactory = new ConfigurationFactory();
+
+        if (configuration.isWithEjbRemote()) {
+            tomcat.getHost().addChild(new TomEERemoteWebapp());
+        }
     }
 
     private static Server createServer(final String serverXml) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/88ae9197/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/RemoteEjbTest.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/RemoteEjbTest.java
b/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/RemoteEjbTest.java
new file mode 100644
index 0000000..83ad248
--- /dev/null
+++ b/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/RemoteEjbTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomee.embedded;
+
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.apache.openejb.loader.JarLocation;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.openejb.util.NetworkUtil;
+import org.junit.Test;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import java.io.File;
+import java.net.MalformedURLException;
+
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+
+public class RemoteEjbTest {
+    @Test
+    public void run() throws NamingException, MalformedURLException {
+        final int http = NetworkUtil.getNextAvailablePort();
+        try (final Container container = new Container(
+                new Configuration()
+                    .withEjbRemote(true)
+                    .http(http)
+                    .property("openejb.container.additional.exclude", "org.apache.tomee.embedded.")
+                    .property("openejb.additional.include", "tomee-"))
+                .deployPathsAsWebapp("app", singletonList(JarLocation.jarLocation(RemoteEjbTest.class).toURI().toURL()),
new File("target/foo"))) {
+            assertEquals(
+                "pong",
+                MyRemote.class.cast(new RemoteInitialContextFactory()
+                    .getInitialContext(new PropertiesBuilder().p(Context.PROVIDER_URL, "http://localhost:"
+ http + "/tomee/ejb").build())
+                    .lookup("global/app/MyRemoteBean!org.apache.tomee.embedded.RemoteEjbTest$MyRemote")).ping());
+        }
+    }
+
+    @Stateless
+    public static class MyRemoteBean implements MyRemote {
+        @Override
+        public String ping() {
+            return "pong";
+        }
+    }
+
+    @Remote
+    public interface MyRemote {
+        String ping();
+    }
+}


Mime
View raw message