You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by st...@apache.org on 2015/05/06 11:13:42 UTC

[01/25] tomee git commit: TOMEE-1568 support overriding of a failed deployment in tomcat webappdeployer

Repository: tomee
Updated Branches:
  refs/heads/fb_tomee2_owb16 cdf0827e0 -> 85043a4b1


TOMEE-1568 support overriding of a failed deployment in tomcat webappdeployer


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

Branch: refs/heads/fb_tomee2_owb16
Commit: fc806570f880036d9103ff25e0ec07ebaa30cc7d
Parents: 1f9fdc9
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Apr 29 22:59:17 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Apr 29 22:59:17 2015 +0200

----------------------------------------------------------------------
 .../org/apache/openejb/assembler/DeployerEjb.java  |  7 +++++--
 .../apache/tomee/catalina/TomcatWebAppBuilder.java | 17 ++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/fc806570/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
index 908d14b..bc4d354 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
@@ -176,8 +176,11 @@ public class DeployerEjb implements Deployer {
             try {
                 final AppInfo appInfo = SystemInstance.get().getComponent(WebAppDeployer.class)
                         .deploy(host, contextRoot(properties, file.getAbsolutePath()), file);
-                saveIfNeeded(properties, file, appInfo);
-                return appInfo;
+                if (appInfo != null) {
+                    saveIfNeeded(properties, file, appInfo);
+                    return appInfo;
+                }
+                throw new OpenEJBException("can't deploy " + file.getAbsolutePath());
             } finally {
                 AUTO_DEPLOY.remove();
             }

http://git-wip-us.apache.org/repos/asf/tomee/blob/fc806570/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
index 1f9c81a..c98ef26 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
@@ -466,7 +466,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
                 }
             }
 
-            if (getContextInfo(webApp.host, webApp.contextRoot) != null) {
+            if (isAlreadyDeployed(webApp)) {
                 continue;
             }
 
@@ -515,7 +515,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
             appParam.setValue(webApp.moduleId);
             standardContext.addApplicationParameter(appParam);
 
-            if (getContextInfo(webApp.host, webApp.contextRoot) == null) {
+            if (!isAlreadyDeployed(webApp)) {
                 if (standardContext.getPath() == null) {
                     if (webApp.contextRoot != null && webApp.contextRoot.startsWith("/")) {
                         standardContext.setPath(webApp.contextRoot);
@@ -542,7 +542,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
                     webApp.contextRoot = "";
                 }
 
-                if (getContextInfo(webApp.host, webApp.contextRoot) != null) { // possible because of the previous renaming
+                if (isAlreadyDeployed(webApp)) { // possible because of the previous renaming
                     continue;
                 }
 
@@ -580,6 +580,17 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
         }
     }
 
+    private boolean isAlreadyDeployed(final WebAppInfo webApp) {
+        final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot);
+        if (contextInfo != null && contextInfo.standardContext != null && contextInfo.standardContext.getState() == LifecycleState.FAILED) {
+            synchronized (this) {
+                infos.remove(getId(webApp.host, webApp.contextRoot));
+            }
+            return false;
+        }
+        return contextInfo != null;
+    }
+
     private static boolean isParent(final ClassLoader parent, final ClassLoader child) {
         ClassLoader current = child;
         while (current != null) {


[06/25] tomee git commit: destroying sessions in application composer as well

Posted by st...@apache.org.
destroying sessions in application composer as well


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

Branch: refs/heads/fb_tomee2_owb16
Commit: fd7e9b2103e44e7610e91ee2d34c39aea3a17b2d
Parents: 5af485d
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sun May 3 22:23:57 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sun May 3 22:23:57 2015 +0200

----------------------------------------------------------------------
 .../openejb/OpenEJBDeployableContainer.java     |  6 ++++--
 .../openejb/testing/ApplicationComposers.java   | 22 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/fd7e9b21/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
index 44915b8..f999c20 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
@@ -319,8 +319,10 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
                         public void close() throws IOException {
                             try {
                                 final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
-                                for (final WebContext web : appCtx.getWebContexts()) {
-                                    sessionManager.destroy(web);
+                                if (sessionManager != null) {
+                                    for (final WebContext web : appCtx.getWebContexts()) {
+                                        sessionManager.destroy(web);
+                                    }
                                 }
                             } catch (final Throwable e) {
                                 // no-op

http://git-wip-us.apache.org/repos/asf/tomee/blob/fd7e9b21/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index 9616622..08c2c5e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -46,6 +46,7 @@ import org.apache.openejb.config.sys.JaxbOpenejb;
 import org.apache.openejb.config.sys.Openejb;
 import org.apache.openejb.core.LocalInitialContextFactory;
 import org.apache.openejb.core.Operation;
+import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.core.ThreadContext;
 import org.apache.openejb.core.WebContext;
 import org.apache.openejb.core.ivm.naming.InitContextFactory;
@@ -75,6 +76,7 @@ import org.apache.openejb.util.NetworkUtil;
 import org.apache.openejb.util.PropertyPlaceHolderHelper;
 import org.apache.openejb.util.ServiceManagerProxy;
 import org.apache.openejb.util.URLs;
+import org.apache.openejb.util.reflection.Reflections;
 import org.apache.openejb.web.LightweightWebAppBuilder;
 import org.apache.webbeans.inject.OWBInjector;
 import org.apache.webbeans.spi.ContextsService;
@@ -1447,6 +1449,26 @@ public class ApplicationComposers {
                     }
                 }
             });
+            if (!composer.appContext.getWebContexts().isEmpty()) {
+                composer.beforeDestroyAfterRunnables.add(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            final Object sessionManager = SystemInstance.get().getComponent(
+                                    ParentClassLoaderFinder.Helper.get().loadClass("org.apache.openejb.server.httpd.session.SessionManager")
+                            );
+                            if (sessionManager != null) {
+                                final Class<?>[] paramTypes = {WebContext.class};
+                                for (final WebContext web : composer.appContext.getWebContexts()) {
+                                    Reflections.invokeByReflection(sessionManager, "destroy", paramTypes, new Object[] { web });
+                                }
+                            }
+                        } catch (final Throwable e) {
+                            // no-op
+                        }
+                    }
+                });
+            }
             composer.afterRunnables.add(new Runnable() {
                 @Override
                 public void run() {


[20/25] tomee git commit: Merge branch 'master' into fb_tomee2_owb16

Posted by st...@apache.org.
Merge branch 'master' into fb_tomee2_owb16

Conflicts:
	container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
	container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
	server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
	server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
	server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
	tck/cdi-tomee/src/test/resources/failing.xml
	tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 6e0ebe15013797f8b6aa08ba9fb0a09b6c67e519
Parents: cdf0827 87a2991
Author: Mark Struberg <st...@apache.org>
Authored: Tue May 5 19:21:58 2015 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Tue May 5 19:21:58 2015 +0200

----------------------------------------------------------------------
 .../openejb/assembler/classic/AppInfo.java      |  1 +
 .../openejb/assembler/classic/Assembler.java    |  5 ++
 .../openejb/cdi/ThreadSingletonServiceImpl.java |  3 +-
 .../apache/openejb/config/AppInfoBuilder.java   | 14 +++
 .../org/apache/openejb/config/AppModule.java    |  6 ++
 .../org/apache/openejb/config/AutoConfig.java   | 58 ++++++++++--
 .../apache/openejb/config/DeploymentLoader.java |  1 +
 .../java/org/apache/openejb/config/Module.java  |  1 +
 .../HerokuDatabasePropertiesProvider.java       | 68 +++++++++++++++
 .../openejb/testing/ApplicationComposers.java   |  8 +-
 .../openejb/util/PropertyPlaceHolderHelper.java |  3 +-
 .../apache/openejb/config/AppContainerTest.java | 77 ++++++++++++++++
 ...uDatabasePropertiesProviderResourceTest.java | 92 ++++++++++++++++++++
 .../HerokuDatabasePropertiesProviderTest.java   | 47 ++++++++++
 .../openejb/maven/plugin/AbstractTomEEMojo.java | 52 +++++++++--
 .../maven/plugin/PreconfiguredTomEEXMlTest.java | 68 +++++++++++++++
 .../maven/plugin/TomEEMavenPluginRule.java      |  4 +-
 .../openejb/server/httpd/HttpRequestImpl.java   |  8 +-
 .../openejb/server/httpd/HttpSessionImpl.java   | 34 +++++---
 .../server/httpd/HttpRequestImplTest.java       | 50 +++++++++++
 .../server/httpd/HttpSessionImplTest.java       | 68 +++++++++++++++
 tck/cdi-embedded/pom.xml                        |  3 +-
 .../src/test/resources/arquillian.xml           |  1 +
 tck/cdi-tomee/src/test/resources/arquillian.xml |  1 +
 24 files changed, 643 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/6e0ebe15/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
----------------------------------------------------------------------
diff --cc container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
index e5c36d0,2f688f7..8967f75
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
@@@ -112,8 -112,11 +112,7 @@@ public class ThreadSingletonServiceImp
          } else {
              properties.setProperty("org.apache.webbeans.proxy.mapping.javax.enterprise.context.RequestScoped", defaultNormalScopeHandlerClass);
          }
--
 -        if (sessionContextClass() != null && tomee) {
 -            properties.setProperty("org.apache.webbeans.proxy.mapping.javax.enterprise.context.SessionScoped", "org.apache.tomee.catalina.cdi.SessionNormalScopeBeanHandler");
 -        }
--
++        
          properties.put(OpenWebBeansConfiguration.PRODUCER_INTERCEPTION_SUPPORT, SystemInstance.get().getProperty("openejb.cdi.producer.interception", "true"));
  
          properties.putAll(appContext.getProperties());

http://git-wip-us.apache.org/repos/asf/tomee/blob/6e0ebe15/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/6e0ebe15/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------


[11/25] tomee git commit: random port for cdi-embedded

Posted by st...@apache.org.
random port for cdi-embedded


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 272cb402a8a0ef2054607e38424676a8dfecf613
Parents: d8b80bf
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon May 4 20:55:13 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon May 4 20:55:13 2015 +0200

----------------------------------------------------------------------
 tck/cdi-embedded/pom.xml                           | 3 ++-
 tck/cdi-embedded/src/test/resources/arquillian.xml | 1 +
 tck/cdi-tomee/src/test/resources/arquillian.xml    | 1 +
 tck/cdi-tomee/src/test/resources/failing.xml       | 2 +-
 4 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/272cb402/tck/cdi-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/pom.xml b/tck/cdi-embedded/pom.xml
index 95f0b3e..89b2a48 100644
--- a/tck/cdi-embedded/pom.xml
+++ b/tck/cdi-embedded/pom.xml
@@ -190,14 +190,15 @@
           <systemPropertyVariables>
             <cdiTckExcludeDummy>true</cdiTckExcludeDummy>
 
-            <jms>new://Resource?type=javax.jms.ConnectionFactory</jms>
             <queue>new://Resource?type=Queue</queue>
             <topic>new://Resource?type=Topic</topic>
             <jdbc>new://Resource?type=DataSource</jdbc>
+            <jms>new://Resource?type=javax.jms.ConnectionFactory</jms>
 
             <admin.disabled>true</admin.disabled>
             <ejbd.disabled>true</ejbd.disabled>
             <ejbds.disabled>true</ejbds.disabled>
+            <httpejbd.port>0</httpejbd.port> <!-- random port for http one -> CI friendly -->
 
             <openejb.cdi.applicationScope.cached>false</openejb.cdi.applicationScope.cached>
             <openejb.cdi.producer.interception>false</openejb.cdi.producer.interception>

http://git-wip-us.apache.org/repos/asf/tomee/blob/272cb402/tck/cdi-embedded/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/arquillian.xml b/tck/cdi-embedded/src/test/resources/arquillian.xml
index 0b46313..5047d58 100644
--- a/tck/cdi-embedded/src/test/resources/arquillian.xml
+++ b/tck/cdi-embedded/src/test/resources/arquillian.xml
@@ -26,6 +26,7 @@
       <property name="startDefaultScopes">false</property>
       <property name="properties">
         Default\ JMS\ Resource\ Adapter = new://Resource?type=ActiveMQResourceAdapter
+        Default\ JMS\ Resource\ Adapter.BrokerXmlConfig = broker:(tcp://localhost:0)?useJmx=false
 
         # used in TCKs
         jdbc = new://Resource?type=DataSource

http://git-wip-us.apache.org/repos/asf/tomee/blob/272cb402/tck/cdi-tomee/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-tomee/src/test/resources/arquillian.xml b/tck/cdi-tomee/src/test/resources/arquillian.xml
index de888b6..5bc7c42 100644
--- a/tck/cdi-tomee/src/test/resources/arquillian.xml
+++ b/tck/cdi-tomee/src/test/resources/arquillian.xml
@@ -42,6 +42,7 @@
         openejb.classloader.forced-load = org.apache.webbeans.test.tck.,org.apache.openejb.tck.cdi.tomee.
 
         jmsRa = new://Resource?type=ActiveMQResourceAdapter
+        jmsRa.BrokerXmlConfig = broker:(tcp://localhost:0)?useJmx=false
         jms = new://Resource?type=javax.jms.ConnectionFactory
         jms.ResourceAdapter = jmsRa
         queue = new://Resource?type=Queue

http://git-wip-us.apache.org/repos/asf/tomee/blob/272cb402/tck/cdi-tomee/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-tomee/src/test/resources/failing.xml b/tck/cdi-tomee/src/test/resources/failing.xml
index 23ceda0..b46f6e5 100644
--- a/tck/cdi-tomee/src/test/resources/failing.xml
+++ b/tck/cdi-tomee/src/test/resources/failing.xml
@@ -23,7 +23,7 @@
   -->
   <test name="CDI TCK for developers (debugging)">
     <classes>
-      <class name="org.jboss.cdi.tck.tests.deployment.shutdown.ApplicationShutdownLifecycleTest" />
+      <class name="org.jboss.cdi.tck.tests.context.session.listener.shutdown.SessionContextListenerShutdownTest" />
     </classes>
   </test>
 </suite>


[08/25] tomee git commit: destroying session in a SessionManager in embedded mode and not in cdi context

Posted by st...@apache.org.
destroying session in a SessionManager in embedded mode and not in cdi context


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

Branch: refs/heads/fb_tomee2_owb16
Commit: de0c9893cc03c5e3fec1647dc87150e96d3bd9b8
Parents: cfe9fdf
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sun May 3 23:59:34 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sun May 3 23:59:34 2015 +0200

----------------------------------------------------------------------
 .../openejb/cdi/CdiAppContextsService.java      | 32 ------------
 .../server/httpd/BeginWebBeansListener.java     | 15 +++---
 .../openejb/server/httpd/HttpRequestImpl.java   |  3 +-
 .../openejb/server/httpd/HttpSessionImpl.java   |  1 -
 .../openejb/server/httpd/OpenEJBHttpServer.java | 17 ++++---
 .../server/httpd/session/SessionManager.java    | 52 ++++++++++++++------
 tck/cdi-embedded/src/test/resources/failing.xml |  2 +-
 7 files changed, 55 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index b8b49bc..d6a202e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -199,26 +199,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                 webBeansContext.getBeanManagerImpl().fireEvent(id, DestroyedLiteral.INSTANCE_CONVERSATION_SCOPED);
             }
         }
-        for (final SessionContext sc : sessionCtxManager.getContextById().values()) {
-            final Object event = HttpSessionContextSessionAware.class.isInstance(sc) ? HttpSessionContextSessionAware.class.cast(sc).getSession() : sc;
-            if (HttpSession.class.isInstance(event)) {
-                final HttpSession httpSession = HttpSession.class.cast(event);
-                if (httpSession.getId() == null) {
-                    continue;
-                }
-                initSessionContext(httpSession);
-                try {
-                    httpSession.invalidate();
-                } catch (final IllegalStateException ise) {
-                    // no-op
-                } finally {
-                    destroySessionContext(httpSession);
-                }
-            } else {
-                sc.destroy();
-            }
-            webBeansContext.getBeanManagerImpl().fireEvent(event, DestroyedLiteral.INSTANCE_SESSION_SCOPED);
-        }
         sessionCtxManager.getContextById().clear();
     }
 
@@ -729,11 +709,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
     }
 
     private Context lazyStartSessionContext() {
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(">lazyStartSessionContext");
-        }
-
         final Context webContext = null;
         final Context context = getCurrentContext(RequestScoped.class);
         if (context instanceof ServletRequestContext) {
@@ -743,10 +718,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                 try {
                     final HttpSession currentSession = servletRequest.getSession();
                     initSessionContext(currentSession);
-
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Lazy SESSION context initialization SUCCESS");
-                    }
                 } catch (final Exception e) {
                     logger.error(OWBLogConst.ERROR_0013, e);
                 }
@@ -758,9 +729,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             logger.warning("Could NOT lazily initialize session context because of " + context + " RequestContext");
         }
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("<lazyStartSessionContext " + webContext);
-        }
         return webContext;
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
index 36e83aa..d379927 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
@@ -117,7 +117,7 @@ public class BeginWebBeansListener implements ServletContextListener, ServletReq
                 elStore.destroyELContextStore();
             }
 
