You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2013/01/28 08:12:59 UTC
svn commit: r1439278 -
/tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
Author: rmannibucau
Date: Mon Jan 28 07:12:58 2013
New Revision: 1439278
URL: http://svn.apache.org/viewvc?rev=1439278&view=rev
Log:
more logic to check jsf activation or not
Modified:
tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
Modified: tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java?rev=1439278&r1=1439277&r2=1439278&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java (original)
+++ tomee/tomee/trunk/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEMyFacesContainerInitializer.java Mon Jan 28 07:12:58 2013
@@ -16,9 +16,12 @@
*/
package org.apache.tomee.myfaces;
+import org.apache.catalina.Container;
import org.apache.catalina.Context;
+import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ApplicationContext;
import org.apache.catalina.core.ApplicationContextFacade;
+import org.apache.catalina.core.StandardContext;
import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
import org.apache.myfaces.ee6.MyFacesContainerInitializer;
import org.apache.myfaces.spi.FacesConfigResourceProvider;
@@ -68,7 +71,7 @@ public class TomEEMyFacesContainerInitia
Level.WARNING, "No mappings of FacesServlet found. Abort initializing MyFaces."),
Level.WARNING, "No mappings of FacesServlet found. Abort destroy MyFaces."));
- if ((classes != null && !classes.isEmpty()) || isFacesConfigPresent(ctx)) {
+ if ((classes != null && !classes.isEmpty()) || isFacesConfigPresent(ctx) || isFacesServletPresent(ctx)) {
// we found a faces-config.xml or some classes so let's delegate to myfaces
// since we don't want to call isFacesConfigPresent again (it scan all jars!!!!)
@@ -99,6 +102,34 @@ public class TomEEMyFacesContainerInitia
}
}
+ private boolean isFacesServletPresent(final ServletContext ctx) {
+ if (ctx instanceof ApplicationContextFacade) {
+ try {
+ final ApplicationContext appCtx = (ApplicationContext) get(ApplicationContextFacade.class, ctx);
+ final Context tomcatCtx = (Context) get(ApplicationContext.class, appCtx);
+ if (tomcatCtx instanceof StandardContext) {
+ final String[] servlets = ((StandardContext) tomcatCtx).getServlets();
+ if (servlets != null) {
+ for (String s : servlets) {
+ if ("Faces Servlet".equals(s)) {
+ return true;
+ }
+ final Container c = tomcatCtx.findChild(s);
+ if (c instanceof Wrapper) {
+ if ("javax.faces.webapp.FacesServlet".equals(((Wrapper) c).getServletClass())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ return false;
+ }
+
private void addListener(final ServletContext ctx) {
final Logger logger = Logger.getLogger(AbstractFacesInitializer.class.getName());
logger.log(Level.INFO, "Installing <listener>" + StartupServletContextListener.class.getName() + "</listener>");