Author: rmannibucau
Date: Tue Aug 14 08:44:58 2012
New Revision: 1372778

URL: http://svn.apache.org/viewvc?rev=1372778&view=rev
Log:
TOMEE-368 TOMEE-369 TOMEE-370 OPENEJB-1888 reactivating tomcat moule (will be 
needed for release), better way to hide messages we don't want (often message 
webapp oriented) + hibernate version update in openejb-core-hibernate

Added:
    
openejb/trunk/openejb/arquillian/arquillian-tomee-tests/src/test/resources/hibernate-pom.xml
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/log/RemoveLogMessage.java
Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
    openejb/trunk/openejb/tomee/pom.xml
    openejb/trunk/openejb/tomee/tomee-myfaces/pom.xml
    
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
    
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContextListener.java
    openejb/trunk/openejb/utils/openejb-core-hibernate/pom.xml

Added: 
openejb/trunk/openejb/arquillian/arquillian-tomee-tests/src/test/resources/hibernate-pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-tests/src/test/resources/hibernate-pom.xml?rev=1372778&view=auto
==============================================================================
--- 
openejb/trunk/openejb/arquillian/arquillian-tomee-tests/src/test/resources/hibernate-pom.xml
 (added)
+++ 
openejb/trunk/openejb/arquillian/arquillian-tomee-tests/src/test/resources/hibernate-pom.xml
 Tue Aug 14 08:44:58 2012
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.openejb.arquillian.tests</groupId>
+  <version>1.0.0</version>
+  <artifactId>codi-deps</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-entitymanager</artifactId>
+      <version>4.1.6.Final</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.hibernate.javax.persistence</groupId>
+          <artifactId>hibernate-jpa-2.0-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.spec.javax.transaction</groupId>
+          <artifactId>jboss-transaction-api_1.1_spec</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-validator</artifactId>
+      <version>4.3.0.Final</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.validation</groupId>
+          <artifactId>validation-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+</project>

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
 Tue Aug 14 08:44:58 2012
@@ -20,6 +20,7 @@ import java.util.logging.Level;
 import org.apache.openejb.jee.bval.PropertyType;
 import org.apache.openejb.jee.bval.ValidationConfigType;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.log.RemoveLogMessage;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 