-            webBeansContext.getContextsService().endContext(RequestScoped.class, event);
+            contextsService.endContext(RequestScoped.class, event);
             if (webBeansContext instanceof WebappWebBeansContext) { // end after child
                 ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().endContext(RequestScoped.class, event);
             }
@@ -145,7 +145,7 @@ public class BeginWebBeansListener implements ServletContextListener, ServletReq
             if (webBeansContext instanceof WebappWebBeansContext) { // start before child
                 ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().startContext(RequestScoped.class, event);
             }
-            this.webBeansContext.getContextsService().startContext(RequestScoped.class, event);
+            contextsService.startContext(RequestScoped.class, event);
 
             // we don't initialise the Session here but do it lazily if it gets requested
             // the first time. See OWB-457
@@ -168,7 +168,7 @@ public class BeginWebBeansListener implements ServletContextListener, ServletReq
             if (webBeansContext instanceof WebappWebBeansContext) { // start before child
                 ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().startContext(SessionScoped.class, event.getSession());
             }
-            this.webBeansContext.getContextsService().startContext(SessionScoped.class, event.getSession());
+            contextsService.startContext(SessionScoped.class, event.getSession());
         } catch (final Exception e) {
             logger.error(OWBLogConst.ERROR_0020, event.getSession());
             WebBeansUtil.throwRuntimeExceptions(e);
@@ -189,16 +189,15 @@ public class BeginWebBeansListener implements ServletContextListener, ServletReq
         }
 
         // ensure session ThreadLocal is set
-        webBeansContext.getContextsService().startContext(SessionScoped.class, event.getSession());
+        contextsService.startContext(SessionScoped.class, event.getSession());
 
         if (WebappWebBeansContext.class.isInstance(webBeansContext)) { // end after child
             WebappWebBeansContext.class.cast(webBeansContext).getParent().getContextsService().endContext(SessionScoped.class, event.getSession());
         }
 
-        final CdiAppContextsService appContextsService = CdiAppContextsService.class.cast(webBeansContext.getContextsService());
-        if (appContextsService.getRequestContext(false) != null) {
+        if (contextsService.getRequestContext(false) != null) {
             final String id = event.getSession().getId(); // capture it eagerly!
-            appContextsService.pushRequestReleasable(new Runnable() {
+            contextsService.pushRequestReleasable(new Runnable() {
                 @Override
                 public void run() {
                     doDestroyConversations(id);
@@ -208,7 +207,7 @@ public class BeginWebBeansListener implements ServletContextListener, ServletReq
             doDestroyConversations(event.getSession().getId());
         }
 
-        webBeansContext.getContextsService().endContext(SessionScoped.class, event.getSession());
+        contextsService.endContext(SessionScoped.class, event.getSession());
 
         WebBeansListenerHelper.destroyFakedRequest(this);
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
index 384e254..eaf420f 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
@@ -896,7 +896,7 @@ public class HttpRequestImpl implements HttpRequest {
             impl.callListeners(); // can call req.getSession() so do it after affectation + do it after cdi init
 
             final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
-            final SessionManager.SessionWrapper previous = sessionManager.newSession(begin, session, application);
+            final SessionManager.SessionWrapper previous = sessionManager.newSession(begin, end, session, application);
             if (previous != null) {
                 session = previous.session;
             }
@@ -1222,7 +1222,6 @@ public class HttpRequestImpl implements HttpRequest {
 
         @Override
         public void invalidate() {
-            SystemInstance.get().getComponent(SessionManager.class).removeSession(session.getId());
             try {
                 super.invalidate();
             } finally {

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
index 657a394..f82b7bf 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
@@ -102,7 +102,6 @@ public class HttpSessionImpl implements HttpSession {
             }
         }
 
-        attributes.clear();
         final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
         if (sessionManager != null) {
             sessionManager.removeSession(sessionId);

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
index 65e8c66..16277fb 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
@@ -29,12 +29,6 @@ import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.OptionsLog;
 
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -46,6 +40,12 @@ import java.net.URI;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
 
 /**
  * This is the main class for the web administration.  It takes care of the
@@ -62,7 +62,7 @@ public class OpenEJBHttpServer implements HttpServer {
     private boolean indent;
 
     public OpenEJBHttpServer() {
-        this(getHttpListenerRegistry());
+        this(null);
     }
 
     public static HttpListenerRegistry getHttpListenerRegistry() {
@@ -76,10 +76,11 @@ public class OpenEJBHttpServer implements HttpServer {
     }
 
     public OpenEJBHttpServer(final HttpListener listener) {
-        this.listener = new OpenEJBHttpRegistry.ClassLoaderHttpListener(listener, ParentClassLoaderFinder.Helper.get());
         if (SystemInstance.get().getComponent(SessionManager.class) == null) {
             SystemInstance.get().setComponent(SessionManager.class, new SessionManager());
         }
+        this.listener = new OpenEJBHttpRegistry.ClassLoaderHttpListener(
+                listener == null ? getHttpListenerRegistry() : listener, ParentClassLoaderFinder.Helper.get());
     }
 
     public static boolean isTextXml(final Map<String, String> headers) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
index ad455b1..2284421 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
@@ -19,10 +19,11 @@ package org.apache.openejb.server.httpd.session;
 import org.apache.openejb.core.WebContext;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.httpd.BeginWebBeansListener;
-import org.apache.openejb.server.httpd.HttpRequestImpl;
+import org.apache.openejb.server.httpd.EndWebBeansListener;
 import org.apache.openejb.server.httpd.HttpSession;
 import org.apache.openejb.util.DaemonThreadFactory;
 import org.apache.openejb.util.Duration;
+import org.apache.webbeans.config.WebBeansContext;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -43,16 +44,37 @@ public class SessionManager {
     private static volatile ScheduledExecutorService es;
 
     public void destroy(final WebContext app) {
+        if (app == null) {
+            return;
+        }
+
+        final WebBeansContext wbc = app.getWebBeansContext();
         final Iterator<SessionWrapper> iterator = sessions.values().iterator();
         while (iterator.hasNext()) {
             final SessionWrapper next = iterator.next();
             if (next.app == app) {
-                next.session.invalidate();
+                doDestroy(next);
                 iterator.remove();
             }
         }
     }
 
+    private void doDestroy(final SessionWrapper next) {
+        HttpSessionEvent event = null;
+        if (next.end != null) {
+            event = new HttpSessionEvent(next.session);
+            next.end.sessionDestroyed(event);
+            next.begin.sessionCreated(event); // just set session thread local
+        }
+        try {
+            next.session.invalidate();
+        } finally {
+            if (next.begin != null) {
+                next.begin.sessionDestroyed(event);
+            }
+        }
+    }
+
     public void destroy() {
         if (es == null) {
             return;
@@ -69,7 +91,7 @@ public class SessionManager {
             return;
         }
         final Duration duration = new Duration(SystemInstance.get().getProperty("openejb.http.eviction.duration", "1 minute"));
-        es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(HttpRequestImpl.class));
+        es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(SessionManager.class));
         es.scheduleWithFixedDelay(new Runnable() {
             @Override
             public void run() {
@@ -77,12 +99,8 @@ public class SessionManager {
                     final HttpSession session = data.session;
                     if (session.getMaxInactiveInterval() > 0
                             && session.getLastAccessedTime() + TimeUnit.SECONDS.toMillis(session.getMaxInactiveInterval()) < System.currentTimeMillis()) {
-                        sessions.remove(session.getId());
-                        session.invalidate();
-
-                        if (data.listener != null) {
-                            data.listener.sessionDestroyed(new HttpSessionEvent(session));
-                        }
+                        doDestroy(data);
+                        sessions.remove(data.session.getId());
                     }
                 }
             }
@@ -105,8 +123,10 @@ public class SessionManager {
         return sessions.size();
     }
 
-    public SessionWrapper newSession(final BeginWebBeansListener listener, final HttpSession session, final WebContext app) {
-        final SessionWrapper existing = sessions.putIfAbsent(session.getId(), new SessionWrapper(listener, session, app));
+    public SessionWrapper newSession(final BeginWebBeansListener begin, final EndWebBeansListener end,
+                                     final HttpSession session, final WebContext app) {
+        final SessionWrapper wrapper = new SessionWrapper(begin, end, session, app);
+        final SessionWrapper existing = sessions.putIfAbsent(session.getId(), wrapper);
         if (existing == null && es == null) {
             synchronized (this) {
                 if (es == null) {
@@ -114,17 +134,19 @@ public class SessionManager {
                 }
             }
         }
-        return existing;
+        return existing == null ? wrapper : existing;
     }
 
     public static class SessionWrapper extends HttpSessionEvent {
-        public final BeginWebBeansListener listener;
+        public final BeginWebBeansListener begin;
+        public final EndWebBeansListener end;
         public final HttpSession session;
         public final WebContext app;
 
-        public SessionWrapper(final BeginWebBeansListener listener, final HttpSession session, final WebContext app) {
+        public SessionWrapper(final BeginWebBeansListener begin, final EndWebBeansListener end, final HttpSession session, final WebContext app) {
             super(session);
-            this.listener = listener;
+            this.begin = begin;
+            this.end = end;
             this.session = session;
             this.app = app;
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/de0c9893/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index bf0d833..3a10892 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -32,7 +32,7 @@
     -Dopenejb.cdi.conversation.http.use-get-parameter=true
     -->
     <classes>
-      <class name="org.jboss.cdi.tck.tests.lookup.injection.non.contextual.InjectionIntoNonContextualComponentTest" />
+      <class name="org.jboss.cdi.tck.tests.context.session.listener.shutdown.SessionContextListenerShutdownTest" />
     </classes>
   </test>
 </suite>


[24/25] tomee git commit: fixing tests based on primitives after upgrading to cxf 3.1

Posted by st...@apache.org.
fixing tests based on primitives after upgrading to cxf 3.1


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 554ccb1ce218ca2a0a72caf126088afcacefacc8
Parents: b27b5ea
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 6 10:43:28 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed May 6 10:43:28 2015 +0200

----------------------------------------------------------------------
 .../cxf/rs/AdvancedProviderConfigTest.java      | 14 +++++++----
 .../server/cxf/rs/CustomContextTest.java        | 15 +++++++----
 .../cxf/rs/CustomSecurityContextTest.java       | 26 ++++++++++++++------
 .../rs/DynamicSubclassEjbDeploymentTest.java    |  9 ++++---
 .../server/cxf/rs/EjbDeploymentTest.java        |  9 ++++---
 .../openejb/server/cxf/rs/RsInjectionTest.java  | 15 +++++++----
 .../cxf/rs/RsInterceptorInjectionTest.java      |  9 ++++++-
 .../server/cxf/rs/RsWithInterfaceTest.java      | 12 +++++++--
 .../server/cxf/rs/SimpleApplicationTest.java    | 17 +++++++------
 .../SimpleApplicationWithLongMappingTest.java   | 11 +++++----
 ...icationWithLongMappingWithNoAppPathTest.java | 11 +++++----
 .../rs/SimpleApplicationWithMappingTest.java    | 11 +++++----
 .../openejb/server/cxf/rs/SingletonTest.java    |  5 ++--
 .../openejb/server/cxf/rs/SubResourceTest.java  |  9 ++++++-
 server/openejb-cxf/pom.xml                      |  2 +-
 15 files changed, 115 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AdvancedProviderConfigTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AdvancedProviderConfigTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AdvancedProviderConfigTest.java
index 3710019..5893213 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AdvancedProviderConfigTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AdvancedProviderConfigTest.java
@@ -27,7 +27,6 @@ import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.jee.oejb3.PojoDeployment;
 import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.loader.IO;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.EnableServices;
 import org.apache.openejb.testing.Module;
@@ -38,18 +37,18 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.lang.annotation.Annotation;
+import java.util.Properties;
 import javax.ejb.Singleton;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.Providers;
 import javax.xml.bind.ValidationEvent;
 import javax.xml.bind.ValidationEventHandler;
 import javax.xml.bind.annotation.XmlRootElement;
-import java.lang.annotation.Annotation;
-import java.net.URL;
-import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
@@ -101,7 +100,12 @@ public class AdvancedProviderConfigTest {
 
     @Test
     public void check() throws Exception {
-        assertEquals("true", IO.slurp(new URL("http://127.0.0.1:" + port + "/AdvancedProviderConfigTest/advanced-provider-config/")));
+        assertEquals("true", ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/AdvancedProviderConfigTest")
+                .path("advanced-provider-config")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class));
     }
 
     @Singleton

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomContextTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomContextTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomContextTest.java
index 9fdd67b..c3845af 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomContextTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomContextTest.java
@@ -26,7 +26,6 @@ import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.jee.oejb3.PojoDeployment;
 import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.loader.IO;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.Module;
 import org.apache.openejb.testng.PropertiesBuilder;
@@ -35,14 +34,15 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.io.IOException;
+import java.util.Properties;
 import javax.ejb.Singleton;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.Provider;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
@@ -83,7 +83,12 @@ public class CustomContextTest {
 
     @Test
     public void rest() throws IOException {
-        final String response = IO.slurp(new URL("http://127.0.0.1:" + port + "/CustomContextTest/custom-context/check"));
+        final String response = ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/CustomContextTest")
+                .path("custom-context/check")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class);
         assertEquals("true", response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomSecurityContextTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomSecurityContextTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomSecurityContextTest.java
index 6129a06..9046254 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomSecurityContextTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CustomSecurityContextTest.java
@@ -18,7 +18,6 @@ package org.apache.openejb.server.cxf.rs;
 
 import org.apache.openejb.jee.WebApp;
 import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.loader.IO;
 import org.apache.openejb.testing.Classes;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.EnableServices;
@@ -30,17 +29,18 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Properties;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.ext.Provider;
-import java.io.IOException;
-import java.net.URL;
-import java.security.Principal;
-import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
@@ -70,8 +70,20 @@ public class CustomSecurityContextTest {
 
     @Test
     public void check() throws IOException {
-        assertEquals("true", IO.slurp(new URL("http://localhost:" + port + "/foo/sc?role=therole")));
-        assertEquals("false", IO.slurp(new URL("http://localhost:" + port + "/foo/sc?role=another")));
+        assertEquals("true", ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port)
+                .path("foo/sc")
+                .queryParam("role", "therole")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class));
+        assertEquals("false", ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port)
+                .path("foo/sc")
+                .queryParam("role", "another")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class));
     }
 
     @Path("sc")

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/DynamicSubclassEjbDeploymentTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/DynamicSubclassEjbDeploymentTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/DynamicSubclassEjbDeploymentTest.java
index f5273ec..5a6663a 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/DynamicSubclassEjbDeploymentTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/DynamicSubclassEjbDeploymentTest.java
@@ -38,6 +38,7 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.util.Properties;
 
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
@@ -75,22 +76,22 @@ public class DynamicSubclassEjbDeploymentTest {
     @Test
     public void rest() {
         final String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs")
-            .path("/ejb/rest").get(String.class);
+            .path("/ejb/rest").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("ok", response);
     }
 
     @Test
     public void restParameterInjected() {
-        String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").get(String.class);
+        String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("true", response);
 
-        response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").query("arg", "foo").get(String.class);
+        response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").query("arg", "foo").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("foo", response);
     }
 
     @Test
     public void restFieldInjected() {
-        final Boolean response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/field").get(Boolean.class);
+        final Boolean response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/field").accept(TEXT_PLAIN_TYPE).get(Boolean.class);
         assertEquals(true, response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
index ecc787d..7219d31 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EjbDeploymentTest.java
@@ -33,6 +33,7 @@ import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Request;
 import java.util.Properties;
 
@@ -71,22 +72,22 @@ public class EjbDeploymentTest {
 
     @Test
     public void rest() {
-        final String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/rest").get(String.class);
+        final String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/rest").accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("ok", response);
     }
 
     @Test
     public void restParameterInjected() {
-        String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").get(String.class);
+        String response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("true", response);
 
-        response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").query("arg", "foo").get(String.class);
+        response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/param").query("arg", "foo").accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("foo", response);
     }
 
     @Test
     public void restFieldInjected() {
-        final Boolean response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/field").get(Boolean.class);
+        final Boolean response = WebClient.create("http://localhost:" + port + "/openejb-cxf-rs").path("/ejb/field").accept(MediaType.TEXT_PLAIN_TYPE).get(Boolean.class);
         assertEquals(true, response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInjectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInjectionTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInjectionTest.java
index c3f51ce..ce10ef7 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInjectionTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInjectionTest.java
@@ -20,7 +20,6 @@ import org.apache.openejb.OpenEjbContainer;
 import org.apache.openejb.jee.Empty;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.loader.IO;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.Module;
 import org.apache.openejb.testng.PropertiesBuilder;
@@ -29,16 +28,17 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.io.IOException;
+import java.util.Properties;
 import javax.ejb.Singleton;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.Providers;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
@@ -69,7 +69,12 @@ public class RsInjectionTest {
 
     @Test
     public void rest() throws IOException {
-        final String response = IO.slurp(new URL("http://127.0.0.1:" + port + "/RsInjectionTest/injections/check"));
+        final String response = ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/RsInjectionTest/")
+                .path("injections/check")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class);
         assertEquals("true", response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInterceptorInjectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInterceptorInjectionTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInterceptorInjectionTest.java
index 3e7d546..99dde7a 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInterceptorInjectionTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsInterceptorInjectionTest.java
@@ -39,8 +39,10 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
@@ -79,7 +81,12 @@ public class RsInterceptorInjectionTest {
 
     @Test
     public void rest() throws IOException {
-        final String response = IO.slurp(new URL("http://127.0.0.1:" + port + "/RsInterceptorInjectionTest/injections/check"));
+        final String response = ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/RsInterceptorInjectionTest/")
+                .path("injections/check")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class);
         assertEquals("true", response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsWithInterfaceTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsWithInterfaceTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsWithInterfaceTest.java
index 4f1439d..12de8b6 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsWithInterfaceTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/RsWithInterfaceTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.server.cxf.rs;
 
+import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.openejb.OpenEjbContainer;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.loader.IO;
@@ -31,8 +32,10 @@ import javax.ejb.Singleton;
 import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.SecurityContext;
 import java.io.IOException;
 import java.net.URL;
@@ -67,7 +70,12 @@ public class RsWithInterfaceTest {
 
     @Test
     public void rest() throws IOException {
-        final String response = IO.slurp(new URL("http://127.0.0.1:" + port + "/RsWithInterfaceTest/itf/check"));
+        final String response = ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/RsWithInterfaceTest/")
+                .path("itf/check")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class);
         assertEquals("true", response);
     }
 
@@ -90,7 +98,7 @@ public class RsWithInterfaceTest {
         }
     }
 
-    public static interface Rs {
+    public interface Rs {
         @GET
         @Path("/check")
         boolean check(@Context final SecurityContext sc);

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationTest.java
index c8dd5b5..444139a 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationTest.java
@@ -48,6 +48,7 @@ import java.io.InputStreamReader;
 import java.io.StringWriter;
 import java.util.Properties;
 
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -83,7 +84,7 @@ public class SimpleApplicationTest {
 
     @Test
     public void wadlXML() throws IOException {
-        final Response response = WebClient.create(BASE_URL).path("/first/hi").query("_wadl").query("_type", "xml").get();
+        final Response response = WebClient.create(BASE_URL).path("/first/hi").query("_wadl").query("_type", "xml").accept(TEXT_PLAIN_TYPE).get();
 
         final StringBuilder sb = new StringBuilder();
         BufferedReader br = null;
@@ -114,7 +115,7 @@ public class SimpleApplicationTest {
 
     @Test
     public void wadlJSON() throws IOException {
-        final Response response = WebClient.create(BASE_URL).path("/first/hi").query("_wadl").query("_type", "json").get();
+        final Response response = WebClient.create(BASE_URL).path("/first/hi").query("_wadl").query("_type", "json").accept(TEXT_PLAIN_TYPE).get();
 
         final StringBuilder sb = new StringBuilder();
         BufferedReader br = null;
@@ -140,19 +141,19 @@ public class SimpleApplicationTest {
 
     @Test
     public void first() {
-        final String hi = WebClient.create(BASE_URL).path("/first/hi").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/first/hi").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("Hi from REST World!", hi);
     }
 
     @Test
     public void second() {
-        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("hi 2nd", hi);
     }
 
     @Test
     public void expert() throws Exception {
-        final Response response = WebClient.create(BASE_URL).path("/expert/still-hi").post("Pink Floyd");
+        final Response response = WebClient.create(BASE_URL).path("/expert/still-hi").accept(TEXT_PLAIN_TYPE).post("Pink Floyd");
         assertEquals(HttpServletResponse.SC_OK, response.getStatus());
 
         final InputStream is = (InputStream) response.getEntity();
@@ -166,16 +167,16 @@ public class SimpleApplicationTest {
 
     @Test(expected = WebApplicationException.class)
     public void nonListed() {
-        WebClient.create(BASE_URL).path("/non-listed/yata/foo").get(String.class);
+        WebClient.create(BASE_URL).path("/non-listed/yata/foo").accept(TEXT_PLAIN_TYPE).get(String.class);
     }
 
     @Test
     public void hooked() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 
     @Test
     public void injectEjb() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
index f35eb45..0883c2e 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
@@ -41,6 +41,7 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import java.util.Properties;
 
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 
 @EnableServices("jax-rs")
@@ -76,28 +77,28 @@ public class SimpleApplicationWithLongMappingTest {
 
     @Test
     public void first() {
-        final String hi = WebClient.create(BASE_URL).path("/first/hi").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/first/hi").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("Hi from REST World!", hi);
     }
 
     @Test
     public void second() {
-        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("hi 2nd", hi);
     }
 
     @Test(expected = WebApplicationException.class)
     public void nonListed() {
-        WebClient.create(BASE_URL).path("/non-listed/yata/foo").get(String.class);
+        WebClient.create(BASE_URL).path("/non-listed/yata/foo").accept(TEXT_PLAIN_TYPE).get(String.class);
     }
 
     @Test
     public void hooked() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 
     @Test
     public void injectEjb() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingWithNoAppPathTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingWithNoAppPathTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingWithNoAppPathTest.java
index 69be2e6..f0ec6f7 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingWithNoAppPathTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingWithNoAppPathTest.java
@@ -41,6 +41,7 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import java.util.Properties;
 
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 
 @EnableServices("jax-rs")
@@ -79,28 +80,28 @@ public class SimpleApplicationWithLongMappingWithNoAppPathTest {
 
     @Test
     public void first() {
-        final String hi = WebClient.create(BASE_URL).path("/first/hi").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/first/hi").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("Hi from REST World!", hi);
     }
 
     @Test
     public void second() {
-        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("hi 2nd", hi);
     }
 
     @Test(expected = WebApplicationException.class)
     public void nonListed() {
-        WebClient.create(BASE_URL).path("/non-listed/yata/foo").get(String.class);
+        WebClient.create(BASE_URL).path("/non-listed/yata/foo").accept(TEXT_PLAIN_TYPE).get(String.class);
     }
 
     @Test
     public void hooked() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 
     @Test
     public void injectEjb() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
index f878bc9..0817644 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
@@ -41,6 +41,7 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import java.util.Properties;
 
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 
 @EnableServices("jax-rs")
@@ -76,28 +77,28 @@ public class SimpleApplicationWithMappingTest {
 
     @Test
     public void first() {
-        final String hi = WebClient.create(BASE_URL).path("/first/hi").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/first/hi").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("Hi from REST World!", hi);
     }
 
     @Test
     public void second() {
-        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").get(String.class);
+        final String hi = WebClient.create(BASE_URL).path("/second/hi2/2nd").accept(TEXT_PLAIN_TYPE).get(String.class);
         assertEquals("hi 2nd", hi);
     }
 
     @Test(expected = WebApplicationException.class)
     public void nonListed() {
-        WebClient.create(BASE_URL).path("/non-listed/yata/foo").get(String.class);
+        WebClient.create(BASE_URL).path("/non-listed/yata/foo").accept(TEXT_PLAIN_TYPE).get(String.class);
     }
 
     @Test
     public void hooked() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/hooked/post").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 
     @Test
     public void injectEjb() {
-        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").get(Boolean.class));
+        assertEquals(true, WebClient.create(BASE_URL).path("/inject/ejb").accept(TEXT_PLAIN_TYPE).get(Boolean.class));
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SingletonTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SingletonTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SingletonTest.java
index 593175a..bf76ecc 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SingletonTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SingletonTest.java
@@ -36,6 +36,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import static java.util.Arrays.asList;
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE;
 import static org.junit.Assert.assertEquals;
 
 @EnableServices("jax-rs")
@@ -56,14 +57,14 @@ public class SingletonTest {
     @Test
     public void checkStateStays() {
         for (int i = 0; i < 3; i++) {
-            assertEquals(i, WebClient.create(base.toExternalForm() + "foo/foo").get(Integer.class).intValue());
+            assertEquals(i, WebClient.create(base.toExternalForm() + "foo/foo").accept(TEXT_PLAIN_TYPE).get(Integer.class).intValue());
         }
     }
 
     @Test
     public void checkCdiInjections() {
         for (int i = 0; i < 3; i++) {
-            assertEquals(i, WebClient.create(base.toExternalForm() + "foo/cdi").get(Integer.class).intValue());
+            assertEquals(i, WebClient.create(base.toExternalForm() + "foo/cdi").accept(TEXT_PLAIN_TYPE).get(Integer.class).intValue());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SubResourceTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SubResourceTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SubResourceTest.java
index d996a5f..2283d6e 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SubResourceTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SubResourceTest.java
@@ -31,8 +31,10 @@ import org.junit.runner.RunWith;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.container.ResourceContext;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Properties;
@@ -65,7 +67,12 @@ public class SubResourceTest {
 
     @Test
     public void rest() throws IOException {
-        final String response = IO.slurp(new URL("http://127.0.0.1:" + port + "/SubResourceTest/sub1/sub2/value"));
+        final String response = ClientBuilder.newClient()
+                .target("http://127.0.0.1:" + port + "/SubResourceTest/")
+                .path("sub1/sub2/value")
+                .request()
+                .accept(MediaType.TEXT_PLAIN_TYPE)
+                .get(String.class);
         assertEquals("2", response);
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/554ccb1c/server/openejb-cxf/pom.xml
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/pom.xml b/server/openejb-cxf/pom.xml
index 264844f..5f1e8a4 100644
--- a/server/openejb-cxf/pom.xml
+++ b/server/openejb-cxf/pom.xml
@@ -33,7 +33,7 @@
   <name>OpenEJB :: Server :: CXF</name>
 
   <properties>
-    <wss4j.version>2.0.3</wss4j.version>
+    <wss4j.version>2.1.0</wss4j.version>
     <openejb.osgi.import.pkg>
       org.apache.xml.resolver*;resolution:=optional,
       *


[09/25] tomee git commit: destroying session scope before session in some tomee lifecycles

Posted by st...@apache.org.
destroying session scope before session in some tomee lifecycles


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

Branch: refs/heads/fb_tomee2_owb16
Commit: bf1b6e58a22a4d5f261f9ac09539e09b704b079c
Parents: de0c989
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon May 4 18:25:48 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon May 4 18:25:48 2015 +0200

----------------------------------------------------------------------
 .../openejb/cdi/CdiAppContextsService.java      | 49 ++++++++++++--------
 tck/cdi-tomee/src/test/resources/failing.xml    |  2 +-
 .../tomee/catalina/TomEEContainerListener.java  |  2 +-
 3 files changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bf1b6e58/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index d6a202e..02c190f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -184,7 +184,7 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             applicationContext.destroy();
             webBeansContext.getBeanManagerImpl().fireEvent(
                     appEvent,
-                    new EventMetadataImpl(null, ServletContext.class.isInstance(appEvent) ? ServletContext.class : Object.class,null, new Annotation[] { DestroyedLiteral.INSTANCE_APPLICATION_SCOPED }, webBeansContext),
+                    new EventMetadataImpl(null, ServletContext.class.isInstance(appEvent) ? ServletContext.class : Object.class, null, new Annotation[]{DestroyedLiteral.INSTANCE_APPLICATION_SCOPED}, webBeansContext),
                     false);
             applicationContext.setActive(true);
 
@@ -199,6 +199,17 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                 webBeansContext.getBeanManagerImpl().fireEvent(id, DestroyedLiteral.INSTANCE_CONVERSATION_SCOPED);
             }
         }
+        for (final SessionContext sc : sessionCtxManager.getContextById().values()) { // ensure to destroy session context in time at shutdown and not with session which can happen later
+            final Object event = HttpSessionContextSessionAware.class.isInstance(sc) ? HttpSessionContextSessionAware.class.cast(sc).getSession() : sc;
+            if (HttpSession.class.isInstance(event)) {
+                final HttpSession httpSession = HttpSession.class.cast(event);
+                if (httpSession.getId() == null) {
+                    continue;
+                }
+                initSessionContext(httpSession);
+            }
+            destroySessionContext(event);
+        }
         sessionCtxManager.getContextById().clear();
     }
 
@@ -244,12 +255,11 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             } else {
                 if (logger.isWarningEnabled()) {
                     logger.warning("CDI-OpenWebBeans container in OpenEJB does not support context scope "
-                        + scopeType.getSimpleName()
-                        + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
+                            + scopeType.getSimpleName()
+                            + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
                 }
             }
         }
-
     }
 
     @Override
@@ -289,8 +299,8 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             } else {
                 if (logger.isWarningEnabled()) {
                     logger.warning("CDI-OpenWebBeans container in OpenEJB does not support context scope "
-                        + scopeType.getSimpleName()
-                        + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
+                            + scopeType.getSimpleName()
+                            + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
                 }
             }
         }
@@ -317,7 +327,7 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             webBeansContext.getBeanManagerImpl().fireEvent(
                     appEvent,
                     new EventMetadataImpl(null,
-                            ServletContext.class.isInstance(appEvent) ? ServletContext.class : Object.class, null, new Annotation[] { InitializedLiteral.INSTANCE_APPLICATION_SCOPED },
+                            ServletContext.class.isInstance(appEvent) ? ServletContext.class : Object.class, null, new Annotation[]{InitializedLiteral.INSTANCE_APPLICATION_SCOPED},
                             webBeansContext),
                     false);
         }
@@ -326,12 +336,11 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
     @Override
     public boolean supportsContext(final Class<? extends Annotation> scopeType) {
         return scopeType.equals(RequestScoped.class)
-            || scopeType.equals(SessionScoped.class)
-            || scopeType.equals(ApplicationScoped.class)
-            || scopeType.equals(Dependent.class)
-            || scopeType.equals(Singleton.class)
-            || scopeType.equals(ConversationScoped.class) && supportsConversation();
-
+                || scopeType.equals(SessionScoped.class)
+                || scopeType.equals(ApplicationScoped.class)
+                || scopeType.equals(Dependent.class)
+                || scopeType.equals(Singleton.class)
+                || scopeType.equals(ConversationScoped.class) && supportsConversation();
     }
 
     private void initRequestContext(final Object event) {
@@ -403,7 +412,7 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
     }
 
     public void checkConversationState() {
-        final ServletRequestContext rc  = getRequestContext(false);
+        final ServletRequestContext rc = getRequestContext(false);
         if (rc != null && rc.getServletRequest() != null && conversationService != null) {
             final HttpSession session = rc.getServletRequest().getSession(false);
             if (session != null) {
@@ -536,7 +545,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                 } catch (final Exception e) {
                     return (SessionContext) clazz.newInstance();
                 }
-
             } catch (final Exception e) {
                 logger.error("Can't instantiate " + classname + ", using default session context", e);
             }
@@ -550,7 +558,7 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
      *
      * @param session http session object
      */
-    private void destroySessionContext(final HttpSession session) {
+    private void destroySessionContext(final Object session) {
         if (session != null) {
             final SessionContext context = sessionContext.get();
 
@@ -573,13 +581,15 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             sessionContext.remove();
 
             //Remove session from manager
-            sessionCtxManager.removeSessionContextWithSessionId(session.getId());
+            if (HttpSession.class.isInstance(session)) {
+                sessionCtxManager.removeSessionContextWithSessionId(HttpSession.class.cast(session).getId());
+            }
         }
     }
 
-    private void doDestroySession(SessionContext context, HttpSession session) {
+    private void doDestroySession(final SessionContext context, final Object event) {
         context.destroy();
-        webBeansContext.getBeanManagerImpl().fireEvent(session, DestroyedLiteral.INSTANCE_SESSION_SCOPED);
+        webBeansContext.getBeanManagerImpl().fireEvent(event, DestroyedLiteral.INSTANCE_SESSION_SCOPED);
     }
 
     //we don't have initApplicationContext
@@ -721,7 +731,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                 } catch (final Exception e) {
                     logger.error(OWBLogConst.ERROR_0013, e);
                 }
-
             } else {
                 logger.warning("Could NOT lazily initialize session context because NO active request context");
             }

http://git-wip-us.apache.org/repos/asf/tomee/blob/bf1b6e58/tck/cdi-tomee/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-tomee/src/test/resources/failing.xml b/tck/cdi-tomee/src/test/resources/failing.xml
index 6ec10c3..23ceda0 100644
--- a/tck/cdi-tomee/src/test/resources/failing.xml
+++ b/tck/cdi-tomee/src/test/resources/failing.xml
@@ -23,7 +23,7 @@
   -->
   <test name="CDI TCK for developers (debugging)">
     <classes>
-      <class name="org.jboss.cdi.tck.tests.context.request.ws.RequestContextTest" />
+      <class name="org.jboss.cdi.tck.tests.deployment.shutdown.ApplicationShutdownLifecycleTest" />
     </classes>
   </test>
 </suite>

http://git-wip-us.apache.org/repos/asf/tomee/blob/bf1b6e58/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java
index 048efa1..24fa536 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEContainerListener.java
@@ -33,7 +33,7 @@ public class TomEEContainerListener implements ContainerListener {
             context.set((StandardContext) event.getContainer());
         } else if ("afterContextInitialized".equals(event.getType())) {
             context.remove();
-        } else if (Context.CHANGE_SESSION_ID_EVENT.endsWith(event.getType())) {
+        } else if (Context.CHANGE_SESSION_ID_EVENT.endsWith(event.getType())) { // note: we could use a javax.servlet.http.HttpSessionIdListener
             final String[] ids = (String[]) event.getData();
 
             final WebBeansContext wbc = WebBeansContext.currentInstance();


[25/25] tomee git commit: Merge branch 'master' into fb_tomee2_owb16

Posted by st...@apache.org.
Merge branch 'master' into fb_tomee2_owb16


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 85043a4b1cf99208fe22304019a7364d4a09a7a4
Parents: 6e0ebe1 554ccb1
Author: Mark Struberg <st...@apache.org>
Authored: Wed May 6 11:12:59 2015 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Wed May 6 11:12:59 2015 +0200

----------------------------------------------------------------------
 .../openejb/config/DeploymentsResolver.java     | 22 +++++-
 .../src/main/resources/default.exclusions       |  1 +
 .../openejb/config/DeploymentsResolverTest.java | 72 ++++++++++++++++++++
 pom.xml                                         |  2 +-
 .../cxf/rs/AdvancedProviderConfigTest.java      | 14 ++--
 .../server/cxf/rs/CustomContextTest.java        | 15 ++--
 .../cxf/rs/CustomSecurityContextTest.java       | 26 +++++--
 .../rs/DynamicSubclassEjbDeploymentTest.java    |  9 +--
 .../server/cxf/rs/EjbDeploymentTest.java        |  9 +--
 .../openejb/server/cxf/rs/RsInjectionTest.java  | 15 ++--
 .../cxf/rs/RsInterceptorInjectionTest.java      |  9 ++-
 .../server/cxf/rs/RsWithInterfaceTest.java      | 12 +++-
 .../server/cxf/rs/SimpleApplicationTest.java    | 17 ++---
 .../SimpleApplicationWithLongMappingTest.java   | 11 +--
 ...icationWithLongMappingWithNoAppPathTest.java | 11 +--
 .../rs/SimpleApplicationWithMappingTest.java    | 11 +--
 .../openejb/server/cxf/rs/SingletonTest.java    |  5 +-
 .../openejb/server/cxf/rs/SubResourceTest.java  |  9 ++-
 server/openejb-cxf/pom.xml                      |  2 +-
 .../org/apache/tomee/embedded/Container.java    | 13 ++--
 20 files changed, 218 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/85043a4b/pom.xml
----------------------------------------------------------------------


[07/25] tomee git commit: OWB-1049 removing failoverservice references

Posted by st...@apache.org.
OWB-1049 removing failoverservice references


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

Branch: refs/heads/fb_tomee2_owb16
Commit: cfe9fdf29149db57097541faf90969e9f3a201b9
Parents: fd7e9b2
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sun May 3 22:26:11 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sun May 3 22:26:11 2015 +0200

----------------------------------------------------------------------
 .../apache/openejb/cdi/CdiAppContextsService.java   |  7 -------
 .../openejb/cdi/ThreadSingletonServiceImpl.java     | 16 ++--------------
 2 files changed, 2 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/cfe9fdf2/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index 655af39..b8b49bc 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -744,13 +744,6 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
                     final HttpSession currentSession = servletRequest.getSession();
                     initSessionContext(currentSession);
 
-                    /*
-                    final FailOverService failoverService = webBeansContext.getService(FailOverService.class);
-                    if (failoverService != null && failoverService.isSupportFailOver()) {
-                        failoverService.sessionIsInUse(currentSession);
-                    }
-                    */
-
                     if (logger.isDebugEnabled()) {
                         logger.debug("Lazy SESSION context initialization SUCCESS");
                     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/cfe9fdf2/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
index ed48b9e..2f688f7 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
@@ -47,8 +47,6 @@ import org.apache.webbeans.spi.TransactionService;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
 import org.apache.webbeans.web.intercept.RequestScopedBeanInterceptorHandler;
 
-import javax.enterprise.inject.spi.DeploymentException;
-import javax.transaction.Transactional;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -56,6 +54,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
+import javax.enterprise.inject.spi.DeploymentException;
+import javax.transaction.Transactional;
 
 /**
  * @version $Rev:$ $Date:$
@@ -71,7 +71,6 @@ public class ThreadSingletonServiceImpl implements ThreadSingletonService {
     //this needs to be static because OWB won't tell us what the existing SingletonService is and you can't set it twice.
     private static final ThreadLocal<WebBeansContext> contexts = new ThreadLocal<WebBeansContext>();
     private static final Map<ClassLoader, WebBeansContext> contextByClassLoader = new ConcurrentHashMap<ClassLoader, WebBeansContext>();
-    private static final String WEBBEANS_FAILOVER_ISSUPPORTFAILOVER = "org.apache.webbeans.web.failover.issupportfailover";
 
     @Override
     public void initialize(final StartupObject startupObject) {
@@ -102,13 +101,6 @@ public class ThreadSingletonServiceImpl implements ThreadSingletonService {
         properties.setProperty(OpenWebBeansConfiguration.APPLICATION_SUPPORTS_CONVERSATION, "true");
         properties.setProperty(OpenWebBeansConfiguration.IGNORED_INTERFACES, "org.apache.aries.proxy.weaving.WovenProxy");
 
-        final String failoverService = startupObject.getAppInfo().properties.getProperty("org.apache.webbeans.spi.FailOverService",
-            SystemInstance.get().getProperty("org.apache.webbeans.spi.FailOverService",
-                null));
-        if (failoverService != null) {
-            properties.setProperty(OpenWebBeansConfiguration.IGNORED_INTERFACES, failoverService);
-        }
-
         final boolean tomee = SystemInstance.get().getProperty("openejb.loader", "foo").startsWith("tomcat");
 
         final String defaultNormalScopeHandlerClass = NormalScopedBeanInterceptorHandler.class.getName();
@@ -125,10 +117,6 @@ public class ThreadSingletonServiceImpl implements ThreadSingletonService {
             properties.setProperty("org.apache.webbeans.proxy.mapping.javax.enterprise.context.SessionScoped", "org.apache.tomee.catalina.cdi.SessionNormalScopeBeanHandler");
         }
 
-        if (SystemInstance.get().getOptions().get(WEBBEANS_FAILOVER_ISSUPPORTFAILOVER, false)) {
-            properties.setProperty(WEBBEANS_FAILOVER_ISSUPPORTFAILOVER, "true");
-        }
-
         properties.put(OpenWebBeansConfiguration.PRODUCER_INTERCEPTION_SUPPORT, SystemInstance.get().getProperty("openejb.cdi.producer.interception", "true"));
 
         properties.putAll(appContext.getProperties());


[15/25] tomee git commit: TOMEE-1577 synchronizing httpsessionimpl invalidate

Posted by st...@apache.org.
TOMEE-1577 synchronizing httpsessionimpl invalidate


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 10280fab2fdf8b452bf44db81d1b7bdeb9096571
Parents: 64febe3
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 09:49:47 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 09:49:47 2015 +0200

----------------------------------------------------------------------
 .../openejb/server/httpd/HttpSessionImpl.java   | 34 +++++++++++++-------
 1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/10280fab/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
index f82b7bf..104deb5 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
@@ -40,6 +40,7 @@ public class HttpSessionImpl implements HttpSession {
     private final long created = System.currentTimeMillis();
     private volatile long timeout;
     private volatile long lastAccessed = created;
+    private volatile boolean valid = true;
 
     public HttpSessionImpl(final String contextPath, final long timeout) {
         this.timeout = timeout;
@@ -91,20 +92,31 @@ public class HttpSessionImpl implements HttpSession {
 
     @Override
     public void invalidate() {
-        if (!listeners.isEmpty()) {
-            final HttpSessionEvent event = new HttpSessionEvent(this);
-            for (final HttpSessionListener o : listeners) {
-                try {
-                    HttpSessionListener.class.cast(o).sessionDestroyed(event);
-                } catch (final Throwable th) {
-                    // ignore, may be undeployed
+        if (!valid) {
+            return;
+        }
+
+        synchronized (this) {
+            if (!valid) {
+                return;
+            }
+
+            if (!listeners.isEmpty()) {
+                final HttpSessionEvent event = new HttpSessionEvent(this);
+                for (final HttpSessionListener o : listeners) {
+                    try {
+                        HttpSessionListener.class.cast(o).sessionDestroyed(event);
+                    } catch (final Throwable th) {
+                        // ignore, may be undeployed
+                    }
                 }
             }
-        }
 
-        final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
-        if (sessionManager != null) {
-            sessionManager.removeSession(sessionId);
+            final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
+            if (sessionManager != null) {
+                sessionManager.removeSession(sessionId);
+            }
+            valid = false;
         }
     }
 


[14/25] tomee git commit: TOMEE-1576 removing cached session in the request - adapted from struberg work in a fb

Posted by st...@apache.org.
TOMEE-1576 removing cached session in the request - adapted from struberg work in a fb


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 64febe3099597077df9472469654ce8033e81ceb
Parents: 1767d48
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 09:43:03 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 09:43:03 2015 +0200

----------------------------------------------------------------------
 .../org/apache/openejb/server/httpd/HttpRequestImpl.java     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/64febe30/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
index eaf420f..7b9d612 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
@@ -887,7 +887,13 @@ public class HttpRequestImpl implements HttpRequest {
                 }
             }
 
-            final HttpSessionImpl impl = new HttpSessionImpl(contextPath, timeout);
+            final HttpSessionImpl impl = new HttpSessionImpl(contextPath, timeout) {
+                @Override
+                public void invalidate() {
+                    super.invalidate();
+                    HttpRequestImpl.this.session = null;
+                }
+            };
             session = impl;
             if (begin != null) {
                 begin.sessionCreated(new HttpSessionEvent(session));


[19/25] tomee git commit: TOMEE-1578 more clever merge of tomee.xml to add deployment 'apps' in tomee maven plugin - the test

Posted by st...@apache.org.
TOMEE-1578 more clever merge of tomee.xml to add deployment 'apps' in tomee maven plugin - the test


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 87a2991dea31f569bb0d4260e6e8f60f617d1e49
Parents: de6fa1c
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 17:45:23 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 17:45:23 2015 +0200

----------------------------------------------------------------------
 .../maven/plugin/PreconfiguredTomEEXMlTest.java | 68 ++++++++++++++++++++
 1 file changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/87a2991d/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/PreconfiguredTomEEXMlTest.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/PreconfiguredTomEEXMlTest.java b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/PreconfiguredTomEEXMlTest.java
new file mode 100644
index 0000000..5c3cfba
--- /dev/null
+++ b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/PreconfiguredTomEEXMlTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.openejb.maven.plugin;
+
+import org.apache.openejb.loader.Files;
+import org.apache.openejb.loader.IO;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+
+public class PreconfiguredTomEEXMlTest {
+    @Rule
+    public TestRule TMPRule = RuleChain
+            .outerRule(new TestRule() {
+                @Override
+                public Statement apply(final Statement base, final Description description) {
+                    return new Statement() {
+                        @Override
+                        public void evaluate() throws Throwable {
+                            IO.writeString(
+                                    new File(Files.mkdirs(new File(PreconfiguredTomEEXMlTest.this.catalinaBase, "conf")), "tomee.xml"),
+                                    "<tomee><Resource id=\"foo\" type=\"DataSource\" /><Deployments dir=\"missing\" /></tomee>");
+                            base.evaluate();
+                        }
+                    };
+                }
+            })
+            .around(new TestRule() {
+                @Override
+                public Statement apply(final Statement base, final Description description) {
+                    return new TomEEMavenPluginRule().apply(base, null, PreconfiguredTomEEXMlTest.this);
+                }
+            });
+
+    @Config
+    public final File catalinaBase = new File("target/PreconfiguredTomEEXMlTest");
+
+    @Config
+    public final boolean overrideOnUnzip = false;
+
+    @Test
+    public void confIsCorrectEvenIfWeEnrichedTheTomEEXmlForApps() throws Exception {
+        assertEquals(
+                "<tomee><Resource id=\"foo\" type=\"DataSource\" /><Deployments dir=\"missing\" />  <Deployments dir=\"apps\" /></tomee>",
+                IO.slurp(new File(catalinaBase, "conf/tomee.xml")).replace("\n", "").replace("\r", ""));
+    }
+}


[13/25] tomee git commit: TOMEE-1575 HerokuDatabasePropertiesProvider

Posted by st...@apache.org.
TOMEE-1575 HerokuDatabasePropertiesProvider


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 1767d4804c05fb9f1579e460e373a9d00ac2cb05
Parents: 9d18256
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon May 4 22:44:50 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon May 4 22:44:50 2015 +0200

----------------------------------------------------------------------
 .../HerokuDatabasePropertiesProvider.java       | 61 +++++++++++++
 .../openejb/util/PropertyPlaceHolderHelper.java |  3 +-
 ...uDatabasePropertiesProviderResourceTest.java | 92 ++++++++++++++++++++
 .../HerokuDatabasePropertiesProviderTest.java   | 42 +++++++++
 4 files changed, 197 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/1767d480/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
new file mode 100644
index 0000000..4c95a4a
--- /dev/null
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
@@ -0,0 +1,61 @@
+/*
+ * 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.openejb.resource.heroku;
+
+import org.apache.openejb.api.resource.PropertiesResourceProvider;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.openejb.util.PropertyPlaceHolderHelper;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+// kind of php to java
+public class HerokuDatabasePropertiesProvider implements PropertiesResourceProvider {
+    private final Map<String, String> jdbcMapping = new HashMap<String, String>() {{
+        put("postgres", "postgresql");
+        put("hsql", "hsqldb:hsql");
+    }};
+
+    @Override
+    public Properties provides() {
+        try {
+            final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); // let it be overridable
+            final String userInfo = url.getUserInfo();
+            final String jdbcUrl =
+                    "jdbc:" +
+                    (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) +
+                    "://" + url.getHost() + (url.getPort() > 0 ? ":" + url.getPort() : "") +
+                    url.getPath();
+            final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl);
+            if (userInfo != null) {
+                final int sep = userInfo.indexOf(':');
+                if (sep > 0) {
+                    builder.p("UserName", userInfo.substring(0, sep))
+                            .p("Password", userInfo.substring(sep + 1, userInfo.length()));
+                } else {
+                    builder.p("UserName", userInfo);
+                }
+            }
+            return builder.build();
+        } catch (final URISyntaxException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/1767d480/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java b/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
index adb13aa..b218d82 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
@@ -34,6 +34,7 @@ public final class PropertyPlaceHolderHelper {
 
     private static final PropertiesLookup RESOLVER = new PropertiesLookup();
     public static final StrSubstitutor SUBSTITUTOR = new StrSubstitutor(RESOLVER);
+
     static {
         SUBSTITUTOR.setEnableSubstitutionInVariables(true);
         SUBSTITUTOR.setValueDelimiter(System.getProperty("openejb.placehodler.delimiter", ":-")); // default one of [lang3]
@@ -68,7 +69,7 @@ public final class PropertyPlaceHolderHelper {
     private static String decryptIfNeeded(final String replace) {
         if (replace.startsWith(CIPHER_PREFIX)) {
             final String algo = replace.substring(CIPHER_PREFIX.length(), replace.indexOf(':', CIPHER_PREFIX.length() + 1));
-            PasswordCipher cipher = null;
+            PasswordCipher cipher;
             try {
                 cipher = PasswordCipherFactory.getPasswordCipher(algo);
             } catch (final PasswordCipherException ex) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/1767d480/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
new file mode 100644
index 0000000..dd20c90
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.openejb.resource.heroku;
+
+import org.apache.openejb.junit.ApplicationComposerRule;
+import org.apache.openejb.loader.Files;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.ContainerProperties;
+import org.apache.openejb.testing.SimpleLog;
+import org.apache.openejb.util.NetworkUtil;
+import org.hsqldb.Server;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@Classes
+@ContainerProperties({
+        @ContainerProperties.Property(name = "DATABASE_URL", value = "hsql://SA@localhost:${hsqldb}/adb"),
+        @ContainerProperties.Property(name = "db", value = "new://Resource?type=DataSource&properties-provider=org.apache.openejb.resource.heroku.HerokuDatabasePropertiesProvider")
+})
+@SimpleLog
+public class HerokuDatabasePropertiesProviderResourceTest {
+    @Rule
+    public final TestRule rule = RuleChain
+            .outerRule(new TestRule() {
+                @Override
+                public Statement apply(final Statement base, final Description description) {
+                    return new Statement() {
+                        @Override
+                        public void evaluate() throws Throwable {
+                            final int port = NetworkUtil.getNextAvailablePort();
+                            final Server server = new Server();
+                            server.setAddress("localhost");
+                            server.setPort(port);
+                            server.setDatabaseName(0, "adb");
+                            server.setDatabasePath(0, Files.mkdirs(new File("target/HerokuDatabasePropertiesProviderResourceTest")).getAbsolutePath());
+                            server.start();
+                            System.setProperty("hsqldb", Integer.toString(port));
+                            try {
+                                base.evaluate();
+                            } finally {
+                                server.stop();
+                            }
+                        }
+                    };
+                }
+            })
+            .around(new ApplicationComposerRule(this));
+
+    @Resource(name = "db")
+    private DataSource db;
+
+    @Test
+    public void herokuToJava() throws Exception {
+        assertNotNull(db);
+
+        final Connection connection = db.getConnection();
+        final DatabaseMetaData metaData = connection.getMetaData();
+        final String url = metaData.getURL();
+        assertTrue(url.startsWith("jdbc:hsqldb:hsql://localhost:"));
+        assertTrue(url.endsWith("/adb"));
+        assertEquals("SA", metaData.getUserName());
+        connection.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/1767d480/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
new file mode 100644
index 0000000..d96dff3
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * 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.openejb.resource.heroku;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class HerokuDatabasePropertiesProviderTest {
+    @Before
+    @After
+    public void reset() {
+        SystemInstance.reset();
+    }
+
+    @Test
+    public void herokuToJava() {
+        SystemInstance.get().setProperty("DATABASE_URL", "postgres://user:pwd@host.com:5432/db");
+        assertEquals(
+                new PropertiesBuilder().p("Password", "pwd").p("JdbcUrl", "jdbc:postgresql://host.com:5432/db").p("UserName", "user").build(),
+                new HerokuDatabasePropertiesProvider().provides());
+    }
+}


[02/25] tomee git commit: TOMEE-1569 forcing container loader for LoggerCreator

Posted by st...@apache.org.
TOMEE-1569 forcing container loader for LoggerCreator


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 2f977cad93ed229ac1f7ff81d27f5dc056436644
Parents: fc80657
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Apr 30 09:53:40 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Apr 30 09:53:40 2015 +0200

----------------------------------------------------------------------
 .../openejb/core/ParentClassLoaderFinder.java   |  3 +-
 .../org/apache/openejb/log/LoggerCreator.java   | 29 ++++++++++++--------
 2 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2f977cad/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java b/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
index dca0d39..c6497a1 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
@@ -27,7 +27,8 @@ public interface ParentClassLoaderFinder {
 
     class Helper {
         public static ClassLoader get() {
-            final ParentClassLoaderFinder parentFinder = SystemInstance.get().getComponent(ParentClassLoaderFinder.class);
+            final ParentClassLoaderFinder parentFinder = SystemInstance.isInitialized() ?
+                SystemInstance.get().getComponent(ParentClassLoaderFinder.class) : null;
             if (parentFinder != null) {
                 return parentFinder.getParentClassLoader(FALLBACK);
             }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2f977cad/container/openejb-core/src/main/java/org/apache/openejb/log/LoggerCreator.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/log/LoggerCreator.java b/container/openejb-core/src/main/java/org/apache/openejb/log/LoggerCreator.java
index 47d2935..c1fb803 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/log/LoggerCreator.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/log/LoggerCreator.java
@@ -52,20 +52,27 @@ public class LoggerCreator implements Callable<Logger> {
         if (logger == null) {
             synchronized (this) { // no need of lock for this part
                 if (logger == null) {
+                    final Thread thread = Thread.currentThread();
+                    final ClassLoader originalLoader = thread.getContextClassLoader();
+                    thread.setContextClassLoader(ParentClassLoaderFinder.Helper.get());
                     try {
-                        logger = Logger.getLogger(name);
-                    } catch (final Exception e) {
-                        logger = Logger.getLogger(name); // try again
-                    }
+                        try {
+                            logger = Logger.getLogger(name);
+                        } catch (final Exception e) {
+                            logger = Logger.getLogger(name); // try again
+                        }
 
-                    // if level set through properties force it
-                    final Properties p = SystemInstance.get().getProperties();
-                    final String levelName = p.getProperty("logging.level." + logger.getName());
-                    if (levelName != null) {
-                        final Level level = Level.parse(levelName);
-                        for (final Handler handler : logger.getHandlers()) {
-                            handler.setLevel(level);
+                        // if level set through properties force it
+                        final Properties p = SystemInstance.get().getProperties();
+                        final String levelName = p.getProperty("logging.level." + logger.getName());
+                        if (levelName != null) {
+                            final Level level = Level.parse(levelName);
+                            for (final Handler handler : logger.getHandlers()) {
+                                handler.setLevel(level);
+                            }
                         }
+                    } finally {
+                        thread.setContextClassLoader(originalLoader);
                     }
                 }
             }


[12/25] tomee git commit: back to the original session.invalidate() for now since CDI tcks need it and our lifecycle doesn't allow us yet to do it later

Posted by st...@apache.org.
back to the original session.invalidate() for now since CDI tcks need it and our lifecycle doesn't allow us yet to do it later


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 9d182562bb67e02bb47395cb77b86ea88cef8014
Parents: 272cb40
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon May 4 21:08:35 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon May 4 21:08:35 2015 +0200

----------------------------------------------------------------------
 .../apache/openejb/cdi/CdiAppContextsService.java    | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/9d182562/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index 02c190f..52b87f6 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -203,12 +203,19 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
             final Object event = HttpSessionContextSessionAware.class.isInstance(sc) ? HttpSessionContextSessionAware.class.cast(sc).getSession() : sc;
             if (HttpSession.class.isInstance(event)) {
                 final HttpSession httpSession = HttpSession.class.cast(event);
-                if (httpSession.getId() == null) {
-                    continue;
+                if (httpSession.getId() != null) { // TODO: think if we add a flag to deactivate this behavior (clustering case??)
+                    initSessionContext(httpSession);
+                    try {
+                        // far to be sexy but we need 1) triggering listeners + 2) destroying it *now*
+                        // -> org.jboss.cdi.tck.tests.context.session.listener.shutdown.SessionContextListenerShutdownTest
+                        httpSession.invalidate();
+                    } finally {
+                        destroySessionContext(event);
+                    }
                 }
-                initSessionContext(httpSession);
+            } else {
+                destroySessionContext(event);
             }
-            destroySessionContext(event);
         }
         sessionCtxManager.getContextById().clear();
     }


[10/25] tomee git commit: TOMEE-1574 TOMEE-1573 @Module Resources for app composer + containers in resources.xml

Posted by st...@apache.org.
TOMEE-1574 TOMEE-1573 @Module Resources for app composer + containers in resources.xml


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

Branch: refs/heads/fb_tomee2_owb16
Commit: d8b80bf10965ba7f3437231973ed5ecd53c412de
Parents: bf1b6e5
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon May 4 19:53:04 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon May 4 19:53:04 2015 +0200

----------------------------------------------------------------------
 .../openejb/assembler/classic/AppInfo.java      |  1 +
 .../openejb/assembler/classic/Assembler.java    |  5 ++
 .../apache/openejb/config/AppInfoBuilder.java   | 14 ++++
 .../org/apache/openejb/config/AppModule.java    |  6 ++
 .../org/apache/openejb/config/AutoConfig.java   | 58 +++++++++++++--
 .../apache/openejb/config/DeploymentLoader.java |  1 +
 .../java/org/apache/openejb/config/Module.java  |  1 +
 .../openejb/testing/ApplicationComposers.java   |  8 +-
 .../apache/openejb/config/AppContainerTest.java | 77 ++++++++++++++++++++
 9 files changed, 164 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
index 1212c8e..e72dd59 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
@@ -45,6 +45,7 @@ public class AppInfo extends InfoObject {
     public List<ServiceInfo> services = new ArrayList<ServiceInfo>();
     public final List<String> libs = new ArrayList<String>();
     public final Set<String> watchedResources = new TreeSet<String>();
+    public final Set<String> containerIds = new TreeSet<String>();
     public final Set<String> resourceIds = new TreeSet<String>();
     public final Set<String> resourceAliases = new TreeSet<String>();
     public final JndiEncInfo globalJndiEnc = new JndiEncInfo();

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 359d9bc..b6cdaf9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -2266,6 +2266,9 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                 }
             }
 
+            for (final String id : appInfo.containerIds) {
+                removeContainer(id);
+            }
             containerSystem.removeAppContext(appInfo.appId);
 
             if (!appInfo.properties.containsKey("tomee.destroying")) { // destroy tomee classloader after resources cleanup
@@ -2465,6 +2468,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
 
         final Object service = serviceRecipe.create();
 
+        serviceRecipe.getUnsetProperties().remove("id"); // we forced it
+        serviceRecipe.getUnsetProperties().remove("securityService"); // we forced it
         logUnusedProperties(serviceRecipe, serviceInfo);
 
         final Class interfce = serviceInterfaces.get(serviceInfo.service);

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
index dcbb451..cc61204 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
@@ -162,6 +162,7 @@ class AppInfoBuilder {
                 containerIds.add(containerInfo.id);
             }
         }
+        containerIds.addAll(appInfo.containerIds);
 
         //
         //  EJB Jars
@@ -176,6 +177,14 @@ class AppInfoBuilder {
 
                 for (final EnterpriseBeanInfo bean : ejbJarInfo.enterpriseBeans) {
                     final EjbDeployment d = deploymentsByEjbName.get(bean.ejbName);
+                    if (d.getContainerId() != null && !containerIds.contains(d.getContainerId())) {
+                        for (final String cId : appInfo.containerIds) {
+                            if (cId.endsWith("/" + d.getContainerId())) {
+                                d.setContainerId(cId);
+                                break;
+                            }
+                        }
+                    }
 
                     /*
                      * JRG - there's probably a better way of handling this, but this code handles the case when:
@@ -348,6 +357,11 @@ class AppInfoBuilder {
                 info.resourceAliases.addAll(def.getAliases());
             }
         }
+        for (final Container def : module.getContainers()) {
+            if (!def.getProperties().containsKey("ApplicationWide")) {
+                info.containerIds.add(def.getId());
+            }
+        }
     }
 
     private void buildClientModules(final AppModule appModule, final AppInfo appInfo, final JndiEncInfoBuilder jndiEncInfoBuilder) throws OpenEJBException {

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
index ea7b841..42bbfb5 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
@@ -17,6 +17,7 @@
 
 package org.apache.openejb.config;
 
+import org.apache.openejb.config.sys.Container;
 import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.config.sys.Service;
 import org.apache.openejb.core.ParentClassLoaderFinder;
@@ -61,6 +62,7 @@ public class AppModule implements DeploymentModule {
     private final Map<String, TransactionType> txTypeByUnit = new HashMap<String, TransactionType>();
     // TODO We could turn this into the Resources JAXB object and support containers and other things as well
     private final Collection<Resource> resources = new HashSet<Resource>();
+    private final Collection<Container> containers = new HashSet<Container>();
     private final Collection<Service> services = new HashSet<Service>();
     private final ClassLoader classLoader;
     private EntityMappings cmpMappings;
@@ -364,6 +366,10 @@ public class AppModule implements DeploymentModule {
         return resources;
     }
 
+    public Collection<Container> getContainers() {
+        return containers;
+    }
+
     public Collection<Service> getServices() {
         return services;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 6661eb2..90883db 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -21,6 +21,7 @@ import org.apache.openejb.JndiConstants;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.assembler.classic.ResourceInfo;
+import org.apache.openejb.config.sys.Container;
 import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.jee.ActivationConfig;
 import org.apache.openejb.jee.ActivationConfigProperty;
@@ -70,6 +71,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -109,6 +111,8 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
     public static final String ORIGIN_FLAG = "Origin";
     public static final String ORIGINAL_ID = "OriginalId";
 
+    private static final AppResources EMPTY_APP_RESOURCES = new AppResources();
+
     public static Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP_CONFIG, AutoConfig.class);
 
     private static final int MAX_IMPLICIT_POOL_SIZE = 5;
@@ -184,6 +188,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
         appResources.dump();
 
         processApplicationResources(appModule);
+        processApplicationContainers(appModule, appResources);
 
         for (final EjbModule ejbModule : appModule.getEjbModules()) {
             processActivationConfig(ejbModule);
@@ -893,6 +898,25 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
         }
     }
 
+    private void processApplicationContainers(final AppModule module, final AppResources appResources) throws OpenEJBException {
+        if (module.getContainers().isEmpty()) {
+            return;
+        }
+
+        final String prefix = module.getModuleId() + "/";
+        for (final Container container : module.getContainers()) {
+            if (container.getId() == null) {
+                throw new IllegalStateException("a container can't get a null id: " + container.getType() + " from " + module.getModuleId());
+            }
+            if (!container.getId().startsWith(prefix)) {
+                container.setId(prefix + container.getId());
+            }
+            final ContainerInfo containerInfo = configFactory.createContainerInfo(container);
+            configFactory.install(containerInfo);
+            appResources.addContainer(containerInfo);
+        }
+    }
+
     private void processApplicationResources(final AppModule module) throws OpenEJBException {
         final Collection<Resource> resources = module.getResources();
 
@@ -1944,7 +1968,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
         }
 
         if (appResources == null) {
-            appResources = new AppResources();
+            appResources = EMPTY_APP_RESOURCES;
         }
 
         // skip references such as URL which are automatically handled by the server
@@ -2146,7 +2170,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
             return null;
         }
         if (appResources == null) {
-            appResources = new AppResources();
+            appResources = EMPTY_APP_RESOURCES;
         }
 
         // skip references such as URLs which are automatically handled by the server
@@ -2198,7 +2222,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
     }
 
     private String getUsableContainer(final Class<? extends ContainerInfo> containerInfoType, final Object bean, final AppResources appResources) {
-        if (bean instanceof MessageDrivenBean) {
+        if (MessageDrivenBean.class.isInstance(bean)) {
             final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
             final String messagingType = messageDrivenBean.getMessagingType();
             final List<String> containerIds = appResources.containerIdsByType.get(messagingType);
@@ -2207,10 +2231,22 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
             }
         }
 
-        for (final ContainerInfo containerInfo : configFactory.getContainerInfos()) {
+        String containerInfo = matchContainer(containerInfoType, bean, appResources.getContainerInfos());
+        if (containerInfo == null) { // avoid to build configFactory.getContainerInfos() if not needed
+            containerInfo = matchContainer(containerInfoType, bean, configFactory.getContainerInfos());
+        }
+        if (containerInfo != null) {
+            return containerInfo;
+        }
+
+        return null;
+    }
+
+    private String matchContainer(final Class<? extends ContainerInfo> containerInfoType, final Object bean, final Collection<ContainerInfo> list) {
+        for (final ContainerInfo containerInfo : list) {
             if (containerInfo.getClass().equals(containerInfoType)) {
                 // MDBs must match message listener interface type
-                if (bean instanceof MessageDrivenBean) {
+                if (MessageDrivenBean.class.isInstance(bean)) {
                     final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
                     final String messagingType = messageDrivenBean.getMessagingType();
                     if (containerInfo.properties.get("MessageListenerInterface").equals(messagingType)) {
@@ -2221,7 +2257,6 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
                 }
             }
         }
-
         return null;
     }
 
@@ -2234,6 +2269,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
         private final Map<String, List<String>> resourceIdsByType = new TreeMap<String, List<String>>();
         private final Map<String, List<String>> resourceEnvIdsByType = new TreeMap<String, List<String>>();
         private final Map<String, List<String>> containerIdsByType = new TreeMap<String, List<String>>();
+        private final Collection<ContainerInfo> containerInfos = new HashSet<>();
 
         public void dump() {
             if (!logger.isDebugEnabled()) {
@@ -2397,6 +2433,16 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
             //            }
         }
 
+        public Collection<ContainerInfo> getContainerInfos() {
+            return containerInfos;
+        }
+
+        // needs to be called after merge otherwise we get wrong/missing data
+        private void addContainer(final ContainerInfo container) {
+            containerInfos.add(container);
+            // no need to enrich containerIdsByType here, TODO: see if we can remove containerIdsByType
+        }
+
         public List<String> getResourceIds(final String type) {
             if (type == null) {
                 final List<String> allResourceIds = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 5ff4034..1242ae2 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -546,6 +546,7 @@ public class DeploymentLoader implements DeploymentFilterable {
 
                     @Override
                     public void initResources(final Resources resources) {
+                        appModule.getContainers().addAll(resources.getContainer());
                         appModule.getResources().addAll(resources.getResource());
                         appModule.getServices().addAll(resources.getService());
                     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java b/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
index 30667f3..bdf1dad 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
@@ -100,6 +100,7 @@ public class Module {
         this.appModule = appModule;
         if (resources != null) {
             this.appModule.getResources().addAll(resources.getResource());
+            this.appModule.getContainers().addAll(resources.getContainer());
             this.appModule.getServices().addAll(resources.getService());
         }
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index 08c2c5e..62d9821 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -44,6 +44,7 @@ import org.apache.openejb.config.WebModule;
 import org.apache.openejb.config.sys.JSonConfigReader;
 import org.apache.openejb.config.sys.JaxbOpenejb;
 import org.apache.openejb.config.sys.Openejb;
+import org.apache.openejb.config.sys.Resources;
 import org.apache.openejb.core.LocalInitialContextFactory;
 import org.apache.openejb.core.Operation;
 import org.apache.openejb.core.ParentClassLoaderFinder;
@@ -146,7 +147,8 @@ public class ApplicationComposers {
         WebApp.class, EjbJar.class, EnterpriseBean.class,
         Persistence.class, PersistenceUnit.class,
         Connector.class, Beans.class,
-        Class[].class, Class.class
+        Class[].class, Class.class,
+        Resources.class
     };
 
     static {
@@ -594,6 +596,10 @@ public class ApplicationComposers {
                     ejbModule.setFinder(new AnnotationFinder((Archive) obj).link());
                     ejbModule.setBeans(new Beans());
                     appModule.getEjbModules().add(ejbModule);
+                } else if (obj instanceof Resources) {
+                    final Resources asResources = Resources.class.cast(obj);
+                    appModule.getResources().addAll(asResources.getResource());
+                    appModule.getContainers().addAll(asResources.getContainer());
                 } else if (obj instanceof AppModule) {
                     // we can probably go further here
                     final AppModule module = (AppModule) obj;

http://git-wip-us.apache.org/repos/asf/tomee/blob/d8b80bf1/container/openejb-core/src/test/java/org/apache/openejb/config/AppContainerTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/AppContainerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/AppContainerTest.java
new file mode 100644
index 0000000..baad710
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/AppContainerTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.openejb.config;
+
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.config.sys.Container;
+import org.apache.openejb.config.sys.Resources;
+import org.apache.openejb.core.singleton.SingletonContainer;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.SimpleLog;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.lang.reflect.Method;
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+
+import static org.junit.Assert.assertEquals;
+
+@SimpleLog
+@Classes(AppContainerTest.Singleton1.class)
+@RunWith(ApplicationComposer.class)
+public class AppContainerTest {
+    @org.apache.openejb.testing.Module
+    public Resources resources() {
+        final Resources resources = new Resources();
+        final Container container = new Container();
+        container.setId("theMine");
+        container.setType("SINGLETON");
+        container.setClassName("org.apache.openejb.config.AppContainerTest$MySingletonContainer");
+        resources.getContainer().add(container);
+        return resources;
+    }
+
+    @Singleton
+    public static class Singleton1 {
+        public String ok() {
+            throw new UnsupportedOperationException("my container mocks it");
+        }
+    }
+
+    @EJB
+    private Singleton1 s1;
+
+    @Test
+    public void run() {
+        assertEquals("yeah!", s1.ok());
+    }
+
+    public static class MySingletonContainer extends SingletonContainer {
+        public MySingletonContainer() throws OpenEJBException {
+            super("mine", null);
+        }
+
+        @Override
+        public Object invoke(final Object deployID, final InterfaceType type, final Class callInterface,
+                             final Method callMethod, final Object[] args, final Object primKey) throws OpenEJBException {
+            return callMethod.getDeclaringClass() == Singleton1.class ? "yeah!" : super.invoke(deployID, type, callInterface, callMethod, args, primKey);
+        }
+    }
+}


[23/25] tomee git commit: TOMEE-1277 cxf 3.1.0

Posted by st...@apache.org.
TOMEE-1277 cxf 3.1.0


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

Branch: refs/heads/fb_tomee2_owb16
Commit: b27b5ea08da161689085aaa7267519134f07424a
Parents: 1381e2f
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 6 10:15:41 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed May 6 10:15:41 2015 +0200

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/b27b5ea0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 967955f..4e9adc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,7 @@
 
     <tomcat.version>8.0.21</tomcat.version>
 
-    <cxf.version>3.0.4</cxf.version>
+    <cxf.version>3.1.0</cxf.version>
     <ehcache.version>2.8.5</ehcache.version>
     <!-- used by cxf for security (replay attack) -->
     <jetty.version>7.5.3.v20111011</jetty.version>


[17/25] tomee git commit: we can also guess the driver for HerokuDatabasePropertiesProvider

Posted by st...@apache.org.
we can also guess the driver for HerokuDatabasePropertiesProvider


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 4aa900ca56ea16574c3b6fbb9fde0cecd735da5d
Parents: 98029f7
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 14:34:05 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 14:34:05 2015 +0200

----------------------------------------------------------------------
 .../resource/heroku/HerokuDatabasePropertiesProvider.java     | 7 +++++++
 .../resource/heroku/HerokuDatabasePropertiesProviderTest.java | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4aa900ca/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
index 4c95a4a..aa9482d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
@@ -33,6 +33,8 @@ public class HerokuDatabasePropertiesProvider implements PropertiesResourceProvi
         put("hsql", "hsqldb:hsql");
     }};
 
+    private Properties properties;
+
     @Override
     public Properties provides() {
         try {
@@ -53,6 +55,11 @@ public class HerokuDatabasePropertiesProvider implements PropertiesResourceProvi
                     builder.p("UserName", userInfo);
                 }
             }
+            if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) {
+                if ("postgres".equalsIgnoreCase(url.getScheme())) {
+                    builder.p("JdbcDriver", "org.postgresql.Driver");
+                } // else TODO
+            }
             return builder.build();
         } catch (final URISyntaxException e) {
             throw new IllegalArgumentException(e);

http://git-wip-us.apache.org/repos/asf/tomee/blob/4aa900ca/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
index d96dff3..ab92e5e 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderTest.java
@@ -36,7 +36,12 @@ public class HerokuDatabasePropertiesProviderTest {
     public void herokuToJava() {
         SystemInstance.get().setProperty("DATABASE_URL", "postgres://user:pwd@host.com:5432/db");
         assertEquals(
-                new PropertiesBuilder().p("Password", "pwd").p("JdbcUrl", "jdbc:postgresql://host.com:5432/db").p("UserName", "user").build(),
+                new PropertiesBuilder()
+                        .p("Password", "pwd")
+                        .p("JdbcUrl", "jdbc:postgresql://host.com:5432/db")
+                        .p("UserName", "user")
+                        .p("JdbcDriver", "org.postgresql.Driver")
+                        .build(),
                 new HerokuDatabasePropertiesProvider().provides());
     }
 }


[05/25] tomee git commit: TOMEE-1571 destroying http session of openejb-http layer when undeploying applications with openejb embedded arquillian adapter

Posted by st...@apache.org.
TOMEE-1571 destroying http session of openejb-http layer when undeploying applications with openejb embedded arquillian adapter


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 5af485d0d271fd8c30b279290d173e88fbf37fd5
Parents: 075c465
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sun May 3 22:20:13 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sun May 3 22:20:13 2015 +0200

----------------------------------------------------------------------
 .../openejb/OpenEJBDeployableContainer.java     |  30 ++++-
 .../http/WebArchiveResourceProvider.java        |  16 +++
 .../arquillian/openejb/SessionDestroyTest.java  | 113 ++++++++++++++++
 .../openejb/server/httpd/HttpRequestImpl.java   | 124 +++++------------
 .../openejb/server/httpd/HttpResponseImpl.java  |   3 +-
 .../openejb/server/httpd/HttpSessionImpl.java   |  26 ++--
 .../server/httpd/OpenEJBHttpRegistry.java       |   2 +
 .../openejb/server/httpd/OpenEJBHttpServer.java |   9 +-
 .../server/httpd/session/SessionManager.java    | 132 +++++++++++++++++++
 .../httpd/HttpResponseImplSessionTest.java      |  16 +--
 10 files changed, 347 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
index 90d86b1..44915b8 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
@@ -37,8 +37,10 @@ import org.apache.openejb.config.DeploymentFilterable;
 import org.apache.openejb.config.WebModule;
 import org.apache.openejb.core.LocalInitialContext;
 import org.apache.openejb.core.LocalInitialContextFactory;
+import org.apache.openejb.core.WebContext;
 import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
 import org.apache.openejb.web.LightweightWebAppBuilder;
 import org.apache.webbeans.web.lifecycle.test.MockHttpSession;
 import org.apache.webbeans.web.lifecycle.test.MockServletContext;
@@ -58,11 +60,6 @@ import org.jboss.arquillian.test.spi.annotation.SuiteScoped;
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.descriptor.api.Descriptor;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSession;
 import java.io.ByteArrayInputStream;
 import java.io.Closeable;
 import java.io.IOException;
@@ -75,6 +72,11 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
 
 import static org.apache.openejb.cdi.ScopeHelper.startContexts;
 import static org.apache.openejb.cdi.ScopeHelper.stopContexts;
@@ -295,7 +297,8 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
                 final AppInfo appInfo = configurationFactory.configureApplication(module);
 
                 final WebAppBuilder webAppBuilder = SystemInstance.get().getComponent(WebAppBuilder.class);
-                if (webAppBuilder != null && LightweightWebAppBuilder.class.isInstance(webAppBuilder)) {
+                final boolean isEmbeddedWebAppBuilder = webAppBuilder != null && LightweightWebAppBuilder.class.isInstance(webAppBuilder);
+                if (isEmbeddedWebAppBuilder) {
                     // for now we keep the same classloader, open to discussion if we should recreate it, not sure it does worth it
                     final LightweightWebAppBuilder lightweightWebAppBuilder = LightweightWebAppBuilder.class.cast(webAppBuilder);
                     for (final WebModule w : module.getWebModules()) {
@@ -310,6 +313,21 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
                     }
                 }
                 final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader());
+                if (isEmbeddedWebAppBuilder && PROPERTIES.containsKey(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE) && !appCtx.getWebContexts().isEmpty()) {
+                    cls.add(new Closeable() {
+                        @Override
+                        public void close() throws IOException {
+                            try {
+                                final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
+                                for (final WebContext web : appCtx.getWebContexts()) {
+                                    sessionManager.destroy(web);
+                                }
+                            } catch (final Throwable e) {
+                                // no-op
+                            }
+                        }
+                    });
+                }
 
                 final ServletContext appServletContext = new MockServletContext();
                 final HttpSession appSession = new MockHttpSession();

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
index 2f1f731..5fd0b04 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
@@ -1,3 +1,19 @@
+/*
+ * 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.openejb.arquillian.openejb.http;
 
 import org.apache.openejb.arquillian.openejb.SWClassLoader;

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/arquillian/arquillian-openejb-embedded-5/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java b/arquillian/arquillian-openejb-embedded-5/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
new file mode 100644
index 0000000..fbae01e
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded-5/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
@@ -0,0 +1,113 @@
+/**
+ * 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.openejb.arquillian.openejb;
+
+import org.apache.openejb.loader.IO;
+import org.jboss.arquillian.container.test.api.Deployer;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class SessionDestroyTest {
+    @Deployment(name = "app", managed = false, testable = false)
+    public static Archive<?> app() {
+        return ShrinkWrap.create(WebArchive.class).addClasses(SessionTestManager.class, SessionListener.class);
+    }
+
+    @ArquillianResource
+    private Deployer deployer;
+
+    private static String id;
+
+    @Test
+    @InSequence(1)
+    public void deploy() {
+        reset();
+        deployer.deploy("app");
+    }
+
+    @Test
+    @InSequence(2)
+    @OperateOnDeployment("app")
+    public void doTest(@ArquillianResource final URL url) throws IOException {
+        id = IO.slurp(new URL(url.toExternalForm() + "create"));
+        assertNotNull(SessionListener.created);
+        assertEquals(id, SessionListener.created);
+    }
+
+    @Test
+    @InSequence(3)
+    public void undeployAndAsserts() {
+        deployer.undeploy("app");
+        assertNotNull(SessionListener.destroyed);
+        assertEquals(id, SessionListener.destroyed);
+        reset();
+    }
+
+    private void reset() {
+        SessionListener.destroyed = null;
+        SessionListener.created = null;
+        id = null;
+    }
+
+    @WebServlet("/create")
+    public static class SessionTestManager extends HttpServlet {
+        @Override
+        protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+            req.getSession().setAttribute("test", "ok");
+            resp.getWriter().write(req.getSession().getId());
+        }
+    }
+
+    @WebListener
+    public static class SessionListener implements HttpSessionListener {
+        private static String created;
+        private static String destroyed;
+
+        @Override
+        public void sessionCreated(final HttpSessionEvent httpSessionEvent) {
+            created = httpSessionEvent.getSession().getId();
+        }
+
+        @Override
+        public void sessionDestroyed(final HttpSessionEvent httpSessionEvent) {
+            destroyed = httpSessionEvent.getSession().getId();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
index 3751ef0..384e254 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
@@ -19,30 +19,13 @@ package org.apache.openejb.server.httpd;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.WebAppInfo;
+import org.apache.openejb.core.WebContext;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
 import org.apache.openejb.spi.SecurityService;
 import org.apache.openejb.util.ArrayEnumeration;
-import org.apache.openejb.util.DaemonThreadFactory;
-import org.apache.openejb.util.Duration;
 import org.apache.openejb.util.Logger;
 
-import javax.security.auth.login.LoginException;
-import javax.servlet.AsyncContext;
-import javax.servlet.DispatcherType;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpUpgradeHandler;
-import javax.servlet.http.Part;
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
@@ -67,11 +50,23 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import javax.security.auth.login.LoginException;
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
 
 import static java.util.Collections.singletonList;
 
@@ -83,11 +78,6 @@ public class HttpRequestImpl implements HttpRequest {
     private static final String FORM_URL_ENCODED = "application/x-www-form-urlencoded";
     private static final String TRANSFER_ENCODING = "Transfer-Encoding";
     private static final String CHUNKED = "chunked";
-    protected static final String EJBSESSIONID = "EJBSESSIONID";
-    protected static final String JSESSIONID = "JSESSIONID";
-
-    // note: no eviction so invalidate has to be called properly
-    private static final ConcurrentMap<String, RequestSession> SESSIONS = new ConcurrentHashMap<>();
 
     public static final Class<?>[] SERVLET_CONTEXT_INTERFACES = new Class<?>[]{ServletContext.class};
     public static final InvocationHandler SERVLET_CONTEXT_HANDLER = new InvocationHandler() {
@@ -97,43 +87,9 @@ public class HttpRequestImpl implements HttpRequest {
         }
     };
 
-    private static volatile ScheduledExecutorService es;
-
-    public static void destroyEviction() {
-        if (es == null) {
-            return;
-        }
-        es.shutdownNow();
-        SESSIONS.clear();
-    }
-
-    public static void initEviction() {
-        if (!"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.http.eviction", "true"))) {
-            return;
-        }
-        final Duration duration = new Duration(SystemInstance.get().getProperty("openejb.http.eviction.duration", "1 minute"));
-        es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(HttpRequestImpl.class));
-        es.scheduleWithFixedDelay(new Runnable() {
-            @Override
-            public void run() {
-                for (final RequestSession data : new ArrayList<>(SESSIONS.values())) {
-                    final HttpSession session = data.session;
-                    if (session.getMaxInactiveInterval() > 0
-                            && session.getLastAccessedTime() + TimeUnit.SECONDS.toMillis(session.getMaxInactiveInterval()) < System.currentTimeMillis()) {
-                        SESSIONS.remove(session.getId());
-                        session.invalidate();
-
-                        if (data.request != null && data.request.begin != null) {
-                            data.request.begin.sessionDestroyed(new HttpSessionEvent(session));
-                        }
-                    }
-                }
-            }
-        }, duration.getTime(), duration.getTime(), duration.getUnit());
-    }
-
     private EndWebBeansListener end;
     private BeginWebBeansListener begin;
+    private WebContext application;
 
     /**
      * 5.1.1    Method
@@ -438,11 +394,13 @@ public class HttpRequestImpl implements HttpRequest {
                 for (String c : cookies) {
                     final String current = c.trim();
                     if (current.startsWith("EJBSESSIONID=")) {
-                        final RequestSession requestSession = SESSIONS.get(current.substring("EJBSESSIONID=".length()));
-                        session = requestSession == null ? null : requestSession.session;
+                        final SessionManager.SessionWrapper sessionWrapper =
+                                SystemInstance.get().getComponent(SessionManager.class).findSession(current.substring("EJBSESSIONID=".length()));
+                        session = sessionWrapper == null ? null : sessionWrapper.session;
                     } else if (current.startsWith("JSESSIONID=")) {
-                        final RequestSession requestSession = SESSIONS.get(current.substring("JSESSIONID=".length()));
-                        session = requestSession == null ? null : requestSession.session;
+                        final SessionManager.SessionWrapper sessionWrapper =
+                                SystemInstance.get().getComponent(SessionManager.class).findSession(current.substring("JSESSIONID=".length()));
+                        session = sessionWrapper == null ? null : sessionWrapper.session;
                     }
                 }
             }
@@ -929,7 +887,7 @@ public class HttpRequestImpl implements HttpRequest {
                 }
             }
 
-            final HttpSessionImpl impl = new HttpSessionImpl(SESSIONS, contextPath, timeout);
+            final HttpSessionImpl impl = new HttpSessionImpl(contextPath, timeout);
             session = impl;
             if (begin != null) {
                 begin.sessionCreated(new HttpSessionEvent(session));
@@ -937,17 +895,10 @@ public class HttpRequestImpl implements HttpRequest {
             }
             impl.callListeners(); // can call req.getSession() so do it after affectation + do it after cdi init
 
-            final RequestSession previous = SESSIONS.putIfAbsent(session.getId(), new RequestSession(this, session));
+            final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
+            final SessionManager.SessionWrapper previous = sessionManager.newSession(begin, session, application);
             if (previous != null) {
                 session = previous.session;
-            } else {
-                if (es == null) {
-                    synchronized (HttpRequestImpl.class) {
-                        if (es == null) {
-                            initEviction();
-                        }
-                    }
-                }
             }
         }
         return session;
@@ -1219,6 +1170,10 @@ public class HttpRequestImpl implements HttpRequest {
         }
     }
 
+    public void setApplication(final WebContext app) {
+        this.application = app;
+    }
+
     public void setBeginListener(final BeginWebBeansListener begin) {
         if (this.begin == null) {
             this.begin = begin;
@@ -1267,7 +1222,7 @@ public class HttpRequestImpl implements HttpRequest {
 
         @Override
         public void invalidate() {
-            SESSIONS.remove(session.getId());
+            SystemInstance.get().getComponent(SessionManager.class).removeSession(session.getId());
             try {
                 super.invalidate();
             } finally {
@@ -1314,15 +1269,4 @@ public class HttpRequestImpl implements HttpRequest {
             // not yet supported: TODO: fake response write in ByteArrayOutputStream and then call HttpListenerRegistry and write it back
         }
     }
-
-    private static class RequestSession extends HttpSessionEvent {
-        private final HttpRequestImpl request;
-        private final HttpSession session;
-
-        public RequestSession(final HttpRequestImpl request, final HttpSession session) {
-            super(session);
-            this.request = request;
-            this.session = session;
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
index 9692e28..180e3e2 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
@@ -17,6 +17,7 @@
 package org.apache.openejb.server.httpd;
 
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.OpenEjbVersion;
@@ -483,7 +484,7 @@ public class HttpResponseImpl implements HttpResponse {
             return;
         }
 
-        headers.put(HttpRequest.HEADER_SET_COOKIE, HttpRequestImpl.EJBSESSIONID + '=' + session.getId() + "; Path=/");
+        headers.put(HttpRequest.HEADER_SET_COOKIE, SessionManager.EJBSESSIONID + '=' + session.getId() + "; Path=/");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
index cd0a394..657a394 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
@@ -18,11 +18,8 @@ package org.apache.openejb.server.httpd;
 
 import org.apache.openejb.client.ArrayEnumeration;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSessionContext;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,19 +28,20 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSessionContext;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
 
 public class HttpSessionImpl implements HttpSession {
     private Collection<HttpSessionListener> listeners;
     private String sessionId = UUID.randomUUID().toString();
     private Map<String, Object> attributes = new HashMap<String, Object>();
-    private final ConcurrentMap<String, ? extends HttpSessionEvent> mapToClean;
     private final long created = System.currentTimeMillis();
     private volatile long timeout;
     private volatile long lastAccessed = created;
 
-    public HttpSessionImpl(final ConcurrentMap<String, ? extends HttpSessionEvent> sessions, final String contextPath, final long timeout) {
-        this.mapToClean = sessions;
+    public HttpSessionImpl(final String contextPath, final long timeout) {
         this.timeout = timeout;
         if (contextPath == null) {
             return;
@@ -62,7 +60,7 @@ public class HttpSessionImpl implements HttpSession {
     }
 
     public HttpSessionImpl() {
-        this(null, null, 30000);
+        this(null, 30000);
     }
 
     public void newSessionId() {
@@ -105,8 +103,9 @@ public class HttpSessionImpl implements HttpSession {
         }
 
         attributes.clear();
-        if (mapToClean != null) {
-            mapToClean.remove(sessionId);
+        final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
+        if (sessionManager != null) {
+            sessionManager.removeSession(sessionId);
         }
     }
 
@@ -186,16 +185,17 @@ public class HttpSessionImpl implements HttpSession {
     @Override
     public HttpSessionContext getSessionContext() {
         touch();
+        final SessionManager component = SystemInstance.get().getComponent(SessionManager.class);
         return new HttpSessionContext() {
             @Override
             public javax.servlet.http.HttpSession getSession(final String sessionId) {
-                final HttpSessionEvent event = mapToClean.get(sessionId);
+                final HttpSessionEvent event = component.findSession(sessionId);
                 return event == null ? null : event.getSession();
             }
 
             @Override
             public Enumeration<String> getIds() {
-                return Collections.enumeration(mapToClean.keySet());
+                return Collections.enumeration(component.findSessionIds());
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
index 3a61442..6dd8d9e 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
@@ -113,6 +113,8 @@ public class OpenEJBHttpRegistry {
                     final HttpRequestImpl httpRequest = HttpRequestImpl.class.cast(request);
                     final WebContext web = findWebContext(request.getURI() == null ? request.getContextPath() : request.getURI().getPath());
                     if (web != null) {
+                        httpRequest.setApplication(web);
+
                         if (web.getClassLoader() != null) {
                             thread.setContextClassLoader(web.getClassLoader());
                         } else if (web.getAppContext().getClassLoader() != null) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
index 33f358c..65e8c66 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpServer.java
@@ -22,6 +22,7 @@ import org.apache.openejb.loader.Options;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.ServiceException;
 import org.apache.openejb.server.context.RequestInfos;
+import org.apache.openejb.server.httpd.session.SessionManager;
 import org.apache.openejb.server.stream.CountingInputStream;
 import org.apache.openejb.server.stream.CountingOutputStream;
 import org.apache.openejb.util.LogCategory;
@@ -76,6 +77,9 @@ public class OpenEJBHttpServer implements HttpServer {
 
     public OpenEJBHttpServer(final HttpListener listener) {
         this.listener = new OpenEJBHttpRegistry.ClassLoaderHttpListener(listener, ParentClassLoaderFinder.Helper.get());
+        if (SystemInstance.get().getComponent(SessionManager.class) == null) {
+            SystemInstance.get().setComponent(SessionManager.class, new SessionManager());
+        }
     }
 
     public static boolean isTextXml(final Map<String, String> headers) {
@@ -170,7 +174,10 @@ public class OpenEJBHttpServer implements HttpServer {
     @Override
     public void stop() throws ServiceException {
         OpenEJBAsyncContext.destroy();
-        HttpRequestImpl.destroyEviction();
+        final SessionManager component = SystemInstance.get().getComponent(SessionManager.class);
+        if (component != null) {
+            component.destroy();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
new file mode 100644
index 0000000..ad455b1
--- /dev/null
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/session/SessionManager.java
@@ -0,0 +1,132 @@
+/**
+ * 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.openejb.server.httpd.session;
+
+import org.apache.openejb.core.WebContext;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.BeginWebBeansListener;
+import org.apache.openejb.server.httpd.HttpRequestImpl;
+import org.apache.openejb.server.httpd.HttpSession;
+import org.apache.openejb.util.DaemonThreadFactory;
+import org.apache.openejb.util.Duration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import javax.servlet.http.HttpSessionEvent;
+
+public class SessionManager {
+    public static final String EJBSESSIONID = "EJBSESSIONID";
+    public static final String JSESSIONID = "JSESSIONID";
+
+    private final ConcurrentMap<String, SessionWrapper> sessions = new ConcurrentHashMap<>();
+
+    private static volatile ScheduledExecutorService es;
+
+    public void destroy(final WebContext app) {
+        final Iterator<SessionWrapper> iterator = sessions.values().iterator();
+        while (iterator.hasNext()) {
+            final SessionWrapper next = iterator.next();
+            if (next.app == app) {
+                next.session.invalidate();
+                iterator.remove();
+            }
+        }
+    }
+
+    public void destroy() {
+        if (es == null) {
+            return;
+        }
+        es.shutdownNow();
+        for (final SessionWrapper rs : sessions.values()) {
+            rs.session.invalidate();
+        }
+        sessions.clear();
+    }
+
+    public void initEviction() {
+        if (!"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.http.eviction", "true"))) {
+            return;
+        }
+        final Duration duration = new Duration(SystemInstance.get().getProperty("openejb.http.eviction.duration", "1 minute"));
+        es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(HttpRequestImpl.class));
+        es.scheduleWithFixedDelay(new Runnable() {
+            @Override
+            public void run() {
+                for (final SessionWrapper data : new ArrayList<>(sessions.values())) {
+                    final HttpSession session = data.session;
+                    if (session.getMaxInactiveInterval() > 0
+                            && session.getLastAccessedTime() + TimeUnit.SECONDS.toMillis(session.getMaxInactiveInterval()) < System.currentTimeMillis()) {
+                        sessions.remove(session.getId());
+                        session.invalidate();
+
+                        if (data.listener != null) {
+                            data.listener.sessionDestroyed(new HttpSessionEvent(session));
+                        }
+                    }
+                }
+            }
+        }, duration.getTime(), duration.getTime(), duration.getUnit());
+    }
+
+    public SessionWrapper findSession(final String id) {
+        return sessions.get(id);
+    }
+
+    public void removeSession(final String sessionId) {
+        sessions.remove(sessionId);
+    }
+
+    public Collection<String> findSessionIds() {
+        return sessions.keySet();
+    }
+
+    public int size() {
+        return sessions.size();
+    }
+
+    public SessionWrapper newSession(final BeginWebBeansListener listener, final HttpSession session, final WebContext app) {
+        final SessionWrapper existing = sessions.putIfAbsent(session.getId(), new SessionWrapper(listener, session, app));
+        if (existing == null && es == null) {
+            synchronized (this) {
+                if (es == null) {
+                    initEviction();
+                }
+            }
+        }
+        return existing;
+    }
+
+    public static class SessionWrapper extends HttpSessionEvent {
+        public final BeginWebBeansListener listener;
+        public final HttpSession session;
+        public final WebContext app;
+
+        public SessionWrapper(final BeginWebBeansListener listener, final HttpSession session, final WebContext app) {
+            super(session);
+            this.listener = listener;
+            this.session = session;
+            this.app = app;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/5af485d0/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpResponseImplSessionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpResponseImplSessionTest.java b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpResponseImplSessionTest.java
index 595c9be..b43d130 100644
--- a/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpResponseImplSessionTest.java
+++ b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpResponseImplSessionTest.java
@@ -21,41 +21,31 @@ import org.apache.openejb.core.CoreContainerSystem;
 import org.apache.openejb.core.ivm.naming.IvmJndiFactory;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.ServiceException;
+import org.apache.openejb.server.httpd.session.SessionManager;
 import org.apache.openejb.spi.ContainerSystem;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-import javax.servlet.http.HttpSession;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.lang.reflect.Field;
 import java.net.Socket;
-import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicReference;
+import javax.servlet.http.HttpSession;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public class HttpResponseImplSessionTest {
-    private static Field sessions;
-
     private OpenEJBHttpEjbServer server;
 
-    @BeforeClass
-    public static void findSessionsField() throws NoSuchFieldException {
-        sessions = HttpRequestImpl.class.getDeclaredField("SESSIONS");
-        sessions.setAccessible(true);
-    }
-
     private static int numberOfSessions() throws IllegalAccessException {
-        return Map.class.cast(sessions.get(null)).size();
+        return SystemInstance.get().getComponent(SessionManager.class).size();
     }
 
     @Before


[22/25] tomee git commit: tesing classpath searcher cleanup of url set

Posted by st...@apache.org.
tesing classpath searcher cleanup of url set


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 1381e2fa7007a8dab5198687f6c5f518fe66f4a5
Parents: ddc5215
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 6 10:01:34 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed May 6 10:01:34 2015 +0200

----------------------------------------------------------------------
 .../openejb/config/DeploymentsResolver.java     |  2 +-
 .../openejb/config/DeploymentsResolverTest.java | 72 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/1381e2fa/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
index 73d783e..d045a23 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
@@ -409,7 +409,7 @@ public class DeploymentsResolver implements DeploymentFilterable {
             final List<URL> copy = set.getUrls();
             for (final URL url : set.getUrls()) {
                 try {
-                    if ("file".equals(url.getProtocol()) && copy.contains(new URL("jar:" + url.toExternalForm() + "!"))) {
+                    if ("file".equals(url.getProtocol()) && copy.contains(new URL("jar:" + url.toExternalForm() + "!/"))) {
                         copy.remove(url);
                     }
                 } catch (final MalformedURLException e) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/1381e2fa/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
new file mode 100644
index 0000000..ee3d4a5
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.openejb.config;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+
+import static java.util.Collections.emptyEnumeration;
+import static java.util.Collections.enumeration;
+import static java.util.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class DeploymentsResolverTest {
+    @Test
+    public void avoidDuplicatedJars() throws MalformedURLException {
+        final File metaInf = new File("target/DeploymentsResolverTest/avoidDuplicatedJars/META-INF");
+        metaInf.getParentFile().mkdirs();
+
+        final URL url = metaInf.getParentFile().toURI().toURL();
+        final ClassLoader loader = new URLClassLoader(new URL[] {url}, new ClassLoader() {
+            @Override
+            protected Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
+                throw new ClassNotFoundException();
+            }
+
+            @Override
+            public Enumeration<URL> getResources(final String name) throws IOException {
+                return emptyEnumeration();
+            }
+        }) {
+            @Override
+            public Enumeration<URL> getResources(final String name) throws IOException {
+                if ("META-INF".equals(name)) {
+                    return emptyEnumeration();
+                }
+                return enumeration(singleton(new URL("jar:file:/tmp/app.jar!/")));
+            }
+
+            @Override
+            public URL[] getURLs() {
+                try {
+                    return new URL[] { new URL("file:/tmp/app.jar") };
+                } catch (final MalformedURLException e) {
+                    fail();
+                    throw new IllegalStateException(e);
+                }
+            }
+        };
+        assertEquals(1, new DeploymentsResolver.ClasspathSearcher().loadUrls(loader).getUrls().size());
+    }
+}


[16/25] tomee git commit: tests for 2 previous commits

Posted by st...@apache.org.
tests for 2 previous commits


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 98029f7374edea604347e1c0a5f598fb793a65e6
Parents: 10280fa
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 09:50:02 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 09:50:02 2015 +0200

----------------------------------------------------------------------
 .../server/httpd/HttpRequestImplTest.java       | 50 ++++++++++++++
 .../server/httpd/HttpSessionImplTest.java       | 68 ++++++++++++++++++++
 2 files changed, 118 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/98029f73/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpRequestImplTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpRequestImplTest.java b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpRequestImplTest.java
new file mode 100644
index 0000000..54b7373
--- /dev/null
+++ b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpRequestImplTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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.openejb.server.httpd;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class HttpRequestImplTest {
+    @Before
+    public void init() {
+        SystemInstance.get().setComponent(SessionManager.class, new SessionManager());
+    }
+
+    @After
+    public void reset() {
+        SystemInstance.reset();
+    }
+
+    @Test
+    public void run() throws URISyntaxException {
+        final HttpRequest req = new HttpRequestImpl(new URI("http://localhost:1234/foo"));
+        final javax.servlet.http.HttpSession session = req.getSession();
+        assertNotNull(session);
+        session.invalidate();
+        assertNull(req.getSession(false));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/98029f73/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpSessionImplTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpSessionImplTest.java b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpSessionImplTest.java
new file mode 100644
index 0000000..990d48e
--- /dev/null
+++ b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpSessionImplTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.openejb.server.httpd;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.session.SessionManager;
+import org.apache.openejb.util.reflection.Reflections;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import static org.junit.Assert.assertEquals;
+
+public class HttpSessionImplTest {
+    @Before
+    public void init() {
+        SystemInstance.get().setComponent(SessionManager.class, new SessionManager());
+    }
+
+    @After
+    public void reset() {
+        SystemInstance.reset();
+    }
+
+    @Test
+    public void run() throws URISyntaxException {
+        final HttpRequest req = new HttpRequestImpl(new URI("http://localhost:1234/foo"));
+        final javax.servlet.http.HttpSession session = req.getSession();
+        Reflections.set(session, "listeners", Collections.<Object>singletonList(new HttpSessionListener() {
+            private int count = 0;
+
+            @Override
+            public void sessionCreated(final HttpSessionEvent se) {
+                // no-op
+            }
+
+            @Override
+            public void sessionDestroyed(final HttpSessionEvent se) {
+                se.getSession().setAttribute("seen", ++count);
+            }
+        }));
+        session.invalidate();
+        final long c1 = Integer.class.cast(session.getAttribute("seen"));
+        session.invalidate();
+        final long c2 = Integer.class.cast(session.getAttribute("seen"));
+        assertEquals(c1, c2);
+    }
+}


[04/25] tomee git commit: TOMEE-1570 adding logger name to openejb log record

Posted by st...@apache.org.
TOMEE-1570 adding logger name to openejb log record


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 075c46542bc66c0e30cab98e43912fdced3013cd
Parents: be42075
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Apr 30 10:59:00 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Apr 30 10:59:00 2015 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/openejb/util/JuliLogStream.java        | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/075c4654/container/openejb-core/src/main/java/org/apache/openejb/util/JuliLogStream.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/JuliLogStream.java b/container/openejb-core/src/main/java/org/apache/openejb/util/JuliLogStream.java
index 75639a2..b99af1d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/JuliLogStream.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/JuliLogStream.java
@@ -102,6 +102,7 @@ public class JuliLogStream implements LogStream {
             if (t != null) {
                 logRecord.setThrown(t);
             }
+            logRecord.setLoggerName(log.getName());
             log.log(logRecord);
         }
     }


[03/25] tomee git commit: fixing test

Posted by st...@apache.org.
fixing test


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

Branch: refs/heads/fb_tomee2_owb16
Commit: be420751324849a14267b9b0778763b41f9d720e
Parents: 2f977ca
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Apr 30 10:27:58 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Apr 30 10:27:58 2015 +0200

----------------------------------------------------------------------
 .../openejb/util/classloader/URLClassLoaderFirstTest.java    | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/be420751/container/openejb-core/src/test/java/org/apache/openejb/util/classloader/URLClassLoaderFirstTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/classloader/URLClassLoaderFirstTest.java b/container/openejb-core/src/test/java/org/apache/openejb/util/classloader/URLClassLoaderFirstTest.java
index f77d7e2..e7646dd 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/classloader/URLClassLoaderFirstTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/classloader/URLClassLoaderFirstTest.java
@@ -21,17 +21,17 @@ import org.apache.openejb.loader.JarLocation;
 import org.apache.openejb.loader.SystemInstance;
 import org.junit.Test;
 
-import javax.wsdl.WSDLException;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.Properties;
+import javax.wsdl.WSDLException;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public class URLClassLoaderFirstTest {
     @Test
-    public void loadFromAppIfNotInContainer() throws MalformedURLException {
+    public void loadFromAppIfNotInContainer() throws Exception {
         assertTrue(URLClassLoaderFirst.shouldSkip("javax.wsdl.WSDLException"));
 
         final URLClassLoader parent = new URLClassLoader(new URL[0]) {
@@ -45,6 +45,7 @@ public class URLClassLoaderFirstTest {
         };
         final URLClassLoader tmpLoader = new URLClassLoaderFirst(new URL[]{JarLocation.jarLocation(WSDLException.class).toURI().toURL()}, parent);
 
+        SystemInstance.init(new Properties());
         SystemInstance.get().setComponent(ParentClassLoaderFinder.class, new ParentClassLoaderFinder() {
             @Override
             public ClassLoader getParentClassLoader(final ClassLoader fallback) {
@@ -62,5 +63,6 @@ public class URLClassLoaderFirstTest {
         }
 
         assertTrue(URLClassLoaderFirst.shouldSkip("javax.wsdl.WSDLException"));
+        SystemInstance.reset();
     }
 }


[18/25] tomee git commit: TOMEE-1578 more clever merge of tomee.xml to add deployment 'apps' in tomee maven plugin

Posted by st...@apache.org.
TOMEE-1578 more clever merge of tomee.xml to add deployment 'apps' in tomee maven plugin


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

Branch: refs/heads/fb_tomee2_owb16
Commit: de6fa1cba4bcde9e6b35578fe4bd541e23b59b6c
Parents: 4aa900c
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 17:45:15 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 17:45:15 2015 +0200

----------------------------------------------------------------------
 .../openejb/maven/plugin/AbstractTomEEMojo.java | 52 +++++++++++++++++---
 .../maven/plugin/TomEEMavenPluginRule.java      |  4 +-
 2 files changed, 49 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/de6fa1cb/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 6c8b412..6149ce2 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
@@ -31,8 +31,12 @@ import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Settings;
+import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.OpenEJBRuntimeException;
 import org.apache.openejb.config.RemoteServer;
+import org.apache.openejb.config.sys.Deployments;
+import org.apache.openejb.config.sys.JaxbOpenejb;
+import org.apache.openejb.config.sys.Openejb;
 import org.apache.openejb.loader.Files;
 import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.Zips;
@@ -329,12 +333,24 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
     @Parameter
     protected List<File> externalRepositories;
 
+    /**
+     * server.xml configured inlined (is Server tag is the first child of inlinedServerXml)
+     */
     @Parameter
     protected PlexusConfiguration inlinedServerXml;
 
+    /**
+     * tomee.xml configured inlined (is tomee tag is the first child of inlinedTomEEXml)
+     */
     @Parameter
     protected PlexusConfiguration inlinedTomEEXml;
 
+    /**
+     * if a file is already there when unpacking tomee zip should it be overriden?
+     */
+    @Parameter(property = "tomee-plugin.override-on-unzip", defaultValue = "true")
+    protected boolean overrideOnUnzip;
+
     protected File deployedFile = null;
     protected RemoteServer server = null;
     protected String container = TOM_EE;
@@ -1272,6 +1288,8 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
                             || (!parent.canRead() && !parent.setReadable(true))) {
                         throw new RuntimeException("Failed to create or set permissions on: " + parent);
                     }
+                } else if (!overrideOnUnzip) {
+                    continue;
                 }
                 if (entry.isDirectory()) {
                     if (!dest.exists() && !dest.mkdir()) {
@@ -1330,13 +1348,35 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
                 && (
                 (apps != null && !apps.isEmpty())
                         || (!"pom".equals(packaging) && !"war".equals(packaging))))) { // webapps doesn't need apps folder in tomee
-            final FileWriter writer = new FileWriter(file);
             final String rootTag = container.toLowerCase(Locale.ENGLISH);
-            writer.write("<?xml version=\"1.0\"?>\n" +
-                    "<" + rootTag + ">\n" +
-                    "  <Deployments dir=\"apps\" />\n" +
-                    "</" + rootTag + ">\n");
-            writer.close();
+            if (file.isFile())  { // can be not existing since we dont always deploy tomee but shouldn't since then apps/ is not guaranteed to work
+                try {
+                    final Openejb jaxb = JaxbOpenejb.readConfig(file.getAbsolutePath());
+                    boolean needAdd = true;
+                    for (final Deployments d : jaxb.getDeployments()) {
+                        if ("apps".equals(d.getDir())) {
+                            needAdd = false;
+                            break;
+                        }
+                    }
+                    if (needAdd) {
+                        final String content = IO.slurp(file);
+                        final FileWriter writer = new FileWriter(file);
+                        final String end = "</" + rootTag + ">";
+                        writer.write(content.replace(end, "  <Deployments dir=\"apps\" />\n" + end));
+                        writer.close();
+                    }
+                } catch (final OpenEJBException e) {
+                    throw new IllegalStateException("illegal tomee.xml:\n" + IO.slurp(file), e);
+                }
+            } else {
+                final FileWriter writer = new FileWriter(file);
+                writer.write("<?xml version=\"1.0\"?>\n" +
+                        "<" + rootTag + ">\n" +
+                        "  <Deployments dir=\"apps\" />\n" +
+                        "</" + rootTag + ">\n");
+                writer.close();
+            }
 
             final File appsFolder = new File(catalinaBase, "apps");
             if (!appsFolder.exists() && !appsFolder.mkdirs()) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/de6fa1cb/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/TomEEMavenPluginRule.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/TomEEMavenPluginRule.java b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/TomEEMavenPluginRule.java
index e898dbd..b8d4e48 100644
--- a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/TomEEMavenPluginRule.java
+++ b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/TomEEMavenPluginRule.java
@@ -73,7 +73,7 @@ assertThat(IO.slurp(new URL(url + "/docs")), containsString("Apache Tomcat"));
  */
 public class TomEEMavenPluginRule implements MethodRule {
     @Override
-    public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
+    public Statement apply(final Statement base, final FrameworkMethod ignored, final Object target) {
         return new RunTest(target, base);
     }
 
@@ -211,6 +211,8 @@ public class TomEEMavenPluginRule implements MethodRule {
         tomEEMojo.useConsole = true;
         tomEEMojo.checkStarted = true;
 
+        tomEEMojo.overrideOnUnzip = true;
+
         // we mock all the artifact resolution in test
         tomEEMojo.remoteRepos = new LinkedList<ArtifactRepository>();
         tomEEMojo.local = new DefaultArtifactRepository("local", tomEEMojo.settings.getLocalRepository(), new DefaultRepositoryLayout());


[21/25] tomee git commit: be more tolerant with shades - also a workaround for xbean

Posted by st...@apache.org.
be more tolerant with shades - also a workaround for xbean


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

Branch: refs/heads/fb_tomee2_owb16
Commit: ddc521585db2fbe5884a8b253b9c8025ce3dc277
Parents: 87a2991
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue May 5 19:25:10 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue May 5 19:25:10 2015 +0200

----------------------------------------------------------------------
 .../openejb/config/DeploymentsResolver.java     | 22 +++++++++++++++++++-
 .../src/main/resources/default.exclusions       |  1 +
 .../org/apache/tomee/embedded/Container.java    | 13 +++++++-----
 3 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ddc52158/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
index bf0f75c..73d783e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
@@ -33,6 +33,7 @@ import org.apache.xbean.finder.filter.IncludeExcludeFilter;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -400,9 +401,28 @@ public class DeploymentsResolver implements DeploymentFilterable {
             return urls;
         }
 
+        private UrlSet cleanUpUrlSet(final UrlSet set) {
+            if (set.size() >= 5) { // if set size == 1 then we use both getURLs() and getresource(META-INF) to find jar, ensure we don't duplicate it, ie size ~ 2
+                return set;
+            }
+
+            final List<URL> copy = set.getUrls();
+            for (final URL url : set.getUrls()) {
+                try {
+                    if ("file".equals(url.getProtocol()) && copy.contains(new URL("jar:" + url.toExternalForm() + "!"))) {
+                        copy.remove(url);
+                    }
+                } catch (final MalformedURLException e) {
+                    // no-op
+                }
+            }
+            return new UrlSet(copy);
+        }
+
         public ClasspathSearcher loadUrls(final ClassLoader classLoader) {
             try {
-                urlSet = URLs.cullSystemJars(new UrlSet(classLoader));
+                final UrlSet original = cleanUpUrlSet(new UrlSet(classLoader));
+                urlSet = URLs.cullSystemJars(original);
 
                 // save the prefiltered list of jars before excluding system apps
                 // so that we can choose not to filter modules with descriptors on the full list

http://git-wip-us.apache.org/repos/asf/tomee/blob/ddc52158/container/openejb-core/src/main/resources/default.exclusions
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/resources/default.exclusions b/container/openejb-core/src/main/resources/default.exclusions
index 93d7a87..8022110 100644
--- a/container/openejb-core/src/main/resources/default.exclusions
+++ b/container/openejb-core/src/main/resources/default.exclusions
@@ -103,6 +103,7 @@ jansi-
 jasper.jar
 jasper-el.jar
 jasypt-
+java-atk-wrapper
 javaee-
 javaee-api
 javassist-

http://git-wip-us.apache.org/repos/asf/tomee/blob/ddc52158/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 00b7eb2..a685f66 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
@@ -212,12 +212,15 @@ public class Container implements AutoCloseable {
         webModule.setRarUrls(Collections.<URL>emptyList());
         webModule.setScannableUrls(jarList);
         try {
+            final String filterContainerClasses = SystemInstance.get().getProperty("tomee.embedded.filter-container-classes");
             webModule.setFinder(
-                new FinderFactory.OpenEJBAnnotationFinder(
-                    // skip container classes in scanning for shades
-                    new WebappAggregatedArchive(webModule, jarList,
-                            jarList.size() == 1 ? new ContainerClassesFilter(configuration.getProperties()) /* shade */ : null))
-                        .link());
+                    new FinderFactory.OpenEJBAnnotationFinder(
+                            // skip container classes in scanning for shades
+                            new WebappAggregatedArchive(webModule, jarList,
+                                    // see org.apache.openejb.config.DeploymentsResolver.ClasspathSearcher.cleanUpUrlSet()
+                                    jarList.size() <= 4 || "true".equalsIgnoreCase(filterContainerClasses) ?
+                                            new ContainerClassesFilter(configuration.getProperties()) /* shade */ : null))
+                            .link());
         } catch (final Exception e) {
             throw new IllegalArgumentException(e);
         }