@@ -42,8 +43,8 @@ public final class ValidatorBuilder {
         // the only message logged is "ignoreXmlConfiguration == true"
         // which is false since we parse it ourself
         // so hidding it
-        
java.util.logging.Logger.getLogger("org.apache.bval.jsr303.ConfigurationImpl")
-                .setLevel(Level.OFF);
+        final java.util.logging.Logger offLogger = 
java.util.logging.Logger.getLogger("org.apache.bval.jsr303.ConfigurationImpl");
+        offLogger.setFilter(new RemoveLogMessage(offLogger.getFilter(), 
Level.INFO, "ignoreXmlConfiguration == true"));
     }
 
     private ValidatorBuilder() {

Added: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/log/RemoveLogMessage.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/log/RemoveLogMessage.java?rev=1372778&view=auto
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/log/RemoveLogMessage.java
 (added)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/log/RemoveLogMessage.java
 Tue Aug 14 08:44:58 2012
@@ -0,0 +1,41 @@
+/**
+ * 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.log;
+
+import java.util.logging.Filter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class RemoveLogMessage implements Filter {
+    private final Level level;
+    private final String message;
+    private final Filter wrapped;
+
+    public RemoveLogMessage(final Filter filter, final Level lvl, final String 
msg) {
+        wrapped = filter;
+        level = lvl;
+        message = msg;
+    }
+
+    @Override
+    public boolean isLoggable(final LogRecord record) {
+        if (wrapped != null && !wrapped.isLoggable(record)) {
+            return false;
+        }
+        return !level.equals(record.getLevel()) || 
!message.equals(record.getMessage());
+    }
+}

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
 Tue Aug 14 08:44:58 2012
@@ -189,19 +189,6 @@ public class URLClassLoaderFirst extends
                 if (apache.startsWith("webbeans.jsf")) return false;
                 if (apache.startsWith("tomee.mojarra.")) return false;
 
-                if (apache.startsWith("openejb.")) {
-                    final String openejb = 
apache.substring("openejb.".length());
-
-                    // webapp enrichment classes
-                    if (openejb.startsWith("hibernate.")) return false;
-                    if (openejb.startsWith("jpa.integration.")) return false;
-                    if (openejb.startsWith("toplink.")) return false;
-                    if (openejb.startsWith("eclipselink.")) return false;
-
-                    // else skip
-                    return true;
-                }
-
                 // here we find server classes
                 if (apache.startsWith("bval.")) return true;
                 if (apache.startsWith("openjpa.")) return true;
@@ -219,6 +206,19 @@ public class URLClassLoaderFirst extends
                 if (apache.startsWith("naming")) return true;
                 if (apache.startsWith("taglibs.")) return true;
 
+                if (apache.startsWith("openejb.")) {
+                    final String openejb = 
apache.substring("openejb.".length());
+
+                    // webapp enrichment classes
+                    if (openejb.startsWith("hibernate.")) return false;
+                    if (openejb.startsWith("jpa.integration.")) return false;
+                    if (openejb.startsWith("toplink.")) return false;
+                    if (openejb.startsWith("eclipselink.")) return false;
+
+                    // else skip
+                    return true;
+                }
+
                 if (apache.startsWith("commons.")) {
                     final String commons = 
apache.substring("commons.".length());
 
@@ -238,26 +238,51 @@ public class URLClassLoaderFirst extends
 
                 if (SKIP_MYFACES && apache.startsWith("myfaces.")) {
                     // we bring only myfaces-impl (+api but that's javax)
+                    // mainly inspired from a comparison with tomahawk packages
                     final String myfaces = name.substring("myfaces.".length());
                     if (myfaces.startsWith("shared")) return true;
                     if (myfaces.startsWith("ee6.")) return true;
                     if (myfaces.startsWith("lifecycle.")) return true;
-                    if (myfaces.startsWith("renderkit.")) return true;
                     if (myfaces.startsWith("context.")) return true;
                     if (myfaces.startsWith("logging.")) return true;
-                    if (myfaces.startsWith("component.")) return true;
+                    // tomahawk uses component.html package
+                    if (myfaces.startsWith("component.visit.") || 
myfaces.equals("component.ComponentResourceContainer")) return true;
                     if (myfaces.startsWith("application.")) return true;
                     if (myfaces.startsWith("config.")) return true;
                     if (myfaces.startsWith("event.")) return true;
-                    if (myfaces.startsWith("taglib.")) return true;
+
                     if (myfaces.startsWith("resource.")) return true;
                     if (myfaces.startsWith("el.")) return true;
-                    if (myfaces.startsWith("webapp.")) return true;
                     if (myfaces.startsWith("spi.")) return true;
                     if (myfaces.startsWith("convert.")) return true;
                     if (myfaces.startsWith("debug.")) return true;
                     if (myfaces.startsWith("util.")) return true;
                     if (myfaces.startsWith("view.")) return true;
+                    if (myfaces.equals("convert.ConverterUtils")) return true;
+
+                    if (myfaces.startsWith("renderkit.")) {
+                        final String renderkit = 
myfaces.substring("renderkit.".length());
+                        if (renderkit.startsWith("html.Html")) return true;
+                        char firstNextletter = renderkit.charAt(0);
+                        if (Character.isUpperCase(firstNextletter)) return 
true;
+                    }
+
+                    if (myfaces.startsWith("taglib.")) {
+                        final String taglib = 
myfaces.substring("taglib.".length());
+                        if (taglib.startsWith("html.Html")) return true;
+                        if (taglib.startsWith("core.")) return true;
+                    }
+
+                    if (myfaces.startsWith("webapp.")) {
+                        final String webapp = 
myfaces.substring("webapp.".length());
+                        if (webapp.startsWith("Faces")) return true;
+                        if (webapp.startsWith("Jsp")) return true;
+                        if (webapp.startsWith("Startup")) return true;
+                        if (webapp.equals("AbstractFacesInitializer")) return 
true;
+                        if (webapp.equals("MyFacesServlet")) return true;
+                        if (webapp.equals("ManagedBeanDestroyerListener")) 
return true;
+                        if (webapp.equals("WebConfigParamsLogger")) return 
true;
+                    }
                 }
             }
 

Modified: openejb/trunk/openejb/tomee/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/pom.xml?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/pom.xml (original)
+++ openejb/trunk/openejb/tomee/pom.xml Tue Aug 14 08:44:58 2012
@@ -44,7 +44,7 @@
     <module>tomee-jaxrs</module>
     <module>tomee-jaxrs-webapp</module>
     <module>apache-tomee</module>
-<!--    <module>apache-tomcat</module>-->
+    <module>apache-tomcat</module>
   </modules>
 
   <repositories>

Modified: openejb/trunk/openejb/tomee/tomee-myfaces/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-myfaces/pom.xml?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-myfaces/pom.xml (original)
+++ openejb/trunk/openejb/tomee/tomee-myfaces/pom.xml Tue Aug 14 08:44:58 2012
@@ -42,5 +42,11 @@
       <version>${myfaces.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-catalina</artifactId>
+      <version>7.0.29</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
 (original)
+++ 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
 Tue Aug 14 08:44:58 2012
@@ -16,11 +16,17 @@
  */
 package org.apache.tomee.myfaces;
 
+import org.apache.catalina.Context;
+import org.apache.catalina.core.ApplicationContext;
+import org.apache.catalina.core.ApplicationContextFacade;
 import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
 import org.apache.myfaces.ee6.MyFacesContainerInitializer;
 import org.apache.myfaces.spi.FacesConfigResourceProvider;
 import org.apache.myfaces.spi.FacesConfigResourceProviderFactory;
+import org.apache.myfaces.webapp.AbstractFacesInitializer;
+import org.apache.myfaces.webapp.StartupServletContextListener;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.log.RemoveLogMessage;
 
 import javax.faces.context.ExternalContext;
 import javax.faces.webapp.FacesServlet;
@@ -28,11 +34,15 @@ import javax.servlet.ServletContainerIni
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import java.io.File;
+import java.lang.reflect.Field;
 import java.net.URL;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 public class TomEEMyFacesContainerInitializer implements 
ServletContainerInitializer {
     public static final String OPENEJB_JSF_SKIP = "openejb.jsf.skip";
@@ -63,11 +73,35 @@ public class TomEEMyFacesContainerInitia
                 passedClasses.add(TomEEMyFacesContainerInitializer.class);
             }
 
+            if (ctx instanceof ApplicationContextFacade) {
+                try {
+                    final ApplicationContext appCtx = (ApplicationContext) 
get(ctx);
+                    final Context tomcatCtx = (Context) get(appCtx);
+                    if 
(!Arrays.asList(tomcatCtx.findApplicationListeners()).contains(StartupServletContextListener.class.getName()))
 {
+                        addListener(ctx);
+                    }
+                } catch (Exception e) {
+                    // add it, not important we'll simply get a warning saying 
it is already here
+                    addListener(ctx);
+                }
+            }
+
+            // some message filtering, not a perf killer since this class 
don't log a lot
+            final Logger abstractInitializerLogger = 
Logger.getLogger(AbstractFacesInitializer.class.getName());
+            abstractInitializerLogger.setFilter(new RemoveLogMessage(
+                    new RemoveLogMessage(abstractInitializerLogger.getFilter(),
+                            Level.WARNING, "No mappings of FacesServlet found. 
Abort initializing MyFaces."),
+                            Level.WARNING, "No mappings of FacesServlet found. 
Abort destroy MyFaces."));
+
             // finally delegating begin sure we'll not call 
isFacesConfigPresent
             delegate.onStartup(classes, ctx);
         }
     }
 
+    private void addListener(final ServletContext ctx) {
+        ctx.addListener(StartupServletContextListener.class);
+    }
+
     // that's the reason why we fork: we don't want to consider our internal 
faces-config.xml
     // see delegate for details
     private boolean isFacesConfigPresent(ServletContext servletContext) {
@@ -91,6 +125,9 @@ public class TomEEMyFacesContainerInitia
                     getFacesConfigResourceProviderFactory(externalContext);
             final FacesConfigResourceProvider provider = 
factory.createFacesConfigResourceProvider(externalContext);
             final Collection<URL> metaInfFacesConfigUrls =  
provider.getMetaInfConfigurationResources(externalContext);
+            if (metaInfFacesConfigUrls == null) {
+                return false;
+            }
 
             // remove our internal faces-config.xml
             final Iterator<URL> it = metaInfFacesConfigUrls.iterator();
@@ -100,10 +137,20 @@ public class TomEEMyFacesContainerInitia
                 }
             }
 
-            return metaInfFacesConfigUrls != null && 
!metaInfFacesConfigUrls.isEmpty();
+            return !metaInfFacesConfigUrls.isEmpty();
         } catch (Exception e) {
             return false;
         }
     }
 
+    private static Object get(final Object facade) throws Exception {
+        final Field field = 
ApplicationContextFacade.class.getDeclaredField("context");
+        boolean acc = field.isAccessible();
+        field.setAccessible(true);
+        try {
+            return field.get(facade);
+        } finally {
+            field.setAccessible(acc);
+        }
+    }
 }

Modified: 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContextListener.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContextListener.java?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContextListener.java
 (original)
+++ 
openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContextListener.java
 Tue Aug 14 08:44:58 2012
@@ -16,10 +16,14 @@
  */
 package org.apache.tomee.myfaces;
 
+import org.apache.myfaces.webapp.StartupServletContextListener;
+
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
 public class TomEEMyFacesContextListener implements ServletContextListener {
+    private StartupServletContextListener delegate;
+
     @Override
     public void contextInitialized(final ServletContextEvent sce) {
         // no-op

Modified: openejb/trunk/openejb/utils/openejb-core-hibernate/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/utils/openejb-core-hibernate/pom.xml?rev=1372778&r1=1372777&r2=1372778&view=diff
==============================================================================
--- openejb/trunk/openejb/utils/openejb-core-hibernate/pom.xml (original)
+++ openejb/trunk/openejb/utils/openejb-core-hibernate/pom.xml Tue Aug 14 
08:44:58 2012
@@ -114,7 +114,7 @@
   </dependencies>
 
   <properties>
-    <hibernate.version>4.1.4.Final</hibernate.version>
+    <hibernate.version>4.1.6.Final</hibernate.version>
     <hibernate-validator.version>4.3.0.Final</hibernate-validator.version>
   </properties>
 </project>


Reply via email to