[jboss-cvs] JBossAS SVN: r81079 - in trunk/tomcat: docs and 19 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 14 12:03:00 EST 2008


Author: dimitris at jboss.org
Date: 2008-11-14 12:02:59 -0500 (Fri, 14 Nov 2008)
New Revision: 81079

Modified:
   trunk/tomcat/docs/HttpSessionRepl.gif
   trunk/tomcat/docs/html/resources/HttpSessionRepl.gif
   trunk/tomcat/pom.xml
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossDelegatingInjectionProvider.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossScanningInjectionProvider.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/AnyXmlMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ConnectorMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/EngineMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ExecutorMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/HostMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ListenerMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/LoaderMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ManagerMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ParameterMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/RealmMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ResourcesMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServiceMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/SessionCookieMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ValveMetaData.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/GenericHeaderAuthenticator.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/SecurityContextEstablishmentValve.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/WebUtil.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/SecurityActions.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPIAuthenticator.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPICallbackHandler.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPBasicServerAuthModule.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPFormServerAuthModule.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/SecurityActions.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/TomcatServerAuthModule.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossWebMicrocontainerBeanLocator.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/MicrocontainerIntegrationLifecycleListener.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/SecurityActions.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatServiceMBean.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/TomcatInjectionUtils.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBHandler.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBRemoteHandler.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceContextPropertyInjector.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceRefInjectionHandler.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredManager.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java
   trunk/tomcat/src/resources/jboss-beans.xml
   trunk/tomcat/src/resources/jboss-structure-sar.xml
   trunk/tomcat/src/resources/jboss-structure.xml
   trunk/tomcat/src/resources/test/metadata/server.xml
   trunk/tomcat/src/tests/org/jboss/test/deployers/jboss-web24-ex1.xml
   trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml
   trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml
   trunk/tomcat/src/tests/org/jboss/test/web/metadata/ServerMetaDataUniTestCase.java
   trunk/tomcat/src/webapps/ROOT.war/favicon.ico
   trunk/tomcat/src/webapps/ROOT.war/images/logo.gif
Log:
fix svn properties


Property changes on: trunk/tomcat/docs/HttpSessionRepl.gif
___________________________________________________________________
Name: svn:mime-type
   - application/octet-stream
   + image/gif


Property changes on: trunk/tomcat/docs/html/resources/HttpSessionRepl.gif
___________________________________________________________________
Name: svn:mime-type
   - application/octet-stream
   + image/gif


Property changes on: trunk/tomcat/pom.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,166 +1,166 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.jsf.integration.config;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * This class provides access to the loggers used by Facelets version 1.1.15.
- *
- * @author Stan Silvert
- * @author Pete Muir
- */
-public class FaceletsLoggers 
-{
-    
-   // Don't allow an instance of this class
-   private FaceletsLoggers() {}
-    
-   /**
-    * Determine if Facelets is in the classpath.
-    *
-    * @return <code>true</code> if Facelets is available,
-    *         <code>false</code> otherwise.
-    */
-   public static boolean isFaceletsAvailable()
-   {
-      try
-      {
-         classForName("com.sun.facelets.Facelet");
-         return true;
-      } 
-      catch (ClassNotFoundException e)
-      {
-         return false;
-      }
-   }
-   
-   /**
-    * Return an Iterator of all the java.util.logging.Logger objects used
-    * in Facelets.
-    *
-    * @return The Loggers, or an empty Iterator if Facelets is not available.
-    */
-   public static Iterator<Logger> getLoggers() throws Exception
-   {
-      List<Logger> loggers = new ArrayList<Logger>();
-      
-      if (!isFaceletsAvailable()) return loggers.iterator();
-      
-      // Gah have to do this by reflection as the loggers are protected
-         
-      // And some aren't static, so this really is best effort
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.TagLibraryConfig", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.Compiler", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.impl.DefaultFaceletFactory", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentHandler", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.util.Resource", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.FaceletViewHandler", "log"));
-
-      // These ones are in a package-scoped class
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.CompilationManager", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentRule", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.MetaRulesetImpl", "log"));
-         
-      return loggers.iterator();
-   }
-   
-   private static Logger getPrivateStaticLogger(Class clazz, String fieldName) throws Exception 
-   {
-      Field field = getField(clazz, fieldName);
-      field.setAccessible(true);
-      return (Logger) get(field, new Object());
-   }
-   
-   private static Logger getPrivateStaticLogger(String className, String fieldName) throws Exception
-   {
-      return getPrivateStaticLogger(classForName(className), fieldName);
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Object get(Field field, Object target) throws Exception
-   {
-      try
-      {
-         return field.get(target);
-      }
-      catch (IllegalArgumentException iae)
-      {
-         String message = "Could not get field value by reflection: " + toString(field) + 
-            " on: " + target.getClass().getName();
-         throw new IllegalArgumentException(message, iae);
-      }
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Field getField(Class clazz, String name)
-   {
-      for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
-      {
-         try
-         {
-            return superClass.getDeclaredField(name);
-         }
-         catch (NoSuchFieldException nsfe) {}
-      }
-      throw new IllegalArgumentException("no such field: " + clazz.getName() + '.' + name);
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Class classForName(String name) throws ClassNotFoundException
-   {
-      try 
-      {
-         return Thread.currentThread().getContextClassLoader().loadClass(name);
-      }
-      catch (Exception e)
-      {
-         return Class.forName(name);
-      }
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static String toString(Member member)
-   {
-      return unqualify( member.getDeclaringClass().getName() ) + 
-            '.' + 
-            member.getName();
-   }
-   
-   // Code copied from org.jboss.seam.util.Strings
-   private static String unqualify(String name)
-   {
-      return unqualify(name, '.');
-   }
-   
-   // Code copied from org.jboss.seam.util.Strings
-   private static String unqualify(String name, char sep)
-   {
-      return name.substring( name.lastIndexOf(sep)+1, name.length() );
-   }
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.jsf.integration.config;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * This class provides access to the loggers used by Facelets version 1.1.15.
+ *
+ * @author Stan Silvert
+ * @author Pete Muir
+ */
+public class FaceletsLoggers 
+{
+    
+   // Don't allow an instance of this class
+   private FaceletsLoggers() {}
+    
+   /**
+    * Determine if Facelets is in the classpath.
+    *
+    * @return <code>true</code> if Facelets is available,
+    *         <code>false</code> otherwise.
+    */
+   public static boolean isFaceletsAvailable()
+   {
+      try
+      {
+         classForName("com.sun.facelets.Facelet");
+         return true;
+      } 
+      catch (ClassNotFoundException e)
+      {
+         return false;
+      }
+   }
+   
+   /**
+    * Return an Iterator of all the java.util.logging.Logger objects used
+    * in Facelets.
+    *
+    * @return The Loggers, or an empty Iterator if Facelets is not available.
+    */
+   public static Iterator<Logger> getLoggers() throws Exception
+   {
+      List<Logger> loggers = new ArrayList<Logger>();
+      
+      if (!isFaceletsAvailable()) return loggers.iterator();
+      
+      // Gah have to do this by reflection as the loggers are protected
+         
+      // And some aren't static, so this really is best effort
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.TagLibraryConfig", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.Compiler", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.impl.DefaultFaceletFactory", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentHandler", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.util.Resource", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.FaceletViewHandler", "log"));
+
+      // These ones are in a package-scoped class
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.CompilationManager", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentRule", "log"));
+      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.MetaRulesetImpl", "log"));
+         
+      return loggers.iterator();
+   }
+   
+   private static Logger getPrivateStaticLogger(Class clazz, String fieldName) throws Exception 
+   {
+      Field field = getField(clazz, fieldName);
+      field.setAccessible(true);
+      return (Logger) get(field, new Object());
+   }
+   
+   private static Logger getPrivateStaticLogger(String className, String fieldName) throws Exception
+   {
+      return getPrivateStaticLogger(classForName(className), fieldName);
+   }
+   
+   // Code copied from org.jboss.seam.util.Reflctions
+   private static Object get(Field field, Object target) throws Exception
+   {
+      try
+      {
+         return field.get(target);
+      }
+      catch (IllegalArgumentException iae)
+      {
+         String message = "Could not get field value by reflection: " + toString(field) + 
+            " on: " + target.getClass().getName();
+         throw new IllegalArgumentException(message, iae);
+      }
+   }
+   
+   // Code copied from org.jboss.seam.util.Reflctions
+   private static Field getField(Class clazz, String name)
+   {
+      for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
+      {
+         try
+         {
+            return superClass.getDeclaredField(name);
+         }
+         catch (NoSuchFieldException nsfe) {}
+      }
+      throw new IllegalArgumentException("no such field: " + clazz.getName() + '.' + name);
+   }
+   
+   // Code copied from org.jboss.seam.util.Reflctions
+   private static Class classForName(String name) throws ClassNotFoundException
+   {
+      try 
+      {
+         return Thread.currentThread().getContextClassLoader().loadClass(name);
+      }
+      catch (Exception e)
+      {
+         return Class.forName(name);
+      }
+   }
+   
+   // Code copied from org.jboss.seam.util.Reflctions
+   private static String toString(Member member)
+   {
+      return unqualify( member.getDeclaringClass().getName() ) + 
+            '.' + 
+            member.getName();
+   }
+   
+   // Code copied from org.jboss.seam.util.Strings
+   private static String unqualify(String name)
+   {
+      return unqualify(name, '.');
+   }
+   
+   // Code copied from org.jboss.seam.util.Strings
+   private static String unqualify(String name, char sep)
+   {
+      return name.substring( name.lastIndexOf(sep)+1, name.length() );
+   }
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossDelegatingInjectionProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossDelegatingInjectionProvider.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossDelegatingInjectionProvider.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,116 +1,116 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.jsf.integration.injection;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-
-import org.apache.InstanceManager;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.TomcatInjectionContainer;
-
-import com.sun.faces.spi.InjectionProvider;
-import com.sun.faces.spi.InjectionProviderException;
-
-/**
- * A JSF injection provider. This class delegates the injection to the <code>TomcatInjectionContainer</code>.
- * The processing of this injectionProvider is based on the <code>JBossWebMetaData</code>
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class JBossDelegatingInjectionProvider implements InjectionProvider
-{
-   /** The injection container. */
-   protected TomcatInjectionContainer injectionContainer = null;
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(InjectionProvider.class);
-   
-   public JBossDelegatingInjectionProvider()
-   {
-      Object context = FacesContext.getCurrentInstance().getExternalContext().getContext();
-      // In case of a servletContext - could maybe also be a PortletContext !?
-      if(context instanceof ServletContext && context != null)
-      {
-         ServletContext servletContext = (ServletContext) (context);
-         this.injectionContainer = (TomcatInjectionContainer) servletContext
-                     .getAttribute(InstanceManager.class.getName());
-         
-      }
-      if(injectionContainer == null)
-         log.debug("JSF injection not available for this web deployment.");
-   }
-   
-   protected JBossDelegatingInjectionProvider(TomcatInjectionContainer injectionContainer)
-   {
-      this.injectionContainer = injectionContainer;
-      
-      if(injectionContainer == null)
-         log.debug("JSF injection not available for this web deployment.");      
-   }
-   
-   public void inject(Object object) throws InjectionProviderException
-   {
-      if(! checkInjectionContainer()) return;
-      try
-      {
-         injectionContainer.processInjectors(object);
-      }
-      catch(Throwable t)
-      {
-         throw new InjectionProviderException("unable to process injections.", t);
-      }
-   }
-
-   public void invokePostConstruct(Object object) throws InjectionProviderException
-   {
-      if(! checkInjectionContainer()) return;
-      try
-      {
-         injectionContainer.postConstruct(object);
-      }
-      catch(Throwable t)
-      {
-         throw new InjectionProviderException("unable to process invokePostConstruct.", t);
-      }
-   }
-
-   public void invokePreDestroy(Object object) throws InjectionProviderException
-   {
-      if(! checkInjectionContainer()) return;
-      try
-      {
-         injectionContainer.preDestroy(object);
-      }
-      catch(Throwable t)
-      {
-         throw new InjectionProviderException("unable to process invokePreDestroy.", t);
-      }
-   }
-
-   private boolean checkInjectionContainer()
-   {
-      return injectionContainer != null;
-   }
-}
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.jsf.integration.injection;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+
+import org.apache.InstanceManager;
+import org.jboss.logging.Logger;
+import org.jboss.web.tomcat.service.TomcatInjectionContainer;
+
+import com.sun.faces.spi.InjectionProvider;
+import com.sun.faces.spi.InjectionProviderException;
+
+/**
+ * A JSF injection provider. This class delegates the injection to the <code>TomcatInjectionContainer</code>.
+ * The processing of this injectionProvider is based on the <code>JBossWebMetaData</code>
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JBossDelegatingInjectionProvider implements InjectionProvider
+{
+   /** The injection container. */
+   protected TomcatInjectionContainer injectionContainer = null;
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(InjectionProvider.class);
+   
+   public JBossDelegatingInjectionProvider()
+   {
+      Object context = FacesContext.getCurrentInstance().getExternalContext().getContext();
+      // In case of a servletContext - could maybe also be a PortletContext !?
+      if(context instanceof ServletContext && context != null)
+      {
+         ServletContext servletContext = (ServletContext) (context);
+         this.injectionContainer = (TomcatInjectionContainer) servletContext
+                     .getAttribute(InstanceManager.class.getName());
+         
+      }
+      if(injectionContainer == null)
+         log.debug("JSF injection not available for this web deployment.");
+   }
+   
+   protected JBossDelegatingInjectionProvider(TomcatInjectionContainer injectionContainer)
+   {
+      this.injectionContainer = injectionContainer;
+      
+      if(injectionContainer == null)
+         log.debug("JSF injection not available for this web deployment.");      
+   }
+   
+   public void inject(Object object) throws InjectionProviderException
+   {
+      if(! checkInjectionContainer()) return;
+      try
+      {
+         injectionContainer.processInjectors(object);
+      }
+      catch(Throwable t)
+      {
+         throw new InjectionProviderException("unable to process injections.", t);
+      }
+   }
+
+   public void invokePostConstruct(Object object) throws InjectionProviderException
+   {
+      if(! checkInjectionContainer()) return;
+      try
+      {
+         injectionContainer.postConstruct(object);
+      }
+      catch(Throwable t)
+      {
+         throw new InjectionProviderException("unable to process invokePostConstruct.", t);
+      }
+   }
+
+   public void invokePreDestroy(Object object) throws InjectionProviderException
+   {
+      if(! checkInjectionContainer()) return;
+      try
+      {
+         injectionContainer.preDestroy(object);
+      }
+      catch(Throwable t)
+      {
+         throw new InjectionProviderException("unable to process invokePreDestroy.", t);
+      }
+   }
+
+   private boolean checkInjectionContainer()
+   {
+      return injectionContainer != null;
+   }
+}
+


Property changes on: trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossDelegatingInjectionProvider.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossScanningInjectionProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossScanningInjectionProvider.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossScanningInjectionProvider.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,183 +1,183 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.jsf.integration.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-
-import org.apache.InstanceManager;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.TomcatInjectionContainer;
-
-import com.sun.faces.spi.InjectionProvider;
-import com.sun.faces.spi.InjectionProviderException;
-
-/**
- * A JSF injection provider.
- * The dynamic processing of annotations and injections is handled by the
- * <code>TomcatInjectionContainer</code>.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class JBossScanningInjectionProvider implements InjectionProvider
-{
-
-   /** The injection container. */
-   protected TomcatInjectionContainer injectionContainer = null;
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(InjectionProvider.class);
-
-   public JBossScanningInjectionProvider()
-   {
-      Object context = FacesContext.getCurrentInstance().getExternalContext().getContext();
-      // In case of a servletContext - could maybe also be a PortletContext !?
-      if (context != null && context instanceof ServletContext)
-      {
-         ServletContext servletContext = (ServletContext) (context);
-         this.injectionContainer = (TomcatInjectionContainer) servletContext
-                     .getAttribute(InstanceManager.class.getName());
-      }
-      if (injectionContainer == null)
-         log.debug("JSF injection not available for this web deployment.");
-   }
-   
-   protected JBossScanningInjectionProvider(TomcatInjectionContainer injectionContainer)
-   {
-      this.injectionContainer = injectionContainer;
-      
-      if(injectionContainer == null)
-         log.debug("JSF injection not available for this web deployment.");      
-   }
-
-   /**
-    * Invoke a postConstruct method annotated with @PostConstruct
-    * 
-    * @param managedBean the managed bean
-    * @throws InjectionProviderException
-    */
-   public void invokePostConstruct(Object managedBean) throws InjectionProviderException
-   {
-      try
-      {
-         Method postConstruct = getLifeCycleMethod(managedBean, PostConstruct.class);
-
-         if (postConstruct != null)
-         {
-            boolean accessibility = postConstruct.isAccessible();
-            postConstruct.setAccessible(true);
-            postConstruct.invoke(managedBean);
-            postConstruct.setAccessible(accessibility);
-         }
-      }
-      catch (Exception e)
-      {
-         throw new InjectionProviderException("PostConstruct failed on managed bean.", e);
-      }
-   }
-   
-   /**
-    * Invoke a preDestroy method annotated with @PreDestroy
-    * 
-    * @param managedBean the managed bean
-    * @throws InjectionProviderException
-    */
-   public void invokePreDestroy(Object managedBean) throws InjectionProviderException
-   {
-      try
-      {
-         Method preDestroy = getLifeCycleMethod(managedBean, PreDestroy.class);
-
-         if (preDestroy != null)
-         {
-            boolean accessibility = preDestroy.isAccessible();
-            preDestroy.setAccessible(true);
-            preDestroy.invoke(managedBean);
-            preDestroy.setAccessible(accessibility);
-         }
-      }
-      catch (Exception e)
-      {
-         throw new InjectionProviderException("PreDestroy failed on managed bean.", e);
-      }
-   }
-   
-   /**
-    * Process annotations and injection for a managedBean.
-    * This delegates the processing of annotations and injection
-    * to the <code>TomcatInjectionContainer</code>.
-    * 
-    * @param managedBean the managed bean
-    * @throws InjectionProviderException
-    */
-   public void inject(Object managedBean) throws InjectionProviderException
-   {
-      if(! checkInjectionContainer()) return;
-      try
-      {
-         // Process annotations
-         injectionContainer.processAnnotations(managedBean);
-         
-         // Process injectors
-         injectionContainer.processInjectors(managedBean);
-         
-      }
-      catch(Exception e)
-      {
-         throw new InjectionProviderException("Injection failed on managed bean.", e);
-      }
-   }
-
-   private Method getLifeCycleMethod(Object managedBean, Class<? extends Annotation> annotation)
-   {
-      Method[] methods = managedBean.getClass().getDeclaredMethods();
-      Method lifeCycleMethod = null;
-      for (int i = 0; i < methods.length; i++)
-      {
-         if (methods[i].isAnnotationPresent(annotation))
-         {
-            if ((lifeCycleMethod != null) || (methods[i].getParameterTypes().length != 0)
-                  || (Modifier.isStatic(methods[i].getModifiers())) || (methods[i].getExceptionTypes().length > 0)
-                  || (!methods[i].getReturnType().getName().equals("void")))
-            {
-               throw new IllegalArgumentException("Invalid PostConstruct method.");
-            }
-            lifeCycleMethod = methods[i];
-         }
-      }
-
-      return lifeCycleMethod;
-   }
-   
-   private boolean checkInjectionContainer()
-   {
-      return injectionContainer != null;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.jsf.integration.injection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+
+import org.apache.InstanceManager;
+import org.jboss.logging.Logger;
+import org.jboss.web.tomcat.service.TomcatInjectionContainer;
+
+import com.sun.faces.spi.InjectionProvider;
+import com.sun.faces.spi.InjectionProviderException;
+
+/**
+ * A JSF injection provider.
+ * The dynamic processing of annotations and injections is handled by the
+ * <code>TomcatInjectionContainer</code>.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JBossScanningInjectionProvider implements InjectionProvider
+{
+
+   /** The injection container. */
+   protected TomcatInjectionContainer injectionContainer = null;
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(InjectionProvider.class);
+
+   public JBossScanningInjectionProvider()
+   {
+      Object context = FacesContext.getCurrentInstance().getExternalContext().getContext();
+      // In case of a servletContext - could maybe also be a PortletContext !?
+      if (context != null && context instanceof ServletContext)
+      {
+         ServletContext servletContext = (ServletContext) (context);
+         this.injectionContainer = (TomcatInjectionContainer) servletContext
+                     .getAttribute(InstanceManager.class.getName());
+      }
+      if (injectionContainer == null)
+         log.debug("JSF injection not available for this web deployment.");
+   }
+   
+   protected JBossScanningInjectionProvider(TomcatInjectionContainer injectionContainer)
+   {
+      this.injectionContainer = injectionContainer;
+      
+      if(injectionContainer == null)
+         log.debug("JSF injection not available for this web deployment.");      
+   }
+
+   /**
+    * Invoke a postConstruct method annotated with @PostConstruct
+    * 
+    * @param managedBean the managed bean
+    * @throws InjectionProviderException
+    */
+   public void invokePostConstruct(Object managedBean) throws InjectionProviderException
+   {
+      try
+      {
+         Method postConstruct = getLifeCycleMethod(managedBean, PostConstruct.class);
+
+         if (postConstruct != null)
+         {
+            boolean accessibility = postConstruct.isAccessible();
+            postConstruct.setAccessible(true);
+            postConstruct.invoke(managedBean);
+            postConstruct.setAccessible(accessibility);
+         }
+      }
+      catch (Exception e)
+      {
+         throw new InjectionProviderException("PostConstruct failed on managed bean.", e);
+      }
+   }
+   
+   /**
+    * Invoke a preDestroy method annotated with @PreDestroy
+    * 
+    * @param managedBean the managed bean
+    * @throws InjectionProviderException
+    */
+   public void invokePreDestroy(Object managedBean) throws InjectionProviderException
+   {
+      try
+      {
+         Method preDestroy = getLifeCycleMethod(managedBean, PreDestroy.class);
+
+         if (preDestroy != null)
+         {
+            boolean accessibility = preDestroy.isAccessible();
+            preDestroy.setAccessible(true);
+            preDestroy.invoke(managedBean);
+            preDestroy.setAccessible(accessibility);
+         }
+      }
+      catch (Exception e)
+      {
+         throw new InjectionProviderException("PreDestroy failed on managed bean.", e);
+      }
+   }
+   
+   /**
+    * Process annotations and injection for a managedBean.
+    * This delegates the processing of annotations and injection
+    * to the <code>TomcatInjectionContainer</code>.
+    * 
+    * @param managedBean the managed bean
+    * @throws InjectionProviderException
+    */
+   public void inject(Object managedBean) throws InjectionProviderException
+   {
+      if(! checkInjectionContainer()) return;
+      try
+      {
+         // Process annotations
+         injectionContainer.processAnnotations(managedBean);
+         
+         // Process injectors
+         injectionContainer.processInjectors(managedBean);
+         
+      }
+      catch(Exception e)
+      {
+         throw new InjectionProviderException("Injection failed on managed bean.", e);
+      }
+   }
+
+   private Method getLifeCycleMethod(Object managedBean, Class<? extends Annotation> annotation)
+   {
+      Method[] methods = managedBean.getClass().getDeclaredMethods();
+      Method lifeCycleMethod = null;
+      for (int i = 0; i < methods.length; i++)
+      {
+         if (methods[i].isAnnotationPresent(annotation))
+         {
+            if ((lifeCycleMethod != null) || (methods[i].getParameterTypes().length != 0)
+                  || (Modifier.isStatic(methods[i].getModifiers())) || (methods[i].getExceptionTypes().length > 0)
+                  || (!methods[i].getReturnType().getName().equals("void")))
+            {
+               throw new IllegalArgumentException("Invalid PostConstruct method.");
+            }
+            lifeCycleMethod = methods[i];
+         }
+      }
+
+      return lifeCycleMethod;
+   }
+   
+   private boolean checkInjectionContainer()
+   {
+      return injectionContainer != null;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossScanningInjectionProvider.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,53 +1,53 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.jsf.integration.serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectStreamClass;
-import org.jboss.serial.io.JBossObjectInputStream;
-
-/**
- * Provides override of resolveClass() as required by the JSF spi.  See javadoc
- * of com.sun.faces.spi.SerializationProvider.createObjectInputStream for details.
- *
- * @author Stan Silvert
- */
-public class JBossFacesObjectInputStream extends JBossObjectInputStream 
-{
-    /**
-     * Create new JBossFacesObjectInputStream.
-     */
-    public JBossFacesObjectInputStream(InputStream source) throws IOException
-    {
-        super(source);
-    }
-    
-    /**
-     * Make sure this resolves to a class from the proper class loader.
-     */
-    protected Class resolveClass(ObjectStreamClass streamClass) throws ClassNotFoundException, IOException 
-    {
-        return Class.forName(streamClass.getName(), true, Thread.currentThread().getContextClassLoader());
-    }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.jsf.integration.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import org.jboss.serial.io.JBossObjectInputStream;
+
+/**
+ * Provides override of resolveClass() as required by the JSF spi.  See javadoc
+ * of com.sun.faces.spi.SerializationProvider.createObjectInputStream for details.
+ *
+ * @author Stan Silvert
+ */
+public class JBossFacesObjectInputStream extends JBossObjectInputStream 
+{
+    /**
+     * Create new JBossFacesObjectInputStream.
+     */
+    public JBossFacesObjectInputStream(InputStream source) throws IOException
+    {
+        super(source);
+    }
+    
+    /**
+     * Make sure this resolves to a class from the proper class loader.
+     */
+    protected Class resolveClass(ObjectStreamClass streamClass) throws ClassNotFoundException, IOException 
+    {
+        return Class.forName(streamClass.getName(), true, Thread.currentThread().getContextClassLoader());
+    }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,66 +1,66 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.jsf.integration.serialization;
-
-import com.sun.faces.spi.SerializationProvider;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import org.jboss.logging.Logger;
-import org.jboss.serial.io.JBossObjectOutputStream;
-
-/**
- * Provides interface between JSF RI and JBoss Serialization for better
- * performance of client-side state saving.
- *
- * @author Stan Silvert
- */
-public class JBossSerializationProvider implements SerializationProvider 
-{
-    private static final Logger LOG = Logger.getLogger(JBossSerializationProvider.class);
-
-    /**
-     * No-arg constructor required.
-     */
-    public JBossSerializationProvider() 
-    {
-        LOG.info("Using JBoss Serialization for JavaServer Faces.");
-    }
-    
-    /**
-     * Create a fast ObjectInputStream using JBoss Serialization.
-     */
-    public ObjectInputStream createObjectInputStream(InputStream source) throws IOException {
-        return new JBossFacesObjectInputStream(source);
-    }
-
-    /**
-     * Create a fast ObjectOutputStream using JBoss Serialization.
-     */
-    public ObjectOutputStream createObjectOutputStream(OutputStream destination) throws IOException 
-    {
-        return new JBossObjectOutputStream(destination);
-    }
-    
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.jsf.integration.serialization;
+
+import com.sun.faces.spi.SerializationProvider;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * Provides interface between JSF RI and JBoss Serialization for better
+ * performance of client-side state saving.
+ *
+ * @author Stan Silvert
+ */
+public class JBossSerializationProvider implements SerializationProvider 
+{
+    private static final Logger LOG = Logger.getLogger(JBossSerializationProvider.class);
+
+    /**
+     * No-arg constructor required.
+     */
+    public JBossSerializationProvider() 
+    {
+        LOG.info("Using JBoss Serialization for JavaServer Faces.");
+    }
+    
+    /**
+     * Create a fast ObjectInputStream using JBoss Serialization.
+     */
+    public ObjectInputStream createObjectInputStream(InputStream source) throws IOException {
+        return new JBossFacesObjectInputStream(source);
+    }
+
+    /**
+     * Create a fast ObjectOutputStream using JBoss Serialization.
+     */
+    public ObjectOutputStream createObjectOutputStream(OutputStream destination) throws IOException 
+    {
+        return new JBossObjectOutputStream(destination);
+    }
+    
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/AnyXmlMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/AnyXmlMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/AnyXmlMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import javax.xml.bind.annotation.XmlAnyAttribute;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.namespace.QName;
-
-public class AnyXmlMetaData implements Serializable
-{
-   private String className;
-   private Map<QName, Object> attributes;
-   
-   public String getClassName()
-   {
-      return className;
-   }
-   @XmlAttribute(name = "className")
-   public void setClassName(String className)
-   {
-      this.className = className;
-   }
-
-   public Map<QName, Object> getAttributes()
-   {
-      return attributes;
-   }
-   @XmlAnyAttribute
-   public void setAttributes(Map<QName, Object> attributes)
-   {
-      this.attributes = attributes;
-   }
-
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.namespace.QName;
+
+public class AnyXmlMetaData implements Serializable
+{
+   private String className;
+   private Map<QName, Object> attributes;
+   
+   public String getClassName()
+   {
+      return className;
+   }
+   @XmlAttribute(name = "className")
+   public void setClassName(String className)
+   {
+      this.className = className;
+   }
+
+   public Map<QName, Object> getAttributes()
+   {
+      return attributes;
+   }
+   @XmlAnyAttribute
+   public void setAttributes(Map<QName, Object> attributes)
+   {
+      this.attributes = attributes;
+   }
+
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/AnyXmlMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ConnectorMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ConnectorMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ConnectorMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,56 +1,56 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import javax.xml.bind.annotation.XmlAttribute;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ConnectorMetaData extends AnyXmlMetaData
-{
-   private String executor;
-   private String protocol;
-   
-   public String getExecutor()
-   {
-      return executor;
-   }
-   @XmlAttribute(name = "executor")
-   public void setExecutor(String executor)
-   {
-      this.executor = executor;
-   }
-   
-   public String getProtocol()
-   {
-      return protocol;
-   }
-   @XmlAttribute(name = "protocol")
-   public void setProtocol(String protocol)
-   {
-      this.protocol = protocol;
-   }
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ConnectorMetaData extends AnyXmlMetaData
+{
+   private String executor;
+   private String protocol;
+   
+   public String getExecutor()
+   {
+      return executor;
+   }
+   @XmlAttribute(name = "executor")
+   public void setExecutor(String executor)
+   {
+      this.executor = executor;
+   }
+   
+   public String getProtocol()
+   {
+      return protocol;
+   }
+   @XmlAttribute(name = "protocol")
+   public void setProtocol(String protocol)
+   {
+      this.protocol = protocol;
+   }
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ConnectorMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,161 +1,161 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
- at XmlRootElement(name="Context")
-public class ContextMetaData extends AnyXmlMetaData
-{
-   private String name;
-   private String docBase;
-   private List<ListenerMetaData> listeners;
-   private List<ValveMetaData> valves;
-   private List<String> instanceListeners;
-   private LoaderMetaData loader;
-   private ManagerMetaData manager;
-   private RealmMetaData realm;
-   private List<ParameterMetaData> parameters;
-   private ResourcesMetaData resources;
-   private SessionCookieMetaData sessionCookie;
-   // FIXME: no support for the naming elements (which might be the right thing to do)
-   // FIXME: no WatchedResource, WrapperLifecycle, WrapperListener
-   
-   public String getName()
-   {
-      return name;
-   }
-   @XmlAttribute(name = "name")
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-   
-   public String getDocBase()
-   {
-      return docBase;
-   }
-   @XmlAttribute(name = "docBase")
-   public void setDocBase(String docBase)
-   {
-      this.docBase = docBase;
-   }
-   
-   public List<ListenerMetaData> getListeners()
-   {
-      return listeners;
-   }
-   @XmlElement(name = "Listener")
-   public void setListeners(List<ListenerMetaData> listeners)
-   {
-      this.listeners = listeners;
-   }
-
-   public RealmMetaData getRealm()
-   {
-      return realm;
-   }
-   @XmlElement(name = "Realm")
-   public void setRealm(RealmMetaData realm)
-   {
-      this.realm = realm;
-   }
-   
-   public List<ValveMetaData> getValves()
-   {
-      return valves;
-   }
-   @XmlElement(name = "Valve")
-   public void setValves(List<ValveMetaData> valves)
-   {
-      this.valves = valves;
-   }
-
-   public List<String> getInstanceListeners()
-   {
-      return instanceListeners;
-   }
-   @XmlElement(name = "InstanceListener")
-   public void setInstanceListeners(List<String> instanceListeners)
-   {
-      this.instanceListeners = instanceListeners;
-   }
-
-   public LoaderMetaData getLoader()
-   {
-      return loader;
-   }
-   @XmlElement(name = "Loader")
-   public void setLoader(LoaderMetaData loader)
-   {
-      this.loader = loader;
-   }
-   
-   public ManagerMetaData getManager()
-   {
-      return manager;
-   }
-   @XmlElement(name = "Manager")
-   public void setManager(ManagerMetaData manager)
-   {
-      this.manager = manager;
-   }
-   
-   public List<ParameterMetaData> getParameters()
-   {
-      return parameters;
-   }
-   @XmlElement(name = "Parameters")
-   public void setParameters(List<ParameterMetaData> parameters)
-   {
-      this.parameters = parameters;
-   }
-
-   public ResourcesMetaData getResources()
-   {
-      return resources;
-   }
-   @XmlElement(name = "Resources")
-   public void setResources(ResourcesMetaData resources)
-   {
-      this.resources = resources;
-   }
-   
-   public SessionCookieMetaData getSessionCookie()
-   {
-      return sessionCookie;
-   }
-   @XmlElement(name = "SessionCookie")
-   public void setSessionCookie(SessionCookieMetaData sessionCookie)
-   {
-      this.sessionCookie = sessionCookie;
-   }
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at XmlRootElement(name="Context")
+public class ContextMetaData extends AnyXmlMetaData
+{
+   private String name;
+   private String docBase;
+   private List<ListenerMetaData> listeners;
+   private List<ValveMetaData> valves;
+   private List<String> instanceListeners;
+   private LoaderMetaData loader;
+   private ManagerMetaData manager;
+   private RealmMetaData realm;
+   private List<ParameterMetaData> parameters;
+   private ResourcesMetaData resources;
+   private SessionCookieMetaData sessionCookie;
+   // FIXME: no support for the naming elements (which might be the right thing to do)
+   // FIXME: no WatchedResource, WrapperLifecycle, WrapperListener
+   
+   public String getName()
+   {
+      return name;
+   }
+   @XmlAttribute(name = "name")
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   public String getDocBase()
+   {
+      return docBase;
+   }
+   @XmlAttribute(name = "docBase")
+   public void setDocBase(String docBase)
+   {
+      this.docBase = docBase;
+   }
+   
+   public List<ListenerMetaData> getListeners()
+   {
+      return listeners;
+   }
+   @XmlElement(name = "Listener")
+   public void setListeners(List<ListenerMetaData> listeners)
+   {
+      this.listeners = listeners;
+   }
+
+   public RealmMetaData getRealm()
+   {
+      return realm;
+   }
+   @XmlElement(name = "Realm")
+   public void setRealm(RealmMetaData realm)
+   {
+      this.realm = realm;
+   }
+   
+   public List<ValveMetaData> getValves()
+   {
+      return valves;
+   }
+   @XmlElement(name = "Valve")
+   public void setValves(List<ValveMetaData> valves)
+   {
+      this.valves = valves;
+   }
+
+   public List<String> getInstanceListeners()
+   {
+      return instanceListeners;
+   }
+   @XmlElement(name = "InstanceListener")
+   public void setInstanceListeners(List<String> instanceListeners)
+   {
+      this.instanceListeners = instanceListeners;
+   }
+
+   public LoaderMetaData getLoader()
+   {
+      return loader;
+   }
+   @XmlElement(name = "Loader")
+   public void setLoader(LoaderMetaData loader)
+   {
+      this.loader = loader;
+   }
+   
+   public ManagerMetaData getManager()
+   {
+      return manager;
+   }
+   @XmlElement(name = "Manager")
+   public void setManager(ManagerMetaData manager)
+   {
+      this.manager = manager;
+   }
+   
+   public List<ParameterMetaData> getParameters()
+   {
+      return parameters;
+   }
+   @XmlElement(name = "Parameters")
+   public void setParameters(List<ParameterMetaData> parameters)
+   {
+      this.parameters = parameters;
+   }
+
+   public ResourcesMetaData getResources()
+   {
+      return resources;
+   }
+   @XmlElement(name = "Resources")
+   public void setResources(ResourcesMetaData resources)
+   {
+      this.resources = resources;
+   }
+   
+   public SessionCookieMetaData getSessionCookie()
+   {
+      return sessionCookie;
+   }
+   @XmlElement(name = "SessionCookie")
+   public void setSessionCookie(SessionCookieMetaData sessionCookie)
+   {
+      this.sessionCookie = sessionCookie;
+   }
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/EngineMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/EngineMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/EngineMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,113 +1,113 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class EngineMetaData extends AnyXmlMetaData
-{
-   private String name;
-   private String jvmRoute;
-   private String defaultHost;
-   private List<HostMetaData> hosts;
-   private List<ListenerMetaData> listeners;
-   private List<ValveMetaData> valves;
-   private RealmMetaData realm;
-
-   public String getName()
-   {
-      return name;
-   }
-   @XmlAttribute(name = "name")
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-   
-   public String getJvmRoute()
-   {
-      return jvmRoute;
-   }
-   @XmlAttribute(name = "jvmRoute")
-   public void setJvmRoute(String jvmRoute)
-   {
-      this.jvmRoute = jvmRoute;
-   }
-   
-   public String getDefaultHost()
-   {
-      return defaultHost;
-   }
-   @XmlAttribute(name = "defaultHost")
-   public void setDefaultHost(String defaultHost)
-   {
-      this.defaultHost = defaultHost;
-   }
-   
-   public List<HostMetaData> getHosts()
-   {
-      return hosts;
-   }
-   @XmlElement(name = "Host")
-   public void setHosts(List<HostMetaData> hosts)
-   {
-      this.hosts = hosts;
-   }
-
-   public List<ListenerMetaData> getListeners()
-   {
-      return listeners;
-   }
-   @XmlElement(name = "Listener")
-   public void setListeners(List<ListenerMetaData> listeners)
-   {
-      this.listeners = listeners;
-   }
-
-   public RealmMetaData getRealm()
-   {
-      return realm;
-   }
-   @XmlElement(name = "Realm")
-   public void setRealm(RealmMetaData realm)
-   {
-      this.realm = realm;
-   }
-   
-   public List<ValveMetaData> getValves()
-   {
-      return valves;
-   }
-   @XmlElement(name = "Valve")
-   public void setValves(List<ValveMetaData> valves)
-   {
-      this.valves = valves;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class EngineMetaData extends AnyXmlMetaData
+{
+   private String name;
+   private String jvmRoute;
+   private String defaultHost;
+   private List<HostMetaData> hosts;
+   private List<ListenerMetaData> listeners;
+   private List<ValveMetaData> valves;
+   private RealmMetaData realm;
+
+   public String getName()
+   {
+      return name;
+   }
+   @XmlAttribute(name = "name")
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   public String getJvmRoute()
+   {
+      return jvmRoute;
+   }
+   @XmlAttribute(name = "jvmRoute")
+   public void setJvmRoute(String jvmRoute)
+   {
+      this.jvmRoute = jvmRoute;
+   }
+   
+   public String getDefaultHost()
+   {
+      return defaultHost;
+   }
+   @XmlAttribute(name = "defaultHost")
+   public void setDefaultHost(String defaultHost)
+   {
+      this.defaultHost = defaultHost;
+   }
+   
+   public List<HostMetaData> getHosts()
+   {
+      return hosts;
+   }
+   @XmlElement(name = "Host")
+   public void setHosts(List<HostMetaData> hosts)
+   {
+      this.hosts = hosts;
+   }
+
+   public List<ListenerMetaData> getListeners()
+   {
+      return listeners;
+   }
+   @XmlElement(name = "Listener")
+   public void setListeners(List<ListenerMetaData> listeners)
+   {
+      this.listeners = listeners;
+   }
+
+   public RealmMetaData getRealm()
+   {
+      return realm;
+   }
+   @XmlElement(name = "Realm")
+   public void setRealm(RealmMetaData realm)
+   {
+      this.realm = realm;
+   }
+   
+   public List<ValveMetaData> getValves()
+   {
+      return valves;
+   }
+   @XmlElement(name = "Valve")
+   public void setValves(List<ValveMetaData> valves)
+   {
+      this.valves = valves;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/EngineMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ExecutorMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ExecutorMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ExecutorMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ExecutorMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ExecutorMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ExecutorMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/HostMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/HostMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/HostMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,105 +1,105 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class HostMetaData extends AnyXmlMetaData
-{
-   private String name;
-   private List<ListenerMetaData> listeners;
-   private List<ValveMetaData> valves;
-   // In AS 5+, hardcoding contexts should be forbidden
-   //private List<ContextMetaData> contexts;
-   private RealmMetaData realm;
-   private List<String> aliases;
-   
-   public String getName()
-   {
-      return name;
-   }
-   @XmlAttribute(name = "name")
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-   
-   public List<String> getAliases()
-   {
-      return aliases;
-   }
-   @XmlElement(name = "Alias")
-   public void setAliases(List<String> aliases)
-   {
-      this.aliases = aliases;
-   }
-
-   /*
-   public List<ContextMetaData> getContexts()
-   {
-      return contexts;
-   }
-   @XmlElement(name = "Context")
-   public void setContexts(List<ContextMetaData> contexts)
-   {
-      this.contexts = contexts;
-   }
-   */
-
-   public List<ListenerMetaData> getListeners()
-   {
-      return listeners;
-   }
-   @XmlElement(name = "Listener")
-   public void setListeners(List<ListenerMetaData> listeners)
-   {
-      this.listeners = listeners;
-   }
-
-   public RealmMetaData getRealm()
-   {
-      return realm;
-   }
-   @XmlElement(name = "Realm")
-   public void setRealm(RealmMetaData realm)
-   {
-      this.realm = realm;
-   }
-   
-   public List<ValveMetaData> getValves()
-   {
-      return valves;
-   }
-   @XmlElement(name = "Valve")
-   public void setValves(List<ValveMetaData> valves)
-   {
-      this.valves = valves;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class HostMetaData extends AnyXmlMetaData
+{
+   private String name;
+   private List<ListenerMetaData> listeners;
+   private List<ValveMetaData> valves;
+   // In AS 5+, hardcoding contexts should be forbidden
+   //private List<ContextMetaData> contexts;
+   private RealmMetaData realm;
+   private List<String> aliases;
+   
+   public String getName()
+   {
+      return name;
+   }
+   @XmlAttribute(name = "name")
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   public List<String> getAliases()
+   {
+      return aliases;
+   }
+   @XmlElement(name = "Alias")
+   public void setAliases(List<String> aliases)
+   {
+      this.aliases = aliases;
+   }
+
+   /*
+   public List<ContextMetaData> getContexts()
+   {
+      return contexts;
+   }
+   @XmlElement(name = "Context")
+   public void setContexts(List<ContextMetaData> contexts)
+   {
+      this.contexts = contexts;
+   }
+   */
+
+   public List<ListenerMetaData> getListeners()
+   {
+      return listeners;
+   }
+   @XmlElement(name = "Listener")
+   public void setListeners(List<ListenerMetaData> listeners)
+   {
+      this.listeners = listeners;
+   }
+
+   public RealmMetaData getRealm()
+   {
+      return realm;
+   }
+   @XmlElement(name = "Realm")
+   public void setRealm(RealmMetaData realm)
+   {
+      this.realm = realm;
+   }
+   
+   public List<ValveMetaData> getValves()
+   {
+      return valves;
+   }
+   @XmlElement(name = "Valve")
+   public void setValves(List<ValveMetaData> valves)
+   {
+      this.valves = valves;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/HostMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ListenerMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ListenerMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ListenerMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ListenerMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ListenerMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ListenerMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/LoaderMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/LoaderMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/LoaderMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class LoaderMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class LoaderMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/LoaderMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ManagerMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ManagerMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ManagerMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagerMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagerMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ManagerMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ParameterMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ParameterMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ParameterMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ParameterMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ParameterMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ParameterMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/RealmMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/RealmMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/RealmMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class RealmMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class RealmMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/RealmMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ResourcesMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ResourcesMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ResourcesMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ResourcesMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ResourcesMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ResourcesMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,59 +1,59 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
- at XmlRootElement(name="Server")
-public class ServerMetaData extends AnyXmlMetaData
-{
-   private List<ServiceMetaData> services;
-   private List<ListenerMetaData> listeners;
-
-   public List<ServiceMetaData> getServices()
-   {
-      return services;
-   }
-   @XmlElement(name = "Service")
-   public void setServices(List<ServiceMetaData> services)
-   {
-      this.services = services;
-   }
-
-   public List<ListenerMetaData> getListeners()
-   {
-      return listeners;
-   }
-   @XmlElement(name = "Listener")
-   public void setListeners(List<ListenerMetaData> listeners)
-   {
-      this.listeners = listeners;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at XmlRootElement(name="Server")
+public class ServerMetaData extends AnyXmlMetaData
+{
+   private List<ServiceMetaData> services;
+   private List<ListenerMetaData> listeners;
+
+   public List<ServiceMetaData> getServices()
+   {
+      return services;
+   }
+   @XmlElement(name = "Service")
+   public void setServices(List<ServiceMetaData> services)
+   {
+      this.services = services;
+   }
+
+   public List<ListenerMetaData> getListeners()
+   {
+      return listeners;
+   }
+   @XmlElement(name = "Listener")
+   public void setListeners(List<ListenerMetaData> listeners)
+   {
+      this.listeners = listeners;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServiceMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServiceMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServiceMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,91 +1,91 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ServiceMetaData extends AnyXmlMetaData
-{
-   private String name;
-   private EngineMetaData engine;
-   private ExecutorMetaData executor;
-   private List<ConnectorMetaData> connectors;
-   private List<ListenerMetaData> listeners;
-
-   public String getName()
-   {
-      return name;
-   }
-   @XmlAttribute(name = "name")
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-   
-   public EngineMetaData getEngine()
-   {
-      return engine;
-   }
-   @XmlElement(name = "Engine")
-   public void setEngine(EngineMetaData engine)
-   {
-      this.engine = engine;
-   }
-
-   public ExecutorMetaData getExecutor()
-   {
-      return executor;
-   }
-   @XmlElement(name = "Executor")
-   public void setExecutor(ExecutorMetaData executor)
-   {
-      this.executor = executor;
-   }
-
-   public List<ConnectorMetaData> getConnectors()
-   {
-      return connectors;
-   }
-   @XmlElement(name = "Connector")
-   public void setConnectors(List<ConnectorMetaData> connectors)
-   {
-      this.connectors = connectors;
-   }
-
-   public List<ListenerMetaData> getListeners()
-   {
-      return listeners;
-   }
-   @XmlElement(name = "Listener")
-   public void setListeners(List<ListenerMetaData> listeners)
-   {
-      this.listeners = listeners;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ServiceMetaData extends AnyXmlMetaData
+{
+   private String name;
+   private EngineMetaData engine;
+   private ExecutorMetaData executor;
+   private List<ConnectorMetaData> connectors;
+   private List<ListenerMetaData> listeners;
+
+   public String getName()
+   {
+      return name;
+   }
+   @XmlAttribute(name = "name")
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   public EngineMetaData getEngine()
+   {
+      return engine;
+   }
+   @XmlElement(name = "Engine")
+   public void setEngine(EngineMetaData engine)
+   {
+      this.engine = engine;
+   }
+
+   public ExecutorMetaData getExecutor()
+   {
+      return executor;
+   }
+   @XmlElement(name = "Executor")
+   public void setExecutor(ExecutorMetaData executor)
+   {
+      this.executor = executor;
+   }
+
+   public List<ConnectorMetaData> getConnectors()
+   {
+      return connectors;
+   }
+   @XmlElement(name = "Connector")
+   public void setConnectors(List<ConnectorMetaData> connectors)
+   {
+      this.connectors = connectors;
+   }
+
+   public List<ListenerMetaData> getListeners()
+   {
+      return listeners;
+   }
+   @XmlElement(name = "Listener")
+   public void setListeners(List<ListenerMetaData> listeners)
+   {
+      this.listeners = listeners;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServiceMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/SessionCookieMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/SessionCookieMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/SessionCookieMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,90 +1,90 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAttribute;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class SessionCookieMetaData implements Serializable
-{
-   private String domain = null;
-   private String path = null;
-   private String comment = null;
-   private boolean httpOnly = false;
-   private boolean secure = false;
-
-   public String getDomain()
-   {
-      return domain;
-   }
-   @XmlAttribute(name = "domain")
-   public void setDomain(String domain)
-   {
-      this.domain = domain;
-   }
-
-   public String getPath()
-   {
-      return path;
-   }
-   @XmlAttribute(name = "path")
-   public void setPath(String path)
-   {
-      this.path = path;
-   }
-
-   public String getComment()
-   {
-      return comment;
-   }
-   @XmlAttribute(name = "comment")
-   public void setComment(String comment)
-   {
-      this.comment = comment;
-   }
-
-   public boolean getHttpOnly()
-   {
-      return httpOnly;
-   }
-   @XmlAttribute(name = "httpOnly")
-   public void setHttpOnly(boolean httpOnly)
-   {
-      this.httpOnly = httpOnly;
-   }
-
-   public boolean getSecure()
-   {
-      return secure;
-   }
-   @XmlAttribute(name = "secure")
-   public void setSecure(boolean secure)
-   {
-      this.secure = secure;
-   }
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class SessionCookieMetaData implements Serializable
+{
+   private String domain = null;
+   private String path = null;
+   private String comment = null;
+   private boolean httpOnly = false;
+   private boolean secure = false;
+
+   public String getDomain()
+   {
+      return domain;
+   }
+   @XmlAttribute(name = "domain")
+   public void setDomain(String domain)
+   {
+      this.domain = domain;
+   }
+
+   public String getPath()
+   {
+      return path;
+   }
+   @XmlAttribute(name = "path")
+   public void setPath(String path)
+   {
+      this.path = path;
+   }
+
+   public String getComment()
+   {
+      return comment;
+   }
+   @XmlAttribute(name = "comment")
+   public void setComment(String comment)
+   {
+      this.comment = comment;
+   }
+
+   public boolean getHttpOnly()
+   {
+      return httpOnly;
+   }
+   @XmlAttribute(name = "httpOnly")
+   public void setHttpOnly(boolean httpOnly)
+   {
+      this.httpOnly = httpOnly;
+   }
+
+   public boolean getSecure()
+   {
+      return secure;
+   }
+   @XmlAttribute(name = "secure")
+   public void setSecure(boolean secure)
+   {
+      this.secure = secure;
+   }
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/SessionCookieMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ValveMetaData.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ValveMetaData.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ValveMetaData.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,31 +1,31 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.metadata;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ValveMetaData extends AnyXmlMetaData
-{
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ValveMetaData extends AnyXmlMetaData
+{
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ValveMetaData.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/GenericHeaderAuthenticator.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/GenericHeaderAuthenticator.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/GenericHeaderAuthenticator.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,293 +1,293 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.StringTokenizer;
-
-import javax.management.JMException;
-import javax.management.ObjectName;
-import javax.servlet.http.Cookie;
-
-import org.apache.catalina.Realm;
-import org.apache.catalina.Session;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.deploy.LoginConfig;
-import org.jboss.logging.Logger;
-
-/**
- *  JBAS-2283: Provide custom header based authentication support
- *  
- *  Header Authenticator that deals with userid from the request header
- *  Requires two attributes configured on the Tomcat Service - one for
- *  the http header denoting the authenticated identity and the other
- *  is the SESSION cookie
- *  
- *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- *  @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
- *  @version $Revision$
- *  @since  Sep 11, 2006
- */
-public class GenericHeaderAuthenticator extends ExtendedFormAuthenticator
-{
-   protected static Logger log = Logger.getLogger(GenericHeaderAuthenticator.class);
-
-   protected boolean trace = log.isTraceEnabled();
-
-   // JBAS-4804: GenericHeaderAuthenticator injection of ssoid and sessioncookie name.
-   private String httpHeaderForSSOAuth = null;
-
-   private String sessionCookieForSSOAuth = null;
-
-   /**
-    * <p>
-    * Obtain the value of the <code>httpHeaderForSSOAuth</code> attribute. This attribute is
-    * used to indicate the request header ids that have to be checked in order to retrieve the SSO
-    * identity set by a third party security system.
-    * </p>
-    * 
-    * @return a <code>String</code> containing the value of the <code>httpHeaderForSSOAuth</code>
-    * attribute.
-    */
-   public String getHttpHeaderForSSOAuth()
-   {
-      return httpHeaderForSSOAuth;
-   }
-
-   /**
-    * <p>
-    * Set the value of the <code>httpHeaderForSSOAuth</code> attribute. This attribute is
-    * used to indicate the request header ids that have to be checked in order to retrieve the SSO
-    * identity set by a third party security system.
-    * </p>
-    * 
-    * @param httpHeaderForSSOAuth   a <code>String</code> containing the value of the 
-    * <code>httpHeaderForSSOAuth</code> attribute.
-    */
-   public void setHttpHeaderForSSOAuth(String httpHeaderForSSOAuth)
-   {
-      this.httpHeaderForSSOAuth = httpHeaderForSSOAuth;
-   }
-
-   /**
-    * <p>
-    * Obtain the value of the <code>sessionCookieForSSOAuth</code> attribute. This attribute is used
-    * to indicate the names of the SSO cookies that may be present in the request object.
-    * </p>
-    * 
-    * @return a <code>String</code> containing the names (separated by a <code>','</code>) of the SSO cookies
-    * that may have been set by a third party security system in the request.
-    */
-   public String getSessionCookieForSSOAuth()
-   {
-      return sessionCookieForSSOAuth;
-   }
-
-   /**
-    * <p>
-    * Set the value of the <code>sessionCookieForSSOAuth</code> attribute. This attribute is used
-    * to indicate the names of the SSO cookies that may be present in the request object.
-    * </p>
-    * 
-    * @param sessionCookieForSSOAuth a <code>String</code> containing the names (separated by a 
-    * <code>','</code>) of the SSO cookies that may have been set by a third party security system in
-    * the request.
-    */
-   public void setSessionCookieForSSOAuth(String sessionCookieForSSOAuth)
-   {
-      this.sessionCookieForSSOAuth = sessionCookieForSSOAuth;
-   }
-
-   /**
-    * <p>
-    * Creates an instance of <code>GenericHeaderAuthenticator</code>.
-    * </p>
-    */
-   public GenericHeaderAuthenticator()
-   {
-      super();
-   }
-
-   public boolean authenticate(Request request, Response response, LoginConfig config) throws IOException
-   {
-      log.trace("Authenticating user");
-
-      Principal principal = request.getUserPrincipal();
-      if (principal != null)
-      {
-         if (trace)
-            log.trace("Already authenticated '" + principal.getName() + "'");
-         return true;
-      }
-
-      Realm realm = context.getRealm();
-      Session session = request.getSessionInternal(true);
-
-      String username = getUserId(request);
-      String password = getSessionCookie(request);
-
-      //Check if there is sso id as well as sessionkey 
-      if (username == null || password == null)
-      {
-         log.trace("Username is null or password(sessionkey) is null:fallback to form auth");
-         return super.authenticate(request, response, config);
-      }
-      principal = realm.authenticate(username, password);
-
-      if (principal == null)
-      {
-         forwardToErrorPage(request, response, config);
-         return false;
-      }
-
-      session.setNote(Constants.SESS_USERNAME_NOTE, username);
-      session.setNote(Constants.SESS_PASSWORD_NOTE, password);
-      request.setUserPrincipal(principal);
-
-      register(request, response, principal, Constants.FORM_METHOD, username, password);
-      return true;
-   }
-
-   /**
-    * Get the username from the request header
-    * @param request
-    * @return
-    */
-   protected String getUserId(Request request)
-   {
-      String ssoid = null;
-      //We can have a comma-separated ids
-      String ids = "";
-      try
-      {
-         ids = this.getIdentityHeaderId();
-      }
-      catch (JMException e)
-      {
-         if (trace)
-            log.trace("getUserId exception", e);
-      }
-      if (ids == null || ids.length() == 0)
-         throw new IllegalStateException("Http headers configuration in tomcat service missing");
-
-      StringTokenizer st = new StringTokenizer(ids, ",");
-      while (st.hasMoreTokens())
-      {
-         ssoid = request.getHeader(st.nextToken());
-         if (ssoid != null)
-            break;
-      }
-      if (trace)
-         log.trace("SSOID-" + ssoid);
-      return ssoid;
-   }
-
-   /**
-    * Obtain the session cookie from the request
-    * @param request
-    * @return
-    */
-   protected String getSessionCookie(Request request)
-   {
-      Cookie[] cookies = request.getCookies();
-      log.trace("Cookies:" + cookies);
-      int numCookies = cookies != null ? cookies.length : 0;
-
-      //We can have comma-separated ids
-      String ids = "";
-      try
-      {
-         ids = this.getSessionCookieId();
-         log.trace("Session Cookie Ids=" + ids);
-      }
-      catch (JMException e)
-      {
-         if (trace)
-            log.trace("checkSessionCookie exception", e);
-      }
-      if (ids == null || ids.length() == 0)
-         throw new IllegalStateException("Session cookies configuration in tomcat service missing");
-
-      StringTokenizer st = new StringTokenizer(ids, ",");
-      while (st.hasMoreTokens())
-      {
-         String cookieToken = st.nextToken();
-         String val = getCookieValue(cookies, numCookies, cookieToken);
-         if (val != null)
-            return val;
-      }
-      if (trace)
-         log.trace("Session Cookie not found");
-      return null;
-   }
-
-   /**
-    * Get the configured header identity id 
-    * in the tomcat service
-    * @return
-    * @throws JMException
-    */
-   protected String getIdentityHeaderId() throws JMException
-   {
-      if (this.httpHeaderForSSOAuth != null)
-         return this.httpHeaderForSSOAuth;
-      return (String) mserver.getAttribute(new ObjectName("jboss.web:service=WebServer"), "HttpHeaderForSSOAuth");
-   }
-
-   /**
-    * Get the configured session cookie id in the tomcat service
-    * @return
-    * @throws JMException
-    */
-   protected String getSessionCookieId() throws JMException
-   {
-      if (this.sessionCookieForSSOAuth != null)
-         return this.sessionCookieForSSOAuth;
-      return (String) mserver.getAttribute(new ObjectName("jboss.web:service=WebServer"), "SessionCookieForSSOAuth");
-   }
-
-   /**
-    * Get the value of a cookie if the name matches the token
-    * @param cookies array of cookies
-    * @param numCookies number of cookies in the array
-    * @param token Key
-    * @return value of cookie
-    */
-   protected String getCookieValue(Cookie[] cookies, int numCookies, String token)
-   {
-      for (int i = 0; i < numCookies; i++)
-      {
-         Cookie cookie = cookies[i];
-         log.trace("Matching cookieToken:" + token + " with cookie name=" + cookie.getName());
-         if (token.equals(cookie.getName()))
-         {
-            if (trace)
-               log.trace("Cookie-" + token + " value=" + cookie.getValue());
-            return cookie.getValue();
-         }
-      }
-      return null;
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.StringTokenizer;
+
+import javax.management.JMException;
+import javax.management.ObjectName;
+import javax.servlet.http.Cookie;
+
+import org.apache.catalina.Realm;
+import org.apache.catalina.Session;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.deploy.LoginConfig;
+import org.jboss.logging.Logger;
+
+/**
+ *  JBAS-2283: Provide custom header based authentication support
+ *  
+ *  Header Authenticator that deals with userid from the request header
+ *  Requires two attributes configured on the Tomcat Service - one for
+ *  the http header denoting the authenticated identity and the other
+ *  is the SESSION cookie
+ *  
+ *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ *  @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ *  @version $Revision$
+ *  @since  Sep 11, 2006
+ */
+public class GenericHeaderAuthenticator extends ExtendedFormAuthenticator
+{
+   protected static Logger log = Logger.getLogger(GenericHeaderAuthenticator.class);
+
+   protected boolean trace = log.isTraceEnabled();
+
+   // JBAS-4804: GenericHeaderAuthenticator injection of ssoid and sessioncookie name.
+   private String httpHeaderForSSOAuth = null;
+
+   private String sessionCookieForSSOAuth = null;
+
+   /**
+    * <p>
+    * Obtain the value of the <code>httpHeaderForSSOAuth</code> attribute. This attribute is
+    * used to indicate the request header ids that have to be checked in order to retrieve the SSO
+    * identity set by a third party security system.
+    * </p>
+    * 
+    * @return a <code>String</code> containing the value of the <code>httpHeaderForSSOAuth</code>
+    * attribute.
+    */
+   public String getHttpHeaderForSSOAuth()
+   {
+      return httpHeaderForSSOAuth;
+   }
+
+   /**
+    * <p>
+    * Set the value of the <code>httpHeaderForSSOAuth</code> attribute. This attribute is
+    * used to indicate the request header ids that have to be checked in order to retrieve the SSO
+    * identity set by a third party security system.
+    * </p>
+    * 
+    * @param httpHeaderForSSOAuth   a <code>String</code> containing the value of the 
+    * <code>httpHeaderForSSOAuth</code> attribute.
+    */
+   public void setHttpHeaderForSSOAuth(String httpHeaderForSSOAuth)
+   {
+      this.httpHeaderForSSOAuth = httpHeaderForSSOAuth;
+   }
+
+   /**
+    * <p>
+    * Obtain the value of the <code>sessionCookieForSSOAuth</code> attribute. This attribute is used
+    * to indicate the names of the SSO cookies that may be present in the request object.
+    * </p>
+    * 
+    * @return a <code>String</code> containing the names (separated by a <code>','</code>) of the SSO cookies
+    * that may have been set by a third party security system in the request.
+    */
+   public String getSessionCookieForSSOAuth()
+   {
+      return sessionCookieForSSOAuth;
+   }
+
+   /**
+    * <p>
+    * Set the value of the <code>sessionCookieForSSOAuth</code> attribute. This attribute is used
+    * to indicate the names of the SSO cookies that may be present in the request object.
+    * </p>
+    * 
+    * @param sessionCookieForSSOAuth a <code>String</code> containing the names (separated by a 
+    * <code>','</code>) of the SSO cookies that may have been set by a third party security system in
+    * the request.
+    */
+   public void setSessionCookieForSSOAuth(String sessionCookieForSSOAuth)
+   {
+      this.sessionCookieForSSOAuth = sessionCookieForSSOAuth;
+   }
+
+   /**
+    * <p>
+    * Creates an instance of <code>GenericHeaderAuthenticator</code>.
+    * </p>
+    */
+   public GenericHeaderAuthenticator()
+   {
+      super();
+   }
+
+   public boolean authenticate(Request request, Response response, LoginConfig config) throws IOException
+   {
+      log.trace("Authenticating user");
+
+      Principal principal = request.getUserPrincipal();
+      if (principal != null)
+      {
+         if (trace)
+            log.trace("Already authenticated '" + principal.getName() + "'");
+         return true;
+      }
+
+      Realm realm = context.getRealm();
+      Session session = request.getSessionInternal(true);
+
+      String username = getUserId(request);
+      String password = getSessionCookie(request);
+
+      //Check if there is sso id as well as sessionkey 
+      if (username == null || password == null)
+      {
+         log.trace("Username is null or password(sessionkey) is null:fallback to form auth");
+         return super.authenticate(request, response, config);
+      }
+      principal = realm.authenticate(username, password);
+
+      if (principal == null)
+      {
+         forwardToErrorPage(request, response, config);
+         return false;
+      }
+
+      session.setNote(Constants.SESS_USERNAME_NOTE, username);
+      session.setNote(Constants.SESS_PASSWORD_NOTE, password);
+      request.setUserPrincipal(principal);
+
+      register(request, response, principal, Constants.FORM_METHOD, username, password);
+      return true;
+   }
+
+   /**
+    * Get the username from the request header
+    * @param request
+    * @return
+    */
+   protected String getUserId(Request request)
+   {
+      String ssoid = null;
+      //We can have a comma-separated ids
+      String ids = "";
+      try
+      {
+         ids = this.getIdentityHeaderId();
+      }
+      catch (JMException e)
+      {
+         if (trace)
+            log.trace("getUserId exception", e);
+      }
+      if (ids == null || ids.length() == 0)
+         throw new IllegalStateException("Http headers configuration in tomcat service missing");
+
+      StringTokenizer st = new StringTokenizer(ids, ",");
+      while (st.hasMoreTokens())
+      {
+         ssoid = request.getHeader(st.nextToken());
+         if (ssoid != null)
+            break;
+      }
+      if (trace)
+         log.trace("SSOID-" + ssoid);
+      return ssoid;
+   }
+
+   /**
+    * Obtain the session cookie from the request
+    * @param request
+    * @return
+    */
+   protected String getSessionCookie(Request request)
+   {
+      Cookie[] cookies = request.getCookies();
+      log.trace("Cookies:" + cookies);
+      int numCookies = cookies != null ? cookies.length : 0;
+
+      //We can have comma-separated ids
+      String ids = "";
+      try
+      {
+         ids = this.getSessionCookieId();
+         log.trace("Session Cookie Ids=" + ids);
+      }
+      catch (JMException e)
+      {
+         if (trace)
+            log.trace("checkSessionCookie exception", e);
+      }
+      if (ids == null || ids.length() == 0)
+         throw new IllegalStateException("Session cookies configuration in tomcat service missing");
+
+      StringTokenizer st = new StringTokenizer(ids, ",");
+      while (st.hasMoreTokens())
+      {
+         String cookieToken = st.nextToken();
+         String val = getCookieValue(cookies, numCookies, cookieToken);
+         if (val != null)
+            return val;
+      }
+      if (trace)
+         log.trace("Session Cookie not found");
+      return null;
+   }
+
+   /**
+    * Get the configured header identity id 
+    * in the tomcat service
+    * @return
+    * @throws JMException
+    */
+   protected String getIdentityHeaderId() throws JMException
+   {
+      if (this.httpHeaderForSSOAuth != null)
+         return this.httpHeaderForSSOAuth;
+      return (String) mserver.getAttribute(new ObjectName("jboss.web:service=WebServer"), "HttpHeaderForSSOAuth");
+   }
+
+   /**
+    * Get the configured session cookie id in the tomcat service
+    * @return
+    * @throws JMException
+    */
+   protected String getSessionCookieId() throws JMException
+   {
+      if (this.sessionCookieForSSOAuth != null)
+         return this.sessionCookieForSSOAuth;
+      return (String) mserver.getAttribute(new ObjectName("jboss.web:service=WebServer"), "SessionCookieForSSOAuth");
+   }
+
+   /**
+    * Get the value of a cookie if the name matches the token
+    * @param cookies array of cookies
+    * @param numCookies number of cookies in the array
+    * @param token Key
+    * @return value of cookie
+    */
+   protected String getCookieValue(Cookie[] cookies, int numCookies, String token)
+   {
+      for (int i = 0; i < numCookies; i++)
+      {
+         Cookie cookie = cookies[i];
+         log.trace("Matching cookieToken:" + token + " with cookie name=" + cookie.getName());
+         if (token.equals(cookie.getName()))
+         {
+            if (trace)
+               log.trace("Cookie-" + token + " value=" + cookie.getValue());
+            return cookie.getValue();
+         }
+      }
+      return null;
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/GenericHeaderAuthenticator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/SecurityContextEstablishmentValve.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/SecurityContextEstablishmentValve.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/SecurityContextEstablishmentValve.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,166 +1,166 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security;
-
-import java.io.IOException;
-import java.security.PrivilegedActionException;
-
-import javax.servlet.ServletException;
-
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.valves.ValveBase;
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityRolesAssociation;
-import org.jboss.security.SecurityUtil;
-import org.jboss.servlet.http.HttpEvent;
-
-
-/**
- *  Establish the Security Context
- *  @author Anil.Saldhana at redhat.com
- *  @since  Sep 12, 2007 
- *  @version $Revision$
- */
-public class SecurityContextEstablishmentValve extends ValveBase
-{  
-   private String configuredSecurityDomainName;
-   private String securityContextClassName; 
-   private ISecurityManagement securityManagement;
-
-   public SecurityContextEstablishmentValve(String configuredSecurityDomain, 
-         String defaultSecurityDomain, String fqnClass,
-         ISecurityManagement securityManagement)
-   {
-      String securityDomain = defaultSecurityDomain;
-      
-      if(configuredSecurityDomain != null)
-        securityDomain  = configuredSecurityDomain; 
-      
-      this.configuredSecurityDomainName = SecurityUtil.unprefixSecurityDomain(securityDomain);  
-      this.securityContextClassName = fqnClass;
-      this.securityManagement = securityManagement;
-   }
-   
-   @Override
-   public void invoke(Request request, Response response)
-   throws IOException, ServletException
-   {
-      SecurityContext cachedContext = null;
-      
-      boolean createdSecurityContext = false;
-      //Set the security context if one is unavailable
-      SecurityContext sc = SecurityAssociationActions.getSecurityContext();
-      if(sc != null && 
-            sc.getSecurityDomain().equals(configuredSecurityDomainName) == false)
-      {
-         cachedContext = sc;
-         SecurityContext newSC = createSecurityContext();
-         SecurityAssociationActions.setSecurityContext(newSC);
-         createdSecurityContext = true;
-      }
-      
-      if(sc == null)
-      {
-         sc = createSecurityContext();
-         SecurityAssociationActions.setSecurityContext(sc);
-         createdSecurityContext = true;
-      }
-      
-      try
-      { 
-         // Perform the request
-         getNext().invoke(request, response);
-      }
-      finally
-      { 
-         SecurityRolesAssociation.setSecurityRoles(null); 
-         if(createdSecurityContext)
-         {
-            SecurityAssociationActions.clearSecurityContext();
-         }
-         if(cachedContext != null)
-            SecurityAssociationActions.setSecurityContext(cachedContext);
-      }
-   } 
-   
-   private SecurityContext createSecurityContext()
-   {
-      SecurityContext securityContext = null;
-      try
-      {
-         securityContext = 
-            SecurityAssociationActions.createSecurityContext(this.configuredSecurityDomainName,
-               this.securityContextClassName); 
-      }
-      catch (PrivilegedActionException e)
-      {
-         throw new RuntimeException(e);
-      } 
-      
-      securityContext.setSecurityManagement(securityManagement);
-      return securityContext; 
-   }
-
-   @Override
-   public void event(Request request, Response response, HttpEvent event)
-      throws IOException, ServletException
-   {
-      SecurityContext cachedContext = null;
-      
-      boolean createdSecurityContext = false;
-      //Set the security context if one is unavailable
-      SecurityContext sc = SecurityAssociationActions.getSecurityContext();
-      if(sc != null && 
-            sc.getSecurityDomain().equals(configuredSecurityDomainName) == false)
-      {
-         cachedContext = sc;
-         SecurityContext newSC = createSecurityContext();
-         SecurityAssociationActions.setSecurityContext(newSC);
-         createdSecurityContext = true;
-      }
-      
-      if(sc == null)
-      {
-         sc = createSecurityContext();
-         SecurityAssociationActions.setSecurityContext(sc);
-         createdSecurityContext = true;
-      }
-      
-      try
-      { 
-         // Perform the request
-         getNext().event(request, response, event);
-      }
-      finally
-      { 
-         SecurityRolesAssociation.setSecurityRoles(null); 
-         if(createdSecurityContext)
-         {
-            SecurityAssociationActions.clearSecurityContext();
-         }
-         if(cachedContext != null)
-            SecurityAssociationActions.setSecurityContext(cachedContext);
-      }
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security;
+
+import java.io.IOException;
+import java.security.PrivilegedActionException;
+
+import javax.servlet.ServletException;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityRolesAssociation;
+import org.jboss.security.SecurityUtil;
+import org.jboss.servlet.http.HttpEvent;
+
+
+/**
+ *  Establish the Security Context
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Sep 12, 2007 
+ *  @version $Revision$
+ */
+public class SecurityContextEstablishmentValve extends ValveBase
+{  
+   private String configuredSecurityDomainName;
+   private String securityContextClassName; 
+   private ISecurityManagement securityManagement;
+
+   public SecurityContextEstablishmentValve(String configuredSecurityDomain, 
+         String defaultSecurityDomain, String fqnClass,
+         ISecurityManagement securityManagement)
+   {
+      String securityDomain = defaultSecurityDomain;
+      
+      if(configuredSecurityDomain != null)
+        securityDomain  = configuredSecurityDomain; 
+      
+      this.configuredSecurityDomainName = SecurityUtil.unprefixSecurityDomain(securityDomain);  
+      this.securityContextClassName = fqnClass;
+      this.securityManagement = securityManagement;
+   }
+   
+   @Override
+   public void invoke(Request request, Response response)
+   throws IOException, ServletException
+   {
+      SecurityContext cachedContext = null;
+      
+      boolean createdSecurityContext = false;
+      //Set the security context if one is unavailable
+      SecurityContext sc = SecurityAssociationActions.getSecurityContext();
+      if(sc != null && 
+            sc.getSecurityDomain().equals(configuredSecurityDomainName) == false)
+      {
+         cachedContext = sc;
+         SecurityContext newSC = createSecurityContext();
+         SecurityAssociationActions.setSecurityContext(newSC);
+         createdSecurityContext = true;
+      }
+      
+      if(sc == null)
+      {
+         sc = createSecurityContext();
+         SecurityAssociationActions.setSecurityContext(sc);
+         createdSecurityContext = true;
+      }
+      
+      try
+      { 
+         // Perform the request
+         getNext().invoke(request, response);
+      }
+      finally
+      { 
+         SecurityRolesAssociation.setSecurityRoles(null); 
+         if(createdSecurityContext)
+         {
+            SecurityAssociationActions.clearSecurityContext();
+         }
+         if(cachedContext != null)
+            SecurityAssociationActions.setSecurityContext(cachedContext);
+      }
+   } 
+   
+   private SecurityContext createSecurityContext()
+   {
+      SecurityContext securityContext = null;
+      try
+      {
+         securityContext = 
+            SecurityAssociationActions.createSecurityContext(this.configuredSecurityDomainName,
+               this.securityContextClassName); 
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw new RuntimeException(e);
+      } 
+      
+      securityContext.setSecurityManagement(securityManagement);
+      return securityContext; 
+   }
+
+   @Override
+   public void event(Request request, Response response, HttpEvent event)
+      throws IOException, ServletException
+   {
+      SecurityContext cachedContext = null;
+      
+      boolean createdSecurityContext = false;
+      //Set the security context if one is unavailable
+      SecurityContext sc = SecurityAssociationActions.getSecurityContext();
+      if(sc != null && 
+            sc.getSecurityDomain().equals(configuredSecurityDomainName) == false)
+      {
+         cachedContext = sc;
+         SecurityContext newSC = createSecurityContext();
+         SecurityAssociationActions.setSecurityContext(newSC);
+         createdSecurityContext = true;
+      }
+      
+      if(sc == null)
+      {
+         sc = createSecurityContext();
+         SecurityAssociationActions.setSecurityContext(sc);
+         createdSecurityContext = true;
+      }
+      
+      try
+      { 
+         // Perform the request
+         getNext().event(request, response, event);
+      }
+      finally
+      { 
+         SecurityRolesAssociation.setSecurityRoles(null); 
+         if(createdSecurityContext)
+         {
+            SecurityAssociationActions.clearSecurityContext();
+         }
+         if(cachedContext != null)
+            SecurityAssociationActions.setSecurityContext(cachedContext);
+      }
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/SecurityContextEstablishmentValve.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/WebUtil.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/WebUtil.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/WebUtil.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,81 +1,81 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security;
-
-import java.util.Enumeration;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- *  Provides utility static methods for the web security integration
- *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- *  @version $Revision$
- *  @since  Aug 22, 2006
- */
-public class WebUtil
-{
-   /**
-    * Obtain debug information from the servlet request object
-    * @param httpRequest
-    * @return
-    */
-   public static String deriveUsefulInfo(HttpServletRequest httpRequest)
-   {
-      StringBuilder sb = new StringBuilder();
-      sb.append("[").append(httpRequest.getContextPath());
-      sb.append(":cookies=").append(httpRequest.getCookies()).append(":headers=");
-      //Append Header information
-      Enumeration<?> en = httpRequest.getHeaderNames();
-      for(;en.hasMoreElements();)
-      {
-         String headerName = (String)en.nextElement();
-         sb.append(headerName).append("=");
-          //Ensure HTTP Basic Password is not logged
-         if(headerName.contains("authorization") == false)
-            sb.append(httpRequest.getHeader(headerName)).append(","); 
-      }
-      sb.append("]");
-      //Append Request parameter information
-      sb.append("[parameters=");
-      Enumeration<?> enparam = httpRequest.getParameterNames();
-      for(;enparam.hasMoreElements();)
-      {
-         String paramName = (String)enparam.nextElement();
-         String[] paramValues = httpRequest.getParameterValues(paramName);
-         int len = paramValues != null ? paramValues.length : 0;
-         for(int i = 0 ; i < len ; i++)
-            sb.append(paramValues[i]).append("::"); 
-         sb.append(",");
-      } 
-      sb.append("][attributes=");
-      //Append Request attribute information
-      Enumeration<?> enu = httpRequest.getAttributeNames();
-      for(;enu.hasMoreElements();)
-      {
-         String attrName = (String)enu.nextElement();
-         sb.append(attrName).append("=");
-         sb.append(httpRequest.getAttribute(attrName)).append(",");
-      }
-      sb.append("]");
-      return sb.toString();
-   } 
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ *  Provides utility static methods for the web security integration
+ *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ *  @version $Revision$
+ *  @since  Aug 22, 2006
+ */
+public class WebUtil
+{
+   /**
+    * Obtain debug information from the servlet request object
+    * @param httpRequest
+    * @return
+    */
+   public static String deriveUsefulInfo(HttpServletRequest httpRequest)
+   {
+      StringBuilder sb = new StringBuilder();
+      sb.append("[").append(httpRequest.getContextPath());
+      sb.append(":cookies=").append(httpRequest.getCookies()).append(":headers=");
+      //Append Header information
+      Enumeration<?> en = httpRequest.getHeaderNames();
+      for(;en.hasMoreElements();)
+      {
+         String headerName = (String)en.nextElement();
+         sb.append(headerName).append("=");
+          //Ensure HTTP Basic Password is not logged
+         if(headerName.contains("authorization") == false)
+            sb.append(httpRequest.getHeader(headerName)).append(","); 
+      }
+      sb.append("]");
+      //Append Request parameter information
+      sb.append("[parameters=");
+      Enumeration<?> enparam = httpRequest.getParameterNames();
+      for(;enparam.hasMoreElements();)
+      {
+         String paramName = (String)enparam.nextElement();
+         String[] paramValues = httpRequest.getParameterValues(paramName);
+         int len = paramValues != null ? paramValues.length : 0;
+         for(int i = 0 ; i < len ; i++)
+            sb.append(paramValues[i]).append("::"); 
+         sb.append(",");
+      } 
+      sb.append("][attributes=");
+      //Append Request attribute information
+      Enumeration<?> enu = httpRequest.getAttributeNames();
+      for(;enu.hasMoreElements();)
+      {
+         String attrName = (String)enu.nextElement();
+         sb.append(attrName).append("=");
+         sb.append(httpRequest.getAttribute(attrName)).append(",");
+      }
+      sb.append("]");
+      return sb.toString();
+   } 
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/WebUtil.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/SecurityActions.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/SecurityActions.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/SecurityActions.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,70 +1,70 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * Privileged Blocks
- * @author Anil.Saldhana at redhat.com
- * @since Oct 8, 2008
- */
-class SecurityActions
-{
-   static Class<?> loadClass(final String fqn) throws PrivilegedActionException
-   {
-     return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
-     {
-        public Class<?> run() throws Exception
-        {
-           ClassLoader tcl = getContextClassLoader();
-           return tcl.loadClass(fqn); 
-        }
-     });  
-   } 
-   
-   static ClassLoader getContextClassLoader()
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
-      {
-         public ClassLoader run()
-         {
-            return Thread.currentThread().getContextClassLoader();
-         }
-      });
-   }
-   
-   static void setContextClassLoader(final ClassLoader tccl)
-   {
-      AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
-      {
-         public ClassLoader run()
-         {
-            Thread.currentThread().setContextClassLoader(tccl);
-            return null;
-         }
-      });
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 8, 2008
+ */
+class SecurityActions
+{
+   static Class<?> loadClass(final String fqn) throws PrivilegedActionException
+   {
+     return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
+     {
+        public Class<?> run() throws Exception
+        {
+           ClassLoader tcl = getContextClassLoader();
+           return tcl.loadClass(fqn); 
+        }
+     });  
+   } 
+   
+   static ClassLoader getContextClassLoader()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+   
+   static void setContextClassLoader(final ClassLoader tccl)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            Thread.currentThread().setContextClassLoader(tccl);
+            return null;
+         }
+      });
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPIAuthenticator.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPIAuthenticator.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPIAuthenticator.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,247 +1,247 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi;
-
-import java.io.IOException;
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-import javax.security.auth.message.callback.CallerPrincipalCallback;
-import javax.security.auth.message.callback.PasswordValidationCallback;
-import javax.servlet.http.Cookie;
-
-import org.apache.catalina.Session;
-import org.apache.catalina.authenticator.AuthenticatorBase;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.deploy.LoginConfig;
-import org.jboss.logging.Logger;
-import org.jboss.security.ServerAuthenticationManager;
-import org.jboss.security.auth.message.GenericMessageInfo;
-import org.jboss.security.plugins.auth.JASPIServerAuthenticationManager;
-
-/**
- * Tomcat authenticator that does JSR-196 (JASPI) authentication
- * @author Anil.Saldhana at redhat.com
- * @since Oct 7, 2008
- */
-public class TomcatJASPIAuthenticator extends AuthenticatorBase
-{
-   private static Logger log = Logger.getLogger(TomcatJASPIAuthenticator.class);
-   
-   private String messageLayer = "HttpServlet";
-   
-   protected String serverAuthenticationManagerClass = JASPIServerAuthenticationManager.class.getName();
- 
-   @Override
-   protected boolean authenticate(Request request, Response response, LoginConfig config) throws IOException
-   { 
-      boolean result = false;
-      
-      String authMethod = config.getAuthMethod(); 
-
-      // Have we already authenticated someone?
-      Principal principal = request.getUserPrincipal();
-      String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
-      if (principal != null) {
-         log.trace("Already authenticated '" + principal.getName() + "'");
-         // Associate the session with any existing SSO session
-         if (ssoId != null)
-            associate(ssoId, request.getSessionInternal(true));
-         return (true);
-      }
-
-      if("BASIC".equalsIgnoreCase(authMethod) ||
-            "FORM".equalsIgnoreCase(authMethod) )
-      {
-         // Is there an SSO session against which we can try to reauthenticate?
-         if (ssoId != null) {
-            log.trace("SSO Id " + ssoId + " set; attempting " +
-               "reauthentication");
-            /* Try to reauthenticate using data cached by SSO.  If this fails,
-                either the original SSO logon was of DIGEST or SSL (which
-                we can't reauthenticate ourselves because there is no
-                cached username and password), or the realm denied
-                the user's reauthentication for some reason.
-                In either case we have to prompt the user for a logon */
-            if (reauthenticateFromSSO(ssoId, request))
-               return true;
-         }
-      }      
-
-      GenericMessageInfo messageInfo = new GenericMessageInfo();
-      messageInfo.setRequestMessage(request);
-      messageInfo.setResponseMessage(response);
-      
-      //Put bits of information needed by tomcat server auth modules
-      messageInfo.getMap().put("CACHE", cache); 
-      
-      TomcatJASPICallbackHandler cbh = new TomcatJASPICallbackHandler();
-      
-      ServerAuthenticationManager sam = getServerAuthenticationManager();
-      if(sam != null)
-      {
-         result = sam.isValid(messageInfo, new Subject(), messageLayer, cbh);
-      } 
-      
-      //The Authentication process has been a success. We need to register
-      //the principal, username, password with the container
-      if(result)
-      {
-         PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
-         CallerPrincipalCallback cpcb = cbh.getCallerPrincipalCallback();
-         this.register(request, response, cpcb.getPrincipal(), authMethod, 
-               pvc.getUsername(), new String(pvc.getPassword()));
-      }
-      
-      return result; 
-   }
-
-   /**
-    * Get the FQN of the class that implements
-    * the org.jboss.security.ServerAuthenticationManager intepasswordrface
-    * @return
-    */
-   public String getServerAuthenticationManagerClass()
-   {
-      return serverAuthenticationManagerClass;
-   }
-
-   /**
-    * Set the FQN of the class that implements
-    * the org.jboss.security.ServerAuthenticationManager interface
-    * @param serverAuthenticationManagerClass
-    */
-   public void setServerAuthenticationManagerClass(String serverAuthenticationManagerClass)
-   {
-      this.serverAuthenticationManagerClass = serverAuthenticationManagerClass;
-   } 
-   
-   protected ServerAuthenticationManager getServerAuthenticationManager()
-   {
-      ServerAuthenticationManager sam = null;
-      Class<?> clazz;
-      try
-      {
-         clazz = SecurityActions.loadClass(serverAuthenticationManagerClass);
-         sam = (ServerAuthenticationManager) clazz.newInstance();
-      }
-      catch (Exception e)
-      {
-         log.error("Exception in obtaining ServerAuthenticationManager:", e);
-      } 
-      
-      return sam;
-   }
-   
-   /**
-    * Register an authenticated Principal and authentication type in our
-    * request, in the current session (if there is one), and with our
-    * SingleSignOn valve, if there is one.  Set the appropriate cookie
-    * to be returned.
-    *
-    * @param request The servlet request we are processing
-    * @param response The servlet response we are generating
-    * @param principal The authenticated Principal to be registered
-    * @param authType The authentication type to be registered
-    * @param username Username used to authenticate (if any)
-    * @param password Password used to authenticate (if any)
-    */
-   protected void register(Request request, Response response,
-                           Principal principal, String authType,
-                           String username, String password) {
-
-       if (log.isTraceEnabled()) {
-           // Bugzilla 39255: http://issues.apache.org/bugzilla/show_bug.cgi?id=39255
-           String name = (principal == null) ? "none" : principal.getName();
-           log.trace("Authenticated '" + name + "' with type '"
-               + authType + "'");
-       }
-
-       // Cache the authentication information in our request
-       request.setAuthType(authType);
-       request.setUserPrincipal(principal);
-
-       Session session = request.getSessionInternal(false);
-       // Cache the authentication information in our session, if any
-       if (cache) {
-           if (session != null) {
-               session.setAuthType(authType);
-               session.setPrincipal(principal);
-               if (username != null)
-                   session.setNote(Constants.SESS_USERNAME_NOTE, username);
-               else
-                   session.removeNote(Constants.SESS_USERNAME_NOTE);
-               if (password != null)
-                   session.setNote(Constants.SESS_PASSWORD_NOTE, password);
-               else
-                   session.removeNote(Constants.SESS_PASSWORD_NOTE);
-           }
-       }
-
-       // Construct a cookie to be returned to the client
-       if (sso == null)
-           return;
-
-       // Only create a new SSO entry if the SSO did not already set a note
-       // for an existing entry (as it would do with subsequent requests
-       // for DIGEST and SSL authenticated contexts)
-       String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
-       if (ssoId == null) {
-           // Construct a cookie to be returned to the client
-           ssoId = generateSessionId();
-           Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
-           cookie.setMaxAge(-1);
-           cookie.setPath("/");
-           
-           // Bugzilla 41217
-           cookie.setSecure(request.isSecure());
-           
-           // Bugzilla 34724
-           String ssoDomain = sso.getCookieDomain();
-           if(ssoDomain != null) {
-               cookie.setDomain(ssoDomain);
-           }
-
-           response.addCookie(cookie);
-
-           // Register this principal with our SSO valve
-           sso.register(ssoId, principal, authType, username, password);
-           request.setNote(Constants.REQ_SSOID_NOTE, ssoId);
-
-       } else {
-           // Update the SSO session with the latest authentication data
-           sso.update(ssoId, principal, authType, username, password);
-       }
-
-       // Fix for Bug 10040
-       // Always associate a session with a new SSO reqistration.
-       // SSO entries are only removed from the SSO registry map when
-       // associated sessions are destroyed; if a new SSO entry is created
-       // above for this request and the user never revisits the context, the
-       // SSO entry will never be cleared if we don't associate the session
-       if (session == null)
-           session = request.getSessionInternal(true);
-       sso.associate(ssoId, session); 
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.callback.CallerPrincipalCallback;
+import javax.security.auth.message.callback.PasswordValidationCallback;
+import javax.servlet.http.Cookie;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.authenticator.AuthenticatorBase;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.deploy.LoginConfig;
+import org.jboss.logging.Logger;
+import org.jboss.security.ServerAuthenticationManager;
+import org.jboss.security.auth.message.GenericMessageInfo;
+import org.jboss.security.plugins.auth.JASPIServerAuthenticationManager;
+
+/**
+ * Tomcat authenticator that does JSR-196 (JASPI) authentication
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 7, 2008
+ */
+public class TomcatJASPIAuthenticator extends AuthenticatorBase
+{
+   private static Logger log = Logger.getLogger(TomcatJASPIAuthenticator.class);
+   
+   private String messageLayer = "HttpServlet";
+   
+   protected String serverAuthenticationManagerClass = JASPIServerAuthenticationManager.class.getName();
+ 
+   @Override
+   protected boolean authenticate(Request request, Response response, LoginConfig config) throws IOException
+   { 
+      boolean result = false;
+      
+      String authMethod = config.getAuthMethod(); 
+
+      // Have we already authenticated someone?
+      Principal principal = request.getUserPrincipal();
+      String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
+      if (principal != null) {
+         log.trace("Already authenticated '" + principal.getName() + "'");
+         // Associate the session with any existing SSO session
+         if (ssoId != null)
+            associate(ssoId, request.getSessionInternal(true));
+         return (true);
+      }
+
+      if("BASIC".equalsIgnoreCase(authMethod) ||
+            "FORM".equalsIgnoreCase(authMethod) )
+      {
+         // Is there an SSO session against which we can try to reauthenticate?
+         if (ssoId != null) {
+            log.trace("SSO Id " + ssoId + " set; attempting " +
+               "reauthentication");
+            /* Try to reauthenticate using data cached by SSO.  If this fails,
+                either the original SSO logon was of DIGEST or SSL (which
+                we can't reauthenticate ourselves because there is no
+                cached username and password), or the realm denied
+                the user's reauthentication for some reason.
+                In either case we have to prompt the user for a logon */
+            if (reauthenticateFromSSO(ssoId, request))
+               return true;
+         }
+      }      
+
+      GenericMessageInfo messageInfo = new GenericMessageInfo();
+      messageInfo.setRequestMessage(request);
+      messageInfo.setResponseMessage(response);
+      
+      //Put bits of information needed by tomcat server auth modules
+      messageInfo.getMap().put("CACHE", cache); 
+      
+      TomcatJASPICallbackHandler cbh = new TomcatJASPICallbackHandler();
+      
+      ServerAuthenticationManager sam = getServerAuthenticationManager();
+      if(sam != null)
+      {
+         result = sam.isValid(messageInfo, new Subject(), messageLayer, cbh);
+      } 
+      
+      //The Authentication process has been a success. We need to register
+      //the principal, username, password with the container
+      if(result)
+      {
+         PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
+         CallerPrincipalCallback cpcb = cbh.getCallerPrincipalCallback();
+         this.register(request, response, cpcb.getPrincipal(), authMethod, 
+               pvc.getUsername(), new String(pvc.getPassword()));
+      }
+      
+      return result; 
+   }
+
+   /**
+    * Get the FQN of the class that implements
+    * the org.jboss.security.ServerAuthenticationManager intepasswordrface
+    * @return
+    */
+   public String getServerAuthenticationManagerClass()
+   {
+      return serverAuthenticationManagerClass;
+   }
+
+   /**
+    * Set the FQN of the class that implements
+    * the org.jboss.security.ServerAuthenticationManager interface
+    * @param serverAuthenticationManagerClass
+    */
+   public void setServerAuthenticationManagerClass(String serverAuthenticationManagerClass)
+   {
+      this.serverAuthenticationManagerClass = serverAuthenticationManagerClass;
+   } 
+   
+   protected ServerAuthenticationManager getServerAuthenticationManager()
+   {
+      ServerAuthenticationManager sam = null;
+      Class<?> clazz;
+      try
+      {
+         clazz = SecurityActions.loadClass(serverAuthenticationManagerClass);
+         sam = (ServerAuthenticationManager) clazz.newInstance();
+      }
+      catch (Exception e)
+      {
+         log.error("Exception in obtaining ServerAuthenticationManager:", e);
+      } 
+      
+      return sam;
+   }
+   
+   /**
+    * Register an authenticated Principal and authentication type in our
+    * request, in the current session (if there is one), and with our
+    * SingleSignOn valve, if there is one.  Set the appropriate cookie
+    * to be returned.
+    *
+    * @param request The servlet request we are processing
+    * @param response The servlet response we are generating
+    * @param principal The authenticated Principal to be registered
+    * @param authType The authentication type to be registered
+    * @param username Username used to authenticate (if any)
+    * @param password Password used to authenticate (if any)
+    */
+   protected void register(Request request, Response response,
+                           Principal principal, String authType,
+                           String username, String password) {
+
+       if (log.isTraceEnabled()) {
+           // Bugzilla 39255: http://issues.apache.org/bugzilla/show_bug.cgi?id=39255
+           String name = (principal == null) ? "none" : principal.getName();
+           log.trace("Authenticated '" + name + "' with type '"
+               + authType + "'");
+       }
+
+       // Cache the authentication information in our request
+       request.setAuthType(authType);
+       request.setUserPrincipal(principal);
+
+       Session session = request.getSessionInternal(false);
+       // Cache the authentication information in our session, if any
+       if (cache) {
+           if (session != null) {
+               session.setAuthType(authType);
+               session.setPrincipal(principal);
+               if (username != null)
+                   session.setNote(Constants.SESS_USERNAME_NOTE, username);
+               else
+                   session.removeNote(Constants.SESS_USERNAME_NOTE);
+               if (password != null)
+                   session.setNote(Constants.SESS_PASSWORD_NOTE, password);
+               else
+                   session.removeNote(Constants.SESS_PASSWORD_NOTE);
+           }
+       }
+
+       // Construct a cookie to be returned to the client
+       if (sso == null)
+           return;
+
+       // Only create a new SSO entry if the SSO did not already set a note
+       // for an existing entry (as it would do with subsequent requests
+       // for DIGEST and SSL authenticated contexts)
+       String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
+       if (ssoId == null) {
+           // Construct a cookie to be returned to the client
+           ssoId = generateSessionId();
+           Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
+           cookie.setMaxAge(-1);
+           cookie.setPath("/");
+           
+           // Bugzilla 41217
+           cookie.setSecure(request.isSecure());
+           
+           // Bugzilla 34724
+           String ssoDomain = sso.getCookieDomain();
+           if(ssoDomain != null) {
+               cookie.setDomain(ssoDomain);
+           }
+
+           response.addCookie(cookie);
+
+           // Register this principal with our SSO valve
+           sso.register(ssoId, principal, authType, username, password);
+           request.setNote(Constants.REQ_SSOID_NOTE, ssoId);
+
+       } else {
+           // Update the SSO session with the latest authentication data
+           sso.update(ssoId, principal, authType, username, password);
+       }
+
+       // Fix for Bug 10040
+       // Always associate a session with a new SSO reqistration.
+       // SSO entries are only removed from the SSO registry map when
+       // associated sessions are destroyed; if a new SSO entry is created
+       // above for this request and the user never revisits the context, the
+       // SSO entry will never be cleared if we don't associate the session
+       if (session == null)
+           session = request.getSessionInternal(true);
+       sso.associate(ssoId, session); 
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPIAuthenticator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPICallbackHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPICallbackHandler.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPICallbackHandler.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,103 +1,103 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi;
-
-import java.io.IOException;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.message.callback.CallerPrincipalCallback;
-import javax.security.auth.message.callback.GroupPrincipalCallback;
-import javax.security.auth.message.callback.PasswordValidationCallback;
-
-import org.apache.log4j.Logger;
-
-/**
- * Callback handler for JASPI Web Profile
- * @author Anil.Saldhana at redhat.com
- * @since Oct 8, 2008
- */
-public class TomcatJASPICallbackHandler implements CallbackHandler
-{
-   private static Logger log = Logger.getLogger(TomcatJASPICallbackHandler.class);
-   
-   private CallerPrincipalCallback callerPrincipalCallback;
-   private PasswordValidationCallback passwordValidationCallback;
-   private GroupPrincipalCallback groupPrincipalCallback;
-
-   public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
-   {
-      if(callbacks.length > 0)
-      {
-         for(Callback callback: callbacks)
-         {
-           if(callback instanceof CallerPrincipalCallback)
-           {
-              callback = this.callerPrincipalCallback;
-           }
-           else
-           if(callback instanceof PasswordValidationCallback)
-           {
-              callback = this.passwordValidationCallback;
-           }
-           else
-           if(callback instanceof GroupPrincipalCallback)
-           {
-              callback = this.groupPrincipalCallback;
-           }
-           else
-              log.trace("Callback " + callback.getClass().getCanonicalName() + " not supported");
-         } 
-      }
-   }
-    
-   public CallerPrincipalCallback getCallerPrincipalCallback()
-   {
-      return callerPrincipalCallback;
-   }
-
-   public PasswordValidationCallback getPasswordValidationCallback()
-   {
-      return passwordValidationCallback;
-   }
-
-   public GroupPrincipalCallback getGroupPrincipalCallback()
-   {
-      return groupPrincipalCallback;
-   }
-
-   public void setCallerPrincipalCallback(CallerPrincipalCallback callerPrincipalCallback)
-   {
-     this.callerPrincipalCallback =  callerPrincipalCallback;
-   }
-   
-   public void setGroupPrincipalCallback(GroupPrincipalCallback groupPrincipalCallback)
-   {
-      this.groupPrincipalCallback = groupPrincipalCallback;
-   }
-   
-   public void setPasswordValidationCallback(PasswordValidationCallback passwordValidationCallback)
-   {
-      this.passwordValidationCallback = passwordValidationCallback;
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.message.callback.CallerPrincipalCallback;
+import javax.security.auth.message.callback.GroupPrincipalCallback;
+import javax.security.auth.message.callback.PasswordValidationCallback;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Callback handler for JASPI Web Profile
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 8, 2008
+ */
+public class TomcatJASPICallbackHandler implements CallbackHandler
+{
+   private static Logger log = Logger.getLogger(TomcatJASPICallbackHandler.class);
+   
+   private CallerPrincipalCallback callerPrincipalCallback;
+   private PasswordValidationCallback passwordValidationCallback;
+   private GroupPrincipalCallback groupPrincipalCallback;
+
+   public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+   {
+      if(callbacks.length > 0)
+      {
+         for(Callback callback: callbacks)
+         {
+           if(callback instanceof CallerPrincipalCallback)
+           {
+              callback = this.callerPrincipalCallback;
+           }
+           else
+           if(callback instanceof PasswordValidationCallback)
+           {
+              callback = this.passwordValidationCallback;
+           }
+           else
+           if(callback instanceof GroupPrincipalCallback)
+           {
+              callback = this.groupPrincipalCallback;
+           }
+           else
+              log.trace("Callback " + callback.getClass().getCanonicalName() + " not supported");
+         } 
+      }
+   }
+    
+   public CallerPrincipalCallback getCallerPrincipalCallback()
+   {
+      return callerPrincipalCallback;
+   }
+
+   public PasswordValidationCallback getPasswordValidationCallback()
+   {
+      return passwordValidationCallback;
+   }
+
+   public GroupPrincipalCallback getGroupPrincipalCallback()
+   {
+      return groupPrincipalCallback;
+   }
+
+   public void setCallerPrincipalCallback(CallerPrincipalCallback callerPrincipalCallback)
+   {
+     this.callerPrincipalCallback =  callerPrincipalCallback;
+   }
+   
+   public void setGroupPrincipalCallback(GroupPrincipalCallback groupPrincipalCallback)
+   {
+      this.groupPrincipalCallback = groupPrincipalCallback;
+   }
+   
+   public void setPasswordValidationCallback(PasswordValidationCallback passwordValidationCallback)
+   {
+      this.passwordValidationCallback = passwordValidationCallback;
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/TomcatJASPICallbackHandler.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPBasicServerAuthModule.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPBasicServerAuthModule.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPBasicServerAuthModule.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,188 +1,188 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi.modules;
-
-import java.io.IOException;
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-import javax.security.auth.message.AuthException;
-import javax.security.auth.message.AuthStatus;
-import javax.security.auth.message.MessageInfo;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.util.Base64;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.CharChunk;
-import org.apache.tomcat.util.buf.MessageBytes;
-import org.jboss.logging.Logger;
-
-/**
- * Server auth module for Basic authentication
- * @author Anil.Saldhana at redhat.com
- * @since Oct 7, 2008
- */
-public class HTTPBasicServerAuthModule extends TomcatServerAuthModule
-{
-   private static Logger log = Logger.getLogger(HTTPBasicServerAuthModule.class);
-
-   protected Context context; 
-   
-   protected boolean cache = false;
-   
-   protected static final StringManager sm =
-      StringManager.getManager(Constants.Package);
-   
-   /**
-    * Authenticate bytes.
-    */
-   public static final byte[] AUTHENTICATE_BYTES = {
-       (byte) 'W',
-       (byte) 'W',
-       (byte) 'W',
-       (byte) '-',
-       (byte) 'A',
-       (byte) 'u',
-       (byte) 't',
-       (byte) 'h',
-       (byte) 'e',
-       (byte) 'n',
-       (byte) 't',
-       (byte) 'i',
-       (byte) 'c',
-       (byte) 'a',
-       (byte) 't',
-       (byte) 'e'
-   };
-
-   
-   /**
-    * The number of random bytes to include when generating a
-    * session identifier.
-    */
-   protected static final int SESSION_ID_BYTES = 16;
-
-   protected String delgatingLoginContextName = null;
-   
-   public HTTPBasicServerAuthModule()
-   { 
-   }
- 
-   public HTTPBasicServerAuthModule(String delgatingLoginContextName)
-   {
-      super();
-      this.delgatingLoginContextName = delgatingLoginContextName;
-   }
-
-   public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject)
-   throws AuthException
-   {
-      throw new RuntimeException("Not Applicable");
-   }
-
-   public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
-         Subject serviceSubject) throws AuthException
-   { 
-      Request request = (Request) messageInfo.getRequestMessage();
-      Response response = (Response) messageInfo.getResponseMessage();
-     
-      Principal principal;
-      context = request.getContext();
-      LoginConfig config = context.getLoginConfig(); 
-      
-      // Validate any credentials already included with this request
-      String username = null;
-      String password = null;
-
-      MessageBytes authorization = 
-          request.getCoyoteRequest().getMimeHeaders()
-          .getValue("authorization");
-      
-      if (authorization != null) {
-          authorization.toBytes();
-          ByteChunk authorizationBC = authorization.getByteChunk();
-          if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
-              authorizationBC.setOffset(authorizationBC.getOffset() + 6);
-              // FIXME: Add trimming
-              // authorizationBC.trim();
-              
-              CharChunk authorizationCC = authorization.getCharChunk();
-              Base64.decode(authorizationBC, authorizationCC);
-              
-              // Get username and password
-              int colon = authorizationCC.indexOf(':');
-              if (colon < 0) {
-                  username = authorizationCC.toString();
-              } else {
-                  char[] buf = authorizationCC.getBuffer();
-                  username = new String(buf, 0, colon);
-                  password = new String(buf, colon + 1, 
-                          authorizationCC.getEnd() - colon - 1);
-              }
-              
-              authorizationBC.setOffset(authorizationBC.getOffset() - 6);
-          }
-
-          principal = context.getRealm().authenticate(username, password);
-          if (principal != null) {
-             registerWithCallbackHandler(principal, username, password);
-             
-              /*register(request, response, principal, Constants.BASIC_METHOD,
-                       username, password);*/
-             return AuthStatus.SUCCESS; 
-          }
-      } 
-
-      // Send an "unauthorized" response and an appropriate challenge
-      MessageBytes authenticate = 
-          response.getCoyoteResponse().getMimeHeaders()
-          .addValue(AUTHENTICATE_BYTES, 0, AUTHENTICATE_BYTES.length);
-      CharChunk authenticateCC = authenticate.getCharChunk();
-      try
-      {
-         authenticateCC.append("Basic realm=\"");
-         if (config.getRealmName() == null) {
-            authenticateCC.append(request.getServerName());
-            authenticateCC.append(':');
-            authenticateCC.append(Integer.toString(request.getServerPort()));
-         } else {
-            authenticateCC.append(config.getRealmName());
-         }
-         authenticateCC.append('\"');        
-         authenticate.toChars();
-
-         response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
-      }
-      catch (IOException e)
-      {
-         log.error("IOException ", e); 
-      }
-      //response.flushBuffer();
-      return AuthStatus.FAILURE;  
-   } 
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi.modules;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.AuthStatus;
+import javax.security.auth.message.MessageInfo;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.deploy.LoginConfig;
+import org.apache.catalina.util.Base64;
+import org.apache.catalina.util.StringManager;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.CharChunk;
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.jboss.logging.Logger;
+
+/**
+ * Server auth module for Basic authentication
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 7, 2008
+ */
+public class HTTPBasicServerAuthModule extends TomcatServerAuthModule
+{
+   private static Logger log = Logger.getLogger(HTTPBasicServerAuthModule.class);
+
+   protected Context context; 
+   
+   protected boolean cache = false;
+   
+   protected static final StringManager sm =
+      StringManager.getManager(Constants.Package);
+   
+   /**
+    * Authenticate bytes.
+    */
+   public static final byte[] AUTHENTICATE_BYTES = {
+       (byte) 'W',
+       (byte) 'W',
+       (byte) 'W',
+       (byte) '-',
+       (byte) 'A',
+       (byte) 'u',
+       (byte) 't',
+       (byte) 'h',
+       (byte) 'e',
+       (byte) 'n',
+       (byte) 't',
+       (byte) 'i',
+       (byte) 'c',
+       (byte) 'a',
+       (byte) 't',
+       (byte) 'e'
+   };
+
+   
+   /**
+    * The number of random bytes to include when generating a
+    * session identifier.
+    */
+   protected static final int SESSION_ID_BYTES = 16;
+
+   protected String delgatingLoginContextName = null;
+   
+   public HTTPBasicServerAuthModule()
+   { 
+   }
+ 
+   public HTTPBasicServerAuthModule(String delgatingLoginContextName)
+   {
+      super();
+      this.delgatingLoginContextName = delgatingLoginContextName;
+   }
+
+   public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject)
+   throws AuthException
+   {
+      throw new RuntimeException("Not Applicable");
+   }
+
+   public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
+         Subject serviceSubject) throws AuthException
+   { 
+      Request request = (Request) messageInfo.getRequestMessage();
+      Response response = (Response) messageInfo.getResponseMessage();
+     
+      Principal principal;
+      context = request.getContext();
+      LoginConfig config = context.getLoginConfig(); 
+      
+      // Validate any credentials already included with this request
+      String username = null;
+      String password = null;
+
+      MessageBytes authorization = 
+          request.getCoyoteRequest().getMimeHeaders()
+          .getValue("authorization");
+      
+      if (authorization != null) {
+          authorization.toBytes();
+          ByteChunk authorizationBC = authorization.getByteChunk();
+          if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
+              authorizationBC.setOffset(authorizationBC.getOffset() + 6);
+              // FIXME: Add trimming
+              // authorizationBC.trim();
+              
+              CharChunk authorizationCC = authorization.getCharChunk();
+              Base64.decode(authorizationBC, authorizationCC);
+              
+              // Get username and password
+              int colon = authorizationCC.indexOf(':');
+              if (colon < 0) {
+                  username = authorizationCC.toString();
+              } else {
+                  char[] buf = authorizationCC.getBuffer();
+                  username = new String(buf, 0, colon);
+                  password = new String(buf, colon + 1, 
+                          authorizationCC.getEnd() - colon - 1);
+              }
+              
+              authorizationBC.setOffset(authorizationBC.getOffset() - 6);
+          }
+
+          principal = context.getRealm().authenticate(username, password);
+          if (principal != null) {
+             registerWithCallbackHandler(principal, username, password);
+             
+              /*register(request, response, principal, Constants.BASIC_METHOD,
+                       username, password);*/
+             return AuthStatus.SUCCESS; 
+          }
+      } 
+
+      // Send an "unauthorized" response and an appropriate challenge
+      MessageBytes authenticate = 
+          response.getCoyoteResponse().getMimeHeaders()
+          .addValue(AUTHENTICATE_BYTES, 0, AUTHENTICATE_BYTES.length);
+      CharChunk authenticateCC = authenticate.getCharChunk();
+      try
+      {
+         authenticateCC.append("Basic realm=\"");
+         if (config.getRealmName() == null) {
+            authenticateCC.append(request.getServerName());
+            authenticateCC.append(':');
+            authenticateCC.append(Integer.toString(request.getServerPort()));
+         } else {
+            authenticateCC.append(config.getRealmName());
+         }
+         authenticateCC.append('\"');        
+         authenticate.toChars();
+
+         response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+      }
+      catch (IOException e)
+      {
+         log.error("IOException ", e); 
+      }
+      //response.flushBuffer();
+      return AuthStatus.FAILURE;  
+   } 
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPBasicServerAuthModule.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPFormServerAuthModule.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPFormServerAuthModule.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPFormServerAuthModule.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,522 +1,522 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi.modules;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Locale;
-
-import javax.security.auth.Subject;
-import javax.security.auth.message.AuthException;
-import javax.security.auth.message.AuthStatus;
-import javax.security.auth.message.MessageInfo;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Realm;
-import org.apache.catalina.Session;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.authenticator.SavedRequest;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.util.StringManager;
-import org.apache.coyote.ActionCode;
-import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.CharChunk;
-import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.jboss.logging.Logger;
-
-/**
- * Server auth module for FORM authentication
- * @author Anil.Saldhana at redhat.com
- * @since Oct 7, 2008
- */
-public class HTTPFormServerAuthModule extends TomcatServerAuthModule
-{
-   private static Logger log = Logger.getLogger(HTTPFormServerAuthModule.class);
-
-   protected Context context; 
-   
-   protected boolean cache = false;
-   
-   protected static final StringManager sm =
-      StringManager.getManager(Constants.Package);
-   
-   /**
-    * The number of random bytes to include when generating a
-    * session identifier.
-    */
-   protected static final int SESSION_ID_BYTES = 16;
-
-   protected String delgatingLoginContextName = null;
-   
-   public HTTPFormServerAuthModule()
-   { 
-   }
- 
-   public HTTPFormServerAuthModule(String delgatingLoginContextName)
-   {
-      super();
-      this.delgatingLoginContextName = delgatingLoginContextName;
-   }
-
-   public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject)
-   throws AuthException
-   {
-      throw new RuntimeException("Not Applicable");
-   }
-
-   public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
-         Subject serviceSubject) throws AuthException
-   { 
-      Request request = (Request) messageInfo.getRequestMessage();
-      Response response = (Response) messageInfo.getResponseMessage();
-     
-      Principal principal;
-      context = request.getContext();
-      LoginConfig config = context.getLoginConfig();
-       
-      // References to objects we will need later
-      Session session = null;
-
-      //Lets find out if the cache is enabled or not 
-      cache = (Boolean) messageInfo.getMap().get("CACHE"); 
-      
-      // Have we authenticated this user before but have caching disabled?
-      if (!cache) {
-          session = request.getSessionInternal(true);
-          log.debug("Checking for reauthenticate in session " + session);
-          String username =
-              (String) session.getNote(Constants.SESS_USERNAME_NOTE);
-          String password =
-              (String) session.getNote(Constants.SESS_PASSWORD_NOTE);
-          if ((username != null) && (password != null)) {
-              log.debug("Reauthenticating username '" + username + "'");
-              principal =
-                  context.getRealm().authenticate(username, password);
-              if (principal != null) {
-                  session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
-                  if (!matchRequest(request)) {
-                     registerWithCallbackHandler(principal, username, password);
-                     
-                      /*register(request, response, principal,
-                               Constants.FORM_METHOD,
-                               username, password);*/
-                      return AuthStatus.SUCCESS;
-                  }
-              }
-              log.trace("Reauthentication failed, proceed normally");
-          }
-      }
-
-      // Is this the re-submit of the original request URI after successful
-      // authentication?  If so, forward the *original* request instead.
-      if (matchRequest(request)) {
-          session = request.getSessionInternal(true);
-          log.trace("Restore request from session '"
-                        + session.getIdInternal() 
-                        + "'");
-          principal = (Principal)
-              session.getNote(Constants.FORM_PRINCIPAL_NOTE);
-          
-          registerWithCallbackHandler(principal, 
-                (String) session.getNote(Constants.SESS_USERNAME_NOTE), 
-                (String) session.getNote(Constants.SESS_PASSWORD_NOTE));
-          
-          /*register(request, response, principal, Constants.FORM_METHOD,
-                   (String) session.getNote(Constants.SESS_USERNAME_NOTE),
-                   (String) session.getNote(Constants.SESS_PASSWORD_NOTE));*/
-          // If we're caching principals we no longer need the username
-          // and password in the session, so remove them
-          if (cache) {
-              session.removeNote(Constants.SESS_USERNAME_NOTE);
-              session.removeNote(Constants.SESS_PASSWORD_NOTE);
-          }
-          if (restoreRequest(request, session)) {
-              log.trace("Proceed to restored request");
-              return (AuthStatus.SUCCESS);
-          } else {
-              log.trace("Restore of original request failed");
-            
-            try
-            {
-               response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-            }
-            catch (IOException e)
-            {
-               log.error(e.getLocalizedMessage(),e);
-            }
-              return AuthStatus.FAILURE;
-          }
-      }
-
-      // Acquire references to objects we will need to evaluate
-      MessageBytes uriMB = MessageBytes.newInstance();
-      CharChunk uriCC = uriMB.getCharChunk();
-      uriCC.setLimit(-1);
-      String contextPath = request.getContextPath();
-      String requestURI = request.getDecodedRequestURI();
-      response.setContext(request.getContext());
-
-      // Is this the action request from the login page?
-      boolean loginAction =
-          requestURI.startsWith(contextPath) &&
-          requestURI.endsWith(Constants.FORM_ACTION);
-
-      // No -- Save this request and redirect to the form login page
-      if (!loginAction) {
-          session = request.getSessionInternal(true);
-          log.trace("Save request in session '" + session.getIdInternal() + "'");
-          try {
-              saveRequest(request, session);
-          } catch (IOException ioe) {
-              log.trace("Request body too big to save during authentication");
-              try
-            {
-               response.sendError(HttpServletResponse.SC_FORBIDDEN,
-                         sm.getString("authenticator.requestBodyTooBig"));
-            }
-            catch (IOException e)
-            {
-               log.error("Exception in Form authentication:",e);
-               throw new AuthException(e.getLocalizedMessage());
-            }
-              return (AuthStatus.FAILURE);
-          }
-          forwardToLoginPage(request, response, config);
-          return (AuthStatus.SEND_CONTINUE);
-      }
-
-      // Yes -- Validate the specified credentials and redirect
-      // to the error page if they are not correct
-      Realm realm = context.getRealm();
-      String characterEncoding = request.getCharacterEncoding();
-      if (characterEncoding != null) {
-          try
-         {
-            request.setCharacterEncoding(characterEncoding);
-         }
-         catch (UnsupportedEncodingException e)
-         {
-            log.error(e.getLocalizedMessage(), e);
-         }
-      }
-      String username = request.getParameter(Constants.FORM_USERNAME);
-      String password = request.getParameter(Constants.FORM_PASSWORD);
-      log.trace("Authenticating username '" + username + "'");
-      principal = realm.authenticate(username, password);
-      if (principal == null) {
-          forwardToErrorPage(request, response, config);
-          return (AuthStatus.FAILURE);
-      }
-
-      log.trace("Authentication of '" + username + "' was successful");
-
-      if (session == null)
-          session = request.getSessionInternal(false);
-      if (session == null) {
-          log.trace
-                  ("User took so long to log on the session expired");
-          try
-         {
-            response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT,
-                                sm.getString("authenticator.sessionExpired"));
-         }
-         catch (IOException e)
-         {
-            log.error(e.getLocalizedMessage(),e);
-         }
-          return (AuthStatus.FAILURE);
-      }
-
-      // Save the authenticated Principal in our session
-      session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
-
-      // Save the username and password as well
-      session.setNote(Constants.SESS_USERNAME_NOTE, username);
-      session.setNote(Constants.SESS_PASSWORD_NOTE, password);
-
-      // Redirect the user to the original request URI (which will cause
-      // the original request to be restored)
-      requestURI = savedRequestURL(session);
-      log.trace("Redirecting to original '" + requestURI + "'");
-      try
-      {
-         if (requestURI == null)
-            response.sendError(HttpServletResponse.SC_BAD_REQUEST,
-                               sm.getString("authenticator.formlogin"));
-        else
-            response.sendRedirect(response.encodeRedirectURL(requestURI));  
-      }
-      catch(IOException ioe)
-      {
-         log.error(ioe.getLocalizedMessage(),ioe);
-      }
-      return (AuthStatus.FAILURE); 
-   }
-   
-   /**
-    * Does this request match the saved one (so that it must be the redirect
-    * we signalled after successful authentication?
-    *
-    * @param request The request to be verified
-    */
-   protected boolean matchRequest(Request request) 
-   { 
-     // Has a session been created?
-     Session session = request.getSessionInternal(false);
-     if (session == null)
-         return (false);
-
-     // Is there a saved request?
-     SavedRequest sreq = (SavedRequest)
-         session.getNote(Constants.FORM_REQUEST_NOTE);
-     if (sreq == null)
-         return (false);
-
-     // Is there a saved principal?
-     if (session.getNote(Constants.FORM_PRINCIPAL_NOTE) == null)
-         return (false);
-
-     // Does the request URI match?
-     String requestURI = request.getRequestURI();
-     if (requestURI == null)
-         return (false);
-     return (requestURI.equals(sreq.getRequestURI()));
-
-   }
-
-
-   /**
-    * Restore the original request from information stored in our session.
-    * If the original request is no longer present (because the session
-    * timed out), return <code>false</code>; otherwise, return
-    * <code>true</code>.
-    *
-    * @param request The request to be restored
-    * @param session The session containing the saved information
-    */
-   @SuppressWarnings("unchecked")
-   protected boolean restoreRequest(Request request, Session session) 
-   { 
-       // Retrieve and remove the SavedRequest object from our session
-       SavedRequest saved = (SavedRequest)
-           session.getNote(Constants.FORM_REQUEST_NOTE);
-       session.removeNote(Constants.FORM_REQUEST_NOTE);
-       session.removeNote(Constants.FORM_PRINCIPAL_NOTE);
-       if (saved == null)
-           return (false);
-
-       // Modify our current request to reflect the original one
-       request.clearCookies();
-       Iterator cookies = saved.getCookies();
-       while (cookies.hasNext()) {
-           request.addCookie((Cookie) cookies.next());
-       }
-
-       MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
-       rmh.recycle();
-       boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
-                          "HEAD".equalsIgnoreCase(saved.getMethod());
-       Iterator names = saved.getHeaderNames();
-       while (names.hasNext()) {
-           String name = (String) names.next();
-           // The browser isn't expecting this conditional response now.
-           // Assuming that it can quietly recover from an unexpected 412.
-           // BZ 43687
-           if(!("If-Modified-Since".equalsIgnoreCase(name) ||
-                (cachable && "If-None-Match".equalsIgnoreCase(name)))) {
-               Iterator values = saved.getHeaderValues(name);
-               while (values.hasNext()) {
-                   rmh.addValue(name).setString( (String)values.next() );
-               }
-           }
-       }
-       
-       request.clearLocales();
-       Iterator locales = saved.getLocales();
-       while (locales.hasNext()) {
-           request.addLocale((Locale) locales.next());
-       }
-       
-       request.getCoyoteRequest().getParameters().recycle();
-       
-       if ("POST".equalsIgnoreCase(saved.getMethod())) {
-           ByteChunk body = saved.getBody();
-           
-           if (body != null) {
-               request.getCoyoteRequest().action
-                   (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
-   
-               // Set content type
-               MessageBytes contentType = MessageBytes.newInstance();
-               
-               // If no content type specified, use default for POST
-               String savedContentType = saved.getContentType();
-               if (savedContentType == null) {
-                   savedContentType = "application/x-www-form-urlencoded";
-               }
-
-               contentType.setString(savedContentType);
-               request.getCoyoteRequest().setContentType(contentType);
-           }
-       }
-       request.getCoyoteRequest().method().setString(saved.getMethod());
-
-       request.getCoyoteRequest().queryString().setString
-           (saved.getQueryString());
-
-       request.getCoyoteRequest().requestURI().setString
-           (saved.getRequestURI());
-       return (true); 
-   }
-
-
-   /**
-    * Save the original request information into our session.
-    *
-    * @param request The request to be saved
-    * @param session The session to contain the saved information
-    * @throws IOException
-    */
-   @SuppressWarnings("unchecked")
-   protected void saveRequest(Request request, Session session)
-       throws IOException {
-
-       // Create and populate a SavedRequest object for this request
-       SavedRequest saved = new SavedRequest();
-       Cookie cookies[] = request.getCookies();
-       if (cookies != null) {
-           for (int i = 0; i < cookies.length; i++)
-               saved.addCookie(cookies[i]);
-       }
-       Enumeration names = request.getHeaderNames();
-       while (names.hasMoreElements()) {
-           String name = (String) names.nextElement();
-           Enumeration values = request.getHeaders(name);
-           while (values.hasMoreElements()) {
-               String value = (String) values.nextElement();
-               saved.addHeader(name, value);
-           }
-       }
-       Enumeration locales = request.getLocales();
-       while (locales.hasMoreElements()) {
-           Locale locale = (Locale) locales.nextElement();
-           saved.addLocale(locale);
-       }
-
-       if ("POST".equalsIgnoreCase(request.getMethod())) {
-           ByteChunk body = new ByteChunk();
-           body.setLimit(request.getConnector().getMaxSavePostSize());
-
-           byte[] buffer = new byte[4096];
-           int bytesRead;
-           InputStream is = request.getInputStream();
-       
-           while ( (bytesRead = is.read(buffer) ) >= 0) {
-               body.append(buffer, 0, bytesRead);
-           }
-           saved.setBody(body);
-           saved.setContentType(request.getContentType());
-       }
-
-       saved.setMethod(request.getMethod());
-       saved.setQueryString(request.getQueryString());
-       saved.setRequestURI(request.getRequestURI());
-
-       // Stash the SavedRequest in our session for later use
-       session.setNote(Constants.FORM_REQUEST_NOTE, saved);
-   }
-
-   /**
-    * Return the request URI (with the corresponding query string, if any)
-    * from the saved request so that we can redirect to it.
-    *
-    * @param session Our current session
-    */
-   protected String savedRequestURL(Session session) 
-   {
-
-       SavedRequest saved =
-           (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE);
-       if (saved == null)
-           return (null);
-       StringBuffer sb = new StringBuffer(saved.getRequestURI());
-       if (saved.getQueryString() != null) {
-           sb.append('?');
-           sb.append(saved.getQueryString());
-       }
-       return (sb.toString());
-
-   }
-   
-   //Forward Methods
-   /**
-    * Called to forward to the login page
-    * 
-    * @param request Request we are processing
-    * @param response Response we are creating
-    * @param config    Login configuration describing how authentication
-    *              should be performed
-    */
-   protected void forwardToLoginPage(Request request, Response response, LoginConfig config) 
-   {
-       RequestDispatcher disp =
-           context.getServletContext().getRequestDispatcher
-           (config.getLoginPage());
-       try {
-           disp.forward(request.getRequest(), response.getResponse());
-           response.finishResponse();
-       } catch (Throwable t) {
-           log.warn("Unexpected error forwarding to login page", t);
-       }
-   }
-
-
-   /**
-    * Called to forward to the error page
-    * 
-    * @param request Request we are processing
-    * @param response Response we are creating
-    * @param config    Login configuration describing how authentication
-    *              should be performed
-    */
-   protected void forwardToErrorPage(Request request, Response response, LoginConfig config) 
-   {
-       RequestDispatcher disp =
-           context.getServletContext().getRequestDispatcher
-           (config.getErrorPage());
-       try {
-           disp.forward(request.getRequest(), response.getResponse());
-       } catch (Throwable t) {
-           log.warn("Unexpected error forwarding to error page", t);
-       }
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi.modules;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.AuthStatus;
+import javax.security.auth.message.MessageInfo;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Session;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.authenticator.SavedRequest;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.deploy.LoginConfig;
+import org.apache.catalina.util.StringManager;
+import org.apache.coyote.ActionCode;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.CharChunk;
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.MimeHeaders;
+import org.jboss.logging.Logger;
+
+/**
+ * Server auth module for FORM authentication
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 7, 2008
+ */
+public class HTTPFormServerAuthModule extends TomcatServerAuthModule
+{
+   private static Logger log = Logger.getLogger(HTTPFormServerAuthModule.class);
+
+   protected Context context; 
+   
+   protected boolean cache = false;
+   
+   protected static final StringManager sm =
+      StringManager.getManager(Constants.Package);
+   
+   /**
+    * The number of random bytes to include when generating a
+    * session identifier.
+    */
+   protected static final int SESSION_ID_BYTES = 16;
+
+   protected String delgatingLoginContextName = null;
+   
+   public HTTPFormServerAuthModule()
+   { 
+   }
+ 
+   public HTTPFormServerAuthModule(String delgatingLoginContextName)
+   {
+      super();
+      this.delgatingLoginContextName = delgatingLoginContextName;
+   }
+
+   public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject)
+   throws AuthException
+   {
+      throw new RuntimeException("Not Applicable");
+   }
+
+   public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
+         Subject serviceSubject) throws AuthException
+   { 
+      Request request = (Request) messageInfo.getRequestMessage();
+      Response response = (Response) messageInfo.getResponseMessage();
+     
+      Principal principal;
+      context = request.getContext();
+      LoginConfig config = context.getLoginConfig();
+       
+      // References to objects we will need later
+      Session session = null;
+
+      //Lets find out if the cache is enabled or not 
+      cache = (Boolean) messageInfo.getMap().get("CACHE"); 
+      
+      // Have we authenticated this user before but have caching disabled?
+      if (!cache) {
+          session = request.getSessionInternal(true);
+          log.debug("Checking for reauthenticate in session " + session);
+          String username =
+              (String) session.getNote(Constants.SESS_USERNAME_NOTE);
+          String password =
+              (String) session.getNote(Constants.SESS_PASSWORD_NOTE);
+          if ((username != null) && (password != null)) {
+              log.debug("Reauthenticating username '" + username + "'");
+              principal =
+                  context.getRealm().authenticate(username, password);
+              if (principal != null) {
+                  session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
+                  if (!matchRequest(request)) {
+                     registerWithCallbackHandler(principal, username, password);
+                     
+                      /*register(request, response, principal,
+                               Constants.FORM_METHOD,
+                               username, password);*/
+                      return AuthStatus.SUCCESS;
+                  }
+              }
+              log.trace("Reauthentication failed, proceed normally");
+          }
+      }
+
+      // Is this the re-submit of the original request URI after successful
+      // authentication?  If so, forward the *original* request instead.
+      if (matchRequest(request)) {
+          session = request.getSessionInternal(true);
+          log.trace("Restore request from session '"
+                        + session.getIdInternal() 
+                        + "'");
+          principal = (Principal)
+              session.getNote(Constants.FORM_PRINCIPAL_NOTE);
+          
+          registerWithCallbackHandler(principal, 
+                (String) session.getNote(Constants.SESS_USERNAME_NOTE), 
+                (String) session.getNote(Constants.SESS_PASSWORD_NOTE));
+          
+          /*register(request, response, principal, Constants.FORM_METHOD,
+                   (String) session.getNote(Constants.SESS_USERNAME_NOTE),
+                   (String) session.getNote(Constants.SESS_PASSWORD_NOTE));*/
+          // If we're caching principals we no longer need the username
+          // and password in the session, so remove them
+          if (cache) {
+              session.removeNote(Constants.SESS_USERNAME_NOTE);
+              session.removeNote(Constants.SESS_PASSWORD_NOTE);
+          }
+          if (restoreRequest(request, session)) {
+              log.trace("Proceed to restored request");
+              return (AuthStatus.SUCCESS);
+          } else {
+              log.trace("Restore of original request failed");
+            
+            try
+            {
+               response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            }
+            catch (IOException e)
+            {
+               log.error(e.getLocalizedMessage(),e);
+            }
+              return AuthStatus.FAILURE;
+          }
+      }
+
+      // Acquire references to objects we will need to evaluate
+      MessageBytes uriMB = MessageBytes.newInstance();
+      CharChunk uriCC = uriMB.getCharChunk();
+      uriCC.setLimit(-1);
+      String contextPath = request.getContextPath();
+      String requestURI = request.getDecodedRequestURI();
+      response.setContext(request.getContext());
+
+      // Is this the action request from the login page?
+      boolean loginAction =
+          requestURI.startsWith(contextPath) &&
+          requestURI.endsWith(Constants.FORM_ACTION);
+
+      // No -- Save this request and redirect to the form login page
+      if (!loginAction) {
+          session = request.getSessionInternal(true);
+          log.trace("Save request in session '" + session.getIdInternal() + "'");
+          try {
+              saveRequest(request, session);
+          } catch (IOException ioe) {
+              log.trace("Request body too big to save during authentication");
+              try
+            {
+               response.sendError(HttpServletResponse.SC_FORBIDDEN,
+                         sm.getString("authenticator.requestBodyTooBig"));
+            }
+            catch (IOException e)
+            {
+               log.error("Exception in Form authentication:",e);
+               throw new AuthException(e.getLocalizedMessage());
+            }
+              return (AuthStatus.FAILURE);
+          }
+          forwardToLoginPage(request, response, config);
+          return (AuthStatus.SEND_CONTINUE);
+      }
+
+      // Yes -- Validate the specified credentials and redirect
+      // to the error page if they are not correct
+      Realm realm = context.getRealm();
+      String characterEncoding = request.getCharacterEncoding();
+      if (characterEncoding != null) {
+          try
+         {
+            request.setCharacterEncoding(characterEncoding);
+         }
+         catch (UnsupportedEncodingException e)
+         {
+            log.error(e.getLocalizedMessage(), e);
+         }
+      }
+      String username = request.getParameter(Constants.FORM_USERNAME);
+      String password = request.getParameter(Constants.FORM_PASSWORD);
+      log.trace("Authenticating username '" + username + "'");
+      principal = realm.authenticate(username, password);
+      if (principal == null) {
+          forwardToErrorPage(request, response, config);
+          return (AuthStatus.FAILURE);
+      }
+
+      log.trace("Authentication of '" + username + "' was successful");
+
+      if (session == null)
+          session = request.getSessionInternal(false);
+      if (session == null) {
+          log.trace
+                  ("User took so long to log on the session expired");
+          try
+         {
+            response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT,
+                                sm.getString("authenticator.sessionExpired"));
+         }
+         catch (IOException e)
+         {
+            log.error(e.getLocalizedMessage(),e);
+         }
+          return (AuthStatus.FAILURE);
+      }
+
+      // Save the authenticated Principal in our session
+      session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
+
+      // Save the username and password as well
+      session.setNote(Constants.SESS_USERNAME_NOTE, username);
+      session.setNote(Constants.SESS_PASSWORD_NOTE, password);
+
+      // Redirect the user to the original request URI (which will cause
+      // the original request to be restored)
+      requestURI = savedRequestURL(session);
+      log.trace("Redirecting to original '" + requestURI + "'");
+      try
+      {
+         if (requestURI == null)
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST,
+                               sm.getString("authenticator.formlogin"));
+        else
+            response.sendRedirect(response.encodeRedirectURL(requestURI));  
+      }
+      catch(IOException ioe)
+      {
+         log.error(ioe.getLocalizedMessage(),ioe);
+      }
+      return (AuthStatus.FAILURE); 
+   }
+   
+   /**
+    * Does this request match the saved one (so that it must be the redirect
+    * we signalled after successful authentication?
+    *
+    * @param request The request to be verified
+    */
+   protected boolean matchRequest(Request request) 
+   { 
+     // Has a session been created?
+     Session session = request.getSessionInternal(false);
+     if (session == null)
+         return (false);
+
+     // Is there a saved request?
+     SavedRequest sreq = (SavedRequest)
+         session.getNote(Constants.FORM_REQUEST_NOTE);
+     if (sreq == null)
+         return (false);
+
+     // Is there a saved principal?
+     if (session.getNote(Constants.FORM_PRINCIPAL_NOTE) == null)
+         return (false);
+
+     // Does the request URI match?
+     String requestURI = request.getRequestURI();
+     if (requestURI == null)
+         return (false);
+     return (requestURI.equals(sreq.getRequestURI()));
+
+   }
+
+
+   /**
+    * Restore the original request from information stored in our session.
+    * If the original request is no longer present (because the session
+    * timed out), return <code>false</code>; otherwise, return
+    * <code>true</code>.
+    *
+    * @param request The request to be restored
+    * @param session The session containing the saved information
+    */
+   @SuppressWarnings("unchecked")
+   protected boolean restoreRequest(Request request, Session session) 
+   { 
+       // Retrieve and remove the SavedRequest object from our session
+       SavedRequest saved = (SavedRequest)
+           session.getNote(Constants.FORM_REQUEST_NOTE);
+       session.removeNote(Constants.FORM_REQUEST_NOTE);
+       session.removeNote(Constants.FORM_PRINCIPAL_NOTE);
+       if (saved == null)
+           return (false);
+
+       // Modify our current request to reflect the original one
+       request.clearCookies();
+       Iterator cookies = saved.getCookies();
+       while (cookies.hasNext()) {
+           request.addCookie((Cookie) cookies.next());
+       }
+
+       MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
+       rmh.recycle();
+       boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
+                          "HEAD".equalsIgnoreCase(saved.getMethod());
+       Iterator names = saved.getHeaderNames();
+       while (names.hasNext()) {
+           String name = (String) names.next();
+           // The browser isn't expecting this conditional response now.
+           // Assuming that it can quietly recover from an unexpected 412.
+           // BZ 43687
+           if(!("If-Modified-Since".equalsIgnoreCase(name) ||
+                (cachable && "If-None-Match".equalsIgnoreCase(name)))) {
+               Iterator values = saved.getHeaderValues(name);
+               while (values.hasNext()) {
+                   rmh.addValue(name).setString( (String)values.next() );
+               }
+           }
+       }
+       
+       request.clearLocales();
+       Iterator locales = saved.getLocales();
+       while (locales.hasNext()) {
+           request.addLocale((Locale) locales.next());
+       }
+       
+       request.getCoyoteRequest().getParameters().recycle();
+       
+       if ("POST".equalsIgnoreCase(saved.getMethod())) {
+           ByteChunk body = saved.getBody();
+           
+           if (body != null) {
+               request.getCoyoteRequest().action
+                   (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
+   
+               // Set content type
+               MessageBytes contentType = MessageBytes.newInstance();
+               
+               // If no content type specified, use default for POST
+               String savedContentType = saved.getContentType();
+               if (savedContentType == null) {
+                   savedContentType = "application/x-www-form-urlencoded";
+               }
+
+               contentType.setString(savedContentType);
+               request.getCoyoteRequest().setContentType(contentType);
+           }
+       }
+       request.getCoyoteRequest().method().setString(saved.getMethod());
+
+       request.getCoyoteRequest().queryString().setString
+           (saved.getQueryString());
+
+       request.getCoyoteRequest().requestURI().setString
+           (saved.getRequestURI());
+       return (true); 
+   }
+
+
+   /**
+    * Save the original request information into our session.
+    *
+    * @param request The request to be saved
+    * @param session The session to contain the saved information
+    * @throws IOException
+    */
+   @SuppressWarnings("unchecked")
+   protected void saveRequest(Request request, Session session)
+       throws IOException {
+
+       // Create and populate a SavedRequest object for this request
+       SavedRequest saved = new SavedRequest();
+       Cookie cookies[] = request.getCookies();
+       if (cookies != null) {
+           for (int i = 0; i < cookies.length; i++)
+               saved.addCookie(cookies[i]);
+       }
+       Enumeration names = request.getHeaderNames();
+       while (names.hasMoreElements()) {
+           String name = (String) names.nextElement();
+           Enumeration values = request.getHeaders(name);
+           while (values.hasMoreElements()) {
+               String value = (String) values.nextElement();
+               saved.addHeader(name, value);
+           }
+       }
+       Enumeration locales = request.getLocales();
+       while (locales.hasMoreElements()) {
+           Locale locale = (Locale) locales.nextElement();
+           saved.addLocale(locale);
+       }
+
+       if ("POST".equalsIgnoreCase(request.getMethod())) {
+           ByteChunk body = new ByteChunk();
+           body.setLimit(request.getConnector().getMaxSavePostSize());
+
+           byte[] buffer = new byte[4096];
+           int bytesRead;
+           InputStream is = request.getInputStream();
+       
+           while ( (bytesRead = is.read(buffer) ) >= 0) {
+               body.append(buffer, 0, bytesRead);
+           }
+           saved.setBody(body);
+           saved.setContentType(request.getContentType());
+       }
+
+       saved.setMethod(request.getMethod());
+       saved.setQueryString(request.getQueryString());
+       saved.setRequestURI(request.getRequestURI());
+
+       // Stash the SavedRequest in our session for later use
+       session.setNote(Constants.FORM_REQUEST_NOTE, saved);
+   }
+
+   /**
+    * Return the request URI (with the corresponding query string, if any)
+    * from the saved request so that we can redirect to it.
+    *
+    * @param session Our current session
+    */
+   protected String savedRequestURL(Session session) 
+   {
+
+       SavedRequest saved =
+           (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE);
+       if (saved == null)
+           return (null);
+       StringBuffer sb = new StringBuffer(saved.getRequestURI());
+       if (saved.getQueryString() != null) {
+           sb.append('?');
+           sb.append(saved.getQueryString());
+       }
+       return (sb.toString());
+
+   }
+   
+   //Forward Methods
+   /**
+    * Called to forward to the login page
+    * 
+    * @param request Request we are processing
+    * @param response Response we are creating
+    * @param config    Login configuration describing how authentication
+    *              should be performed
+    */
+   protected void forwardToLoginPage(Request request, Response response, LoginConfig config) 
+   {
+       RequestDispatcher disp =
+           context.getServletContext().getRequestDispatcher
+           (config.getLoginPage());
+       try {
+           disp.forward(request.getRequest(), response.getResponse());
+           response.finishResponse();
+       } catch (Throwable t) {
+           log.warn("Unexpected error forwarding to login page", t);
+       }
+   }
+
+
+   /**
+    * Called to forward to the error page
+    * 
+    * @param request Request we are processing
+    * @param response Response we are creating
+    * @param config    Login configuration describing how authentication
+    *              should be performed
+    */
+   protected void forwardToErrorPage(Request request, Response response, LoginConfig config) 
+   {
+       RequestDispatcher disp =
+           context.getServletContext().getRequestDispatcher
+           (config.getErrorPage());
+       try {
+           disp.forward(request.getRequest(), response.getResponse());
+       } catch (Throwable t) {
+           log.warn("Unexpected error forwarding to error page", t);
+       }
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/HTTPFormServerAuthModule.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/SecurityActions.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/SecurityActions.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/SecurityActions.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,70 +1,70 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi.modules;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * Privileged Blocks
- * @author Anil.Saldhana at redhat.com
- * @since Oct 8, 2008
- */
-class SecurityActions
-{
-   static Class<?> loadClass(final String fqn) throws PrivilegedActionException
-   {
-     return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
-     {
-        public Class<?> run() throws Exception
-        {
-           ClassLoader tcl = getContextClassLoader();
-           return tcl.loadClass(fqn); 
-        }
-     });  
-   } 
-   
-   static ClassLoader getContextClassLoader()
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
-      {
-         public ClassLoader run()
-         {
-            return Thread.currentThread().getContextClassLoader();
-         }
-      });
-   }
-   
-   static void setSystemProperty(final String key, final String value)
-   {
-      AccessController.doPrivileged(new PrivilegedAction<Object>()
-      {
-         public Object run()
-         {
-            System.setProperty(key, value);
-            return null;
-         }
-      });
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi.modules;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 8, 2008
+ */
+class SecurityActions
+{
+   static Class<?> loadClass(final String fqn) throws PrivilegedActionException
+   {
+     return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
+     {
+        public Class<?> run() throws Exception
+        {
+           ClassLoader tcl = getContextClassLoader();
+           return tcl.loadClass(fqn); 
+        }
+     });  
+   } 
+   
+   static ClassLoader getContextClassLoader()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+   
+   static void setSystemProperty(final String key, final String value)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            System.setProperty(key, value);
+            return null;
+         }
+      });
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/TomcatServerAuthModule.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/TomcatServerAuthModule.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/TomcatServerAuthModule.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,106 +1,106 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.jaspi.modules;
-
-import java.security.Principal;
-import java.util.Map;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.message.AuthException;
-import javax.security.auth.message.AuthStatus;
-import javax.security.auth.message.MessageInfo;
-import javax.security.auth.message.MessagePolicy;
-import javax.security.auth.message.callback.CallerPrincipalCallback;
-import javax.security.auth.message.callback.PasswordValidationCallback;
-import javax.security.auth.message.module.ServerAuthModule;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.jboss.web.tomcat.security.jaspi.TomcatJASPICallbackHandler;
-
-/**
- * Base class for Tomcat JSR-196 server auth modules
- * @author Anil.Saldhana at redhat.com
- * @since Oct 7, 2008
- */
-public abstract class TomcatServerAuthModule implements ServerAuthModule
-{
-   protected CallbackHandler callbackHandler;
-   
-   @SuppressWarnings("unchecked")
-   protected Map options;
-   
-   @SuppressWarnings("unchecked")
-   public Class[] getSupportedMessageTypes()
-   { 
-      return new Class[]{Request.class, Response.class, 
-            HttpServletRequest.class,HttpServletResponse.class};
-   }
-
-   @SuppressWarnings("unchecked")
-   public void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy,
-         CallbackHandler handler, Map options) throws AuthException
-   {
-      this.callbackHandler = handler;
-      this.options = options;
-   }
-
-   public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException
-   { 
-      Request request = (Request) messageInfo.getRequestMessage();
-      Principal principal = request.getUserPrincipal();
-      if(subject != null)
-         subject.getPrincipals().remove(principal);
-   }
-
-   public abstract AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException;
-
-   public abstract AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
-         Subject serviceSubject) throws AuthException;
-   
-   /**
-    * Register with the CallbackHandler
-    * @param userPrincipal
-    * @param username
-    * @param password
-    */
-   protected void registerWithCallbackHandler(Principal userPrincipal, String username,
-         String password)
-   {
-      if(this.callbackHandler instanceof TomcatJASPICallbackHandler)
-      {
-         TomcatJASPICallbackHandler cbh = (TomcatJASPICallbackHandler) callbackHandler;
-         
-         PasswordValidationCallback passwordValidationCallback = 
-            new PasswordValidationCallback(null,username,password.toCharArray());   
-         cbh.setPasswordValidationCallback(passwordValidationCallback);
-         
-         cbh.setCallerPrincipalCallback(new CallerPrincipalCallback(null,userPrincipal));
-      }
-      else
-         throw new RuntimeException(" Unsupported Callback handler "
-               + this.callbackHandler.getClass().getCanonicalName());
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.jaspi.modules;
+
+import java.security.Principal;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.AuthStatus;
+import javax.security.auth.message.MessageInfo;
+import javax.security.auth.message.MessagePolicy;
+import javax.security.auth.message.callback.CallerPrincipalCallback;
+import javax.security.auth.message.callback.PasswordValidationCallback;
+import javax.security.auth.message.module.ServerAuthModule;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.jboss.web.tomcat.security.jaspi.TomcatJASPICallbackHandler;
+
+/**
+ * Base class for Tomcat JSR-196 server auth modules
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 7, 2008
+ */
+public abstract class TomcatServerAuthModule implements ServerAuthModule
+{
+   protected CallbackHandler callbackHandler;
+   
+   @SuppressWarnings("unchecked")
+   protected Map options;
+   
+   @SuppressWarnings("unchecked")
+   public Class[] getSupportedMessageTypes()
+   { 
+      return new Class[]{Request.class, Response.class, 
+            HttpServletRequest.class,HttpServletResponse.class};
+   }
+
+   @SuppressWarnings("unchecked")
+   public void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy,
+         CallbackHandler handler, Map options) throws AuthException
+   {
+      this.callbackHandler = handler;
+      this.options = options;
+   }
+
+   public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException
+   { 
+      Request request = (Request) messageInfo.getRequestMessage();
+      Principal principal = request.getUserPrincipal();
+      if(subject != null)
+         subject.getPrincipals().remove(principal);
+   }
+
+   public abstract AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException;
+
+   public abstract AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, 
+         Subject serviceSubject) throws AuthException;
+   
+   /**
+    * Register with the CallbackHandler
+    * @param userPrincipal
+    * @param username
+    * @param password
+    */
+   protected void registerWithCallbackHandler(Principal userPrincipal, String username,
+         String password)
+   {
+      if(this.callbackHandler instanceof TomcatJASPICallbackHandler)
+      {
+         TomcatJASPICallbackHandler cbh = (TomcatJASPICallbackHandler) callbackHandler;
+         
+         PasswordValidationCallback passwordValidationCallback = 
+            new PasswordValidationCallback(null,username,password.toCharArray());   
+         cbh.setPasswordValidationCallback(passwordValidationCallback);
+         
+         cbh.setCallerPrincipalCallback(new CallerPrincipalCallback(null,userPrincipal));
+      }
+      else
+         throw new RuntimeException(" Unsupported Callback handler "
+               + this.callbackHandler.getClass().getCanonicalName());
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/jaspi/modules/TomcatServerAuthModule.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,290 +1,290 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.security.login;
-
-import java.security.Principal;
-import java.security.cert.X509Certificate;
-import java.util.UUID;
-
-import javax.naming.NamingException;
-import javax.servlet.http.Cookie;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Pipeline;
-import org.apache.catalina.Session;
-import org.apache.catalina.Valve;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.authenticator.SingleSignOn;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.jboss.web.tomcat.security.SecurityAssociationValve;
-
-//$Id$
-
-/**
- *  JBAS-4077: Programmatic Web Login
- *  @author Anil.Saldhana at redhat.com
- *  @since  Mar 12, 2007 
- *  @version $Revision$
- */
-public class WebAuthentication
-{
-   private static final String AUTH_TYPE = "PROGRAMMATIC_WEB_LOGIN";
-
-   public WebAuthentication()
-   {
-   }
-
-   /**
-    * Login an user via the CLIENT-CERT method
-    * @param certs X509 certificates
-    * @return Authenticated User Principal
-    */
-   public boolean login(X509Certificate[] certs)
-   {
-      //Get the active request
-      Request request = SecurityAssociationValve.activeRequest.get();
-      if (request == null)
-         throw new IllegalStateException("request is null");
-      Principal p = request.getContext().getRealm().authenticate(certs);
-      if (p != null)
-      {
-         register(request, p, null, null);
-      }
-      return p != null;
-   }
-
-   /**
-    * Login an user via the BASIC, FORM, DIGEST methods
-    * @param username
-    * @param credential
-    * @return
-    * @throws NamingException
-    */
-   public boolean login(String username, Object credential)
-   {
-      //Get the active request
-      Request request = SecurityAssociationValve.activeRequest.get();
-      if (request == null)
-         throw new IllegalStateException("request is null");
-
-      Principal p = null;
-      if (credential instanceof String)
-      {
-         p = request.getContext().getRealm().authenticate(username, (String) credential);
-      }
-      else if (credential instanceof byte[])
-      {
-         p = request.getContext().getRealm().authenticate(username, (byte[]) credential);
-      }
-      if (p != null)
-      {
-         register(request, p, username, credential);
-      }
-      return p != null;
-   }
-
-   /**
-    * Log the user out
-    *
-    */
-   public void logout()
-   {
-      //Get the active request
-      Request request = SecurityAssociationValve.activeRequest.get();
-      if (request == null)
-         throw new IllegalStateException("request is null");
-      unregister(request);
-   }
-
-   /**
-    * Register the principal with the request, session etc just the way AuthenticatorBase does
-    * @param request Catalina Request
-    * @param principal User Principal generated via authentication
-    * @param username username passed by the user (null for client-cert)
-    * @param credential Password (null for client-cert and digest)
-    */
-   protected void register(Request request, Principal principal, String username, Object password)
-   {
-      request.setAuthType(AUTH_TYPE);
-      request.setUserPrincipal(principal);
-
-      //Cache the authentication principal in the session
-      Session session = request.getSessionInternal(false);
-      if (session != null)
-      {
-         session.setAuthType(AUTH_TYPE);
-         session.setPrincipal(principal);
-         if (username != null)
-            session.setNote(Constants.SESS_USERNAME_NOTE, username);
-         else
-            session.removeNote(Constants.SESS_USERNAME_NOTE);
-         if (password != null)
-            session.setNote(Constants.SESS_PASSWORD_NOTE, getPasswordAsString(password));
-         else
-            session.removeNote(Constants.SESS_PASSWORD_NOTE);
-      }
-
-      // JBAS-4424: Programmatic web authentication with SSO
-      SingleSignOn sso = this.getSingleSignOn(request);
-      if (sso == null)
-         return;
-
-      // Only create a new SSO entry if the SSO did not already set a note
-      // for an existing entry (as it would do with subsequent requests
-      // for DIGEST and SSL authenticated contexts)
-      String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
-      if (ssoId == null)
-      {
-         // Construct a cookie to be returned to the client
-         ssoId = generateSessionId();
-         Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
-         cookie.setMaxAge(-1);
-         cookie.setPath("/");
-
-         // Bugzilla 41217
-         cookie.setSecure(request.isSecure());
-
-         // Bugzilla 34724
-         String ssoDomain = sso.getCookieDomain();
-         if (ssoDomain != null)
-         {
-            cookie.setDomain(ssoDomain);
-         }
-
-         Response response = (Response) SecurityAssociationValve.activeResponse.get();
-         response.addCookie(cookie);
-
-         // Register this principal with our SSO valve
-         sso.register(ssoId, principal, AUTH_TYPE, username, this.getPasswordAsString(password));
-         request.setNote(Constants.REQ_SSOID_NOTE, ssoId);
-
-      }
-      else
-      {
-         // Update the SSO session with the latest authentication data
-         sso.update(ssoId, principal, AUTH_TYPE, username, this.getPasswordAsString(password));
-      }
-
-      // Always associate a session with a new SSO reqistration.
-      // SSO entries are only removed from the SSO registry map when
-      // associated sessions are destroyed; if a new SSO entry is created
-      // above for this request and the user never revisits the context, the
-      // SSO entry will never be cleared if we don't associate the session
-      if (session == null)
-         session = request.getSessionInternal(true);
-      sso.associate(ssoId, session);
-   }
-
-   /**
-    * Log the user out
-    * @param request
-    */
-   protected void unregister(Request request)
-   {
-      request.setAuthType(null);
-      request.setUserPrincipal(null);
-
-      // Cache the authentication principal in the session.
-      Session session = request.getSessionInternal(false);
-      if (session != null)
-      {
-         session.setAuthType(null);
-         session.setPrincipal(null);
-         session.removeNote(Constants.SESS_USERNAME_NOTE);
-         session.removeNote(Constants.SESS_PASSWORD_NOTE);
-      }
-      // Unregister the SSOID.
-      SingleSignOn sso = this.getSingleSignOn(request);
-      if (sso != null)
-      {
-         String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
-         sso.deregister(ssoId);
-      }
-   }
-
-   private String getPasswordAsString(Object cred)
-   {
-      String p = null;
-
-      if (cred instanceof String)
-      {
-         p = (String) cred;
-      }
-      else if (cred instanceof byte[])
-      {
-         p = new String((byte[]) cred);
-      }
-      return p;
-   }
-
-   /**
-    * <p>
-    * Generate and return a new session identifier for the cookie that identifies an SSO principal.
-    * </p>
-    * 
-    * @return a <code>String</code> representing the generated identifier.
-    */
-   private String generateSessionId()
-   {
-      UUID uid = UUID.randomUUID();
-      String higherBits = Long.toHexString(uid.getMostSignificantBits());
-      String lowerBits = Long.toHexString(uid.getLeastSignificantBits());
-
-      return (higherBits + lowerBits).toUpperCase();
-   }
-
-   /**
-    * <p>
-    * Obtain a reference to the <code>SingleSignOn</code> valve, if one was configured.
-    * </p>
-    * 
-    * @param request    the <code>Request</code> object used to look up the SSO valve.
-    * @return   a reference to the <code>SingleSignOn</code> valve, or <code>null</code> if no SSO valve
-    * has been configured.
-    */
-   private SingleSignOn getSingleSignOn(Request request)
-   {
-      SingleSignOn sso = null;
-      Container parent = request.getContext().getParent();
-      while ((sso == null) && (parent != null))
-      {
-         if (!(parent instanceof Pipeline))
-         {
-            parent = parent.getParent();
-            continue;
-         }
-         Valve valves[] = ((Pipeline) parent).getValves();
-         for (int i = 0; i < valves.length; i++)
-         {
-            if (valves[i] instanceof SingleSignOn)
-            {
-               sso = (SingleSignOn) valves[i];
-               break;
-            }
-         }
-         if (sso == null)
-            parent = parent.getParent();
-      }
-      return sso;
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.security.login;
+
+import java.security.Principal;
+import java.security.cert.X509Certificate;
+import java.util.UUID;
+
+import javax.naming.NamingException;
+import javax.servlet.http.Cookie;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.Session;
+import org.apache.catalina.Valve;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.authenticator.SingleSignOn;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.jboss.web.tomcat.security.SecurityAssociationValve;
+
+//$Id$
+
+/**
+ *  JBAS-4077: Programmatic Web Login
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Mar 12, 2007 
+ *  @version $Revision$
+ */
+public class WebAuthentication
+{
+   private static final String AUTH_TYPE = "PROGRAMMATIC_WEB_LOGIN";
+
+   public WebAuthentication()
+   {
+   }
+
+   /**
+    * Login an user via the CLIENT-CERT method
+    * @param certs X509 certificates
+    * @return Authenticated User Principal
+    */
+   public boolean login(X509Certificate[] certs)
+   {
+      //Get the active request
+      Request request = SecurityAssociationValve.activeRequest.get();
+      if (request == null)
+         throw new IllegalStateException("request is null");
+      Principal p = request.getContext().getRealm().authenticate(certs);
+      if (p != null)
+      {
+         register(request, p, null, null);
+      }
+      return p != null;
+   }
+
+   /**
+    * Login an user via the BASIC, FORM, DIGEST methods
+    * @param username
+    * @param credential
+    * @return
+    * @throws NamingException
+    */
+   public boolean login(String username, Object credential)
+   {
+      //Get the active request
+      Request request = SecurityAssociationValve.activeRequest.get();
+      if (request == null)
+         throw new IllegalStateException("request is null");
+
+      Principal p = null;
+      if (credential instanceof String)
+      {
+         p = request.getContext().getRealm().authenticate(username, (String) credential);
+      }
+      else if (credential instanceof byte[])
+      {
+         p = request.getContext().getRealm().authenticate(username, (byte[]) credential);
+      }
+      if (p != null)
+      {
+         register(request, p, username, credential);
+      }
+      return p != null;
+   }
+
+   /**
+    * Log the user out
+    *
+    */
+   public void logout()
+   {
+      //Get the active request
+      Request request = SecurityAssociationValve.activeRequest.get();
+      if (request == null)
+         throw new IllegalStateException("request is null");
+      unregister(request);
+   }
+
+   /**
+    * Register the principal with the request, session etc just the way AuthenticatorBase does
+    * @param request Catalina Request
+    * @param principal User Principal generated via authentication
+    * @param username username passed by the user (null for client-cert)
+    * @param credential Password (null for client-cert and digest)
+    */
+   protected void register(Request request, Principal principal, String username, Object password)
+   {
+      request.setAuthType(AUTH_TYPE);
+      request.setUserPrincipal(principal);
+
+      //Cache the authentication principal in the session
+      Session session = request.getSessionInternal(false);
+      if (session != null)
+      {
+         session.setAuthType(AUTH_TYPE);
+         session.setPrincipal(principal);
+         if (username != null)
+            session.setNote(Constants.SESS_USERNAME_NOTE, username);
+         else
+            session.removeNote(Constants.SESS_USERNAME_NOTE);
+         if (password != null)
+            session.setNote(Constants.SESS_PASSWORD_NOTE, getPasswordAsString(password));
+         else
+            session.removeNote(Constants.SESS_PASSWORD_NOTE);
+      }
+
+      // JBAS-4424: Programmatic web authentication with SSO
+      SingleSignOn sso = this.getSingleSignOn(request);
+      if (sso == null)
+         return;
+
+      // Only create a new SSO entry if the SSO did not already set a note
+      // for an existing entry (as it would do with subsequent requests
+      // for DIGEST and SSL authenticated contexts)
+      String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
+      if (ssoId == null)
+      {
+         // Construct a cookie to be returned to the client
+         ssoId = generateSessionId();
+         Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
+         cookie.setMaxAge(-1);
+         cookie.setPath("/");
+
+         // Bugzilla 41217
+         cookie.setSecure(request.isSecure());
+
+         // Bugzilla 34724
+         String ssoDomain = sso.getCookieDomain();
+         if (ssoDomain != null)
+         {
+            cookie.setDomain(ssoDomain);
+         }
+
+         Response response = (Response) SecurityAssociationValve.activeResponse.get();
+         response.addCookie(cookie);
+
+         // Register this principal with our SSO valve
+         sso.register(ssoId, principal, AUTH_TYPE, username, this.getPasswordAsString(password));
+         request.setNote(Constants.REQ_SSOID_NOTE, ssoId);
+
+      }
+      else
+      {
+         // Update the SSO session with the latest authentication data
+         sso.update(ssoId, principal, AUTH_TYPE, username, this.getPasswordAsString(password));
+      }
+
+      // Always associate a session with a new SSO reqistration.
+      // SSO entries are only removed from the SSO registry map when
+      // associated sessions are destroyed; if a new SSO entry is created
+      // above for this request and the user never revisits the context, the
+      // SSO entry will never be cleared if we don't associate the session
+      if (session == null)
+         session = request.getSessionInternal(true);
+      sso.associate(ssoId, session);
+   }
+
+   /**
+    * Log the user out
+    * @param request
+    */
+   protected void unregister(Request request)
+   {
+      request.setAuthType(null);
+      request.setUserPrincipal(null);
+
+      // Cache the authentication principal in the session.
+      Session session = request.getSessionInternal(false);
+      if (session != null)
+      {
+         session.setAuthType(null);
+         session.setPrincipal(null);
+         session.removeNote(Constants.SESS_USERNAME_NOTE);
+         session.removeNote(Constants.SESS_PASSWORD_NOTE);
+      }
+      // Unregister the SSOID.
+      SingleSignOn sso = this.getSingleSignOn(request);
+      if (sso != null)
+      {
+         String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
+         sso.deregister(ssoId);
+      }
+   }
+
+   private String getPasswordAsString(Object cred)
+   {
+      String p = null;
+
+      if (cred instanceof String)
+      {
+         p = (String) cred;
+      }
+      else if (cred instanceof byte[])
+      {
+         p = new String((byte[]) cred);
+      }
+      return p;
+   }
+
+   /**
+    * <p>
+    * Generate and return a new session identifier for the cookie that identifies an SSO principal.
+    * </p>
+    * 
+    * @return a <code>String</code> representing the generated identifier.
+    */
+   private String generateSessionId()
+   {
+      UUID uid = UUID.randomUUID();
+      String higherBits = Long.toHexString(uid.getMostSignificantBits());
+      String lowerBits = Long.toHexString(uid.getLeastSignificantBits());
+
+      return (higherBits + lowerBits).toUpperCase();
+   }
+
+   /**
+    * <p>
+    * Obtain a reference to the <code>SingleSignOn</code> valve, if one was configured.
+    * </p>
+    * 
+    * @param request    the <code>Request</code> object used to look up the SSO valve.
+    * @return   a reference to the <code>SingleSignOn</code> valve, or <code>null</code> if no SSO valve
+    * has been configured.
+    */
+   private SingleSignOn getSingleSignOn(Request request)
+   {
+      SingleSignOn sso = null;
+      Container parent = request.getContext().getParent();
+      while ((sso == null) && (parent != null))
+      {
+         if (!(parent instanceof Pipeline))
+         {
+            parent = parent.getParent();
+            continue;
+         }
+         Valve valves[] = ((Pipeline) parent).getValves();
+         for (int i = 0; i < valves.length; i++)
+         {
+            if (valves[i] instanceof SingleSignOn)
+            {
+               sso = (SingleSignOn) valves[i];
+               break;
+            }
+         }
+         if (sso == null)
+            parent = parent.getParent();
+      }
+      return sso;
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/security/login/WebAuthentication.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,291 +1,291 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.jboss.PassivationConfig;
-import org.jboss.metadata.web.jboss.ReplicationConfig;
-import org.jboss.metadata.web.jboss.ReplicationGranularity;
-import org.jboss.metadata.web.jboss.ReplicationTrigger;
-import org.jboss.metadata.web.jboss.SnapshotMode;
-
-/**
- * Injects default clustering values into JBossWebMetaData.
- * 
- * TODO. A better approach is to use a jboss-web.xml equivalent to conf/web.xml 
- * and conf/standardjboss.xml as the source for defaults.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class ClusteringDefaultsDeployer extends AbstractDeployer
-{
-   public static final int IGNORED = -1;
-   
-   private String cacheName;
-   private String fieldGranularityCacheName;
-   private SnapshotMode snapshotMode;
-   private int snapshotInterval;
-   private ReplicationGranularity replicationGranularity;
-   private ReplicationTrigger replicationTrigger;
-   private boolean replicationFieldBatchMode = true;
-   private Boolean useJK;
-   private int maxUnreplicatedInterval;
-   private boolean useSessionPassivation;
-   private int passivationMinIdleTime = IGNORED;
-   private int passivationMaxIdleTime = IGNORED;
-   private boolean useLocalCache = true;
-   
-   /**
-    * Create a new CacheManagerDependencyDeployer. 
-    */
-   public ClusteringDefaultsDeployer()
-   {
-      setStage(DeploymentStages.POST_PARSE);
-      setInput(JBossWebMetaData.class);
-      setOutput(JBossWebMetaData.class);
-   }
-
-   public Boolean isUseJK()
-   {
-      return useJK;
-   }
-
-   public void setUseJK(Boolean useJK)
-   {
-      this.useJK = useJK;
-   }
-
-   public String getCacheName()
-   {
-      return cacheName;
-   }
-
-   public void setCacheName(String cacheName)
-   {
-      this.cacheName = cacheName;
-   }
-
-   public String getFieldGranularityCacheName()
-   {
-      return fieldGranularityCacheName;
-   }
-
-   public void setFieldGranularityCacheName(String fieldGranularityCacheName)
-   {
-      this.fieldGranularityCacheName = fieldGranularityCacheName;
-   }
-
-   public SnapshotMode getSnapshotMode()
-   {
-      return snapshotMode;
-   }
-
-   public void setSnapshotMode(SnapshotMode snapshotMode)
-   {
-      this.snapshotMode = snapshotMode;
-   }
-
-   /**
-    * Get the snapshot interval.
-    */
-   public int getSnapshotInterval()
-   {
-      return snapshotInterval;
-   }
-   
-   /**
-    * Get the snapshot interval.
-    */
-   public void setSnapshotInterval(int snapshotInterval)
-   {
-      this.snapshotInterval = snapshotInterval;
-   }
-
-   public ReplicationGranularity getReplicationGranularity()
-   {
-      return replicationGranularity;
-   }
-
-   public void setReplicationGranularity(ReplicationGranularity granularity)
-   {
-      this.replicationGranularity = granularity;
-   }
-
-   public ReplicationTrigger getReplicationTrigger()
-   {
-      return replicationTrigger;
-   }
-
-   public void setReplicationTrigger(ReplicationTrigger trigger)
-   {
-      this.replicationTrigger = trigger;
-   }
-
-   public boolean isReplicationFieldBatchMode()
-   {
-      return replicationFieldBatchMode;
-   }
-
-   public void setReplicationFieldBatchMode(boolean fieldBatchMode)
-   {
-      this.replicationFieldBatchMode = fieldBatchMode;
-   }
-
-   public boolean isUseLocalCache()
-   {
-      return useLocalCache;
-   }
-
-   public void setUseLocalCache(boolean useLocalCache)
-   {
-      this.useLocalCache = useLocalCache;
-   }
-
-   public boolean isUseSessionPassivation()
-   {
-      return useSessionPassivation;
-   }
-
-   public void setUseSessionPassivation(boolean useSessionPassivation)
-   {
-      this.useSessionPassivation = useSessionPassivation;
-   }
-
-   public int getPassivationMinIdleTime()
-   {
-      return passivationMinIdleTime;
-   }
-
-   public void setPassivationMinIdleTime(int passivationMinIdleTime)
-   {
-      this.passivationMinIdleTime = passivationMinIdleTime;
-   }
-
-   public int getPassivationMaxIdleTime()
-   {
-      return passivationMaxIdleTime;
-   }
-
-   public void setPassivationMaxIdleTime(int passivationMaxIdleTime)
-   {
-      this.passivationMaxIdleTime = passivationMaxIdleTime;
-   }
-
-   public int getMaxUnreplicatedInterval()
-   {
-      return maxUnreplicatedInterval;
-   }
-
-   public void setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
-   {
-      this.maxUnreplicatedInterval = maxUnreplicatedInterval;
-   }
-
-   /**
-    * Injects the configured default property values into any
-    * {@link JBossWebMetaData} attached to <code>unit</code> if the 
-    * relevant property isn't already configured.
-    */
-   public void deploy(DeploymentUnit unit) throws DeploymentException
-   {
-      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
-      if( metaData != null && metaData.getDistributable() != null )
-      {
-         if (metaData.getDistributable() != null)
-         {
-            addReplicationConfigDefaults(metaData);
-            
-            addPassivationConfigDefaults(metaData);
-         }
-      }
-   }
-
-   /**
-    * Inject default values in {@link PassivationConfig}
-    * 
-    * @param metaData
-    */
-   private void addPassivationConfigDefaults(JBossWebMetaData metaData)
-   {
-      PassivationConfig passCfg = metaData.getPassivationConfig();
-      if (passCfg == null)
-      {
-         passCfg = new PassivationConfig();
-         metaData.setPassivationConfig(passCfg);
-      }
-      
-      if (passCfg.getUseSessionPassivation() == null)
-         passCfg.setUseSessionPassivation(Boolean.valueOf(this.useSessionPassivation));
-      if (passCfg.getPassivationMinIdleTime() == null)
-         passCfg.setPassivationMinIdleTime(new Integer(this.passivationMinIdleTime));
-      if (passCfg.getPassivationMinIdleTime() == null)
-         passCfg.setPassivationMaxIdleTime(new Integer(this.passivationMaxIdleTime));
-   }
-
-   /**
-    * Inject default values in {@link ReplicationConfig}
-    * 
-    * @param metaData
-    */
-   private void addReplicationConfigDefaults(JBossWebMetaData metaData)
-   {
-      ReplicationConfig repCfg = metaData.getReplicationConfig();
-      if (repCfg == null)
-      {
-         repCfg = new ReplicationConfig();
-         metaData.setReplicationConfig(repCfg);
-      }
-      
-      if (repCfg.getUseJK() == null && useJK != null)
-         repCfg.setUseJK(this.useJK);
-      if (repCfg.getSnapshotMode() == null)
-         repCfg.setSnapshotMode(this.snapshotMode);
-      if (repCfg.getSnapshotInterval() == null)
-         repCfg.setSnapshotInterval(new Integer(this.snapshotInterval));
-      if (repCfg.getReplicationGranularity() == null)
-         repCfg.setReplicationGranularity(this.replicationGranularity);
-      if (repCfg.getReplicationTrigger() == null)
-         repCfg.setReplicationTrigger(this.replicationTrigger);
-      if (repCfg.getReplicationFieldBatchMode() == null)
-         repCfg.setReplicationFieldBatchMode(Boolean.valueOf(this.replicationFieldBatchMode));
-
-      if (repCfg.getCacheName() == null)
-      {
-         String cacheConfig = ReplicationGranularity.FIELD == repCfg.getReplicationGranularity() 
-                                                           ? fieldGranularityCacheName : cacheName;
-         repCfg.setCacheName(cacheConfig);
-      }
-      
-      if (repCfg.getMaxUnreplicatedInterval() == null)
-      {
-         repCfg.setMaxUnreplicatedInterval(new Integer(maxUnreplicatedInterval));
-      }
-   }
-   
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.jboss.PassivationConfig;
+import org.jboss.metadata.web.jboss.ReplicationConfig;
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.metadata.web.jboss.SnapshotMode;
+
+/**
+ * Injects default clustering values into JBossWebMetaData.
+ * 
+ * TODO. A better approach is to use a jboss-web.xml equivalent to conf/web.xml 
+ * and conf/standardjboss.xml as the source for defaults.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class ClusteringDefaultsDeployer extends AbstractDeployer
+{
+   public static final int IGNORED = -1;
+   
+   private String cacheName;
+   private String fieldGranularityCacheName;
+   private SnapshotMode snapshotMode;
+   private int snapshotInterval;
+   private ReplicationGranularity replicationGranularity;
+   private ReplicationTrigger replicationTrigger;
+   private boolean replicationFieldBatchMode = true;
+   private Boolean useJK;
+   private int maxUnreplicatedInterval;
+   private boolean useSessionPassivation;
+   private int passivationMinIdleTime = IGNORED;
+   private int passivationMaxIdleTime = IGNORED;
+   private boolean useLocalCache = true;
+   
+   /**
+    * Create a new CacheManagerDependencyDeployer. 
+    */
+   public ClusteringDefaultsDeployer()
+   {
+      setStage(DeploymentStages.POST_PARSE);
+      setInput(JBossWebMetaData.class);
+      setOutput(JBossWebMetaData.class);
+   }
+
+   public Boolean isUseJK()
+   {
+      return useJK;
+   }
+
+   public void setUseJK(Boolean useJK)
+   {
+      this.useJK = useJK;
+   }
+
+   public String getCacheName()
+   {
+      return cacheName;
+   }
+
+   public void setCacheName(String cacheName)
+   {
+      this.cacheName = cacheName;
+   }
+
+   public String getFieldGranularityCacheName()
+   {
+      return fieldGranularityCacheName;
+   }
+
+   public void setFieldGranularityCacheName(String fieldGranularityCacheName)
+   {
+      this.fieldGranularityCacheName = fieldGranularityCacheName;
+   }
+
+   public SnapshotMode getSnapshotMode()
+   {
+      return snapshotMode;
+   }
+
+   public void setSnapshotMode(SnapshotMode snapshotMode)
+   {
+      this.snapshotMode = snapshotMode;
+   }
+
+   /**
+    * Get the snapshot interval.
+    */
+   public int getSnapshotInterval()
+   {
+      return snapshotInterval;
+   }
+   
+   /**
+    * Get the snapshot interval.
+    */
+   public void setSnapshotInterval(int snapshotInterval)
+   {
+      this.snapshotInterval = snapshotInterval;
+   }
+
+   public ReplicationGranularity getReplicationGranularity()
+   {
+      return replicationGranularity;
+   }
+
+   public void setReplicationGranularity(ReplicationGranularity granularity)
+   {
+      this.replicationGranularity = granularity;
+   }
+
+   public ReplicationTrigger getReplicationTrigger()
+   {
+      return replicationTrigger;
+   }
+
+   public void setReplicationTrigger(ReplicationTrigger trigger)
+   {
+      this.replicationTrigger = trigger;
+   }
+
+   public boolean isReplicationFieldBatchMode()
+   {
+      return replicationFieldBatchMode;
+   }
+
+   public void setReplicationFieldBatchMode(boolean fieldBatchMode)
+   {
+      this.replicationFieldBatchMode = fieldBatchMode;
+   }
+
+   public boolean isUseLocalCache()
+   {
+      return useLocalCache;
+   }
+
+   public void setUseLocalCache(boolean useLocalCache)
+   {
+      this.useLocalCache = useLocalCache;
+   }
+
+   public boolean isUseSessionPassivation()
+   {
+      return useSessionPassivation;
+   }
+
+   public void setUseSessionPassivation(boolean useSessionPassivation)
+   {
+      this.useSessionPassivation = useSessionPassivation;
+   }
+
+   public int getPassivationMinIdleTime()
+   {
+      return passivationMinIdleTime;
+   }
+
+   public void setPassivationMinIdleTime(int passivationMinIdleTime)
+   {
+      this.passivationMinIdleTime = passivationMinIdleTime;
+   }
+
+   public int getPassivationMaxIdleTime()
+   {
+      return passivationMaxIdleTime;
+   }
+
+   public void setPassivationMaxIdleTime(int passivationMaxIdleTime)
+   {
+      this.passivationMaxIdleTime = passivationMaxIdleTime;
+   }
+
+   public int getMaxUnreplicatedInterval()
+   {
+      return maxUnreplicatedInterval;
+   }
+
+   public void setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
+   {
+      this.maxUnreplicatedInterval = maxUnreplicatedInterval;
+   }
+
+   /**
+    * Injects the configured default property values into any
+    * {@link JBossWebMetaData} attached to <code>unit</code> if the 
+    * relevant property isn't already configured.
+    */
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+      if( metaData != null && metaData.getDistributable() != null )
+      {
+         if (metaData.getDistributable() != null)
+         {
+            addReplicationConfigDefaults(metaData);
+            
+            addPassivationConfigDefaults(metaData);
+         }
+      }
+   }
+
+   /**
+    * Inject default values in {@link PassivationConfig}
+    * 
+    * @param metaData
+    */
+   private void addPassivationConfigDefaults(JBossWebMetaData metaData)
+   {
+      PassivationConfig passCfg = metaData.getPassivationConfig();
+      if (passCfg == null)
+      {
+         passCfg = new PassivationConfig();
+         metaData.setPassivationConfig(passCfg);
+      }
+      
+      if (passCfg.getUseSessionPassivation() == null)
+         passCfg.setUseSessionPassivation(Boolean.valueOf(this.useSessionPassivation));
+      if (passCfg.getPassivationMinIdleTime() == null)
+         passCfg.setPassivationMinIdleTime(new Integer(this.passivationMinIdleTime));
+      if (passCfg.getPassivationMinIdleTime() == null)
+         passCfg.setPassivationMaxIdleTime(new Integer(this.passivationMaxIdleTime));
+   }
+
+   /**
+    * Inject default values in {@link ReplicationConfig}
+    * 
+    * @param metaData
+    */
+   private void addReplicationConfigDefaults(JBossWebMetaData metaData)
+   {
+      ReplicationConfig repCfg = metaData.getReplicationConfig();
+      if (repCfg == null)
+      {
+         repCfg = new ReplicationConfig();
+         metaData.setReplicationConfig(repCfg);
+      }
+      
+      if (repCfg.getUseJK() == null && useJK != null)
+         repCfg.setUseJK(this.useJK);
+      if (repCfg.getSnapshotMode() == null)
+         repCfg.setSnapshotMode(this.snapshotMode);
+      if (repCfg.getSnapshotInterval() == null)
+         repCfg.setSnapshotInterval(new Integer(this.snapshotInterval));
+      if (repCfg.getReplicationGranularity() == null)
+         repCfg.setReplicationGranularity(this.replicationGranularity);
+      if (repCfg.getReplicationTrigger() == null)
+         repCfg.setReplicationTrigger(this.replicationTrigger);
+      if (repCfg.getReplicationFieldBatchMode() == null)
+         repCfg.setReplicationFieldBatchMode(Boolean.valueOf(this.replicationFieldBatchMode));
+
+      if (repCfg.getCacheName() == null)
+      {
+         String cacheConfig = ReplicationGranularity.FIELD == repCfg.getReplicationGranularity() 
+                                                           ? fieldGranularityCacheName : cacheName;
+         repCfg.setCacheName(cacheConfig);
+      }
+      
+      if (repCfg.getMaxUnreplicatedInterval() == null)
+      {
+         repCfg.setMaxUnreplicatedInterval(new Integer(maxUnreplicatedInterval));
+      }
+   }
+   
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,89 +1,89 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-
-/**
- * Adds a dependency on a clustered cache.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class ClusteringDependencyDeployer extends AbstractDeployer
-{
-   private String clusterCacheDependency;
-   
-   /**
-    * Create a new ClusteringDependencyDeployer.
-    * 
-    */
-   public ClusteringDependencyDeployer()
-   {      
-      setStage(DeploymentStages.DESCRIBE);
-      setInput(JBossWebMetaData.class);
-      setOutput(JBossWebMetaData.class);
-   }
-
-   public void deploy(DeploymentUnit unit) throws DeploymentException
-   {
-      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
-      if( metaData != null && metaData.getDistributable() != null )
-      {
-         if (clusterCacheDependency != null)
-         {
-            log.debug("Adding dependency on " + clusterCacheDependency + " to " + unit.getName());
-            List<String> depends = metaData.getDepends();
-            if (depends == null)
-               depends = new ArrayList<String>();
-            if (!depends.contains(clusterCacheDependency))
-            {
-               depends.add(clusterCacheDependency);
-            }
-            metaData.setDepends(depends);
-         }
-         else
-         {
-            log.warn("clusterCacheDependency is null; either configure it or remove this deployer");
-         }
-      }
-   }
-
-   public String getClusterCacheDependency()
-   {
-      return clusterCacheDependency;
-   }
-
-   public void setClusterCacheDependency(String clusterDependency)
-   {
-      this.clusterCacheDependency = clusterDependency;
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+
+/**
+ * Adds a dependency on a clustered cache.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class ClusteringDependencyDeployer extends AbstractDeployer
+{
+   private String clusterCacheDependency;
+   
+   /**
+    * Create a new ClusteringDependencyDeployer.
+    * 
+    */
+   public ClusteringDependencyDeployer()
+   {      
+      setStage(DeploymentStages.DESCRIBE);
+      setInput(JBossWebMetaData.class);
+      setOutput(JBossWebMetaData.class);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+      if( metaData != null && metaData.getDistributable() != null )
+      {
+         if (clusterCacheDependency != null)
+         {
+            log.debug("Adding dependency on " + clusterCacheDependency + " to " + unit.getName());
+            List<String> depends = metaData.getDepends();
+            if (depends == null)
+               depends = new ArrayList<String>();
+            if (!depends.contains(clusterCacheDependency))
+            {
+               depends.add(clusterCacheDependency);
+            }
+            metaData.setDepends(depends);
+         }
+         else
+         {
+            log.warn("clusterCacheDependency is null; either configure it or remove this deployer");
+         }
+      }
+   }
+
+   public String getClusterCacheDependency()
+   {
+      return clusterCacheDependency;
+   }
+
+   public void setClusterCacheDependency(String clusterDependency)
+   {
+      this.clusterCacheDependency = clusterDependency;
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossWebMicrocontainerBeanLocator.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossWebMicrocontainerBeanLocator.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossWebMicrocontainerBeanLocator.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,70 +1,70 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.spi.dependency.KernelController;
-
-/**
- * Service locator utility for finding microcontainer beans associated with
- * the <code>KernelController</code> that manages the local {@link TomcatService}.
- * 
- * @author Brian Stansberry
- *
- */
-public class JBossWebMicrocontainerBeanLocator
-{
-   private static KernelController kernelController;
-   
-   /**
-    * Returns the bean installed under the given name.
-    * 
-    * @param beanName the name of the bean
-    * @return the bean, or <code>null</code> if no bean is installed under <code>name</code>
-    * 
-    * @throws IllegalStateException if no KernelController is available to perform
-    *                               the lookup
-    */
-   public static Object getInstalledBean(Object beanName)
-   {
-      if (kernelController == null)
-      {
-         throw new IllegalStateException("KernelController not installed");
-      }
-      
-      ControllerContext context = kernelController.getInstalledContext(beanName);
-      return context == null ? null : context.getTarget();
-   }
-   
-   static void setKernelController(KernelController controller)
-   {
-      kernelController = controller;
-   }
-   
-   /** Prevent instantiation */
-   private JBossWebMicrocontainerBeanLocator()
-   {
-      
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+
+/**
+ * Service locator utility for finding microcontainer beans associated with
+ * the <code>KernelController</code> that manages the local {@link TomcatService}.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class JBossWebMicrocontainerBeanLocator
+{
+   private static KernelController kernelController;
+   
+   /**
+    * Returns the bean installed under the given name.
+    * 
+    * @param beanName the name of the bean
+    * @return the bean, or <code>null</code> if no bean is installed under <code>name</code>
+    * 
+    * @throws IllegalStateException if no KernelController is available to perform
+    *                               the lookup
+    */
+   public static Object getInstalledBean(Object beanName)
+   {
+      if (kernelController == null)
+      {
+         throw new IllegalStateException("KernelController not installed");
+      }
+      
+      ControllerContext context = kernelController.getInstalledContext(beanName);
+      return context == null ? null : context.getTarget();
+   }
+   
+   static void setKernelController(KernelController controller)
+   {
+      kernelController = controller;
+   }
+   
+   /** Prevent instantiation */
+   private JBossWebMicrocontainerBeanLocator()
+   {
+      
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossWebMicrocontainerBeanLocator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/MicrocontainerIntegrationLifecycleListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/MicrocontainerIntegrationLifecycleListener.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/MicrocontainerIntegrationLifecycleListener.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,131 +1,131 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.jboss.logging.Logger;
-
-/**
- * {@link LifecycleListener} that delegates handling of event callbacks
- * to an arbitrary microcontainer bean that also implements 
- * <code>LifecycleListener</code>.  Serves as an integration hook to allow
- * microcontainer-based beans to integrate into the <code>server.xml</code> and
- * <code>org.apache.tomcat.util.digester.Digester</code>-based process by
- * which the JBoss Web server is instantiated.
- * <p>
- * Listener exposes a {@link #getDelegateBeanName() delegateBeanName} property
- * (configurable in <code>server.xml</code>).  Upon first 
- * {@link #lifecycleEvent(LifecycleEvent) receipt of a lifecycle event}, 
- * a service lookup of the bean registered in the microcontainer under
- * <code>delegateBeanName</code> is performed.  All lifecycle event callbacks
- * are delegated to that bean.
- * </p>
- * 
- * @author Brian Stansberry
- */
-public class MicrocontainerIntegrationLifecycleListener implements LifecycleListener
-{
-   private static final Logger log = Logger.getLogger(MicrocontainerIntegrationLifecycleListener.class);
-   
-   private volatile boolean inited;
-   private LifecycleListener delegate;
-   private String delegateBeanName;
-   private boolean failIfBeanMissing = true;
-   private boolean warnIfBeanMissing = true;
-   
-   public final String getDelegateBeanName()
-   {
-      return this.delegateBeanName;
-   }
-
-   public final void setDelegateBeanName(String delegateBeanName)
-   {
-      this.delegateBeanName = delegateBeanName;
-   }  
-
-   public boolean getFailIfBeanMissing()
-   {
-      return this.failIfBeanMissing;
-   }
-
-   public void setFailIfBeanMissing(boolean failIfBeanMissing)
-   {
-      this.failIfBeanMissing = failIfBeanMissing;
-   }
-
-   public final boolean getWarnIfBeanMissing()
-   {
-      return this.warnIfBeanMissing;
-   }
-
-   public final void setWarnIfBeanMissing(boolean warnIfBeanMissing)
-   {
-      this.warnIfBeanMissing = warnIfBeanMissing;
-   }
-
-   /**
-    * Passes the event to the delegate bean.  On first invocation does
-    * the lookup of the delegate bean.
-    * 
-    * @param event the event
-    */
-   public void lifecycleEvent(LifecycleEvent event)
-   {
-      if (!inited)
-      {
-         init();
-      }
-      
-      if (this.delegate != null)
-      {
-         this.delegate.lifecycleEvent(event);
-      }
-   }
-   
-   private synchronized void init()
-   {
-      if (!inited)
-      {         
-         if (this.delegateBeanName != null)
-         {
-            this.delegate = (LifecycleListener) JBossWebMicrocontainerBeanLocator.getInstalledBean(this.delegateBeanName);
-         }
-         
-         if (this.delegate == null)
-         {  
-            if (this.failIfBeanMissing)
-            {
-               throw new IllegalStateException("Unable to locate delegate bean " + this.delegateBeanName + "; listener is nonfunctional");
-            }
-            else if (this.warnIfBeanMissing)
-            {
-               log.warn("Unable to locate delegate bean " + this.delegateBeanName + "; listener is nonfunctional");
-            }
-         }
-         
-         this.inited = true;
-      }
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.jboss.logging.Logger;
+
+/**
+ * {@link LifecycleListener} that delegates handling of event callbacks
+ * to an arbitrary microcontainer bean that also implements 
+ * <code>LifecycleListener</code>.  Serves as an integration hook to allow
+ * microcontainer-based beans to integrate into the <code>server.xml</code> and
+ * <code>org.apache.tomcat.util.digester.Digester</code>-based process by
+ * which the JBoss Web server is instantiated.
+ * <p>
+ * Listener exposes a {@link #getDelegateBeanName() delegateBeanName} property
+ * (configurable in <code>server.xml</code>).  Upon first 
+ * {@link #lifecycleEvent(LifecycleEvent) receipt of a lifecycle event}, 
+ * a service lookup of the bean registered in the microcontainer under
+ * <code>delegateBeanName</code> is performed.  All lifecycle event callbacks
+ * are delegated to that bean.
+ * </p>
+ * 
+ * @author Brian Stansberry
+ */
+public class MicrocontainerIntegrationLifecycleListener implements LifecycleListener
+{
+   private static final Logger log = Logger.getLogger(MicrocontainerIntegrationLifecycleListener.class);
+   
+   private volatile boolean inited;
+   private LifecycleListener delegate;
+   private String delegateBeanName;
+   private boolean failIfBeanMissing = true;
+   private boolean warnIfBeanMissing = true;
+   
+   public final String getDelegateBeanName()
+   {
+      return this.delegateBeanName;
+   }
+
+   public final void setDelegateBeanName(String delegateBeanName)
+   {
+      this.delegateBeanName = delegateBeanName;
+   }  
+
+   public boolean getFailIfBeanMissing()
+   {
+      return this.failIfBeanMissing;
+   }
+
+   public void setFailIfBeanMissing(boolean failIfBeanMissing)
+   {
+      this.failIfBeanMissing = failIfBeanMissing;
+   }
+
+   public final boolean getWarnIfBeanMissing()
+   {
+      return this.warnIfBeanMissing;
+   }
+
+   public final void setWarnIfBeanMissing(boolean warnIfBeanMissing)
+   {
+      this.warnIfBeanMissing = warnIfBeanMissing;
+   }
+
+   /**
+    * Passes the event to the delegate bean.  On first invocation does
+    * the lookup of the delegate bean.
+    * 
+    * @param event the event
+    */
+   public void lifecycleEvent(LifecycleEvent event)
+   {
+      if (!inited)
+      {
+         init();
+      }
+      
+      if (this.delegate != null)
+      {
+         this.delegate.lifecycleEvent(event);
+      }
+   }
+   
+   private synchronized void init()
+   {
+      if (!inited)
+      {         
+         if (this.delegateBeanName != null)
+         {
+            this.delegate = (LifecycleListener) JBossWebMicrocontainerBeanLocator.getInstalledBean(this.delegateBeanName);
+         }
+         
+         if (this.delegate == null)
+         {  
+            if (this.failIfBeanMissing)
+            {
+               throw new IllegalStateException("Unable to locate delegate bean " + this.delegateBeanName + "; listener is nonfunctional");
+            }
+            else if (this.warnIfBeanMissing)
+            {
+               log.warn("Unable to locate delegate bean " + this.delegateBeanName + "; listener is nonfunctional");
+            }
+         }
+         
+         this.inited = true;
+      }
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/MicrocontainerIntegrationLifecycleListener.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/SecurityActions.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/SecurityActions.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/SecurityActions.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.deployers;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Privileged Blocks
- * @author Anil.Saldhana at redhat.com
- * @since Nov 7, 2008
- */
-class SecurityActions
-{
-   static String getSystemProperty(final String key, final String defaultValue)
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<String>()
-      {
-         public String run()
-         {
-            return System.getProperty(key, defaultValue); 
-         }
-      });
-   }
-   
-   static void setSystemProperty(final String key, final String value)
-   {
-      AccessController.doPrivileged(new PrivilegedAction<Object>()
-      {
-         public Object run()
-         {
-            System.setProperty(key, value);
-            return null;
-         }
-      });
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.deployers;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 7, 2008
+ */
+class SecurityActions
+{
+   static String getSystemProperty(final String key, final String defaultValue)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<String>()
+      {
+         public String run()
+         {
+            return System.getProperty(key, defaultValue); 
+         }
+      });
+   }
+   
+   static void setSystemProperty(final String key, final String value)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            System.setProperty(key, value);
+            return null;
+         }
+      });
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,794 +1,794 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.security.jacc.PolicyContext;
-import javax.xml.namespace.QName;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.startup.Catalina;
-import org.apache.catalina.startup.CatalinaProperties;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.system.server.ServerImplMBean;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.web.tomcat.metadata.AnyXmlMetaData;
-import org.jboss.web.tomcat.metadata.ConnectorMetaData;
-import org.jboss.web.tomcat.metadata.EngineMetaData;
-import org.jboss.web.tomcat.metadata.HostMetaData;
-import org.jboss.web.tomcat.metadata.ListenerMetaData;
-import org.jboss.web.tomcat.metadata.ServerMetaData;
-import org.jboss.web.tomcat.metadata.ServiceMetaData;
-import org.jboss.web.tomcat.metadata.ValveMetaData;
-import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.builder.JBossXBBuilder;
-
-/**
- * Temporary workaround to support controlling the lifecycle of the webserver runtime portion of TomcatDeployer via a
- * JMX service in the deploy directory. We want it in deploy so dependencies on services in deploy can be properly
- * expressed. We want it as a JMX service so the ServiceBindingManager can alter the connector ports.
- * <p>
- * A more long term solution involves:
- * <ol>
- * <li>separating out the JBossWeb runtime aspects from TomcatDeployer and putting them in a separate class</li>
- * <li>developing a ProfileService-based alternative to ServiceBindingManager</li>
- * </ol>
- * </p>
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class TomcatService extends ServiceMBeanSupport implements NotificationListener, TomcatServiceMBean
-{
-   
-   /** The associated Tomcat deployer * */
-   private TomcatDeployer tomcatDeployer;
-
-   // Dependency inject the TomcatDeployer pojo
-
-   public TomcatDeployer getTomcatDeployer()
-   {
-      return tomcatDeployer;
-   }
-
-   public void setTomcatDeployer(TomcatDeployer tomcatDeployer)
-   {
-      this.tomcatDeployer = tomcatDeployer;
-   }
-
-   public static boolean OLD_CODE = false;
-   
-   // In our lifecycle, we invoke the webserver lifecycle-related operations
-   // in the TomcatDeployer
-
-   @Override
-   protected void startService() throws Exception
-   {
-      if (tomcatDeployer == null)
-         throw new IllegalStateException("Must set TomcatDeployer before starting");
-
-      tomcatDeployer.setServiceClassLoader(getClass().getClassLoader());
-
-      // Load Catalina properties
-      CatalinaProperties.getProperty("");
-
-      log.debug("Starting tomcat deployer");
-      MBeanServer server = super.getServer();
-      SecurityActions.setSystemProperty("catalina.ext.dirs", 
-            (SecurityActions.getSystemProperty("jboss.server.home.dir", null) + File.separator + "lib"));
-
-      String objectNameS = tomcatDeployer.getDomain() + ":type=server";
-      ObjectName objectName = new ObjectName(objectNameS);
-
-      if (OLD_CODE) {
-
-         // Set the modeler Registry MBeanServer to the that of the tomcat service
-         Registry.getRegistry().setMBeanServer(server);
-
-         Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(),
-               objectName, "org.apache.catalina.startup.Catalina");
-
-         server.setAttribute(objectName, new Attribute("catalinaHome", System.getProperty("jboss.server.home.dir")));
-         server.setAttribute(objectName, new Attribute("configFile", tomcatDeployer.getConfigFile()));
-         server.setAttribute(objectName, new Attribute("useNaming", new Boolean(false)));
-         server.setAttribute(objectName, new Attribute("useShutdownHook", new Boolean(false)));
-         server.setAttribute(objectName, new Attribute("await", new Boolean(false)));
-         server.setAttribute(objectName, new Attribute("redirectStreams", new Boolean(false)));
-
-      } else {
-      
-         // Parse main server.xml
-         // FIXME: this could be done somewhere else
-         SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
-         Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
-         u.setSchemaValidation(false);
-         u.setValidation(false);
-         u.setEntityResolver(new JBossEntityResolver());
-         InputStream is = null;
-         ServerMetaData serverMetaData = null;
-         try {
-            File configFile = new File(tomcatDeployer.getConfigFile());
-            if (configFile.exists())
-            {
-               is = new FileInputStream(configFile);
-            }
-            else
-            {
-               is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
-            }
-            if (is == null) {
-               log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
-               is = getClass().getClassLoader().getResourceAsStream("server.xml");
-            }
-            serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
-         } finally {
-            if (is != null) {
-               try {
-                  is.close();
-               } catch (IOException e) {
-                  // Ignore
-               }
-            }
-         }
-         
-         // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
-         //        should be useful in JBoss
-         
-         // Create the Catalina instance
-         Catalina catalina = new Catalina();
-         catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));
-         catalina.setUseNaming(false);
-         catalina.setUseShutdownHook(false);
-         catalina.setAwait(false);
-         catalina.setRedirectStreams(false);
-         
-         // Set the modeler Registry MBeanServer to the that of the tomcat service
-         Registry.getRegistry(null, null).setMBeanServer(server);
-         // Register the Catalina instance
-         Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");
-         
-         // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance
-         
-         // Server
-         org.apache.catalina.Server catalinaServer = 
-            (org.apache.catalina.Server) getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
-         addLifecycleListeners(catalinaServer, serverMetaData.getListeners());
-         
-         // Server/Service
-         if (serverMetaData.getServices() == null)
-         {
-            throw new IllegalArgumentException("No services");
-         }
-         Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
-         while (serviceMetaDatas.hasNext())
-         {
-            ServiceMetaData serviceMetaData = serviceMetaDatas.next();
-            org.apache.catalina.Service service = 
-               (org.apache.catalina.Service) getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
-            addLifecycleListeners(service, serviceMetaData.getListeners());
-            service.setName(serviceMetaData.getName());
-            service.setServer(catalinaServer);
-            catalinaServer.addService(service);
-            
-            // Server/Service/Executor
-            // FIXME
-            
-            // Server/Service/Connector
-            if (serviceMetaData.getConnectors() != null)
-            {
-               Iterator<ConnectorMetaData> connectorMetaDatas = serviceMetaData.getConnectors().iterator();
-               while (connectorMetaDatas.hasNext())
-               {
-                  ConnectorMetaData connectorMetaData = connectorMetaDatas.next();
-                  Connector connector = new Connector(connectorMetaData.getProtocol());
-                  if (connectorMetaData.getAttributes() != null)
-                  {
-                     Iterator<QName> names = connectorMetaData.getAttributes().keySet().iterator();
-                     while (names.hasNext())
-                     {
-                        QName name = names.next();
-                        String value = (String) connectorMetaData.getAttributes().get(name);
-                        // FIXME: This should be done by XB
-                        value = StringPropertyReplacer.replaceProperties(value);
-                        IntrospectionUtils.setProperty(connector, name.getLocalPart(), value);
-                     }
-                  }
-                  service.addConnector(connector);
-               }
-            }
-            
-            // Server/Service/Engine
-            EngineMetaData engineMetaData = serviceMetaData.getEngine();
-            org.apache.catalina.Engine engine = 
-               (org.apache.catalina.Engine) getInstance(engineMetaData, "org.apache.catalina.core.StandardEngine");
-            addLifecycleListeners(engine, engineMetaData.getListeners());
-            engine.setName(engineMetaData.getName());
-            // FIXME: This should be done by XB
-            if (engineMetaData.getJvmRoute() != null) {
-               engine.setJvmRoute(StringPropertyReplacer.replaceProperties(engineMetaData.getJvmRoute()));
-            }
-            //engine.setJvmRoute(engineMetaData.getJvmRoute());
-            engine.setDefaultHost(engineMetaData.getDefaultHost());
-            service.setContainer(engine);
-            
-            // Server/Service/Engine/Realm
-            if (engineMetaData.getRealm() != null) {
-               engine.setRealm((org.apache.catalina.Realm) getInstance(engineMetaData.getRealm(), null));
-            }
-            
-            // Server/Service/Engine/Valve
-            addValves(engine, engineMetaData.getValves());
-            
-            // Server/Service/Engine/Host
-            if (engineMetaData.getHosts() != null)
-            {
-               Iterator<HostMetaData> hostMetaDatas = engineMetaData.getHosts().iterator();
-               while (hostMetaDatas.hasNext())
-               {
-                  HostMetaData hostMetaData = hostMetaDatas.next();
-                  org.apache.catalina.Host host =
-                     (org.apache.catalina.Host) getInstance(hostMetaData, "org.apache.catalina.core.StandardHost");
-                  addLifecycleListeners(host, hostMetaData.getListeners());
-                  host.setName(hostMetaData.getName());
-                  // FIXME: not really needed, and could hurt extensibility; probably needed until JBW GA with a fix
-                  host.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
-                  engine.addChild(host);
-                  
-                  // Server/Service/Engine/Host/Realm
-                  if (hostMetaData.getRealm() != null) {
-                     host.setRealm((org.apache.catalina.Realm) getInstance(hostMetaData.getRealm(), null));
-                  }
-                  
-                  // Server/Service/Engine/Host/Valve
-                  addValves(host, hostMetaData.getValves());
-                  
-                  // Server/Service/Engine/Host/Alias
-                  if (hostMetaData.getAliases() != null) {
-                     Iterator<String> aliases = hostMetaData.getAliases().iterator();
-                     while (aliases.hasNext()) {
-                        host.addAlias(aliases.next());
-                     }
-                  }
-                  
-               }
-            }
-            
-         }
-         
-         // Set the resulting Server to the Catalina instance
-         catalina.setServer(catalinaServer);
-      }
-      
-      // Start Tomcat
-      server.invoke(objectName, "create", new Object[]{}, new String[]{});
-      server.invoke(objectName, "start", new Object[]{}, new String[]{});
-
-      // Set up the authenticators in JNDI such that they can be configured for web apps
-      InitialContext ic = new InitialContext();
-      try
-      {
-         ic.bind("TomcatAuthenticators", tomcatDeployer.getAuthenticators());
-      }
-      catch (NamingException ne)
-      {
-         if (log.isTraceEnabled())
-            log.trace("Binding Authenticators to JNDI failed", ne);
-      }
-      finally
-      {
-         try
-         {
-            ic.close();
-         }
-         catch (NamingException nee)
-         {
-         }
-      }
-
-      // Register the web container JACC PolicyContextHandlers
-      HttpServletRequestPolicyContextHandler handler = new HttpServletRequestPolicyContextHandler();
-      PolicyContext.registerHandler(HttpServletRequestPolicyContextHandler.WEB_REQUEST_KEY, handler, true);
-
-      // If we are hot-deployed *after* the overall server is started
-      // we'll never receive Server.START_NOTIFICATION_TYPE, so check
-      // with the Server and start the connectors immediately, if this is the case.
-      // Otherwise register to receive the server start-up notification.
-      Boolean started = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
-      if (started.booleanValue() == true)
-      {
-         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, starting connectors now");
-
-         startConnectors();
-      }
-      else
-      {
-         // Register for notification of the overall server startup
-         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' not started, registering for start-up notification");
-
-         server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
-      }
-
-   }
-
-   /**
-    * Create a JavaBean corresponding to the given metadata, similar to what the digester is doing.
-    */
-   protected static Object getInstance(AnyXmlMetaData metaData, String defaultClassName) throws Exception
-   {
-      String className = metaData.getClassName();
-      if (className == null) {
-         className = defaultClassName;
-      }
-      if (className == null) {
-         throw new IllegalArgumentException("No className specified for element");
-      }
-      Object instance = TomcatService.class.getClassLoader().loadClass(className).newInstance();
-      if (metaData.getAttributes() != null) {
-         Iterator<QName> names = metaData.getAttributes().keySet().iterator();
-         while (names.hasNext()) {
-            QName name = names.next();
-            String value = (String) metaData.getAttributes().get(name);
-            // FIXME: This should be done by XB
-            value = StringPropertyReplacer.replaceProperties(value);
-            IntrospectionUtils.setProperty(instance, name.getLocalPart(), value);
-         }
-      }
-      return instance;
-   }
-   
-   /**
-    * Associate lifecycle listeners with the instance, if it implements Lifecycle.
-    */
-   protected static void addLifecycleListeners(Object instance, List<ListenerMetaData> list) throws Exception
-   {
-      if (list == null) {
-         return;
-      }
-      org.apache.catalina.Lifecycle lifecycle = null;
-      if (!(instance instanceof org.apache.catalina.Lifecycle))
-      {
-         return;
-      }
-      else
-      {
-         lifecycle = (org.apache.catalina.Lifecycle) instance;
-      }
-      Iterator<ListenerMetaData> listenerMetaDatas = list.iterator();
-      while (listenerMetaDatas.hasNext())
-      {
-         ListenerMetaData listenerMetaData = listenerMetaDatas.next();
-         lifecycle.addLifecycleListener((org.apache.catalina.LifecycleListener) getInstance(listenerMetaData, null));
-      }
-
-   }
-   
-   
-   /**
-    * Associate valves with the instance, if it implements Lifecycle.
-    */
-   protected static void addValves(Object instance, List<ValveMetaData> list) throws Exception
-   {
-      if (list == null) {
-         return;
-      }
-      org.apache.catalina.Pipeline pipeline = null;
-      if (!(instance instanceof org.apache.catalina.Pipeline))
-      {
-         return;
-      }
-      else
-      {
-         pipeline = (org.apache.catalina.Pipeline) instance;
-      }
-      Iterator<ValveMetaData> valveMetaDatas = list.iterator();
-      while (valveMetaDatas.hasNext())
-      {
-         ValveMetaData valveMetaData = valveMetaDatas.next();
-         pipeline.addValve((org.apache.catalina.Valve) getInstance(valveMetaData, null));
-      }
-
-   }
-   
-   
-   @Override
-   protected void stopService() throws Exception
-   {
-
-      if (tomcatDeployer == null)
-         throw new IllegalStateException("Must set TomcatDeployer before stopping");
-
-      // Hot undeploy
-      Boolean inShutdown = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "InShutdown");
-      if (inShutdown.booleanValue() == false)
-      {
-         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, stopping connectors now");
-
-         stopConnectors();
-      }
-
-      MBeanServer server = super.getServer();
-      String objectNameS = tomcatDeployer.getDomain() + ":type=server";
-      ObjectName objectName = new ObjectName(objectNameS);
-
-      server.invoke(objectName, "stop", new Object[]{}, new String[]{});
-
-      server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
-
-      server.unregisterMBean(objectName);
-
-      MBeanServer server2 = server;
-
-      // Unregister any remaining jboss.web or Catalina MBeans
-      ObjectName queryObjectName = new ObjectName(tomcatDeployer.getDomain() + ":*");
-      Iterator iterator = server2.queryMBeans(queryObjectName, null).iterator();
-      while (iterator.hasNext())
-      {
-         ObjectInstance oi = (ObjectInstance) iterator.next();
-         ObjectName toRemove = oi.getObjectName();
-         // Exception: Don't unregister the service right now
-         if (!"WebServer".equals(toRemove.getKeyProperty("service")))
-         {
-            if (server2.isRegistered(toRemove))
-            {
-               server2.unregisterMBean(toRemove);
-            }
-         }
-      }
-      queryObjectName = new ObjectName("Catalina:*");
-      iterator = server2.queryMBeans(queryObjectName, null).iterator();
-      while (iterator.hasNext())
-      {
-         ObjectInstance oi = (ObjectInstance) iterator.next();
-         ObjectName name = oi.getObjectName();
-         server2.unregisterMBean(name);
-      }
-
-   }
-
-   // Expose the TomcatDeployer MBean interface
-
-   public String getConfigFile()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getConfigFile();
-   }
-
-   public String getContextMBeanCode()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getContextMBeanCode();
-   }
-
-   public boolean getUseJBossWebLoader()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.getUseJBossWebLoader();
-   }
-
-   public String getDomain()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getDomain();
-   }
-
-   public String[] getFilteredPackages()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getFilteredPackages();
-   }
-
-   public String getManagerClass()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getManagerClass();
-   }
-
-   public String getSessionIdAlphabet()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getSessionIdAlphabet();
-   }
-
-   public String getSubjectAttributeName()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getSubjectAttributeName();
-   }
-
-   public boolean getDeleteWorkDirOnContextDestroy()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.getDeleteWorkDirOnContextDestroy();
-   }
-
-   public boolean isAllowSelfPrivilegedWebApps()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.isAllowSelfPrivilegedWebApps();
-   }
-
-   public void setAllowSelfPrivilegedWebApps(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setAllowSelfPrivilegedWebApps(flag);
-   }
-
-   public void setConfigFile(String configFile)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setConfigFile(configFile);
-   }
-
-   public void setContextMBeanCode(String className)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setContextMBeanCode(className);
-   }
-
-   public void setDeleteWorkDirOnContextDestroy(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setDeleteWorkDirOnContextDestroy(flag);
-   }
-
-   public void setDomain(String domainName)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setDomain(domainName);
-   }
-
-   public void setFilteredPackages(String[] pkgs)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setFilteredPackages(pkgs);
-   }
-
-   public void setManagerClass(String managerClass)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setManagerClass(managerClass);
-   }
-
-   public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setSecurityManagerService(mgr);
-   }
-
-   public void setSessionIdAlphabet(String sessionIdAlphabet)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setSessionIdAlphabet(sessionIdAlphabet);
-   }
-
-   public void setSubjectAttributeName(String name)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setSubjectAttributeName(name);
-   }
-
-   public void setUseJBossWebLoader(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setUseJBossWebLoader(flag);
-   }
-
-   public void startConnectors() throws Exception
-   {
-      if (tomcatDeployer == null)
-         throw new IllegalStateException("Must set TomcatDeployer before starting connectors");
-
-      MBeanServer server = super.getServer();
-      ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
-      Object[] args = {};
-      String[] sig = {};
-      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
-      for (int n = 0; n < connectors.length; n++)
-      {
-         Lifecycle lc = connectors[n];
-         lc.start();
-      }
-      /*
-       * TODO: // Notify listeners that connectors have started processing requests sendNotification(new
-       * Notification(TOMCAT_CONNECTORS_STARTED, this, getNextNotificationSequenceNumber()));
-       */
-   }
-
-   public void stopConnectors() throws Exception
-   {
-      if (tomcatDeployer == null)
-         throw new IllegalStateException("Must set TomcatDeployer before stopping connectors");
-
-      MBeanServer server = super.getServer();
-      ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
-      Object[] args = {};
-      String[] sig = {};
-      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
-      for (int n = 0; n < connectors.length; n++)
-      {
-         connectors[n].pause();
-         connectors[n].stop();
-      }
-   }
-
-   /**
-    * Used to receive notification of the server start msg so the tomcat connectors can be started after all web apps
-    * are deployed.
-    */
-   public void handleNotification(Notification msg, Object handback)
-   {
-      String type = msg.getType();
-      if (type.equals(Server.START_NOTIFICATION_TYPE))
-      {
-         log.debug("Saw " + type + " notification, starting connectors");
-         try
-         {
-            startConnectors();
-         }
-         catch (Exception e)
-         {
-            log.warn("Failed to startConnectors", e);
-         }
-      }
-      if (type.equals(Server.STOP_NOTIFICATION_TYPE))
-      {
-         log.debug("Saw " + type + " notification, stopping connectors");
-         try
-         {
-            stopConnectors();
-         }
-         catch (Exception e)
-         {
-            log.warn("Failed to stopConnectors", e);
-         }
-      }
-   }
-
-   public String getDefaultSecurityDomain()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getDefaultSecurityDomain();
-   }
-
-   public boolean getJava2ClassLoadingCompliance()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.getJava2ClassLoadingCompliance();
-   }
-
-   public boolean getLenientEjbLink()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.getLenientEjbLink();
-   }
-
-   public boolean getUnpackWars()
-   {
-      return tomcatDeployer == null ? false : tomcatDeployer.getUnpackWars();
-   }
-
-   public void setDefaultSecurityDomain(String defaultSecurityDomain)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setDefaultSecurityDomain(defaultSecurityDomain);
-   }
-
-   public void setJava2ClassLoadingCompliance(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setJava2ClassLoadingCompliance(flag);
-   }
-
-   public void setLenientEjbLink(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setLenientEjbLink(flag);
-   }
-
-   public void setUnpackWars(boolean flag)
-   {
-      if (tomcatDeployer != null)
-         tomcatDeployer.setUnpackWars(flag);
-   }
-
-   /*
-    * (non-Javadoc)
-    * 
-    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#getHttpHeaderForSSOAuth()
-    */
-   public String getHttpHeaderForSSOAuth()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getHttpHeaderForSSOAuth();
-   }
-
-   /*
-    * (non-Javadoc)
-    * 
-    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#setHttpHeaderForSSOAuth(java.lang.String)
-    */
-   public void setHttpHeaderForSSOAuth(String httpHeaderForSSOAuth)
-   {
-      if (this.tomcatDeployer != null)
-         this.tomcatDeployer.setHttpHeaderForSSOAuth(httpHeaderForSSOAuth);
-   }
-
-   /*
-    * (non-Javadoc)
-    * 
-    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#getSessionCookieForSSOAuth()
-    */
-   public String getSessionCookieForSSOAuth()
-   {
-      return tomcatDeployer == null ? null : tomcatDeployer.getSessionCookieForSSOAuth();
-   }
-
-   /*
-    * (non-Javadoc)
-    * 
-    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#setSessionCookieForSSOAuth(java.lang.String)
-    */
-   public void setSessionCookieForSSOAuth(String sessionCookieForSSOAuth)
-   {
-      if (this.tomcatDeployer != null)
-         this.tomcatDeployer.setSessionCookieForSSOAuth(sessionCookieForSSOAuth);
-   }
-   
-   /**
-    * {@inheritDoc}
-    * 
-    * Overrides the superclass version to inject the <code>KernelController</code>
-    * into {@link JBossWebMicrocontainerBeanLocator}.
-    */
-   @Override
-   public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
-   {
-      super.setKernelControllerContext(controllerContext);
-      KernelController kernelController = controllerContext == null ? null : controllerContext.getKernel().getController();
-      JBossWebMicrocontainerBeanLocator.setKernelController(kernelController);
-   }
-   
-   /**
-    * {@inheritDoc}
-    * 
-    * Overrides the superclass version to clear the <code>KernelController</code>
-    * from {@link JBossWebMicrocontainerBeanLocator}.
-    */
-   @Override
-   public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
-   {
-      super.unsetKernelControllerContext(controllerContext);
-      JBossWebMicrocontainerBeanLocator.setKernelController(null);
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.security.jacc.PolicyContext;
+import javax.xml.namespace.QName;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Catalina;
+import org.apache.catalina.startup.CatalinaProperties;
+import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.tomcat.util.modeler.Registry;
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
+import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.system.server.ServerImplMBean;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.web.tomcat.metadata.AnyXmlMetaData;
+import org.jboss.web.tomcat.metadata.ConnectorMetaData;
+import org.jboss.web.tomcat.metadata.EngineMetaData;
+import org.jboss.web.tomcat.metadata.HostMetaData;
+import org.jboss.web.tomcat.metadata.ListenerMetaData;
+import org.jboss.web.tomcat.metadata.ServerMetaData;
+import org.jboss.web.tomcat.metadata.ServiceMetaData;
+import org.jboss.web.tomcat.metadata.ValveMetaData;
+import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.builder.JBossXBBuilder;
+
+/**
+ * Temporary workaround to support controlling the lifecycle of the webserver runtime portion of TomcatDeployer via a
+ * JMX service in the deploy directory. We want it in deploy so dependencies on services in deploy can be properly
+ * expressed. We want it as a JMX service so the ServiceBindingManager can alter the connector ports.
+ * <p>
+ * A more long term solution involves:
+ * <ol>
+ * <li>separating out the JBossWeb runtime aspects from TomcatDeployer and putting them in a separate class</li>
+ * <li>developing a ProfileService-based alternative to ServiceBindingManager</li>
+ * </ol>
+ * </p>
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class TomcatService extends ServiceMBeanSupport implements NotificationListener, TomcatServiceMBean
+{
+   
+   /** The associated Tomcat deployer * */
+   private TomcatDeployer tomcatDeployer;
+
+   // Dependency inject the TomcatDeployer pojo
+
+   public TomcatDeployer getTomcatDeployer()
+   {
+      return tomcatDeployer;
+   }
+
+   public void setTomcatDeployer(TomcatDeployer tomcatDeployer)
+   {
+      this.tomcatDeployer = tomcatDeployer;
+   }
+
+   public static boolean OLD_CODE = false;
+   
+   // In our lifecycle, we invoke the webserver lifecycle-related operations
+   // in the TomcatDeployer
+
+   @Override
+   protected void startService() throws Exception
+   {
+      if (tomcatDeployer == null)
+         throw new IllegalStateException("Must set TomcatDeployer before starting");
+
+      tomcatDeployer.setServiceClassLoader(getClass().getClassLoader());
+
+      // Load Catalina properties
+      CatalinaProperties.getProperty("");
+
+      log.debug("Starting tomcat deployer");
+      MBeanServer server = super.getServer();
+      SecurityActions.setSystemProperty("catalina.ext.dirs", 
+            (SecurityActions.getSystemProperty("jboss.server.home.dir", null) + File.separator + "lib"));
+
+      String objectNameS = tomcatDeployer.getDomain() + ":type=server";
+      ObjectName objectName = new ObjectName(objectNameS);
+
+      if (OLD_CODE) {
+
+         // Set the modeler Registry MBeanServer to the that of the tomcat service
+         Registry.getRegistry().setMBeanServer(server);
+
+         Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(),
+               objectName, "org.apache.catalina.startup.Catalina");
+
+         server.setAttribute(objectName, new Attribute("catalinaHome", System.getProperty("jboss.server.home.dir")));
+         server.setAttribute(objectName, new Attribute("configFile", tomcatDeployer.getConfigFile()));
+         server.setAttribute(objectName, new Attribute("useNaming", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("useShutdownHook", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("await", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("redirectStreams", new Boolean(false)));
+
+      } else {
+      
+         // Parse main server.xml
+         // FIXME: this could be done somewhere else
+         SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
+         Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
+         u.setSchemaValidation(false);
+         u.setValidation(false);
+         u.setEntityResolver(new JBossEntityResolver());
+         InputStream is = null;
+         ServerMetaData serverMetaData = null;
+         try {
+            File configFile = new File(tomcatDeployer.getConfigFile());
+            if (configFile.exists())
+            {
+               is = new FileInputStream(configFile);
+            }
+            else
+            {
+               is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
+            }
+            if (is == null) {
+               log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
+               is = getClass().getClassLoader().getResourceAsStream("server.xml");
+            }
+            serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
+         } finally {
+            if (is != null) {
+               try {
+                  is.close();
+               } catch (IOException e) {
+                  // Ignore
+               }
+            }
+         }
+         
+         // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
+         //        should be useful in JBoss
+         
+         // Create the Catalina instance
+         Catalina catalina = new Catalina();
+         catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));
+         catalina.setUseNaming(false);
+         catalina.setUseShutdownHook(false);
+         catalina.setAwait(false);
+         catalina.setRedirectStreams(false);
+         
+         // Set the modeler Registry MBeanServer to the that of the tomcat service
+         Registry.getRegistry(null, null).setMBeanServer(server);
+         // Register the Catalina instance
+         Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");
+         
+         // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance
+         
+         // Server
+         org.apache.catalina.Server catalinaServer = 
+            (org.apache.catalina.Server) getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
+         addLifecycleListeners(catalinaServer, serverMetaData.getListeners());
+         
+         // Server/Service
+         if (serverMetaData.getServices() == null)
+         {
+            throw new IllegalArgumentException("No services");
+         }
+         Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
+         while (serviceMetaDatas.hasNext())
+         {
+            ServiceMetaData serviceMetaData = serviceMetaDatas.next();
+            org.apache.catalina.Service service = 
+               (org.apache.catalina.Service) getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
+            addLifecycleListeners(service, serviceMetaData.getListeners());
+            service.setName(serviceMetaData.getName());
+            service.setServer(catalinaServer);
+            catalinaServer.addService(service);
+            
+            // Server/Service/Executor
+            // FIXME
+            
+            // Server/Service/Connector
+            if (serviceMetaData.getConnectors() != null)
+            {
+               Iterator<ConnectorMetaData> connectorMetaDatas = serviceMetaData.getConnectors().iterator();
+               while (connectorMetaDatas.hasNext())
+               {
+                  ConnectorMetaData connectorMetaData = connectorMetaDatas.next();
+                  Connector connector = new Connector(connectorMetaData.getProtocol());
+                  if (connectorMetaData.getAttributes() != null)
+                  {
+                     Iterator<QName> names = connectorMetaData.getAttributes().keySet().iterator();
+                     while (names.hasNext())
+                     {
+                        QName name = names.next();
+                        String value = (String) connectorMetaData.getAttributes().get(name);
+                        // FIXME: This should be done by XB
+                        value = StringPropertyReplacer.replaceProperties(value);
+                        IntrospectionUtils.setProperty(connector, name.getLocalPart(), value);
+                     }
+                  }
+                  service.addConnector(connector);
+               }
+            }
+            
+            // Server/Service/Engine
+            EngineMetaData engineMetaData = serviceMetaData.getEngine();
+            org.apache.catalina.Engine engine = 
+               (org.apache.catalina.Engine) getInstance(engineMetaData, "org.apache.catalina.core.StandardEngine");
+            addLifecycleListeners(engine, engineMetaData.getListeners());
+            engine.setName(engineMetaData.getName());
+            // FIXME: This should be done by XB
+            if (engineMetaData.getJvmRoute() != null) {
+               engine.setJvmRoute(StringPropertyReplacer.replaceProperties(engineMetaData.getJvmRoute()));
+            }
+            //engine.setJvmRoute(engineMetaData.getJvmRoute());
+            engine.setDefaultHost(engineMetaData.getDefaultHost());
+            service.setContainer(engine);
+            
+            // Server/Service/Engine/Realm
+            if (engineMetaData.getRealm() != null) {
+               engine.setRealm((org.apache.catalina.Realm) getInstance(engineMetaData.getRealm(), null));
+            }
+            
+            // Server/Service/Engine/Valve
+            addValves(engine, engineMetaData.getValves());
+            
+            // Server/Service/Engine/Host
+            if (engineMetaData.getHosts() != null)
+            {
+               Iterator<HostMetaData> hostMetaDatas = engineMetaData.getHosts().iterator();
+               while (hostMetaDatas.hasNext())
+               {
+                  HostMetaData hostMetaData = hostMetaDatas.next();
+                  org.apache.catalina.Host host =
+                     (org.apache.catalina.Host) getInstance(hostMetaData, "org.apache.catalina.core.StandardHost");
+                  addLifecycleListeners(host, hostMetaData.getListeners());
+                  host.setName(hostMetaData.getName());
+                  // FIXME: not really needed, and could hurt extensibility; probably needed until JBW GA with a fix
+                  host.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
+                  engine.addChild(host);
+                  
+                  // Server/Service/Engine/Host/Realm
+                  if (hostMetaData.getRealm() != null) {
+                     host.setRealm((org.apache.catalina.Realm) getInstance(hostMetaData.getRealm(), null));
+                  }
+                  
+                  // Server/Service/Engine/Host/Valve
+                  addValves(host, hostMetaData.getValves());
+                  
+                  // Server/Service/Engine/Host/Alias
+                  if (hostMetaData.getAliases() != null) {
+                     Iterator<String> aliases = hostMetaData.getAliases().iterator();
+                     while (aliases.hasNext()) {
+                        host.addAlias(aliases.next());
+                     }
+                  }
+                  
+               }
+            }
+            
+         }
+         
+         // Set the resulting Server to the Catalina instance
+         catalina.setServer(catalinaServer);
+      }
+      
+      // Start Tomcat
+      server.invoke(objectName, "create", new Object[]{}, new String[]{});
+      server.invoke(objectName, "start", new Object[]{}, new String[]{});
+
+      // Set up the authenticators in JNDI such that they can be configured for web apps
+      InitialContext ic = new InitialContext();
+      try
+      {
+         ic.bind("TomcatAuthenticators", tomcatDeployer.getAuthenticators());
+      }
+      catch (NamingException ne)
+      {
+         if (log.isTraceEnabled())
+            log.trace("Binding Authenticators to JNDI failed", ne);
+      }
+      finally
+      {
+         try
+         {
+            ic.close();
+         }
+         catch (NamingException nee)
+         {
+         }
+      }
+
+      // Register the web container JACC PolicyContextHandlers
+      HttpServletRequestPolicyContextHandler handler = new HttpServletRequestPolicyContextHandler();
+      PolicyContext.registerHandler(HttpServletRequestPolicyContextHandler.WEB_REQUEST_KEY, handler, true);
+
+      // If we are hot-deployed *after* the overall server is started
+      // we'll never receive Server.START_NOTIFICATION_TYPE, so check
+      // with the Server and start the connectors immediately, if this is the case.
+      // Otherwise register to receive the server start-up notification.
+      Boolean started = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
+      if (started.booleanValue() == true)
+      {
+         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, starting connectors now");
+
+         startConnectors();
+      }
+      else
+      {
+         // Register for notification of the overall server startup
+         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' not started, registering for start-up notification");
+
+         server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
+      }
+
+   }
+
+   /**
+    * Create a JavaBean corresponding to the given metadata, similar to what the digester is doing.
+    */
+   protected static Object getInstance(AnyXmlMetaData metaData, String defaultClassName) throws Exception
+   {
+      String className = metaData.getClassName();
+      if (className == null) {
+         className = defaultClassName;
+      }
+      if (className == null) {
+         throw new IllegalArgumentException("No className specified for element");
+      }
+      Object instance = TomcatService.class.getClassLoader().loadClass(className).newInstance();
+      if (metaData.getAttributes() != null) {
+         Iterator<QName> names = metaData.getAttributes().keySet().iterator();
+         while (names.hasNext()) {
+            QName name = names.next();
+            String value = (String) metaData.getAttributes().get(name);
+            // FIXME: This should be done by XB
+            value = StringPropertyReplacer.replaceProperties(value);
+            IntrospectionUtils.setProperty(instance, name.getLocalPart(), value);
+         }
+      }
+      return instance;
+   }
+   
+   /**
+    * Associate lifecycle listeners with the instance, if it implements Lifecycle.
+    */
+   protected static void addLifecycleListeners(Object instance, List<ListenerMetaData> list) throws Exception
+   {
+      if (list == null) {
+         return;
+      }
+      org.apache.catalina.Lifecycle lifecycle = null;
+      if (!(instance instanceof org.apache.catalina.Lifecycle))
+      {
+         return;
+      }
+      else
+      {
+         lifecycle = (org.apache.catalina.Lifecycle) instance;
+      }
+      Iterator<ListenerMetaData> listenerMetaDatas = list.iterator();
+      while (listenerMetaDatas.hasNext())
+      {
+         ListenerMetaData listenerMetaData = listenerMetaDatas.next();
+         lifecycle.addLifecycleListener((org.apache.catalina.LifecycleListener) getInstance(listenerMetaData, null));
+      }
+
+   }
+   
+   
+   /**
+    * Associate valves with the instance, if it implements Lifecycle.
+    */
+   protected static void addValves(Object instance, List<ValveMetaData> list) throws Exception
+   {
+      if (list == null) {
+         return;
+      }
+      org.apache.catalina.Pipeline pipeline = null;
+      if (!(instance instanceof org.apache.catalina.Pipeline))
+      {
+         return;
+      }
+      else
+      {
+         pipeline = (org.apache.catalina.Pipeline) instance;
+      }
+      Iterator<ValveMetaData> valveMetaDatas = list.iterator();
+      while (valveMetaDatas.hasNext())
+      {
+         ValveMetaData valveMetaData = valveMetaDatas.next();
+         pipeline.addValve((org.apache.catalina.Valve) getInstance(valveMetaData, null));
+      }
+
+   }
+   
+   
+   @Override
+   protected void stopService() throws Exception
+   {
+
+      if (tomcatDeployer == null)
+         throw new IllegalStateException("Must set TomcatDeployer before stopping");
+
+      // Hot undeploy
+      Boolean inShutdown = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "InShutdown");
+      if (inShutdown.booleanValue() == false)
+      {
+         log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, stopping connectors now");
+
+         stopConnectors();
+      }
+
+      MBeanServer server = super.getServer();
+      String objectNameS = tomcatDeployer.getDomain() + ":type=server";
+      ObjectName objectName = new ObjectName(objectNameS);
+
+      server.invoke(objectName, "stop", new Object[]{}, new String[]{});
+
+      server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
+
+      server.unregisterMBean(objectName);
+
+      MBeanServer server2 = server;
+
+      // Unregister any remaining jboss.web or Catalina MBeans
+      ObjectName queryObjectName = new ObjectName(tomcatDeployer.getDomain() + ":*");
+      Iterator iterator = server2.queryMBeans(queryObjectName, null).iterator();
+      while (iterator.hasNext())
+      {
+         ObjectInstance oi = (ObjectInstance) iterator.next();
+         ObjectName toRemove = oi.getObjectName();
+         // Exception: Don't unregister the service right now
+         if (!"WebServer".equals(toRemove.getKeyProperty("service")))
+         {
+            if (server2.isRegistered(toRemove))
+            {
+               server2.unregisterMBean(toRemove);
+            }
+         }
+      }
+      queryObjectName = new ObjectName("Catalina:*");
+      iterator = server2.queryMBeans(queryObjectName, null).iterator();
+      while (iterator.hasNext())
+      {
+         ObjectInstance oi = (ObjectInstance) iterator.next();
+         ObjectName name = oi.getObjectName();
+         server2.unregisterMBean(name);
+      }
+
+   }
+
+   // Expose the TomcatDeployer MBean interface
+
+   public String getConfigFile()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getConfigFile();
+   }
+
+   public String getContextMBeanCode()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getContextMBeanCode();
+   }
+
+   public boolean getUseJBossWebLoader()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.getUseJBossWebLoader();
+   }
+
+   public String getDomain()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getDomain();
+   }
+
+   public String[] getFilteredPackages()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getFilteredPackages();
+   }
+
+   public String getManagerClass()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getManagerClass();
+   }
+
+   public String getSessionIdAlphabet()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getSessionIdAlphabet();
+   }
+
+   public String getSubjectAttributeName()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getSubjectAttributeName();
+   }
+
+   public boolean getDeleteWorkDirOnContextDestroy()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.getDeleteWorkDirOnContextDestroy();
+   }
+
+   public boolean isAllowSelfPrivilegedWebApps()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.isAllowSelfPrivilegedWebApps();
+   }
+
+   public void setAllowSelfPrivilegedWebApps(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setAllowSelfPrivilegedWebApps(flag);
+   }
+
+   public void setConfigFile(String configFile)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setConfigFile(configFile);
+   }
+
+   public void setContextMBeanCode(String className)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setContextMBeanCode(className);
+   }
+
+   public void setDeleteWorkDirOnContextDestroy(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setDeleteWorkDirOnContextDestroy(flag);
+   }
+
+   public void setDomain(String domainName)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setDomain(domainName);
+   }
+
+   public void setFilteredPackages(String[] pkgs)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setFilteredPackages(pkgs);
+   }
+
+   public void setManagerClass(String managerClass)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setManagerClass(managerClass);
+   }
+
+   public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setSecurityManagerService(mgr);
+   }
+
+   public void setSessionIdAlphabet(String sessionIdAlphabet)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setSessionIdAlphabet(sessionIdAlphabet);
+   }
+
+   public void setSubjectAttributeName(String name)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setSubjectAttributeName(name);
+   }
+
+   public void setUseJBossWebLoader(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setUseJBossWebLoader(flag);
+   }
+
+   public void startConnectors() throws Exception
+   {
+      if (tomcatDeployer == null)
+         throw new IllegalStateException("Must set TomcatDeployer before starting connectors");
+
+      MBeanServer server = super.getServer();
+      ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
+      Object[] args = {};
+      String[] sig = {};
+      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
+      for (int n = 0; n < connectors.length; n++)
+      {
+         Lifecycle lc = connectors[n];
+         lc.start();
+      }
+      /*
+       * TODO: // Notify listeners that connectors have started processing requests sendNotification(new
+       * Notification(TOMCAT_CONNECTORS_STARTED, this, getNextNotificationSequenceNumber()));
+       */
+   }
+
+   public void stopConnectors() throws Exception
+   {
+      if (tomcatDeployer == null)
+         throw new IllegalStateException("Must set TomcatDeployer before stopping connectors");
+
+      MBeanServer server = super.getServer();
+      ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
+      Object[] args = {};
+      String[] sig = {};
+      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
+      for (int n = 0; n < connectors.length; n++)
+      {
+         connectors[n].pause();
+         connectors[n].stop();
+      }
+   }
+
+   /**
+    * Used to receive notification of the server start msg so the tomcat connectors can be started after all web apps
+    * are deployed.
+    */
+   public void handleNotification(Notification msg, Object handback)
+   {
+      String type = msg.getType();
+      if (type.equals(Server.START_NOTIFICATION_TYPE))
+      {
+         log.debug("Saw " + type + " notification, starting connectors");
+         try
+         {
+            startConnectors();
+         }
+         catch (Exception e)
+         {
+            log.warn("Failed to startConnectors", e);
+         }
+      }
+      if (type.equals(Server.STOP_NOTIFICATION_TYPE))
+      {
+         log.debug("Saw " + type + " notification, stopping connectors");
+         try
+         {
+            stopConnectors();
+         }
+         catch (Exception e)
+         {
+            log.warn("Failed to stopConnectors", e);
+         }
+      }
+   }
+
+   public String getDefaultSecurityDomain()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getDefaultSecurityDomain();
+   }
+
+   public boolean getJava2ClassLoadingCompliance()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.getJava2ClassLoadingCompliance();
+   }
+
+   public boolean getLenientEjbLink()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.getLenientEjbLink();
+   }
+
+   public boolean getUnpackWars()
+   {
+      return tomcatDeployer == null ? false : tomcatDeployer.getUnpackWars();
+   }
+
+   public void setDefaultSecurityDomain(String defaultSecurityDomain)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setDefaultSecurityDomain(defaultSecurityDomain);
+   }
+
+   public void setJava2ClassLoadingCompliance(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setJava2ClassLoadingCompliance(flag);
+   }
+
+   public void setLenientEjbLink(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setLenientEjbLink(flag);
+   }
+
+   public void setUnpackWars(boolean flag)
+   {
+      if (tomcatDeployer != null)
+         tomcatDeployer.setUnpackWars(flag);
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#getHttpHeaderForSSOAuth()
+    */
+   public String getHttpHeaderForSSOAuth()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getHttpHeaderForSSOAuth();
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#setHttpHeaderForSSOAuth(java.lang.String)
+    */
+   public void setHttpHeaderForSSOAuth(String httpHeaderForSSOAuth)
+   {
+      if (this.tomcatDeployer != null)
+         this.tomcatDeployer.setHttpHeaderForSSOAuth(httpHeaderForSSOAuth);
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#getSessionCookieForSSOAuth()
+    */
+   public String getSessionCookieForSSOAuth()
+   {
+      return tomcatDeployer == null ? null : tomcatDeployer.getSessionCookieForSSOAuth();
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean#setSessionCookieForSSOAuth(java.lang.String)
+    */
+   public void setSessionCookieForSSOAuth(String sessionCookieForSSOAuth)
+   {
+      if (this.tomcatDeployer != null)
+         this.tomcatDeployer.setSessionCookieForSSOAuth(sessionCookieForSSOAuth);
+   }
+   
+   /**
+    * {@inheritDoc}
+    * 
+    * Overrides the superclass version to inject the <code>KernelController</code>
+    * into {@link JBossWebMicrocontainerBeanLocator}.
+    */
+   @Override
+   public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
+   {
+      super.setKernelControllerContext(controllerContext);
+      KernelController kernelController = controllerContext == null ? null : controllerContext.getKernel().getController();
+      JBossWebMicrocontainerBeanLocator.setKernelController(kernelController);
+   }
+   
+   /**
+    * {@inheritDoc}
+    * 
+    * Overrides the superclass version to clear the <code>KernelController</code>
+    * from {@link JBossWebMicrocontainerBeanLocator}.
+    */
+   @Override
+   public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
+   {
+      super.unsetKernelControllerContext(controllerContext);
+      JBossWebMicrocontainerBeanLocator.setKernelController(null);
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatServiceMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatServiceMBean.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatServiceMBean.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,36 +1,36 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.deployers;
-
-import org.jboss.system.ServiceMBean;
-
-/**
- * StandardMBean interface for the TomcatDeployerWrapper.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public interface TomcatServiceMBean extends TomcatDeployerMBean, ServiceMBean
-{
-   public void setTomcatDeployer(TomcatDeployer tomcatDeployer);
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.deployers;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * StandardMBean interface for the TomcatDeployerWrapper.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TomcatServiceMBean extends TomcatDeployerMBean, ServiceMBean
+{
+   public void setTomcatDeployer(TomcatDeployer tomcatDeployer);
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatServiceMBean.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/TomcatInjectionUtils.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/TomcatInjectionUtils.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/TomcatInjectionUtils.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,86 +1,86 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.BeanPropertyFactory;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-
-/**
- * TomcatInjectionContainer injection utils.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class TomcatInjectionUtils extends InjectionUtil
-{
-   
-   public static <X extends RemoteEnvironment> void processDynamicBeanAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz)
-   {
-      Map<AccessibleObject, Injector> classInjectors = container.getEncInjections().get(clazz.getName());
-      if(classInjectors == null)
-      {
-         classInjectors = new HashMap<AccessibleObject, Injector>();
-         container.getEncInjections().put(clazz.getName(), classInjectors);
-      }
-      
-      HashSet<String> visitedMethods = new HashSet<String>();
-      collapseXmlMethodInjectors(visitedMethods, clazz, container.getEncInjections(), classInjectors);
-
-      processClassAnnotations(container, handlers, clazz);
-      visitedMethods = new HashSet<String>();
-      processMethodAnnotations(container, handlers, visitedMethods, clazz, classInjectors);
-      processFieldAnnotations(container, handlers, clazz, classInjectors);
-   }
-   
-   
-   public static void createInjectors(Map<String, Map<AccessibleObject, Injector>> injectors, ClassLoader classLoader, InjectorFactory<?> factory, Collection<ResourceInjectionTargetMetaData> injectionTargets)
-   {
-      for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
-      {
-         Map<AccessibleObject, Injector> map = injectors.get(injectionTarget.getInjectionTargetClass());
-         if(map == null)
-         {
-            map = new HashMap<AccessibleObject, Injector>();
-            injectors.put(injectionTarget.getInjectionTargetClass(), map);
-         }
-         
-         AccessibleObject ao = InjectionUtil.findInjectionTarget(classLoader, injectionTarget);
-         BeanProperty property = BeanPropertyFactory.create(ao);
-         map.put(ao, factory.create(property));
-      }
-   }
-
-}
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * TomcatInjectionContainer injection utils.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TomcatInjectionUtils extends InjectionUtil
+{
+   
+   public static <X extends RemoteEnvironment> void processDynamicBeanAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz)
+   {
+      Map<AccessibleObject, Injector> classInjectors = container.getEncInjections().get(clazz.getName());
+      if(classInjectors == null)
+      {
+         classInjectors = new HashMap<AccessibleObject, Injector>();
+         container.getEncInjections().put(clazz.getName(), classInjectors);
+      }
+      
+      HashSet<String> visitedMethods = new HashSet<String>();
+      collapseXmlMethodInjectors(visitedMethods, clazz, container.getEncInjections(), classInjectors);
+
+      processClassAnnotations(container, handlers, clazz);
+      visitedMethods = new HashSet<String>();
+      processMethodAnnotations(container, handlers, visitedMethods, clazz, classInjectors);
+      processFieldAnnotations(container, handlers, clazz, classInjectors);
+   }
+   
+   
+   public static void createInjectors(Map<String, Map<AccessibleObject, Injector>> injectors, ClassLoader classLoader, InjectorFactory<?> factory, Collection<ResourceInjectionTargetMetaData> injectionTargets)
+   {
+      for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
+      {
+         Map<AccessibleObject, Injector> map = injectors.get(injectionTarget.getInjectionTargetClass());
+         if(map == null)
+         {
+            map = new HashMap<AccessibleObject, Injector>();
+            injectors.put(injectionTarget.getInjectionTargetClass(), map);
+         }
+         
+         AccessibleObject ao = InjectionUtil.findInjectionTarget(classLoader, injectionTarget);
+         BeanProperty property = BeanPropertyFactory.create(ao);
+         map.put(ao, factory.create(property));
+      }
+   }
+
+}
+


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/TomcatInjectionUtils.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBHandler.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBHandler.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,95 +1,95 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.jboss.deployment.dependency.ContainerDependencyMetaData;
-import org.jboss.deployment.spi.DeploymentEndpointResolver;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData;
-import org.jboss.metadata.javaee.spec.Environment;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-
-/**
- * Process all ejb references. The non local references are processed
- * by inheritance. Forked to allow for web specific processing.
- *
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: 66558 $
- */
-public class WebEJBHandler<X extends Environment> extends WebEJBRemoteHandler<X>
-{
-   @SuppressWarnings("unused")
-   private static final Logger log = Logger.getLogger(WebEJBHandler.class);
-
-   public WebEJBHandler(JBossWebMetaData webDD,
-         DeploymentEndpointResolver resolver,
-         Map<String, ContainerDependencyMetaData> endpoints,
-         String vfsContext)
-   {
-      super(webDD, resolver, endpoints, vfsContext);
-   }
-
-   public void loadXml(X xml, InjectionContainer container)
-   {
-      super.loadXml(xml, container);
-      if (xml != null)
-      {
-         // local references
-         log.trace("localEjbRefs:" + xml.getEjbLocalReferences());
-         if (xml.getEjbLocalReferences() != null)
-            loadEjbLocalXml(xml.getEjbLocalReferences(), container);
-         // annotated references
-         log.trace("annotatedEjbRefs:" + xml.getEjbLocalReferences());
-         if (xml.getAnnotatedEjbReferences() != null)
-            loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
-      }
-   }
-
-   protected void loadEjbLocalXml(Collection<EJBLocalReferenceMetaData> refs, InjectionContainer container)
-   {
-      for (EJBLocalReferenceMetaData ref : refs)
-      {
-         String interfaceName = ref.getLocal();
-         String errorType = "<ejb-local-ref>";
-
-         ejbRefXml(ref, interfaceName, container, errorType);
-      }
-   }
-   
-   protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs, InjectionContainer container)
-   {
-      for (AnnotatedEJBReferenceMetaData ref : refs)
-      {
-         String interfaceName = ref.getBeanInterface().getName();
-         String errorType = "@EJB";
-
-         ejbRefXml(ref, interfaceName, container, errorType);
-      }      
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+
+/**
+ * Process all ejb references. The non local references are processed
+ * by inheritance. Forked to allow for web specific processing.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 66558 $
+ */
+public class WebEJBHandler<X extends Environment> extends WebEJBRemoteHandler<X>
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(WebEJBHandler.class);
+
+   public WebEJBHandler(JBossWebMetaData webDD,
+         DeploymentEndpointResolver resolver,
+         Map<String, ContainerDependencyMetaData> endpoints,
+         String vfsContext)
+   {
+      super(webDD, resolver, endpoints, vfsContext);
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      super.loadXml(xml, container);
+      if (xml != null)
+      {
+         // local references
+         log.trace("localEjbRefs:" + xml.getEjbLocalReferences());
+         if (xml.getEjbLocalReferences() != null)
+            loadEjbLocalXml(xml.getEjbLocalReferences(), container);
+         // annotated references
+         log.trace("annotatedEjbRefs:" + xml.getEjbLocalReferences());
+         if (xml.getAnnotatedEjbReferences() != null)
+            loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
+      }
+   }
+
+   protected void loadEjbLocalXml(Collection<EJBLocalReferenceMetaData> refs, InjectionContainer container)
+   {
+      for (EJBLocalReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getLocal();
+         String errorType = "<ejb-local-ref>";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }
+   }
+   
+   protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs, InjectionContainer container)
+   {
+      for (AnnotatedEJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getBeanInterface().getName();
+         String errorType = "@EJB";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }      
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBHandler.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBRemoteHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBRemoteHandler.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBRemoteHandler.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,469 +1,469 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBs;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.deployment.dependency.ContainerDependencyMetaData;
-import org.jboss.deployment.spi.DeploymentEndpointResolver;
-import org.jboss.deployment.spi.EndpointInfo;
-import org.jboss.deployment.spi.EndpointType;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.injection.EJBInjectionHandler;
-import org.jboss.injection.EjbEncInjector;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-
-/**
- * Searches bean class for all @Inject and create Injectors
- * for a remote environment.
- *
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 73523 $
- */
-public class WebEJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
-{
-   private static final Logger log = Logger.getLogger(WebEJBRemoteHandler.class);
-   private JBossWebMetaData webDD;
-   private DeploymentEndpointResolver resolver;
-   private Map<String, ContainerDependencyMetaData> endpoints;
-   private String vfsContext;
-
-   public WebEJBRemoteHandler(JBossWebMetaData webDD,
-         DeploymentEndpointResolver resolver,
-         Map<String, ContainerDependencyMetaData> endpoints,
-         String vfsContext)
-   {
-      this.webDD = webDD;
-      this.resolver = resolver;
-      this.endpoints = endpoints;
-      this.vfsContext = vfsContext;
-   }
-
-   public void loadXml(X xml, InjectionContainer container)
-   {
-      if (xml != null)
-      {
-         log.trace("ejbRefs = " + xml.getEjbReferences());
-         if (xml.getEjbReferences() != null)
-            loadEjbRefXml(xml.getEjbReferences(), container);
-      }
-   }
-
-   protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
-   {
-      for (EJBReferenceMetaData ref : refs)
-      {
-         String interfaceName = ref.getRemote();
-         String errorType = "<ejb-ref>";
-
-         ejbRefXml(ref, interfaceName, container, errorType);
-      }
-   }
-
-   protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
-   {
-      String encName = "env/" + ref.getEjbRefName();
-      InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
-      if (container.getEncInjectors().containsKey(encName))
-         return;
-
-      String mappedName = ref.getMappedName();
-      if (mappedName != null && mappedName.equals(""))
-         mappedName = null;
-      if(mappedName == null && ref.getResolvedJndiName() != null)
-         mappedName = ref.getResolvedJndiName();
-
-      String link = ref.getLink();
-      if (link != null && link.trim().equals("")) link = null;
-
-      Class<?> refClass = null;
-
-      if (interfaceName != null)
-      {
-         try
-         {
-            refClass = container.getClassloader().loadClass(interfaceName);
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-         }
-      }
-      
-      //----- injectors
-
-      if (mappedName == null && refClass == null && link == null)
-      {
-         // must be jboss.xml only with @EJB used to define reference.  jboss.xml used to tag for ignore dependency
-         // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
-      }
-      else
-      {
-         ejbRefEncInjector(mappedName, encName, null, refClass, link, errorType, container);
-         if (ref.getIgnoreDependency() != null)
-         {
-            log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
-            return;
-         }
-
-         ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
-      }
-   }
-
-   protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
-   {
-      if(mappedName != null && mappedName.length() == 0) mappedName = null;
-      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
-      
-      if(mappedName == null)
-         mappedName = getMappedName(encName, container);
-      
-      if(mappedName != null)
-      {
-         addJNDIDependency(container, mappedName);
-         return;
-      }
-      
-      if (refClass != null)
-      {
-         if (link != null && !link.trim().equals(""))
-         {
-            addDependency(container, link, refClass);
-         }
-         else
-         {
-            addDependency(container, refClass);
-         }
-      }
-      
-      else
-      {
-         String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
-         log.warn(msg);
-      }
-   }
-
-   protected void ejbRefEncInjector(String mappedName, String encName, String fieldName, Class refClass, String link, String errorType, InjectionContainer container)
-   {
-      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class)))
-         refClass = null;
-      if (mappedName != null && mappedName.trim().equals(""))
-         mappedName = null;
-      
-      if(mappedName == null)
-         mappedName = getMappedName(encName, container, fieldName);
-
-      EncInjector injector = null;
-      
-      if (mappedName == null)
-      {
-         // TODO: remove this block, see previous comments
-         log.warn("EJBTHREE-1289: Using legacy EjbEncInjector, because mappedName for enc \"" + encName + "\", field \"" + fieldName
-            + "\" is null (container.environmentRefGroup.annotatedEjbReferences = "
-            + container.getEnvironmentRefGroup().getAnnotatedEjbReferences() + ")");
-         // legacy
-         injector = new EjbEncInjector(encName, refClass, link, errorType);
-      }
-      else
-      {
-         injector = new EjbEncInjector(encName, mappedName, errorType);
-      }
-
-      container.getEncInjectors().put(encName, injector);
-   }
-
-   public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
-   {
-      EJBContainer rtn = null;
-
-      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
-      {
-         return null;
-      }
-
-      if (ref.beanName().equals("") && memberType == null)
-         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
-
-      Class<?> businessInterface = memberType;
-      if (!ref.beanInterface().getName().equals(Object.class.getName()))
-      {
-         businessInterface = ref.beanInterface();
-      }
-
-      if (ref.beanName().equals(""))
-      {
-         try
-         {
-            rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
-         }
-         catch (NameNotFoundException e)
-         {
-            log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
-         }
-      }
-      else
-      {
-         rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
-      }
-
-      return rtn;
-   }
-
-   public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
-   {
-      String jndiName;
-
-      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
-      {
-         return ref.mappedName();
-      }
-
-      if (ref.beanName().equals("") && memberType == null)
-         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
-
-      Class<?> businessInterface = memberType;
-      if (!ref.beanInterface().getName().equals(Object.class.getName()))
-      {
-         businessInterface = ref.beanInterface();
-      }
-
-      if (ref.beanName().equals(""))
-      {
-         try
-         {
-            jndiName = container.getEjbJndiName(businessInterface);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
-         }
-         if (jndiName == null)
-         {
-            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
-         }
-      }
-      else
-      {
-         jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
-         if (jndiName == null)
-         {
-            throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
-         }
-      }
-
-      return jndiName;
-   }
-
-   private String getMappedName(String encName, InjectionContainer container)
-   {
-      return getMappedName(encName, container, null);
-   }
-   
-   /**
-    * Find a mapped name in the meta data which came from the mapped resolver.
-    * 
-    * @param encName
-    * @param container
-    * @param fieldName
-    * @return
-    */
-   private String getMappedName(String encName, InjectionContainer container, String fieldName)
-   {
-      String mappedName = null;
-      
-      // Initialize the lookupName to the encName
-      String lookupName = encName;
-      
-      // Currently encName has 'env/' prepended (see getEncName)
-      assert lookupName.startsWith("env/") : "encName used to start with 'env/'";
-      lookupName = lookupName.substring(4);
-      
-      // EJBTHREE-1289: find a resolved jndi name
-      AnnotatedEJBReferencesMetaData amds = webDD.getJndiEnvironmentRefsGroup().getAnnotatedEjbReferences();
-      if(amds != null)
-      {
-         AnnotatedEJBReferenceMetaData amd = amds.get(lookupName);
-         if (amd == null && fieldName != null)
-         {
-            lookupName = fieldName;
-            amd = amds.get(lookupName);
-         }
-         if (amd != null)
-         {
-            mappedName = amd.getMappedName();
-            if (mappedName == null)
-               mappedName = amd.getResolvedJndiName();
-         }
-      }
-      
-      // The MappedDeploymentEndpointResolver should have put resolvedJndiName everywhere.
-      // If no mappedName is known by now, we have a bug.
-//      assert mappedName != null : "mappedName for enc \"" + encName + "\", field \"" + fieldName
-//            + "\" is null (container.environmentRefGroup.annotatedEjbReferences = "
-//            + container.getEnvironmentRefGroup().getAnnotatedEjbReferences() + ")";
-      
-      return mappedName;
-   }
-   
-   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
-   {
-      EJBs ref = container.getAnnotation(EJBs.class, clazz);
-      if (ref != null)
-      {
-         EJB[] ejbs = ref.value();
-
-         for (EJB ejb : ejbs)
-         {
-            handleClassAnnotation(ejb, clazz, container);
-         }
-      }
-      EJB ejbref = container.getAnnotation(EJB.class, clazz);
-      if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
-   }
-
-   protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
-   {
-      String encName = ejb.name();
-      if (encName == null || encName.equals(""))
-      {
-         throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
-      }
-      encName = "env/" + encName;
-
-      if (container.getEncInjectors().containsKey(encName)) return;
-      ejbRefEncInjector(ejb.mappedName(), encName, null, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
-
-      // handle dependencies
-
-      if (isIgnoreDependency(container, ejb))
-         log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
-      else
-         ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
-   }
-
-   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-   {
-      EJB ref = container.getAnnotation(EJB.class, method);
-      if (ref != null)
-      {
-         if (!method.getName().startsWith("set"))
-            throw new RuntimeException("@EJB can only be used with a set method: " + method);
-         String encName = getEncName(ref, method);
-         if (!container.getEncInjectors().containsKey(encName))
-         {
-            ejbRefEncInjector(ref.mappedName(), encName, method.getName().substring(0), method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
-            
-            if (isIgnoreDependency(container, ref))
-               log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
-            else
-               ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
-         }
-
-         super.handleMethodAnnotations(method, container, injectors);
-      }
-   }
-
-   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-   {
-      EJB ref = container.getAnnotation(EJB.class, field);
-      if (ref != null)
-      {
-         String encName = getEncName(ref, field);
-         if (!container.getEncInjectors().containsKey(encName))
-         {
-            String mappedName = null;
-            if(ref.mappedName().length() > 0)
-               mappedName = ref.mappedName();
-            
-            if(mappedName == null)
-            {
-               EndpointInfo info = null;
-               String link = null;
-               
-               if(ref.beanName().length() > 0)
-                  link = ref.beanName();
-               
-               if(link != null)
-                  info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext);
-               if(info == null)
-                  info = resolver.getEndpointInfo(field.getType(), EndpointType.EJB, vfsContext);
-               if(info == null)
-                  throw new IllegalStateException("No mapped-name for field: "+field+", "+ref);
-
-               ContainerDependencyMetaData cdmd = endpoints.get(info.getComponentKey());
-               if(cdmd == null)
-                  throw new IllegalStateException("Failed to resolve ContainerDependencyMetaData for info: "+info+", "+ref);
-                mappedName = cdmd.getContainerName();
-            }
-            
-            if (isIgnoreDependency(container, ref))
-               log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
-            else
-            {
-               ejbRefDependency(mappedName, ref.beanName(), container, field.getType(), "@EJB", encName);
-            }
-            ejbRefEncInjector(mappedName, encName, field.getName(), field.getType(), ref.beanName(), "@EJB", container);
-         }
-         super.handleFieldAnnotations(field, container, injectors);
-      }
-   }
-
-   protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
-   {
-      RemoteEnvironment refGroup =  container.getEnvironmentRefGroup();
-      
-      if (refGroup != null)
-      {
-         if(refGroup.getEjbReferences() != null)
-         for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
-         {
-            if (ejbRef.getEjbRefName().equals(ref.name()))
-            {
-               return ejbRef.getIgnoreDependency() != null;
-            }
-         }
-      }
-      
-      // TODO: shouldn't we scan local ejb refs as well?
-      
-      return false;
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.injection.EJBInjectionHandler;
+import org.jboss.injection.EjbEncInjector;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+
+/**
+ * Searches bean class for all @Inject and create Injectors
+ * for a remote environment.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 73523 $
+ */
+public class WebEJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
+{
+   private static final Logger log = Logger.getLogger(WebEJBRemoteHandler.class);
+   private JBossWebMetaData webDD;
+   private DeploymentEndpointResolver resolver;
+   private Map<String, ContainerDependencyMetaData> endpoints;
+   private String vfsContext;
+
+   public WebEJBRemoteHandler(JBossWebMetaData webDD,
+         DeploymentEndpointResolver resolver,
+         Map<String, ContainerDependencyMetaData> endpoints,
+         String vfsContext)
+   {
+      this.webDD = webDD;
+      this.resolver = resolver;
+      this.endpoints = endpoints;
+      this.vfsContext = vfsContext;
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml != null)
+      {
+         log.trace("ejbRefs = " + xml.getEjbReferences());
+         if (xml.getEjbReferences() != null)
+            loadEjbRefXml(xml.getEjbReferences(), container);
+      }
+   }
+
+   protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+   {
+      for (EJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getRemote();
+         String errorType = "<ejb-ref>";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }
+   }
+
+   protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+   {
+      String encName = "env/" + ref.getEjbRefName();
+      InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+      if (container.getEncInjectors().containsKey(encName))
+         return;
+
+      String mappedName = ref.getMappedName();
+      if (mappedName != null && mappedName.equals(""))
+         mappedName = null;
+      if(mappedName == null && ref.getResolvedJndiName() != null)
+         mappedName = ref.getResolvedJndiName();
+
+      String link = ref.getLink();
+      if (link != null && link.trim().equals("")) link = null;
+
+      Class<?> refClass = null;
+
+      if (interfaceName != null)
+      {
+         try
+         {
+            refClass = container.getClassloader().loadClass(interfaceName);
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
+         }
+      }
+      
+      //----- injectors
+
+      if (mappedName == null && refClass == null && link == null)
+      {
+         // must be jboss.xml only with @EJB used to define reference.  jboss.xml used to tag for ignore dependency
+         // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
+      }
+      else
+      {
+         ejbRefEncInjector(mappedName, encName, null, refClass, link, errorType, container);
+         if (ref.getIgnoreDependency() != null)
+         {
+            log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+            return;
+         }
+
+         ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
+      }
+   }
+
+   protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
+   {
+      if(mappedName != null && mappedName.length() == 0) mappedName = null;
+      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
+      
+      if(mappedName == null)
+         mappedName = getMappedName(encName, container);
+      
+      if(mappedName != null)
+      {
+         addJNDIDependency(container, mappedName);
+         return;
+      }
+      
+      if (refClass != null)
+      {
+         if (link != null && !link.trim().equals(""))
+         {
+            addDependency(container, link, refClass);
+         }
+         else
+         {
+            addDependency(container, refClass);
+         }
+      }
+      
+      else
+      {
+         String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
+         log.warn(msg);
+      }
+   }
+
+   protected void ejbRefEncInjector(String mappedName, String encName, String fieldName, Class refClass, String link, String errorType, InjectionContainer container)
+   {
+      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class)))
+         refClass = null;
+      if (mappedName != null && mappedName.trim().equals(""))
+         mappedName = null;
+      
+      if(mappedName == null)
+         mappedName = getMappedName(encName, container, fieldName);
+
+      EncInjector injector = null;
+      
+      if (mappedName == null)
+      {
+         // TODO: remove this block, see previous comments
+         log.warn("EJBTHREE-1289: Using legacy EjbEncInjector, because mappedName for enc \"" + encName + "\", field \"" + fieldName
+            + "\" is null (container.environmentRefGroup.annotatedEjbReferences = "
+            + container.getEnvironmentRefGroup().getAnnotatedEjbReferences() + ")");
+         // legacy
+         injector = new EjbEncInjector(encName, refClass, link, errorType);
+      }
+      else
+      {
+         injector = new EjbEncInjector(encName, mappedName, errorType);
+      }
+
+      container.getEncInjectors().put(encName, injector);
+   }
+
+   public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
+   {
+      EJBContainer rtn = null;
+
+      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+      {
+         return null;
+      }
+
+      if (ref.beanName().equals("") && memberType == null)
+         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
+
+      Class<?> businessInterface = memberType;
+      if (!ref.beanInterface().getName().equals(Object.class.getName()))
+      {
+         businessInterface = ref.beanInterface();
+      }
+
+      if (ref.beanName().equals(""))
+      {
+         try
+         {
+            rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
+         }
+         catch (NameNotFoundException e)
+         {
+            log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+         }
+      }
+      else
+      {
+         rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
+      }
+
+      return rtn;
+   }
+
+   public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
+   {
+      String jndiName;
+
+      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+      {
+         return ref.mappedName();
+      }
+
+      if (ref.beanName().equals("") && memberType == null)
+         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
+
+      Class<?> businessInterface = memberType;
+      if (!ref.beanInterface().getName().equals(Object.class.getName()))
+      {
+         businessInterface = ref.beanInterface();
+      }
+
+      if (ref.beanName().equals(""))
+      {
+         try
+         {
+            jndiName = container.getEjbJndiName(businessInterface);
+         }
+         catch (NameNotFoundException e)
+         {
+            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+         }
+         if (jndiName == null)
+         {
+            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
+         }
+      }
+      else
+      {
+         jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
+         if (jndiName == null)
+         {
+            throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
+         }
+      }
+
+      return jndiName;
+   }
+
+   private String getMappedName(String encName, InjectionContainer container)
+   {
+      return getMappedName(encName, container, null);
+   }
+   
+   /**
+    * Find a mapped name in the meta data which came from the mapped resolver.
+    * 
+    * @param encName
+    * @param container
+    * @param fieldName
+    * @return
+    */
+   private String getMappedName(String encName, InjectionContainer container, String fieldName)
+   {
+      String mappedName = null;
+      
+      // Initialize the lookupName to the encName
+      String lookupName = encName;
+      
+      // Currently encName has 'env/' prepended (see getEncName)
+      assert lookupName.startsWith("env/") : "encName used to start with 'env/'";
+      lookupName = lookupName.substring(4);
+      
+      // EJBTHREE-1289: find a resolved jndi name
+      AnnotatedEJBReferencesMetaData amds = webDD.getJndiEnvironmentRefsGroup().getAnnotatedEjbReferences();
+      if(amds != null)
+      {
+         AnnotatedEJBReferenceMetaData amd = amds.get(lookupName);
+         if (amd == null && fieldName != null)
+         {
+            lookupName = fieldName;
+            amd = amds.get(lookupName);
+         }
+         if (amd != null)
+         {
+            mappedName = amd.getMappedName();
+            if (mappedName == null)
+               mappedName = amd.getResolvedJndiName();
+         }
+      }
+      
+      // The MappedDeploymentEndpointResolver should have put resolvedJndiName everywhere.
+      // If no mappedName is known by now, we have a bug.
+//      assert mappedName != null : "mappedName for enc \"" + encName + "\", field \"" + fieldName
+//            + "\" is null (container.environmentRefGroup.annotatedEjbReferences = "
+//            + container.getEnvironmentRefGroup().getAnnotatedEjbReferences() + ")";
+      
+      return mappedName;
+   }
+   
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      EJBs ref = container.getAnnotation(EJBs.class, clazz);
+      if (ref != null)
+      {
+         EJB[] ejbs = ref.value();
+
+         for (EJB ejb : ejbs)
+         {
+            handleClassAnnotation(ejb, clazz, container);
+         }
+      }
+      EJB ejbref = container.getAnnotation(EJB.class, clazz);
+      if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
+   }
+
+   protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
+   {
+      String encName = ejb.name();
+      if (encName == null || encName.equals(""))
+      {
+         throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
+      }
+      encName = "env/" + encName;
+
+      if (container.getEncInjectors().containsKey(encName)) return;
+      ejbRefEncInjector(ejb.mappedName(), encName, null, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
+
+      // handle dependencies
+
+      if (isIgnoreDependency(container, ejb))
+         log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+      else
+         ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      EJB ref = container.getAnnotation(EJB.class, method);
+      if (ref != null)
+      {
+         if (!method.getName().startsWith("set"))
+            throw new RuntimeException("@EJB can only be used with a set method: " + method);
+         String encName = getEncName(ref, method);
+         if (!container.getEncInjectors().containsKey(encName))
+         {
+            ejbRefEncInjector(ref.mappedName(), encName, method.getName().substring(0), method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
+            
+            if (isIgnoreDependency(container, ref))
+               log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+            else
+               ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
+         }
+
+         super.handleMethodAnnotations(method, container, injectors);
+      }
+   }
+
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      EJB ref = container.getAnnotation(EJB.class, field);
+      if (ref != null)
+      {
+         String encName = getEncName(ref, field);
+         if (!container.getEncInjectors().containsKey(encName))
+         {
+            String mappedName = null;
+            if(ref.mappedName().length() > 0)
+               mappedName = ref.mappedName();
+            
+            if(mappedName == null)
+            {
+               EndpointInfo info = null;
+               String link = null;
+               
+               if(ref.beanName().length() > 0)
+                  link = ref.beanName();
+               
+               if(link != null)
+                  info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext);
+               if(info == null)
+                  info = resolver.getEndpointInfo(field.getType(), EndpointType.EJB, vfsContext);
+               if(info == null)
+                  throw new IllegalStateException("No mapped-name for field: "+field+", "+ref);
+
+               ContainerDependencyMetaData cdmd = endpoints.get(info.getComponentKey());
+               if(cdmd == null)
+                  throw new IllegalStateException("Failed to resolve ContainerDependencyMetaData for info: "+info+", "+ref);
+                mappedName = cdmd.getContainerName();
+            }
+            
+            if (isIgnoreDependency(container, ref))
+               log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+            else
+            {
+               ejbRefDependency(mappedName, ref.beanName(), container, field.getType(), "@EJB", encName);
+            }
+            ejbRefEncInjector(mappedName, encName, field.getName(), field.getType(), ref.beanName(), "@EJB", container);
+         }
+         super.handleFieldAnnotations(field, container, injectors);
+      }
+   }
+
+   protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
+   {
+      RemoteEnvironment refGroup =  container.getEnvironmentRefGroup();
+      
+      if (refGroup != null)
+      {
+         if(refGroup.getEjbReferences() != null)
+         for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
+         {
+            if (ejbRef.getEjbRefName().equals(ref.name()))
+            {
+               return ejbRef.getIgnoreDependency() != null;
+            }
+         }
+      }
+      
+      // TODO: shouldn't we scan local ejb refs as well?
+      
+      return false;
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebEJBRemoteHandler.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,488 +1,488 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.ejb.EJBException;
-import javax.ejb.SessionContext;
-import javax.ejb.TimerService;
-import javax.transaction.UserTransaction;
-import javax.xml.ws.WebServiceContext;
-
-import org.jboss.ejb3.Container;
-import org.jboss.injection.EnvEntryEncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.JndiPropertyInjector;
-import org.jboss.injection.LinkRefEncInjector;
-import org.jboss.injection.TimerServicePropertyInjector;
-import org.jboss.injection.UserTransactionPropertyInjector;
-import org.jboss.injection.ValueEncInjector;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.FieldBeanProperty;
-import org.jboss.injection.lang.reflect.MethodBeanProperty;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.omg.CORBA.ORB;
-
-/**
- * RemoteEnvironment InjectionHandler for web components
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class WebResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
-{
-private static final Logger log = Logger.getLogger(WebResourceHandler.class);
-      
-      private boolean checkEncInjectors;
-
-      public WebResourceHandler()
-      {
-         this(true);
-      }
-      
-      public WebResourceHandler(boolean checkEncInjectors)
-      {
-         this.checkEncInjectors = checkEncInjectors;
-      }
-      
-      private static void createURLInjector(String encName, String mappedName, InjectionContainer container)
-      {
-         assert encName.length() > 0 : "encName is empty";
-         assert mappedName.length() > 0 : "mappedName is empty";
-         
-         // Create a URL from the mappedName
-         try
-         {
-            URL url = new URL(mappedName.trim());
-            container.getEncInjectors().put(encName, new ValueEncInjector(encName, url, "@Resource"));
-         }
-         catch (MalformedURLException e)
-         {
-            throw new RuntimeException("failed to create url injector for: "+ encName, e);
-         }
-      }
-      
-      private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
-      {
-         for (EnvironmentEntryMetaData envEntry : envEntries)
-         {
-            String encName = "env/" + envEntry.getEnvEntryName();
-            // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
-            // will not be initialized into the naming context.
-            if(envEntry.getValue() == null)
-            {
-               log.debug("ignoring env-entry " + envEntry);
-               continue;
-            }
-            InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
-            if (container.getEncInjectors().containsKey(encName)) continue;
-            log.trace("adding env-entry injector " + encName);
-            container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
-         }
-      }
-
-      private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
-      {
-         for (ResourceReferenceMetaData envRef : refs)
-         {
-            String encName = "env/" + envRef.getResourceRefName();
-            if (container.getEncInjectors().containsKey(encName))
-               continue;
-
-            String mappedName = envRef.getMappedName();
-            if(mappedName == null || mappedName.length() == 0)
-               mappedName = envRef.getResolvedJndiName();
-            if (mappedName == null || mappedName.length() == 0)
-            {
-               if (envRef.getResUrl() != null)
-               {
-                  try
-                  {
-                     container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
-                  }
-                  catch (MalformedURLException e)
-                  {
-                     throw new RuntimeException(e);
-                  }
-               }
-               else if (UserTransaction.class.getName().equals(envRef.getType()))
-               {
-                  final InjectionContainer ic = container;
-                  InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
-                  {
-                     public UserTransactionPropertyInjector create(BeanProperty property)
-                     {
-                        return new UserTransactionPropertyInjector(property, ic);
-                     }
-                  };
-                  if(envRef.getInjectionTargets() != null)
-                  {
-                     TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
-                     continue;
-                  }
-                  else
-                  {
-                     encName = "java:comp/UserTransaction";
-                  }
-               }
-               else if (ORB.class.getName().equals(envRef.getType()))
-               {
-                  encName = "java:comp/ORB";
-               }            
-               else
-               {
-                  throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
-               }
-            }
-            else if(URL.class.getName().equals(envRef.getType()) && ! mappedName.startsWith("java:") )
-            {
-               createURLInjector(encName, mappedName, container);
-               InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
-               continue;
-            }
-            else if(envRef.getResUrl() != null)
-            {
-               try
-               {
-                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
-               }
-               catch (MalformedURLException e)
-               {
-                  throw new RuntimeException(e);
-               }
-            }
-            else
-            {
-               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
-            }
-            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
-         }
-      }
-
-      private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
-      {
-         for (ResourceEnvironmentReferenceMetaData envRef : refs)
-         {
-            String resTypeName = envRef.getType();
-            String mappedName = envRef.getMappedName();
-            if(mappedName == null || mappedName.length() == 0)
-               mappedName = envRef.getResolvedJndiName();
-            try
-            {
-               if(resTypeName != null)
-               {
-                  Class<?> resType = Class.forName(resTypeName);
-                  if(TimerService.class.isAssignableFrom(resType))
-                  {
-                     log.warn("Ignoring invalid TimerService resource-env-ref");
-                     continue;
-                  }
-                  else if(SessionContext.class.isAssignableFrom(resType))
-                  {
-                     log.warn("Ignoring invalid SessionContext resource-env-ref");
-                     continue;
-                  }
-                  else if (resType.equals(UserTransaction.class))
-                  {
-                     final InjectionContainer ic = container;
-                     InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
-                     {
-                        public UserTransactionPropertyInjector create(BeanProperty property)
-                        {
-                           return new UserTransactionPropertyInjector(property, ic);
-                        }
-                     };
-                     if(envRef.getInjectionTargets() != null)
-                     {
-                        TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
-                        continue;
-                     }
-                     else
-                     {
-                        mappedName = "java:comp/UserTransaction";
-                     }
-                  }
-                  else if (resType.equals(ORB.class))
-                  {
-                     mappedName = "java:comp/ORB";
-                     continue;
-                  }
-                  else if(WebServiceContext.class.getName().equals(envRef.getType()))                      
-                  {     
-                     // JBAS-5359
-                     InjectorFactory<?> factory = new InjectorFactory<WebServiceContextPropertyInjector>()
-                     {                       public WebServiceContextPropertyInjector create(BeanProperty property)          
-                        {
-                           return new WebServiceContextPropertyInjector(property);
-                        }
-                     }; 
-                     if(envRef.getInjectionTargets() != null)
-                     {
-                        TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
-                        continue; 
-                     }  
-                  }
-               }
-            }
-            catch(ClassNotFoundException e)
-            {
-               throw new EJBException(e);
-            }
-            
-            String encName = "env/" + envRef.getResourceEnvRefName();
-            if (container.getEncInjectors().containsKey(encName))
-               continue;
-            if (mappedName == null || mappedName.equals(""))
-            {
-               throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
-            }
-            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
-            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
-         }
-      }
-
-      private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
-      {
-         for (MessageDestinationReferenceMetaData envRef : refs)
-         {
-            String encName = "env/" + envRef.getMessageDestinationRefName();
-            if (container.getEncInjectors().containsKey(encName)) continue;
-            String jndiName = envRef.getMappedName();
-            if (jndiName == null || jndiName.equals(""))
-            {
-               jndiName = envRef.getResolvedJndiName();
-               if (jndiName == null || jndiName.equals(""))
-                  throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
-            }
-            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
-            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
-         }
-      }
-
-      public void loadXml(X xml, InjectionContainer container)
-      {
-         if (xml == null)
-            return;
-         if (xml.getMessageDestinationReferences() != null)
-            loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
-         if (xml.getResourceEnvironmentReferences() != null)
-            loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
-         if (xml.getResourceReferences() != null)
-            loadXmlResourceRefs(container, xml.getResourceReferences());
-         if (xml.getEnvironmentEntries() != null)
-            loadEnvEntry(container, xml.getEnvironmentEntries());
-      }
-
-      public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
-      {
-         Resources resources = container.getAnnotation(Resources.class, clazz);
-         if (resources != null)
-         {
-         for (Resource ref : resources.value())
-         {
-            handleClassAnnotation(ref, container, clazz);
-         }
-         }
-         Resource res = container.getAnnotation(Resource.class, clazz);
-         if (res != null) handleClassAnnotation(res, container, clazz);
-      }
-
-      private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
-      {
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException("JBoss requires name() for class level @Resource");
-         }
-         encName = "env/" + ref.name();
-         if (container.getEncInjectors().containsKey(encName)) return;
-
-         String mappedName = ref.mappedName();
-         if (mappedName == null || mappedName.equals(""))
-         {
-            // Handle class level @Resource(type=ORB.class)
-            if(ORB.class.isAssignableFrom(ref.type()))
-            {
-               mappedName = "java:comp/ORB";
-            }
-            else if(UserTransaction.class.isAssignableFrom(ref.type()))
-            {
-               mappedName = "java:comp/UserTransaction";
-            }
-            else
-            {
-               throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
-                     +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
-            }
-         }
-
-         if (ref.type() == URL.class)
-         {
-            createURLInjector(encName, mappedName, container);
-         }
-         else
-         {
-            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
-         }
-      }
-
-      public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-      {
-         Resource ref = container.getAnnotation(Resource.class, method);
-         if (ref == null) return;
-
-         log.trace("method " + method + " has @Resource");
-         
-         handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
-      }
-      
-      public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-      {
-         Resource ref = container.getAnnotation(Resource.class, field);
-         if (ref == null) return;
-
-         log.trace("field " + field + " has @Resource");
-         
-         handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
-      }
-
-      private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-      {
-         assert ref != null;
-         assert property != null;
-         assert container != null;
-         assert injectors != null;
-         
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            //encName = InjectionUtil.getEncName(field);
-            encName = property.getDeclaringClass().getName() + "/" + property.getName();
-         }
-         if (!encName.startsWith("env/"))
-         {
-            encName = "env/" + encName;
-         }
-
-         AccessibleObject accObj = property.getAccessibleObject();
-         
-         Class<?> type = property.getType();
-         if (!ref.type().equals(Object.class))
-         {
-            type = ref.type();
-         }
-         
-         if (type.equals(UserTransaction.class))
-         {
-            injectors.put(accObj, new UserTransactionPropertyInjector(property, container));
-         }
-         else if (type.equals(TimerService.class))
-         {
-            injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
-         }
-         else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
-         {
-            createURLInjector(encName, ref.mappedName(), container);
-            injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
-         }
-         else if (type.equals(String.class)
-                 || type.equals(Character.class)
-                 || type.equals(Byte.class)
-                 || type.equals(Short.class)
-                 || type.equals(Integer.class)
-                 || type.equals(Long.class)
-                 || type.equals(Boolean.class)
-                 || type.equals(Double.class)
-                 || type.equals(Float.class)
-                 || type.isPrimitive()
-                 )
-         {
-            // don't add an injector if no XML <env-entry is present as there will be no value to inject
-            if (container.getEncInjectors().containsKey(encName))
-            {
-               injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
-            }
-            else if (ref.mappedName() != null && ref.mappedName().length() > 0)
-            {
-               // Use the mappedName as the string value
-               String s = ref.mappedName().trim();
-               try
-               {
-                  Object value = ValueConvertor.convertValue(type, s);
-                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
-                  injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
-               }
-               catch(Throwable t)
-               {
-                  throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
-               }
-            }
-            else
-            {
-               log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
-            }
-         }
-         else
-         {
-            if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
-            {
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                  // TODO: is this a nice trick?
-//                  if(ConnectionFactory.class.isAssignableFrom(type))
-//                  {
-//                     // neat little trick
-//                     mappedName = "java:/ConnectionFactory";
-//                  }
-//                  else
-                  if(ORB.class.isAssignableFrom(type))
-                     mappedName = "java:comp/ORB";
-                  else
-                     throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
-               }
-               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
-            }
-            injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
-         }      
-      }
-            
-   }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.EJBException;
+import javax.ejb.SessionContext;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.ejb3.Container;
+import org.jboss.injection.EnvEntryEncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.JndiPropertyInjector;
+import org.jboss.injection.LinkRefEncInjector;
+import org.jboss.injection.TimerServicePropertyInjector;
+import org.jboss.injection.UserTransactionPropertyInjector;
+import org.jboss.injection.ValueEncInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.FieldBeanProperty;
+import org.jboss.injection.lang.reflect.MethodBeanProperty;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.omg.CORBA.ORB;
+
+/**
+ * RemoteEnvironment InjectionHandler for web components
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class WebResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+private static final Logger log = Logger.getLogger(WebResourceHandler.class);
+      
+      private boolean checkEncInjectors;
+
+      public WebResourceHandler()
+      {
+         this(true);
+      }
+      
+      public WebResourceHandler(boolean checkEncInjectors)
+      {
+         this.checkEncInjectors = checkEncInjectors;
+      }
+      
+      private static void createURLInjector(String encName, String mappedName, InjectionContainer container)
+      {
+         assert encName.length() > 0 : "encName is empty";
+         assert mappedName.length() > 0 : "mappedName is empty";
+         
+         // Create a URL from the mappedName
+         try
+         {
+            URL url = new URL(mappedName.trim());
+            container.getEncInjectors().put(encName, new ValueEncInjector(encName, url, "@Resource"));
+         }
+         catch (MalformedURLException e)
+         {
+            throw new RuntimeException("failed to create url injector for: "+ encName, e);
+         }
+      }
+      
+      private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
+      {
+         for (EnvironmentEntryMetaData envEntry : envEntries)
+         {
+            String encName = "env/" + envEntry.getEnvEntryName();
+            // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
+            // will not be initialized into the naming context.
+            if(envEntry.getValue() == null)
+            {
+               log.debug("ignoring env-entry " + envEntry);
+               continue;
+            }
+            InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
+            if (container.getEncInjectors().containsKey(encName)) continue;
+            log.trace("adding env-entry injector " + encName);
+            container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
+         }
+      }
+
+      private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
+      {
+         for (ResourceReferenceMetaData envRef : refs)
+         {
+            String encName = "env/" + envRef.getResourceRefName();
+            if (container.getEncInjectors().containsKey(encName))
+               continue;
+
+            String mappedName = envRef.getMappedName();
+            if(mappedName == null || mappedName.length() == 0)
+               mappedName = envRef.getResolvedJndiName();
+            if (mappedName == null || mappedName.length() == 0)
+            {
+               if (envRef.getResUrl() != null)
+               {
+                  try
+                  {
+                     container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
+                  }
+                  catch (MalformedURLException e)
+                  {
+                     throw new RuntimeException(e);
+                  }
+               }
+               else if (UserTransaction.class.getName().equals(envRef.getType()))
+               {
+                  final InjectionContainer ic = container;
+                  InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+                  {
+                     public UserTransactionPropertyInjector create(BeanProperty property)
+                     {
+                        return new UserTransactionPropertyInjector(property, ic);
+                     }
+                  };
+                  if(envRef.getInjectionTargets() != null)
+                  {
+                     TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                     continue;
+                  }
+                  else
+                  {
+                     encName = "java:comp/UserTransaction";
+                  }
+               }
+               else if (ORB.class.getName().equals(envRef.getType()))
+               {
+                  encName = "java:comp/ORB";
+               }            
+               else
+               {
+                  throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
+               }
+            }
+            else if(URL.class.getName().equals(envRef.getType()) && ! mappedName.startsWith("java:") )
+            {
+               createURLInjector(encName, mappedName, container);
+               InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+               continue;
+            }
+            else if(envRef.getResUrl() != null)
+            {
+               try
+               {
+                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
+               }
+               catch (MalformedURLException e)
+               {
+                  throw new RuntimeException(e);
+               }
+            }
+            else
+            {
+               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
+            }
+            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+         }
+      }
+
+      private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
+      {
+         for (ResourceEnvironmentReferenceMetaData envRef : refs)
+         {
+            String resTypeName = envRef.getType();
+            String mappedName = envRef.getMappedName();
+            if(mappedName == null || mappedName.length() == 0)
+               mappedName = envRef.getResolvedJndiName();
+            try
+            {
+               if(resTypeName != null)
+               {
+                  Class<?> resType = Class.forName(resTypeName);
+                  if(TimerService.class.isAssignableFrom(resType))
+                  {
+                     log.warn("Ignoring invalid TimerService resource-env-ref");
+                     continue;
+                  }
+                  else if(SessionContext.class.isAssignableFrom(resType))
+                  {
+                     log.warn("Ignoring invalid SessionContext resource-env-ref");
+                     continue;
+                  }
+                  else if (resType.equals(UserTransaction.class))
+                  {
+                     final InjectionContainer ic = container;
+                     InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+                     {
+                        public UserTransactionPropertyInjector create(BeanProperty property)
+                        {
+                           return new UserTransactionPropertyInjector(property, ic);
+                        }
+                     };
+                     if(envRef.getInjectionTargets() != null)
+                     {
+                        TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                        continue;
+                     }
+                     else
+                     {
+                        mappedName = "java:comp/UserTransaction";
+                     }
+                  }
+                  else if (resType.equals(ORB.class))
+                  {
+                     mappedName = "java:comp/ORB";
+                     continue;
+                  }
+                  else if(WebServiceContext.class.getName().equals(envRef.getType()))                      
+                  {     
+                     // JBAS-5359
+                     InjectorFactory<?> factory = new InjectorFactory<WebServiceContextPropertyInjector>()
+                     {                       public WebServiceContextPropertyInjector create(BeanProperty property)          
+                        {
+                           return new WebServiceContextPropertyInjector(property);
+                        }
+                     }; 
+                     if(envRef.getInjectionTargets() != null)
+                     {
+                        TomcatInjectionUtils.createInjectors(container.getEncInjections(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                        continue; 
+                     }  
+                  }
+               }
+            }
+            catch(ClassNotFoundException e)
+            {
+               throw new EJBException(e);
+            }
+            
+            String encName = "env/" + envRef.getResourceEnvRefName();
+            if (container.getEncInjectors().containsKey(encName))
+               continue;
+            if (mappedName == null || mappedName.equals(""))
+            {
+               throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
+            }
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
+            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+         }
+      }
+
+      private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
+      {
+         for (MessageDestinationReferenceMetaData envRef : refs)
+         {
+            String encName = "env/" + envRef.getMessageDestinationRefName();
+            if (container.getEncInjectors().containsKey(encName)) continue;
+            String jndiName = envRef.getMappedName();
+            if (jndiName == null || jndiName.equals(""))
+            {
+               jndiName = envRef.getResolvedJndiName();
+               if (jndiName == null || jndiName.equals(""))
+                  throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
+            }
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
+            InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+         }
+      }
+
+      public void loadXml(X xml, InjectionContainer container)
+      {
+         if (xml == null)
+            return;
+         if (xml.getMessageDestinationReferences() != null)
+            loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+         if (xml.getResourceEnvironmentReferences() != null)
+            loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+         if (xml.getResourceReferences() != null)
+            loadXmlResourceRefs(container, xml.getResourceReferences());
+         if (xml.getEnvironmentEntries() != null)
+            loadEnvEntry(container, xml.getEnvironmentEntries());
+      }
+
+      public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+      {
+         Resources resources = container.getAnnotation(Resources.class, clazz);
+         if (resources != null)
+         {
+         for (Resource ref : resources.value())
+         {
+            handleClassAnnotation(ref, container, clazz);
+         }
+         }
+         Resource res = container.getAnnotation(Resource.class, clazz);
+         if (res != null) handleClassAnnotation(res, container, clazz);
+      }
+
+      private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
+      {
+         String encName = ref.name();
+         if (encName == null || encName.equals(""))
+         {
+            throw new RuntimeException("JBoss requires name() for class level @Resource");
+         }
+         encName = "env/" + ref.name();
+         if (container.getEncInjectors().containsKey(encName)) return;
+
+         String mappedName = ref.mappedName();
+         if (mappedName == null || mappedName.equals(""))
+         {
+            // Handle class level @Resource(type=ORB.class)
+            if(ORB.class.isAssignableFrom(ref.type()))
+            {
+               mappedName = "java:comp/ORB";
+            }
+            else if(UserTransaction.class.isAssignableFrom(ref.type()))
+            {
+               mappedName = "java:comp/UserTransaction";
+            }
+            else
+            {
+               throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
+                     +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
+            }
+         }
+
+         if (ref.type() == URL.class)
+         {
+            createURLInjector(encName, mappedName, container);
+         }
+         else
+         {
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+         }
+      }
+
+      public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+      {
+         Resource ref = container.getAnnotation(Resource.class, method);
+         if (ref == null) return;
+
+         log.trace("method " + method + " has @Resource");
+         
+         handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
+      }
+      
+      public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+      {
+         Resource ref = container.getAnnotation(Resource.class, field);
+         if (ref == null) return;
+
+         log.trace("field " + field + " has @Resource");
+         
+         handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
+      }
+
+      private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+      {
+         assert ref != null;
+         assert property != null;
+         assert container != null;
+         assert injectors != null;
+         
+         String encName = ref.name();
+         if (encName == null || encName.equals(""))
+         {
+            //encName = InjectionUtil.getEncName(field);
+            encName = property.getDeclaringClass().getName() + "/" + property.getName();
+         }
+         if (!encName.startsWith("env/"))
+         {
+            encName = "env/" + encName;
+         }
+
+         AccessibleObject accObj = property.getAccessibleObject();
+         
+         Class<?> type = property.getType();
+         if (!ref.type().equals(Object.class))
+         {
+            type = ref.type();
+         }
+         
+         if (type.equals(UserTransaction.class))
+         {
+            injectors.put(accObj, new UserTransactionPropertyInjector(property, container));
+         }
+         else if (type.equals(TimerService.class))
+         {
+            injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
+         }
+         else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
+         {
+            createURLInjector(encName, ref.mappedName(), container);
+            injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+         }
+         else if (type.equals(String.class)
+                 || type.equals(Character.class)
+                 || type.equals(Byte.class)
+                 || type.equals(Short.class)
+                 || type.equals(Integer.class)
+                 || type.equals(Long.class)
+                 || type.equals(Boolean.class)
+                 || type.equals(Double.class)
+                 || type.equals(Float.class)
+                 || type.isPrimitive()
+                 )
+         {
+            // don't add an injector if no XML <env-entry is present as there will be no value to inject
+            if (container.getEncInjectors().containsKey(encName))
+            {
+               injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+            }
+            else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+            {
+               // Use the mappedName as the string value
+               String s = ref.mappedName().trim();
+               try
+               {
+                  Object value = ValueConvertor.convertValue(type, s);
+                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+                  injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+               }
+               catch(Throwable t)
+               {
+                  throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+               }
+            }
+            else
+            {
+               log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
+            }
+         }
+         else
+         {
+            if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
+            {
+               String mappedName = ref.mappedName();
+               if (mappedName == null || mappedName.equals(""))
+               {
+                  // TODO: is this a nice trick?
+//                  if(ConnectionFactory.class.isAssignableFrom(type))
+//                  {
+//                     // neat little trick
+//                     mappedName = "java:/ConnectionFactory";
+//                  }
+//                  else
+                  if(ORB.class.isAssignableFrom(type))
+                     mappedName = "java:comp/ORB";
+                  else
+                     throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
+               }
+               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
+            }
+            injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+         }      
+      }
+            
+   }


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceContextPropertyInjector.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceContextPropertyInjector.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceContextPropertyInjector.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,68 +1,68 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.stateless.StatelessBeanContext;
-import org.jboss.injection.Injector;
-import org.jboss.injection.WebServiceContextProxy;
-import org.jboss.injection.lang.reflect.BeanProperty;
-
-/**
- * Copy of the ejb3 version to isolate changes and make the ctor public.
- * 
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author Thomas.Diesler at jboss.com
- * @version $Revision:$
- */
-public class WebServiceContextPropertyInjector implements Injector
-{
-   private BeanProperty property;
-   
-   public WebServiceContextPropertyInjector(BeanProperty property)
-   {
-      assert property != null : "property must be set";
-      
-      this.property = property;
-   }
-
-   public void inject(Object instance)
-   {
-      throw new RuntimeException("Illegal operation");
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      property.set(ctx.getInstance(), new WebServiceContextProxy());
-      
-      if(!(ctx instanceof StatelessBeanContext))
-         throw new RuntimeException("Can only inject on stateless bean context");
-      
-      ((StatelessBeanContext)ctx).setWebServiceContextProperty(property);
-   }
-   
-   public Class getInjectionClass()
-   {
-      return property.getType();
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.stateless.StatelessBeanContext;
+import org.jboss.injection.Injector;
+import org.jboss.injection.WebServiceContextProxy;
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * Copy of the ejb3 version to isolate changes and make the ctor public.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision:$
+ */
+public class WebServiceContextPropertyInjector implements Injector
+{
+   private BeanProperty property;
+   
+   public WebServiceContextPropertyInjector(BeanProperty property)
+   {
+      assert property != null : "property must be set";
+      
+      this.property = property;
+   }
+
+   public void inject(Object instance)
+   {
+      throw new RuntimeException("Illegal operation");
+   }
+
+   public void inject(BeanContext ctx)
+   {
+      property.set(ctx.getInstance(), new WebServiceContextProxy());
+      
+      if(!(ctx instanceof StatelessBeanContext))
+         throw new RuntimeException("Can only inject on stateless bean context");
+      
+      ((StatelessBeanContext)ctx).setWebServiceContextProperty(property);
+   }
+   
+   public Class getInjectionClass()
+   {
+      return property.getType();
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceContextPropertyInjector.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceRefInjectionHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceRefInjectionHandler.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceRefInjectionHandler.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,130 +1,130 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.JndiFieldInjector;
-import org.jboss.injection.JndiMethodInjector;
-import org.jboss.injection.ServiceRefInjector;
-import org.jboss.injection.WebServiceRefHandler;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
-
-/**
- * A WebServiceRef injection Handler.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class WebServiceRefInjectionHandler<X extends RemoteEnvironment> extends WebServiceRefHandler<X> 
-{
-   private static final Logger log = Logger.getLogger(WebServiceRefInjectionHandler.class);
-   private Map<String, ServiceReferenceMetaData> srefMap = new HashMap<String, ServiceReferenceMetaData>();
-   
-   public void loadXml(X xml, InjectionContainer container)
-   {
-      if (xml == null) return;
-      ServiceReferencesMetaData serviceRefs = xml.getServiceReferences();
-      if (serviceRefs == null) return;
-
-      for (ServiceReferenceMetaData sref : serviceRefs)
-      {
-         log.debug("service-ref: " + sref);
-         if (srefMap.get(sref.getServiceRefName()) != null)
-               throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
-         
-         srefMap.put(sref.getServiceRefName(), sref);
-
-         String srefName = sref.getServiceRefName();
-         String encName = "env/" + srefName;
-         AnnotatedElement annotatedElement = sref.getAnnotatedElement();
-         if(sref.getInjectionTargets() != null && sref.getInjectionTargets().size() > 0)
-         {
-            for(ResourceInjectionTargetMetaData trg : sref.getInjectionTargets())
-            {
-               // Find the annotatedElement
-               annotatedElement = InjectionUtil.findInjectionTarget(container.getClassloader(), trg);
-               
-               // Add a JndiPropertyInjector
-               addInjector(container, encName, annotatedElement);
-               
-               // Add the ServicerefEncInjector
-               if(!container.getEncInjectors().containsKey(srefName))
-                  container.getEncInjectors().put(srefName, new ServiceRefInjector(encName, annotatedElement, sref));
-            }
-         }
-         else
-         {
-            if(container.getEncInjectors().containsKey(srefName))
-               continue;
-            
-            // Add the ServicerefEncInjector only
-            container.getEncInjectors().put(srefName, new ServiceRefInjector(encName, annotatedElement, sref));
-         }
-      }
-   }
-   
-   private void addInjector(InjectionContainer container, String encName, AnnotatedElement annotatedElement)
-   {
-      Injector jndiInjector = null;
-      if(annotatedElement instanceof Method)
-      {
-         Method method = (Method) annotatedElement; 
-         jndiInjector = new JndiMethodInjector(method, encName, container.getEnc());
-         addInjector(container, method, method.getDeclaringClass(), jndiInjector);
-      }
-      else if(annotatedElement instanceof Field)
-      {
-         Field field = (Field) annotatedElement;
-         jndiInjector = new JndiFieldInjector(field, encName, container.getEnc());
-         addInjector(container, field, field.getDeclaringClass(), jndiInjector);
-      }
-      else
-         throw new IllegalStateException("Annotated element for '" + encName + "' is niether Method nor Field: " + annotatedElement);
-   }
-   
-   private void addInjector(InjectionContainer container, AccessibleObject ao, Class<?> declaringClass, Injector injector)
-   {
-      if(injector == null)
-         throw new IllegalArgumentException("null injector.");
-      
-      Map<AccessibleObject, Injector> map = container.getEncInjections().get(declaringClass.getName());
-      if(map == null)
-      {
-         map = new HashMap<AccessibleObject, Injector>();
-         container.getEncInjections().put(declaringClass.getName(), map);
-      }
-      map.put(ao, injector);      
-   }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiFieldInjector;
+import org.jboss.injection.JndiMethodInjector;
+import org.jboss.injection.ServiceRefInjector;
+import org.jboss.injection.WebServiceRefHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
+
+/**
+ * A WebServiceRef injection Handler.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class WebServiceRefInjectionHandler<X extends RemoteEnvironment> extends WebServiceRefHandler<X> 
+{
+   private static final Logger log = Logger.getLogger(WebServiceRefInjectionHandler.class);
+   private Map<String, ServiceReferenceMetaData> srefMap = new HashMap<String, ServiceReferenceMetaData>();
+   
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml == null) return;
+      ServiceReferencesMetaData serviceRefs = xml.getServiceReferences();
+      if (serviceRefs == null) return;
+
+      for (ServiceReferenceMetaData sref : serviceRefs)
+      {
+         log.debug("service-ref: " + sref);
+         if (srefMap.get(sref.getServiceRefName()) != null)
+               throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
+         
+         srefMap.put(sref.getServiceRefName(), sref);
+
+         String srefName = sref.getServiceRefName();
+         String encName = "env/" + srefName;
+         AnnotatedElement annotatedElement = sref.getAnnotatedElement();
+         if(sref.getInjectionTargets() != null && sref.getInjectionTargets().size() > 0)
+         {
+            for(ResourceInjectionTargetMetaData trg : sref.getInjectionTargets())
+            {
+               // Find the annotatedElement
+               annotatedElement = InjectionUtil.findInjectionTarget(container.getClassloader(), trg);
+               
+               // Add a JndiPropertyInjector
+               addInjector(container, encName, annotatedElement);
+               
+               // Add the ServicerefEncInjector
+               if(!container.getEncInjectors().containsKey(srefName))
+                  container.getEncInjectors().put(srefName, new ServiceRefInjector(encName, annotatedElement, sref));
+            }
+         }
+         else
+         {
+            if(container.getEncInjectors().containsKey(srefName))
+               continue;
+            
+            // Add the ServicerefEncInjector only
+            container.getEncInjectors().put(srefName, new ServiceRefInjector(encName, annotatedElement, sref));
+         }
+      }
+   }
+   
+   private void addInjector(InjectionContainer container, String encName, AnnotatedElement annotatedElement)
+   {
+      Injector jndiInjector = null;
+      if(annotatedElement instanceof Method)
+      {
+         Method method = (Method) annotatedElement; 
+         jndiInjector = new JndiMethodInjector(method, encName, container.getEnc());
+         addInjector(container, method, method.getDeclaringClass(), jndiInjector);
+      }
+      else if(annotatedElement instanceof Field)
+      {
+         Field field = (Field) annotatedElement;
+         jndiInjector = new JndiFieldInjector(field, encName, container.getEnc());
+         addInjector(container, field, field.getDeclaringClass(), jndiInjector);
+      }
+      else
+         throw new IllegalStateException("Annotated element for '" + encName + "' is niether Method nor Field: " + annotatedElement);
+   }
+   
+   private void addInjector(InjectionContainer container, AccessibleObject ao, Class<?> declaringClass, Injector injector)
+   {
+      if(injector == null)
+         throw new IllegalArgumentException("null injector.");
+      
+      Map<AccessibleObject, Injector> map = container.getEncInjections().get(declaringClass.getName());
+      if(map == null)
+      {
+         map = new HashMap<AccessibleObject, Injector>();
+         container.getEncInjections().put(declaringClass.getName(), map);
+      }
+      map.put(ao, injector);      
+   }
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebServiceRefInjectionHandler.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredManager.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredManager.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,89 +1,89 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session;
-
-import org.jboss.metadata.web.jboss.ReplicationTrigger;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
-import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
-
-/**
- * View of a Manager from a ClusteredSession.
- * 
- * @author Brian Stansberry
- *
- */
-public interface ClusteredManager extends AbstractJBossManager
-{
-   
-   /**
-    * Get the maximum interval between requests, in seconds, after which a
-    * request will trigger replication of the session's metadata regardless
-    * of whether the request has otherwise made the session dirty. Such 
-    * replication ensures that other nodes in the cluster are aware of a 
-    * relatively recent value for the session's timestamp and won't incorrectly
-    * expire an unreplicated session upon failover.
-    * <p/>
-    * Default value is <code>-1</code>.
-    * <p/>
-    * The cost of the metadata replication depends on the configured
-    * {@link #setReplicationGranularityString(String) replication granularity}.
-    * With <code>SESSION</code>, the sesssion's attribute map is replicated 
-    * along with the metadata, so it can be fairly costly.  With other 
-    * granularities, the metadata object is replicated separately from the
-    * attributes and only contains a String, and a few longs, ints and booleans.
-    * 
-    * @return the maximum interval since last replication after which a request
-    *         will trigger session metadata replication. A value of 
-    *         <code>0</code> means replicate metadata on every request; a value 
-    *         of <code>-1</code> means never replicate metadata unless the 
-    *         session is otherwise dirty.
-    */
-   int getMaxUnreplicatedInterval();
-   
-   /**
-    * Gets the policy for determining whether the servlet spec notifications related
-    * to session events are allowed to be emitted on the local cluster node.
-    */
-   ClusteredSessionNotificationPolicy getNotificationPolicy();
-   
-   /**
-    * Gets the policy controlling whether session attribute reads and writes
-    * mark the session/attribute as needing replication.
-    * 
-    * @return SET, SET_AND_GET, SET_AND_NON_PRIMITIVE_GET or <code>null</code> 
-    *         if this has not yet been configured.
-    */
-   ReplicationTrigger getReplicationTrigger();
-   
-   /**
-    * Gets whether JK is being used and special handling of a jvmRoute
-    * portion of session ids is needed.
-    */
-   boolean getUseJK();
-   
-   /**
-    * Gets the <code>DistributedCacheManager</code> through which we interact
-    * with the distributed cache.
-    */
-   DistributedCacheManager getDistributedCacheManager();
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session;
+
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
+
+/**
+ * View of a Manager from a ClusteredSession.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public interface ClusteredManager extends AbstractJBossManager
+{
+   
+   /**
+    * Get the maximum interval between requests, in seconds, after which a
+    * request will trigger replication of the session's metadata regardless
+    * of whether the request has otherwise made the session dirty. Such 
+    * replication ensures that other nodes in the cluster are aware of a 
+    * relatively recent value for the session's timestamp and won't incorrectly
+    * expire an unreplicated session upon failover.
+    * <p/>
+    * Default value is <code>-1</code>.
+    * <p/>
+    * The cost of the metadata replication depends on the configured
+    * {@link #setReplicationGranularityString(String) replication granularity}.
+    * With <code>SESSION</code>, the sesssion's attribute map is replicated 
+    * along with the metadata, so it can be fairly costly.  With other 
+    * granularities, the metadata object is replicated separately from the
+    * attributes and only contains a String, and a few longs, ints and booleans.
+    * 
+    * @return the maximum interval since last replication after which a request
+    *         will trigger session metadata replication. A value of 
+    *         <code>0</code> means replicate metadata on every request; a value 
+    *         of <code>-1</code> means never replicate metadata unless the 
+    *         session is otherwise dirty.
+    */
+   int getMaxUnreplicatedInterval();
+   
+   /**
+    * Gets the policy for determining whether the servlet spec notifications related
+    * to session events are allowed to be emitted on the local cluster node.
+    */
+   ClusteredSessionNotificationPolicy getNotificationPolicy();
+   
+   /**
+    * Gets the policy controlling whether session attribute reads and writes
+    * mark the session/attribute as needing replication.
+    * 
+    * @return SET, SET_AND_GET, SET_AND_NON_PRIMITIVE_GET or <code>null</code> 
+    *         if this has not yet been configured.
+    */
+   ReplicationTrigger getReplicationTrigger();
+   
+   /**
+    * Gets whether JK is being used and special handling of a jvmRoute
+    * portion of session ids is needed.
+    */
+   boolean getUseJK();
+   
+   /**
+    * Gets the <code>DistributedCacheManager</code> through which we interact
+    * with the distributed cache.
+    */
+   DistributedCacheManager getDistributedCacheManager();
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredManager.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,2345 +1,2345 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.session;
-
-import java.security.AccessController;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.Session;
-import org.apache.catalina.Valve;
-import org.apache.catalina.core.ContainerBase;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.jboss.ReplicationConfig;
-import org.jboss.metadata.web.jboss.ReplicationGranularity;
-import org.jboss.metadata.web.jboss.ReplicationTrigger;
-import org.jboss.metadata.web.jboss.SnapshotMode;
-import org.jboss.util.loading.ContextClassLoaderSwitcher;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.BatchingManager;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionData;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactoryFactory;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
-import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCapability;
-import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause;
-import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
-import org.jboss.web.tomcat.service.session.notification.LegacyClusteredSessionNotificationPolicy;
-
-/**
- * Implementation of a clustered session manager for
- * catalina using JBossCache replication.
- *
- * @author Ben Wang
- * @author Brian Stansberry
- * @author Hany Mesha
- * @version $Revision: 58587 $
- */
-public class JBossCacheManager
-   extends JBossManager
-   implements JBossCacheManagerMBean, LocalDistributableSessionManager, ClusteredManager
-{
-   // --------------------------------------------------------------- Constants
-   
-   /**
-    * Informational name for this Catalina component
-    */
-   private static final String info_ = "JBossCacheManager/1.0";
-
-   // ------------------------------------------------------------------ Fields
-
-   /** The transaction manager. */
-   private BatchingManager batchingManager;
-
-   /** Proxy-object for the JBossCache */
-   private DistributedCacheManager proxy_;
-
-   /** The factory for our distributed cache manager */
-   private final DistributedCacheManagerFactory distributedCacheManagerFactory;
-   
-   /** Id/timestamp of sessions in distributedcache that we haven't loaded locally*/
-   private Map<String, OwnedSessionUpdate> unloadedSessions_ = 
-         new ConcurrentHashMap<String, OwnedSessionUpdate>();
-   
-   /** Number of passivated sessions */
-   private AtomicInteger passivatedCount_ = new AtomicInteger();
-   
-   /** Maximum number of concurrently passivated sessions */
-   private AtomicInteger maxPassivatedCount_ = new AtomicInteger();
-   
-   /** If set to true, will add a JvmRouteFilter to the request. */
-   private Boolean useJK_;
-
-   /** Are we running embedded in JBoss? */
-   private boolean embedded_ = false;
-
-   /** Our ClusteredSessionValve's snapshot mode. */
-   private SnapshotMode snapshotMode_ = null;
-
-   /** Our ClusteredSessionValve's snapshot interval. */
-   private int snapshotInterval_ = 0;
-   
-   /** Replication granularity. */
-   private ReplicationGranularity replicationGranularity_;
-
-   /** Policy to determine if a session is dirty */
-   private ReplicationTrigger replicationTrigger_;
-
-   /**
-    * Whether we use batch mode replication for field level granularity.
-    * We store this in a Boolean rather than a primitive so JBossCacheCluster
-    * can determine if this was set via a <Manager> element.
-    */
-   private Boolean replicationFieldBatchMode_;
-   
-   /** Class loader for this web app. */
-   private ClassLoader tcl_;
-   
-   /** The snapshot manager we are using. */
-   private SnapshotManager snapshotManager_;
-   
-   /** The name of our cache's configuration */
-   private String cacheConfigName_;
-   
-   private int maxUnreplicatedInterval_ = -1;
-
-   private String notificationPolicyClass_;
-   private ClusteredSessionNotificationPolicy notificationPolicy_;
-   
-   private ReplicationConfig replicationConfig_;
-
-   //  ----------------------------------------------------------  Constructors
-
-   public JBossCacheManager() throws ClusteringNotSupportedException
-   {
-      this(DistributedCacheManagerFactoryFactory.getInstance().getDistributedCacheManagerFactory());
-   }
-   
-   public JBossCacheManager(DistributedCacheManagerFactory distributedManagerFactory)
-   {
-      assert distributedManagerFactory != null : "distributedManagerFactory is null";
-      
-      this.distributedCacheManagerFactory = distributedManagerFactory;
-   }
-
-   // ---------------------------------------------------- AbstractJBossManager
-
-   /**
-    * {@inheritDoc}
-    * <p>
-    * <strong>NOTE:</strong> This method should not be called when
-    * running unembedded.
-    * </p>
-    */
-   @Override
-   public void init(String name, JBossWebMetaData webMetaData)
-      throws ClusteringNotSupportedException
-   {
-      super.init(name, webMetaData);
-      
-      this.replicationConfig_ = webMetaData.getReplicationConfig();
-      this.replicationTrigger_ = replicationConfig_.getReplicationTrigger();
-      this.replicationGranularity_ = replicationConfig_.getReplicationGranularity();
-      
-      // Only configure JK usage if it was explicitly set; otherwise
-      // wait until we're starting when we can check for a jvmRoute
-      // in our containing Engine
-      Boolean jk = replicationConfig_.getUseJK();
-      if (jk != null)
-      {
-         this.useJK_ = jk;
-      }
-      
-      Boolean batch = replicationConfig_.getReplicationFieldBatchMode();
-      this.replicationFieldBatchMode_ = (batch == null ? Boolean.TRUE : batch);
-      setSnapshotMode(replicationConfig_.getSnapshotMode());
-      Integer snapshotInt = replicationConfig_.getSnapshotInterval();
-      setSnapshotInterval(snapshotInt == null ? 0 : snapshotInt.intValue());
-      
-      Integer maxUnrep = replicationConfig_.getMaxUnreplicatedInterval();
-      if (maxUnrep != null)
-      {
-         this.maxUnreplicatedInterval_ = maxUnrep.intValue();
-      }
-      
-      log_.debug("init(): replicationGranularity_ is " + replicationGranularity_ +
-         " and replicationTrigger is " + replicationTrigger_ +
-         " and replicationFieldBatchMode is " + replicationFieldBatchMode_ +
-         " and useJK is " + useJK_ +
-         " and snapshotMode is " + snapshotMode_ +
-         " and snapshotInterval is " + snapshotInterval_);     
-      
-      this.cacheConfigName_ = replicationConfig_.getCacheName();
-      
-      this.notificationPolicyClass_ = replicationConfig_.getSessionNotificationPolicy();
-      
-      // Initing the proxy would be better in start, but we do it here so we
-      // can detect ClusteringNotSupportedException at this deploy stage
-      initCacheProxy();
-
-      embedded_ = true;
-   }
-
-   /**
-    * {@inheritDoc}
-    * <p>
-    * Removes the session from this Manager's collection of actively managed
-    * sessions.  Also removes the session from this server's copy of the
-    * distributed cache (but does not remove it from other servers'
-    * distributed cache).
-    * </p>
-    */
-   public void removeLocal(Session session)
-   {
-      ClusteredSession clusterSess = (ClusteredSession) session;
-      synchronized (clusterSess)
-      {
-         String realId = clusterSess.getRealId();
-         if (realId == null) return;
-
-         if (trace_)
-         {
-            log_.trace("Removing session from local store with id: " + realId);
-         }
-
-         try {
-            // Ignore any cache notifications that our own work generates
-            SessionReplicationContext.startCacheActivity();
-            clusterSess.removeMyselfLocal();
-         }
-         finally
-         {
-            SessionReplicationContext.finishCacheActivity();
-            
-            // We don't want to replicate this session at the end
-            // of the request; the removal process took care of that
-            SessionReplicationContext.sessionExpired(clusterSess, realId, snapshotManager_);
-            
-            sessions_.remove(realId);
-            stats_.removeStats(realId);
-
-            // Compute how long this session has been alive, and update
-            // our statistics accordingly
-            int timeAlive = (int) ((System.currentTimeMillis() - clusterSess.getCreationTimeInternal())/1000);
-            sessionExpired(timeAlive);
-         }
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public boolean storeSession(Session baseSession)
-   {
-      boolean stored = false;
-      if(baseSession != null && started_)
-      {
-         ClusteredSession session = (ClusteredSession) baseSession;
-
-         synchronized (session)
-         {
-            if (trace_)
-            {
-               log_.trace("check to see if needs to store and replicate " +
-                          "session with id " + session.getIdInternal());
-            }
-
-            if (session.isValid() &&
-                  (session.isSessionDirty() || session.getMustReplicateTimestamp()))
-            {
-               String realId = session.getRealId();
-
-               // Notify all session attributes that they get serialized (SRV 7.7.2)
-               long begin = System.currentTimeMillis();
-               session.notifyWillPassivate(ClusteredSessionNotificationCause.REPLICATION);
-               long elapsed = System.currentTimeMillis() - begin;
-               stats_.updatePassivationStats(realId, elapsed);
-
-               // Do the actual replication
-               begin = System.currentTimeMillis();
-               processSessionRepl(session);
-               elapsed = System.currentTimeMillis() - begin;
-               stored = true;
-               stats_.updateReplicationStats(realId, elapsed);
-            }
-            else if (trace_)
-            {
-               log_.trace("Session " + session.getIdInternal() + 
-                          " did not require replication.");
-            }
-         }
-      }
-
-      return stored;
-   }
-
-   // ----------------------------------------------------------------- Manager
-
-   /**
-    * {@inheritDoc}
-    */
-   public void add(Session session)
-   {
-      if (session == null)
-         return;
-
-      if (!(session instanceof ClusteredSession))
-      {
-         throw new IllegalArgumentException("You can only add instances of " +
-               "type ClusteredSession to this Manager. Session class name: " +
-               session.getClass().getName());
-      }
-
-//      add((ClusteredSession) session, true);
-      add((ClusteredSession) session, false); // wait to replicate until req end
-   }
-
-   // Satisfy the Manager interface.  Internally we use
-   // createEmptyClusteredSession to avoid a cast
-   public Session createEmptySession()
-   {
-      if (trace_)
-      {
-         log_.trace("Creating an empty ClusteredSession");
-      }
-      
-      return createEmptyClusteredSession();
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public Session createSession()
-   {
-      return createSession(null);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public Session createSession(String sessionId)
-   {      
-      // First check if we've reached the max allowed sessions, 
-      // then try to expire/passivate sessions to free memory
-      // maxActiveAllowed_ -1 is unlimited
-      // We check here for maxActive instead of in add().  add() gets called
-      // when we load an already existing session from the distributed cache
-      // (e.g. in a failover) and we don't want to fail in that situation.
-
-      if(maxActiveAllowed_ != -1 && calcActiveSessions() >= maxActiveAllowed_)
-      {
-         if (trace_)
-         {
-            log_.trace("createSession(): active sessions = " + calcActiveSessions() +
-                       " and max allowed sessions = " + maxActiveAllowed_);
-         }
-         
-         processExpirationPassivation();
-         
-         if (calcActiveSessions() >= maxActiveAllowed_)
-         {
-            // Exceeds limit. We need to reject it.
-            rejectedCounter_.incrementAndGet();
-            // Catalina api does not specify what happens
-            // but we will throw a runtime exception for now.
-            String msgEnd = (sessionId == null) ? "" : " id " + sessionId;
-            throw new IllegalStateException("createSession(): number of " +
-                   "active sessions exceeds the maximum limit: " +
-                   maxActiveAllowed_ + " when trying to create session" + msgEnd);
-         }
-      }
-
-      ClusteredSession session = createEmptyClusteredSession();
-
-      session.setNew(true);
-      session.setCreationTime(System.currentTimeMillis());
-      session.setMaxInactiveInterval(this.maxInactiveInterval_);
-      session.setValid(true);
-
-      if (sessionId == null)
-      {
-          sessionId = this.getNextId();
-
-          // We are using mod_jk for load balancing. Append the JvmRoute.
-          if (getUseJK())
-          {
-              if (trace_)
-              {
-                  log_.trace("createSession(): useJK is true. Will append JvmRoute: " + this.getJvmRoute());
-              }
-              sessionId += "." + this.getJvmRoute();
-          }
-      }
-
-      session.setId(sessionId); // Setting the id leads to a call to add()
-      
-      getDistributedCacheManager().sessionCreated(session);
-      
-      session.tellNew(ClusteredSessionNotificationCause.CREATE);
-
-      if (trace_)
-      {
-         log_.trace("Created a ClusteredSession with id: " + sessionId);
-      }
-
-      createdCounter_.incrementAndGet(); // the call to add() handles the other counters 
-      
-      // Add this session to the set of those potentially needing replication
-      SessionReplicationContext.bindSession(session, snapshotManager_);
-      
-      return session;
-   }
-
-   /**
-    * Attempts to find the session in the collection of those being managed
-    * locally, and if not found there, in the distributed cache of sessions.
-    * <p>
-    * If a session is found in the distributed cache, it is added to the
-    * collection of those being managed locally.
-    * </p>
-    *
-    * @param id the session id, which may include an appended jvmRoute
-    *
-    * @return the session, or <code>null</code> if no such session could
-    *         be found
-    */
-   public Session findSession(String id)
-   {
-      String realId = getRealId(id);
-      // Find it from the local store first
-      ClusteredSession session = findLocalSession(realId);
-      
-      // If we didn't find it locally, only check the distributed cache
-      // if we haven't previously handled this session id on this request.
-      // If we handled it previously but it's no longer local, that means
-      // it's been invalidated. If we request an invalidated session from
-      // the distributed cache, it will be missing from the local cache but
-      // may still exist on other nodes (i.e. if the invalidation hasn't 
-      // replicated yet because we are running in a tx). With buddy replication,
-      // asking the local cache for the session will cause the out-of-date
-      // session from the other nodes to be gravitated, thus resuscitating
-      // the session.
-      if (session == null 
-            && !SessionReplicationContext.isSessionBoundAndExpired(realId, snapshotManager_))
-      {
-         if (trace_)
-            log_.trace("Checking for session " + realId + " in the distributed cache");
-         
-         session = loadSession(realId);
-//       if (session != null)
-//       {
-//          add(session);
-//          // We now notify, since we've added a policy to allow listeners 
-//          // to discriminate. But the default policy will not allow the 
-//          // notification to be emitted for FAILOVER, so the standard
-//          // behavior is unchanged.
-//          session.tellNew(ClusteredSessionNotificationCause.FAILOVER);
-//       }
-      }
-      else if (session != null && session.isOutdated())
-      {
-         if (trace_)
-            log_.trace("Updating session " + realId + " from the distributed cache");
-         
-         // Need to update it from the cache
-         loadSession(realId);
-      }
-
-      if (session != null)
-      {
-         // Add this session to the set of those potentially needing replication
-         SessionReplicationContext.bindSession(session, snapshotManager_);
-         
-         // If we previously called passivate() on the session due to
-         // replication, we need to make an offsetting activate() call
-         if (session.getNeedsPostReplicateActivation())
-         {
-            session.notifyDidActivate(ClusteredSessionNotificationCause.REPLICATION);
-         }
-      }
-
-      return session;
-   }
-
-   /**
-    * Return the sessions. Note that this will return not only the local
-    * in-memory sessions, but also any sessions that are in the distributed
-    * cache but have not previously been accessed on this server.  Invoking
-    * this method will bring all such sessions into local memory and can
-    * potentially be quite expensive.
-    *
-    * <p>
-    * Note also that when sessions are loaded from the distributed cache, no
-    * check is made as to whether the number of local sessions will thereafter
-    * exceed the maximum number allowed on this server.
-    * </p>
-    *
-    * @return an array of all the sessions
-    */
-   public Session[] findSessions()
-   {
-      // Need to load all the unloaded sessions
-      if(unloadedSessions_.size() > 0)
-      {
-         // Make a thread-safe copy of the new id list to work with
-         Set<String> ids = new HashSet<String>(unloadedSessions_.keySet());
-
-         if(trace_) {
-            log_.trace("findSessions: loading sessions from distributed cache: " + ids);
-         }
-
-         for(String id :  ids) {
-            loadSession(id);
-         }
-      }
-
-      // All sessions are now "local" so just return the local sessions
-      return findLocalSessions();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public String getInfo()
-   {
-      return info_;
-   }
-
-   /**
-    * Removes the session from this Manager's collection of actively managed
-    * sessions.  Also removes the session from the distributed cache, both
-    * on this server and on all other server to which this one replicates.
-    */
-   public void remove(Session session)
-   {
-      ClusteredSession clusterSess = (ClusteredSession) session;
-      synchronized (clusterSess)
-      {
-         String realId = clusterSess.getRealId();
-         if (realId == null)
-            return;
-
-         if (trace_)
-         {
-            log_.trace("Removing session from store with id: " + realId);
-         }
-
-         try {
-            // Ignore any cache notifications that our own work generates
-            SessionReplicationContext.startCacheActivity();
-            clusterSess.removeMyself();
-         }
-         finally {
-            SessionReplicationContext.finishCacheActivity();
-            
-            // We don't want to replicate this session at the end
-            // of the request; the removal process took care of that
-            SessionReplicationContext.sessionExpired(clusterSess, realId, snapshotManager_);
-            
-            sessions_.remove(realId);
-            stats_.removeStats(realId);
-
-            // Compute how long this session has been alive, and update
-            // our statistics accordingly
-            int timeAlive = (int) ((System.currentTimeMillis() - clusterSess.getCreationTimeInternal())/1000);
-            sessionExpired(timeAlive);
-         }
-      }
-   }
-
-   // -------------------------------------------------------  ClusteredManager
-
-   /**
-    * Gets the <code>JBossCacheService</code> through which we interact
-    * with the <code>Cache</code>.
-    */
-   public DistributedCacheManager getDistributedCacheManager()
-   {
-      return proxy_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public int getMaxUnreplicatedInterval()
-   {
-      return maxUnreplicatedInterval_;
-   }
-
-   public ClusteredSessionNotificationPolicy getNotificationPolicy()
-   {
-      return notificationPolicy_;
-   }    
-   
-   /**
-    * {@inheritDoc}
-    */
-   public ReplicationTrigger getReplicationTrigger()
-   {
-      return this.replicationTrigger_;
-   }
-
-   // --------------------------------------------------------------- Lifecycle
-   
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   public void start() throws LifecycleException
-   {
-      // Identify ourself more clearly
-      log_ = Logger.getLogger(getClass().getName() + "." + 
-                              getContainer().getName().replaceAll("/", ""));
-      
-      if (embedded_)
-      {
-         startEmbedded();
-      }
-      else
-      {
-         startUnembedded();
-      }
-      
-      log_.debug("Started");
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   public void stop() throws LifecycleException
-   {
-      if (!started_)
-      {
-         throw new IllegalStateException("Manager not started");
-      }
-      
-      log_.debug("Stopping");
-      
-      // Block for any ongoing backgroundProcess, then disable
-      synchronized (backgroundProcessAllowed)
-      {
-         backgroundProcessAllowed.set(false);
-      }
-      
-      resetStats();
-      
-      // Notify our interested LifecycleListeners
-      lifecycle_.fireLifecycleEvent(BEFORE_STOP_EVENT, this);
-      
-      clearSessions();
-      
-      // Don't leak the classloader
-      tcl_ = null;
-      
-      proxy_.stop();
-      proxy_ = null;
-      
-      batchingManager = null;
-      
-      snapshotManager_.stop();
-      
-      // Clean up maps
-      sessions_.clear();
-      unloadedSessions_.clear();
-      
-      passivatedCount_.set(0);
-      
-      started_ = false;
-      
-      // Notify our interested LifecycleListeners
-      lifecycle_.fireLifecycleEvent(AFTER_STOP_EVENT, this);
-      
-      unregisterManagerMBean();
-   }
-   
-
-   // -------------------------------------------------- JBossCacheManagerMBean
-
-   /**
-    * {@inheritDoc}
-    */
-   public void expireSession(String sessionId)
-   {
-      Session session = findSession(sessionId);
-      if (session != null)
-         session.expire();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public String getCacheConfigName()
-   {
-      return cacheConfigName_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public String getCreationTime(String sessionId)
-   {
-      Session session = findSession(sessionId);
-      if(session == null) 
-      {
-         log_.info("getCreationTime(): Session " + sessionId + 
-                       " not found");
-         return "";
-      }
-     return new Date(session.getCreationTime()).toString();
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public int getDuplicates()
-   {
-      return duplicates_.get();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public String getLastAccessedTime(String sessionId)
-   {
-      Session session = findSession(sessionId);
-      if(session == null) {
-         log_.info("getLastAccessedTime(): Session " + sessionId + 
-                   " not found");
-         return "";
-      }
-     return new Date(session.getLastAccessedTime()).toString();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public String getSessionAttribute(String sessionId, String key)
-   {
-      Object attr = null;
-      ClusteredSession session = (ClusteredSession) findSession(sessionId);
-      if (session != null)
-      {
-         attr = session.getAttribute(key);
-      }
-      
-      return attr == null ? null : attr.toString();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public long getMaxPassivatedSessionCount()
-   {
-      return maxPassivatedCount_.get();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
-   {
-      this.maxUnreplicatedInterval_ = maxUnreplicatedInterval;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public long getPassivatedSessionCount()
-   {
-      return passivatedCount_.get();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public long getPassivationMaxIdleTime()
-   {
-      return passivationMaxIdleTime_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public long getPassivationMinIdleTime()
-   {
-      return passivationMinIdleTime_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public ReplicationGranularity getReplicationGranularity()
-   {
-      return replicationGranularity_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public int getSnapshotInterval()
-   {
-      return snapshotInterval_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public SnapshotMode getSnapshotMode()
-   {
-      return snapshotMode_;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public boolean getUseJK()
-   {
-      return useJK_ == null ? false : useJK_.booleanValue();
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public boolean isPassivationEnabled()
-   {
-      return (passivationMode_ && proxy_.isPassivationEnabled());
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public Boolean isReplicationFieldBatchMode()
-   {
-      return replicationFieldBatchMode_;
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public String listLocalSessionIds()
-   {
-      return reportSessionIds(sessions_.keySet());
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
-   public String listSessionIds()
-   {
-      Set<String> ids = new HashSet<String>(sessions_.keySet());
-      ids.addAll(unloadedSessions_.keySet());
-      return reportSessionIds(ids);
-   }
-   
-   // --------------------------------------- LocalDistributableSessionManager
-
-   public String getContextName()
-   {
-      return getContainer().getName();
-   }
-   
-   public String getHostName()
-   {
-      return getContainer().getParent().getName();
-   }
-   
-   public ClassLoader getApplicationClassLoader()
-   {
-      return tcl_;
-   }
-   
-   public ReplicationConfig getReplicationConfig()
-   {
-      return replicationConfig_;
-   }
-   
-   /**
-    * Notifies the manager that a session in the distributed cache has
-    * been invalidated
-    * 
-    * @param realId the session id excluding any jvmRoute
-    */
-   public void notifyRemoteInvalidation(String realId)
-   {
-      // Remove the session from our local map
-      ClusteredSession session = (ClusteredSession) sessions_.remove(realId);
-      if (session == null)
-      {
-         // We weren't managing the session anyway.  But remove it
-         // from the list of cached sessions we haven't loaded
-         if (unloadedSessions_.remove(realId) != null)
-         {
-            if (trace_)
-               log_.trace("Removed entry for session " + realId + " from unloaded session map");
-         }
-      }
-      else
-      {
-         // Expire the session
-         // DON'T SYNCHRONIZE ON SESSION HERE -- isValid() and
-         // expire() are meant to be multi-threaded and synchronize
-         // properly internally; synchronizing externally can lead
-         // to deadlocks!!
-         boolean notify = false; // Don't notify listeners. SRV.10.7
-                                 // allows this, and sending notifications
-                                 // leads to all sorts of issues; e.g.
-                                 // circular calls with ClusteredSSO
-         boolean localCall = false; // this call originated from the cache;
-                                    // we have already removed session
-         boolean localOnly = true; // Don't pass attr removals to cache
-         
-         // Ensure the correct TCL is in place
-         ContextClassLoaderSwitcher.SwitchContext switcher = null;
-         try
-         {
-            switcher = getContextClassLoaderSwitcher().getSwitchContext();
-            switcher.setClassLoader(tcl_);
-            session.expire(notify, localCall, localOnly, ClusteredSessionNotificationCause.INVALIDATE);
-         }
-         finally
-         {
-            if (switcher != null)
-            {
-               switcher.reset();
-            }
-         }
-
-         // Remove any stats for this session
-         stats_.removeStats(realId);
-      }
-   }
-   
-   /**
-    * Callback from the distributed cache notifying of a local modification
-    * to a session's attributes.  Meant for use with FIELD granularity,
-    * where the session may not be aware of modifications.
-    * 
-    * @param realId the session id excluding any jvmRoute
-    */
-   public void notifyLocalAttributeModification(String realId)
-   {
-      ClusteredSession session = (ClusteredSession) sessions_.get(realId);
-      if (session != null)
-      {
-         session.sessionAttributesDirty();
-      }
-      else
-      {
-         log_.warn("Received local attribute notification for " + realId + 
-               " but session is not locally active");
-      }
-   }
-   
-   public void sessionActivated()
-   {
-      int pc = passivatedCount_.decrementAndGet();
-      // Correct for drift since we don't know the true passivation
-      // count when we started.  We can get activations of sessions
-      // we didn't know were passivated.
-      // FIXME -- is the above statement still correct? Is this needed?
-      if (pc < 0) 
-      {
-         // Just reverse our decrement.
-         passivatedCount_.incrementAndGet();
-      }
-   }
-   
-   /**
-    * Callback from the distributed cache to notify us that a session
-    * has been modified remotely.
-    * 
-    * @param realId the session id, without any trailing jvmRoute
-    * @param dataOwner  the owner of the session.  Can be <code>null</code> if
-    *                   the owner is unknown.
-    * @param distributedVersion the session's version per the distributed cache
-    * @param timestamp the session's timestamp per the distributed cache
-    * @param metadata the session's metadata per the distributed cache
-    */
-   public boolean sessionChangedInDistributedCache(String realId, 
-                                         String dataOwner,
-                                         int distributedVersion,
-                                         long timestamp, 
-                                         DistributableSessionMetadata metadata)
-   {
-      boolean updated = true;
-      
-      ClusteredSession session = findLocalSession(realId);
-      if (session != null)
-      {
-         // Need to invalidate the loaded session. We get back whether
-         // this an actual version increment
-         updated = session.setVersionFromDistributedCache(distributedVersion);
-         if (updated && trace_)      
-         {            
-            log_.trace("session in-memory data is invalidated for id: " + realId + 
-                       " new version: " + distributedVersion);
-         }         
-      }
-      else
-      {
-         int maxLife = metadata == null ? getMaxInactiveInterval() : metadata.getMaxInactiveInterval();
-         
-         Object existing = unloadedSessions_.put(realId, new OwnedSessionUpdate(dataOwner, timestamp, maxLife, false));
-         if (existing == null)
-         {
-            calcActiveSessions();
-            if (trace_)
-            {
-               log_.trace("New session " + realId + " added to unloaded session map");
-            }
-         }
-         else if (trace_)
-         {
-            log_.trace("Updated timestamp for unloaded session " + realId);
-         }
-      }
-      
-      return updated;
-   }
-   
-   // ----------------------------------------------- JBossCacheCluster Support
-
-   /**
-    * Sets how often session changes should be replicated to other nodes.
-    *
-    * @param snapshotInterval the number of milliseconds between
-    *                         session replications.
-    */
-   public void setSnapshotInterval(int snapshotInterval)
-   {
-      this.snapshotInterval_ = snapshotInterval;
-   }
-
-   /**
-    * Sets when sessions are replicated to the other nodes. Valid values are:
-    * <ul>
-    * <li>instant</li>
-    * <li>interval</li>
-    * </ul>
-    */
-   public void setSnapshotMode(SnapshotMode snapshotMode)
-   {
-      this.snapshotMode_ = snapshotMode;
-   }
-
-   /**
-    * Sets whether the <code>Engine</code> in which we are running
-    * uses <code>mod_jk</code>.
-    */
-   public void setUseJK(boolean useJK)
-   {
-      this.useJK_ = Boolean.valueOf(useJK);
-   }
-
-   /**
-    * Sets the granularity of session data replicated across the cluster.
-    * Valid values are:
-    * <ul>
-    * <li>SESSION</li>
-    * <li>ATTRIBUTE</li>
-    * <li>FIELD</li>
-    * </ul>
-    */
-   public void setReplicationGranularity(ReplicationGranularity granularity)
-   {
-      this.replicationGranularity_ = granularity;
-   }
-
-   /**
-    * Returns the replication granularity.
-    *
-    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_ATTRIBUTE
-    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_FIELD
-    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_SESSION
-    */
-   public String getReplicationGranularityString()
-   {
-      return replicationGranularity_ == null ? null : replicationGranularity_.toString();
-   }
-
-   /**
-    * Sets the granularity of session data replicated across the cluster.
-    * Valid values are:
-    * <ul>
-    * <li>SESSION</li>
-    * <li>ATTRIBUTE</li>
-    * <li>FIELD</li>
-    * </ul>
-    */
-   public void setReplicationGranularityString(String granularity)
-   {
-      setReplicationGranularity(granularity == null ? null : 
-                  ReplicationGranularity.fromString(granularity.toUpperCase()));
-   } 
-   
-   /**
-    * Sets the type of operations on a <code>HttpSession</code> that
-    * trigger replication.  Valid values are:
-    * <ul>
-    * <li>SET_AND_GET</li>
-    * <li>SET_AND_NON_PRIMITIVE_GET</li>
-    * <li>SET</li>
-    * </ul>
-    */
-   public void setReplicationTrigger(ReplicationTrigger trigger)
-   {
-      this.replicationTrigger_ = trigger;
-   }
-
-   public String getReplicationTriggerString()
-   {      
-      return replicationTrigger_ == null ? null : replicationTrigger_.toString();
-   }
-
-   public void setReplicationTriggerString(String trigger)
-   {      
-      setReplicationTrigger(trigger == null ? null : ReplicationTrigger.fromString(trigger.toUpperCase()));
-   }
-
-   /**
-    * Sets whether, if replication granularity is set to <code>FIELD</code>,
-    * replication should be done in batch mode.  Ignored if field-level
-    * granularity is not used.
-    */
-   public void setReplicationFieldBatchMode(boolean replicationFieldBatchMode)
-   {
-      this.replicationFieldBatchMode_ = Boolean.valueOf(replicationFieldBatchMode);
-   }
-
-   // --------------------------------------------------------------- Overrides
-
-   /**
-    * {@inheritDoc}
-    * <p>
-    * Overrides the superclass version to ensure that the generated id
-    * does not duplicate the id of any other session this manager is aware of.
-    * </p>
-    */
-   @Override
-   protected String getNextId()
-   {
-      while (true)
-      {
-         String id = super.getNextId();
-         if (sessions_.containsKey(id) || unloadedSessions_.containsKey(id))
-         {
-            duplicates_.incrementAndGet();
-         }
-         else
-         {
-            return id;
-         }
-      }
-   }
-
-   protected int getTotalActiveSessions()
-   {
-      return localActiveCounter_.get() + unloadedSessions_.size() - passivatedCount_.get();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected void processExpirationPassivation()
-   {      
-      boolean expire = maxInactiveInterval_ >= 0;
-      boolean passivate = isPassivationEnabled();
-      
-      long passivationMax = passivationMaxIdleTime_ * 1000L;
-      long passivationMin = passivationMinIdleTime_ * 1000L;
-
-      if (trace_)
-      { 
-         log_.trace("processExpirationPassivation(): Looking for sessions that have expired ...");
-         log_.trace("processExpirationPassivation(): active sessions = " + calcActiveSessions());
-         log_.trace("processExpirationPassivation(): expired sessions = " + expiredCounter_);
-         if (passivate)
-         {
-            log_.trace("processExpirationPassivation(): passivated count = " + getPassivatedSessionCount());
-         }
-      }
-      
-      // Holder for sessions or OwnedSessionUpdates that survive expiration,
-      // sorted by last acccessed time
-      TreeSet<PassivationCheck> passivationChecks = new TreeSet<PassivationCheck>();
-      
-      try
-      {
-         // First, handle the sessions we are actively managing
-         Session sessions[] = findLocalSessions();
-         for (int i = 0; i < sessions.length; ++i)
-         {
-            try
-            {
-               ClusteredSession session = (ClusteredSession) sessions[i];
-               if(session == null)
-               {
-                  log_.warn("processExpirationPassivation(): processing null session at index " +i);
-                  continue;
-               }
-
-               if (expire)
-               {
-                  // JBAS-2403. Check for outdated sessions where we think
-                  // the local copy has timed out.  If found, refresh the
-                  // session from the cache in case that might change the timeout
-                  if (session.isOutdated() && !(session.isValid(false)))
-                  {
-                     // JBAS-2792 don't assign the result of loadSession to session
-                     // just update the object from the cache or fall through if
-                     // the session has been removed from the cache
-                     loadSession(session.getRealId());
-                  }
-   
-                  // Do a normal invalidation check that will expire the
-                  // session if it has timed out
-                  // DON'T SYNCHRONIZE on session here -- isValid() and
-                  // expire() are meant to be multi-threaded and synchronize
-                  // properly internally; synchronizing externally can lead
-                  // to deadlocks!!
-                  if (!session.isValid()) continue;
-               }
-                
-               // we now have a valid session; store it so we can check later
-               // if we need to passivate it
-               if (passivate)
-               {
-                  passivationChecks.add(new PassivationCheck(session));
-               }
-               
-            }
-            catch (Exception ex)
-            {
-               log_.error("processExpirationPassivation(): failed handling " + 
-                          sessions[i].getIdInternal() + " with exception: " + 
-                          ex, ex);
-            }
-         }
-
-         // Next, handle any unloaded sessions
-
-         
-         // We may have not gotten replication of a timestamp for requests 
-         // that occurred w/in maxUnreplicatedInterval_ of the previous
-         // request. So we add a grace period to avoid flushing a session early
-         // and permanently losing part of its node structure in JBoss Cache.
-         long maxUnrep = maxUnreplicatedInterval_ < 0 ? 60 : maxUnreplicatedInterval_;
-         
-         Map<String, OwnedSessionUpdate> unloaded = new HashMap<String, OwnedSessionUpdate>(unloadedSessions_);
-         for (Map.Entry<String, OwnedSessionUpdate> entry : unloaded.entrySet())
-         {
-            String realId = entry.getKey();
-            OwnedSessionUpdate osu = entry.getValue();
-            
-            long now = System.currentTimeMillis();
-            long elapsed = (now - osu.updateTime);
-            try
-            {
-               if (expire && osu.maxInactive >= 1 && elapsed >= (osu.maxInactive + maxUnrep) * 1000L)
-               {
-                  if (osu.passivated)
-                  {
-                     // Passivated session needs to be expired. A call to 
-                     // findSession will bring it out of passivation
-                     Session session = findSession(realId);
-                     if (session != null)
-                     {
-                        session.isValid(); // will expire
-                        continue;
-                     }
-                  }
-                  
-                  // If we get here either !osu.passivated, or the session
-                  // couldn't be reactivated (invalidated by user). 
-                  // Either way, do a cleanup
-                  proxy_.removeSessionLocal(realId, osu.owner);
-                  unloadedSessions_.remove(realId);
-                  
-               }
-               else if (passivate && !osu.passivated)
-               {  
-                  // we now have a valid session; store it so we can check later
-                  // if we need to passivate it
-                  passivationChecks.add(new PassivationCheck(realId, osu));
-               }
-            } 
-            catch (Exception ex)
-            {
-               log_.error("processExpirationPassivation(): failed handling unloaded session " + 
-                       realId, ex);
-            }
-         }
-         
-         // Now, passivations
-         if (passivate)
-         {
-            // Iterate through sessions, earliest lastAccessedTime to latest
-            for (PassivationCheck passivationCheck : passivationChecks)
-            {               
-               try
-               {
-                  long timeNow = System.currentTimeMillis();
-                  long timeIdle = timeNow - passivationCheck.getLastUpdate();
-                  // if maxIdle time configured, means that we need to passivate sessions that have
-                  // exceeded the max allowed idle time
-                  if (passivationMax >= 0 
-                        && timeIdle > passivationMax)
-                  {
-                     passivationCheck.passivate();
-                  }
-                  // If the session didn't exceed the passivationMaxIdleTime_, see   
-                  // if the number of sessions managed by this manager greater than the max allowed 
-                  // active sessions, passivate the session if it exceed passivationMinIdleTime_ 
-                  else if (maxActiveAllowed_ > 0 
-                              && passivationMin > 0 
-                              && calcActiveSessions() >= maxActiveAllowed_ 
-                              && timeIdle > passivationMin)
-                  {
-                     passivationCheck.passivate();
-                  }
-                  else
-                  {
-                     // the entries are ordered by lastAccessed, so once
-                     // we don't passivate one, we won't passivate any
-                     break;
-                  }
-               }
-               catch (Exception e)
-               {
-                  String unloadMark = passivationCheck.isUnloaded() ? "unloaded " : "";
-                  log_.error("processExpirationPassivation(): failed passivating " + unloadMark + "session " + 
-                        passivationCheck.getRealId(), e);
-               }                  
-            }
-         }
-      }
-      catch (Exception ex)
-      {
-         log_.error("processExpirationPassivation(): failed with exception: " + ex, ex);
-      }
-      
-      if (trace_)
-      { 
-         log_.trace("processExpirationPassivation(): Completed ...");
-         log_.trace("processExpirationPassivation(): active sessions = " + calcActiveSessions());
-         log_.trace("processExpirationPassivation(): expired sessions = " + expiredCounter_);
-         if (passivate)
-         {
-            log_.trace("processExpirationPassivation(): passivated count = " + getPassivatedSessionCount());
-         }
-      }
-   }
-   
-   @Override
-   public void resetStats()
-   {
-      super.resetStats();
-      
-      this.maxPassivatedCount_.set(this.passivatedCount_.get());
-   }
-   
-   // ------------------------------------------------------ Session Management
-
-   private ClusteredSession createEmptyClusteredSession()
-   {     
-
-      ClusteredSession session = null;
-      switch (replicationGranularity_)
-      {
-         case ATTRIBUTE:
-         session = new AttributeBasedClusteredSession(this);
-            break;
-         case FIELD:
-            session = new FieldBasedClusteredSession(this);
-            break;
-         default:
-            session = new SessionBasedClusteredSession(this);
-            break;
-      }
-      return session;
-   }
-
-   /**
-    * Adds the given session to the collection of those being managed by this
-    * Manager.
-    *
-    * @param session   the session. Cannot be <code>null</code>.
-    * @param replicate whether the session should be replicated
-    *
-    * @throws NullPointerException if <code>session</code> is <code>null</code>.
-    */
-   private void add(ClusteredSession session, boolean replicate)
-   {
-      // TODO -- why are we doing this check? The request checks session 
-      // validity and will expire the session; this seems redundant
-      if (!session.isValid())
-      {
-         // Not an error; this can happen if a failover request pulls in an
-         // outdated session from the distributed cache (see TODO above)
-         log_.debug("Cannot add session with id=" + session.getIdInternal() +
-                    " because it is invalid");
-         return;
-      }
-
-      String realId = session.getRealId();
-      Object existing = sessions_.put(realId, session);
-      unloadedSessions_.remove(realId);
-
-      if (!session.equals(existing))
-      {
-         if (replicate)
-         {
-            storeSession(session);
-         }
-
-         // Update counters
-         calcActiveSessions();
-         
-         if (trace_)
-         {
-            log_.trace("Session with id=" + session.getIdInternal() + " added. " +
-                       "Current active sessions " + localActiveCounter_.get());
-         }
-      }
-   }
-   
-   /**
-    * Loads a session from the distributed store.  If an existing session with
-    * the id is already under local management, that session's internal state
-    * will be updated from the distributed store.  Otherwise a new session
-    * will be created and added to the collection of those sessions under
-    * local management.
-    *
-    * @param realId  id of the session-id with any jvmRoute removed
-    *
-    * @return the session or <code>null</code> if the session cannot be found
-    *         in the distributed store
-    */
-   private ClusteredSession loadSession(String realId)
-   {
-      if (realId == null)
-      {
-         return null;
-      }
-
-      long begin = System.currentTimeMillis();
-      boolean mustAdd = false;
-      boolean passivated = false;
-      
-      ClusteredSession session = sessions_.get(realId);
-      
-      if (session == null)
-      {                 
-         // This is either the first time we've seen this session on this
-         // server, or we previously expired it and have since gotten
-         // a replication message from another server
-         mustAdd = true;
-         session = createEmptyClusteredSession();
-         
-         OwnedSessionUpdate osu = unloadedSessions_.get(realId);
-         passivated = (osu != null && osu.passivated);
-      }
-
-      synchronized (session)
-      {
-         ContextClassLoaderSwitcher.SwitchContext switcher = null; 
-         boolean doTx = false; 
-         try
-         {
-            // We need transaction so any data gravitation replication 
-            // is sent in batch.
-            // Don't do anything if there is already transaction context
-            // associated with this thread.
-            if (batchingManager.isBatchInProgress() == false)
-            {
-               batchingManager.startBatch();
-               doTx = true;
-            }
-            
-            // Ignore cache notifications we may generate for this 
-            // session if data gravitation occurs. 
-            SessionReplicationContext.startCacheActivity();
-            
-            // Tomcat calls Manager.findSession before setting the tccl,
-            // so we need to do it :(
-            switcher = getContextClassLoaderSwitcher().getSwitchContext();
-            switcher.setClassLoader(tcl_);
-            
-            session = proxy_.loadSession(realId, session);
-            
-            if (session != null)
-            {
-               ClusteredSessionNotificationCause cause = passivated ? ClusteredSessionNotificationCause.ACTIVATION 
-                                                                    : ClusteredSessionNotificationCause.FAILOVER;
-               session.notifyDidActivate(cause);
-            }
-         }
-         catch (Exception ex)
-         {
-            try
-            {
-//                  if(doTx)
-               // Let's set it no matter what.
-               batchingManager.setBatchRollbackOnly();
-            }
-            catch (Exception exn)
-            {
-               log_.error("Caught exception rolling back transaction", exn);
-            }
-            // We will need to alert Tomcat of this exception.
-            if (ex instanceof RuntimeException)
-               throw (RuntimeException) ex;
-            
-            throw new RuntimeException("loadSession(): failed to load session " +
-                                       realId, ex);
-         }
-         finally
-         {
-            try {
-               if(doTx)
-               {
-                  batchingManager.endBatch();
-               }
-            }
-            finally {
-               if (switcher != null)
-               {
-                  switcher.reset();
-               }
-               SessionReplicationContext.finishCacheActivity();
-            }
-         }
-
-         if (session != null)
-         {            
-            if (mustAdd)
-            {
-               add(session, false); // don't replicate
-               if (!passivated)
-               {
-                  session.tellNew(ClusteredSessionNotificationCause.FAILOVER);
-               }
-            }
-            long elapsed = System.currentTimeMillis() - begin;
-            stats_.updateLoadStats(realId, elapsed);
-
-            if (trace_)
-            {
-               log_.trace("loadSession(): id= " + realId + ", session=" + session);
-            }
-         }
-         else if (trace_)
-         {
-            log_.trace("loadSession(): session " + realId +
-                       " not found in distributed cache");
-         }
-      }
-
-      return session;
-   }
-
-   /**
-    * Places the current session contents in the distributed cache and
-    * replicates them to the cluster
-    *
-    * @param session  the session.  Cannot be <code>null</code>.
-    */
-   private void processSessionRepl(ClusteredSession session)
-   {
-      // If we are using SESSION granularity, we don't want to initiate a TX
-      // for a single put
-      boolean notSession = (replicationGranularity_ != ReplicationGranularity.SESSION);
-      boolean doTx = false;
-      try
-      {
-         // We need transaction so all the replication are sent in batch.
-         // Don't do anything if there is already transaction context
-         // associated with this thread.
-         if(notSession && batchingManager.isBatchInProgress() == false)
-         {
-            batchingManager.startBatch();
-            doTx = true;
-         }
-
-         // Tell the proxy to ignore cache notifications we are about
-         // to generate for this session. We have to do this
-         // at this level because we don't want to resume handling
-         // notifications until any compensating changes resulting
-         // from a tx rollback are done.
-         SessionReplicationContext.startCacheActivity();
-
-         session.processSessionReplication();
-      }
-      catch (Exception ex)
-      {
-         log_.debug("processSessionRepl(): failed with exception", ex);
-         
-         try
-         {
-            //if(doTx)
-            // Let's setRollbackOnly no matter what.
-            // (except if there's no tx due to SESSION (JBAS-3840))
-            if (notSession)
-               batchingManager.setBatchRollbackOnly();
-         }
-         catch (Exception exn)
-         {
-            log_.error("Caught exception rolling back transaction", exn);
-         }
-         
-         // We will need to alert Tomcat of this exception.
-         if (ex instanceof RuntimeException)
-            throw (RuntimeException) ex;
-         
-         throw new RuntimeException("JBossCacheManager.processSessionRepl(): " +
-                                    "failed to replicate session.", ex);
-      }
-      finally
-      {
-         try {
-            if(doTx)
-            {
-               batchingManager.endBatch();
-            }
-         }
-         finally {
-            SessionReplicationContext.finishCacheActivity();
-         }
-      }
-   }
-   
-   /**
-    * Session passivation logic for an actively managed session.
-    * 
-    * @param realId the session id, minus any jvmRoute
-    */
-   private void processSessionPassivation(String realId)
-   {
-      // get the session from the local map
-      ClusteredSession session = findLocalSession(realId);
-      // Remove actively managed session and add to the unloaded sessions
-      // if it's already unloaded session (session == null) don't do anything, 
-      if (session != null)
-      {
-         synchronized (session)
-         {
-            if (trace_)
-            {
-               log_.trace("Passivating session with id: " + realId);
-            }
-
-            try {
-               // Tell the proxy to ignore cache notifications we are about
-               // to generate for this session.
-               SessionReplicationContext.startCacheActivity();
-               session.notifyWillPassivate(ClusteredSessionNotificationCause.PASSIVATION);
-               proxy_.evictSession(realId);
-               sessionPassivated();
-            }
-            finally {
-               SessionReplicationContext.finishCacheActivity();
-            }
-            
-            // Put the session in the unloadedSessions map. This will
-            // expose the session to regular invalidation.
-            Object obj = unloadedSessions_.put(realId, 
-                  new OwnedSessionUpdate(null, session.getLastAccessedTime(), session.getMaxInactiveInterval(), true));
-            if (trace_)
-            {
-               if (obj == null)
-               {
-                  log_.trace("New session " + realId + " added to unloaded session map");
-               }
-               else
-               {
-                  log_.trace("Updated timestamp for unloaded session " + realId);
-               }
-            }
-            sessions_.remove(realId);
-         }
-      }
-      else if (trace_)
-      {
-         log_.trace("processSessionPassivation():  could not find session " + realId);
-      }
-   }
-   
-   /**
-    * Session passivation logic for sessions only in the distributed store.
-    * 
-    * @param realId the session id, minus any jvmRoute
-    */
-   private void processUnloadedSessionPassivation(String realId, OwnedSessionUpdate osu)
-   {
-      if (trace_)
-      {
-         log_.trace("Passivating session with id: " + realId);
-      }
-
-      try {
-         // Tell the proxy to ignore cache notifications we are about
-         // to generate for this session.
-         SessionReplicationContext.startCacheActivity();
-         proxy_.evictSession(realId, osu.owner);
-         osu.passivated = true;
-         sessionPassivated();
-      }
-      finally {
-         SessionReplicationContext.finishCacheActivity();
-      }
-      
-   }
-   
-   private void sessionPassivated()
-   {
-      int pc = passivatedCount_.incrementAndGet();
-      int max = maxPassivatedCount_.get();
-      while (pc > max)
-      {
-         if (!maxPassivatedCount_ .compareAndSet(max, pc))
-         {
-            max = maxPassivatedCount_.get();
-         }
-      }
-   }
-   
-   // -----------------------------------------------  Lifecyle When Unembedded
-
-   /**
-    * Start this Manager when running in standalone Tomcat.
-    */
-   private void startUnembedded() throws LifecycleException
-   {
-      if (started_)
-      {
-         return;
-      }
-      
-      log_.info("Manager is about to start");      
-
-      // Notify our interested LifecycleListeners
-      lifecycle_.fireLifecycleEvent(BEFORE_START_EVENT, this);
-      
-      if (snapshotMode_ == null) 
-      {
-         // We were not instantiated by a JBossCacheCluster, so we need to
-         // find one and let it configure our cluster-wide properties
-         try 
-         {
-            JBossCacheCluster cluster = (JBossCacheCluster) container_.getCluster();
-            cluster.configureManager(this);
-         }
-         catch (ClassCastException e)
-         {
-            String msg = "Cluster is not an instance of JBossCacheCluster";
-            log_.error(msg, e);
-            throw new LifecycleException(msg, e);
-         }
-      }      
-      
-      initClusteredSessionNotificationPolicy();
-      
-      // Create the JBossCacheService
-      try
-      {
-         if (replicationConfig_ == null)
-         {
-            synthesizeReplicationConfig();
-         }
-         
-         if (proxy_ == null)
-         {
-            initCacheProxy();
-         }
-         
-         // We need to pass the classloader that is associated with this 
-         // web app so de-serialization will work correctly.
-         tcl_ = container_.getLoader().getClassLoader();
-         proxy_.start();
-      }
-      catch (Throwable t)
-      {
-         String str = "Problem starting JBossCacheService for Tomcat clustering";
-         log_.error(str, t);
-         throw new LifecycleException(str, t);
-      }
-
-      batchingManager = proxy_.getBatchingManager();
-      if(batchingManager == null)
-      {
-         throw new LifecycleException("JBossCacheManager.start(): Obtain null batchingManager");
-      }
-      
-      try
-      {
-         initializeUnloadedSessions();
-
-         // Add SnapshotValve and, if needed, JvmRouteValve and batch repl valve
-         installValves();
-
-         started_ = true;
-         
-         // Notify our interested LifecycleListeners
-         lifecycle_.fireLifecycleEvent(AFTER_START_EVENT, this);
-         
-         log_.debug("start(): JBossCacheService started");
-      } 
-      catch (Exception e)
-      {
-         log_.error("Unable to start manager.", e);
-         throw new LifecycleException(e);
-      }
-      
-      registerManagerMBean();
-   }
-
-   /**
-    * Accesses the underlying cache and creates the proxy
-    * 
-    * @throws ClusteringNotSupportedException
-    */
-   private void initCacheProxy() throws ClusteringNotSupportedException
-   {
-      proxy_ = distributedCacheManagerFactory.getDistributedCacheManager(this);
-   }
-   
-   private void synthesizeReplicationConfig()
-   {
-      ReplicationConfig cfg = new ReplicationConfig();
-      cfg.setReplicationGranularity(replicationGranularity_);
-      cfg.setReplicationTrigger(replicationTrigger_);
-      cfg.setUseJK(useJK_);
-      cfg.setCacheName(cacheConfigName_);
-      cfg.setSnapshotMode(snapshotMode_);
-      cfg.setSnapshotInterval(Integer.valueOf(snapshotInterval_));
-      cfg.setMaxUnreplicatedInterval(Integer.valueOf(maxUnreplicatedInterval_));
-      cfg.setSessionNotificationPolicy(notificationPolicyClass_);      
-      this.replicationConfig_ = cfg;
-   }
-
-   private void initClusteredSessionNotificationPolicy()
-   {
-      if (this.notificationPolicyClass_ == null || this.notificationPolicyClass_.length() == 0)
-      {
-         this.notificationPolicyClass_ = System.getProperty("jboss.web.clustered.session.notification.policy",
-                                                            LegacyClusteredSessionNotificationPolicy.class.getName());
-      }
-      
-      try
-      {
-         this.notificationPolicy_ = (ClusteredSessionNotificationPolicy) Thread.currentThread().getContextClassLoader().loadClass(this.notificationPolicyClass_).newInstance();
-      }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Failed to instantiate " + 
-               ClusteredSessionNotificationPolicy.class.getName() + 
-               " " + this.notificationPolicyClass_, e);
-      }
-      
-      this.notificationPolicy_.setClusteredSessionNotificationCapability(new ClusteredSessionNotificationCapability());      
-   }
-   
-   /**
-    * Gets the ids of all sessions in the distributed cache and adds
-    * them to the unloaded sessions map, along with their lastAccessedTime
-    * and their maxInactiveInterval. Passivates overage or excess sessions.
-    */
-   private void initializeUnloadedSessions()
-   {      
-      Map<String, String> sessions = proxy_.getSessionIds();
-      if (sessions != null)
-      {
-         boolean passivate = isPassivationEnabled();
-
-         long passivationMax = passivationMaxIdleTime_ * 1000L;
-         long passivationMin = passivationMinIdleTime_ * 1000L;
-         
-         for (Map.Entry<String, String> entry : sessions.entrySet())
-         {
-            String realId = entry.getKey();
-            String owner = entry.getValue();
-
-            long ts = -1;
-            DistributableSessionMetadata md = null;
-            try
-            {
-               DistributableSessionData sessionData = proxy_.getSessionData(realId, owner, false);
-               ts = sessionData.getTimestamp();
-               md = sessionData.getMetadata();
-            }
-            catch (Exception e)
-            {
-               // most likely a lock conflict if the session is being updated remotely; 
-               // ignore it and use default values for timstamp and maxInactive
-               log_.debug("Problem reading metadata for session " + realId + " -- " + e.toString());               
-            }
-            
-            long lastMod = ts == -1 ? System.currentTimeMillis() : ts;
-            int maxLife = md == null ? getMaxInactiveInterval() : md.getMaxInactiveInterval();
-            
-            OwnedSessionUpdate osu = new OwnedSessionUpdate(owner, lastMod, maxLife, false);
-            unloadedSessions_.put(realId, osu);
-            if (passivate)
-            {
-               try
-               {
-                  long elapsed = System.currentTimeMillis() - lastMod;
-                  // if maxIdle time configured, means that we need to passivate sessions that have
-                  // exceeded the max allowed idle time
-                  if (passivationMax >= 0 
-                        && elapsed > passivationMax)
-                  {
-                     if (trace_)
-                     {
-                        log_.trace("Elapsed time of " + elapsed + " for session "+ 
-                              realId + " exceeds max of " + passivationMax + "; passivating");
-                     }
-                     processUnloadedSessionPassivation(realId, osu);
-                  }
-                  // If the session didn't exceed the passivationMaxIdleTime_, see   
-                  // if the number of sessions managed by this manager greater than the max allowed 
-                  // active sessions, passivate the session if it exceed passivationMinIdleTime_ 
-                  else if (maxActiveAllowed_ > 0 
-                              && passivationMin >= 0 
-                              && calcActiveSessions() > maxActiveAllowed_ 
-                              && elapsed >= passivationMin)
-                  {
-                     if (trace_)
-                     {
-                        log_.trace("Elapsed time of " + elapsed + " for session "+ 
-                              realId + " exceeds min of " + passivationMin + "; passivating");
-                     }
-                     processUnloadedSessionPassivation(realId, osu);
-                  }
-               }
-               catch (Exception e)
-               {
-                  // most likely a lock conflict if the session is being updated remotely; ignore it
-                  log_.debug("Problem passivating session " + realId + " -- " + e.toString());
-               }
-            }
-         }
-      }
-   }
-
-   /**
-    * Instantiate a SnapshotManager and ClusteredSessionValve and add 
-    * the valve to our parent Context's pipeline.  
-    * Add a JvmRouteValve and BatchReplicationClusteredSessionValve if needed.
-    */
-   private void installValves()
-   {      
-      // If JK usage wasn't explicitly configured, default to enabling
-      // it if jvmRoute is set on our containing Engine
-      if (useJK_ == null)
-      {
-         useJK_ = Boolean.valueOf(getJvmRoute() != null);
-      }
-      
-      if (getUseJK())
-      {
-         log_.debug("We are using JK for load-balancing. Adding JvmRouteValve.");         
-         installContextValve(new JvmRouteValve(this));         
-      }   
-      
-      // Handle batch replication if needed.
-      // TODO -- should we add this even if not FIELD in case a cross-context
-      // call traverses a field-based webapp?   
-      BatchingManager valveBM = null;
-      if (replicationGranularity_ == ReplicationGranularity.FIELD
-            && Boolean.TRUE.equals(replicationFieldBatchMode_))
-      {
-         valveBM = this.batchingManager;
-         log_.debug("Including transaction manager in ClusteredSessionValve to support batch replication.");
-      }
-
-      // Add clustered session valve
-      ClusteredSessionValve valve = new ClusteredSessionValve(this, valveBM);
-      log_.debug("Adding ClusteredSessionValve");
-      installContextValve(valve);
-   }
-
-   /**
-    * Create and start a snapshot manager.
-    */
-   private void initSnapshotManager()
-   {
-      String ctxPath = ((Context) container_).getPath();
-      if (SnapshotMode.INSTANT == snapshotMode_)
-      {
-         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);
-      }
-      else if (snapshotMode_ == null)
-      {
-         log_.warn("Snapshot mode must be 'instant' or 'interval' - " +
-                   "using 'instant'");
-         snapshotMode_ = SnapshotMode.INSTANT;
-         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);
-      }
-      else if (ReplicationGranularity.FIELD == replicationGranularity_)
-      {
-         throw new IllegalStateException("Property snapshotMode must be " + 
-               SnapshotMode.INTERVAL + " when FIELD granularity is used");
-      }
-      else if (snapshotInterval_ < 1)
-      {
-         log_.warn("Snapshot mode set to 'interval' but snapshotInterval is < 1 " +
-                   "using 'instant'");
-         snapshotMode_ = SnapshotMode.INSTANT;
-         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);         
-      }
-      else
-      {
-         snapshotManager_ = new IntervalSnapshotManager(this, ctxPath, snapshotInterval_);
-      }
-      
-      snapshotManager_.start();
-   }
-   
-   private void installContextValve(Valve valve)
-   {
-      boolean installed = false;
-      
-      // In embedded mode, install the valve via JMX to be consistent
-      // with the way the overall context is created in TomcatDeployer.
-      // We can't do this in unembedded mode because we are called
-      // before our Context is registered with the MBean server
-      if (embedded_ && getContextObjectName() != null) {
-         try
-         {
-            getMBeanServer().invoke(getContextObjectName(), "addValve",
-                                    new Object[]{valve},
-                                    new String[]{"org.apache.catalina.Valve"});
-            installed = true;
-         }
-         catch (Exception e)
-         {
-            // JBAS-2422.  If the context is restarted via JMX, the above
-            // JMX call will fail as the context will not be registered
-            // when it's made.  So we catch the exception and fall back
-            // to adding the valve directly.
-            // TODO consider skipping adding via JMX and just do it directly
-            log_.debug("Caught exception installing valve to Context", e);
-         }
-      }
-      
-      if (!installed)
-      {
-         // If possible install via the ContainerBase.addValve() API.
-         if (container_ instanceof ContainerBase)
-         {            
-            ((ContainerBase) container_).addValve(valve);
-         }
-         else
-         {
-            // No choice; have to add it to the context's pipeline
-            container_.getPipeline().addValve(valve);
-         }
-      }
-   }
-   
-   private ObjectName getContextObjectName()
-   {
-      String oname = container_.getObjectName();
-      try
-      {         
-         return (oname == null) ? null : new ObjectName(oname);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         log_.warn("Error creating object name from string " + oname, e);
-         return null;
-      }
-   }
-
-   /**
-    * Clear the underlying cache store.
-    */
-   private void clearSessions()
-   {
-      boolean passivation = isPassivationEnabled();
-      // First, the sessions we have actively loaded
-      ClusteredSession[] sessions = findLocalSessions();
-      for(int i=0; i < sessions.length; i++)
-      {
-         ClusteredSession ses = sessions[i];
-         
-         if (trace_)
-         {
-             log_.trace("clearSessions(): clear session by expiring or passivating: " + ses);
-         }
-         try
-         {
-            // if session passivation is enabled, passivate sessions instead of expiring them which means
-            // they'll be available to the manager for activation after a restart. 
-            if(passivation && ses.isValid())
-            {               
-               processSessionPassivation(ses.getRealId());
-            }
-            else
-            {               
-               boolean notify = true;
-               boolean localCall = true;
-               boolean localOnly = true;
-               ses.expire(notify, localCall, localOnly, ClusteredSessionNotificationCause.UNDEPLOY);               
-            }
-         }
-         catch (Throwable t)
-         {
-            log_.warn("clearSessions(): Caught exception expiring or passivating session " +
-                     ses.getIdInternal(), t);
-         }
-         finally
-         {
-            // Guard against leaking memory if anything is holding a
-            // ref to the session by clearing its internal state
-            ses.recycle();
-         }
-      }      
-      
-      String action = passivation ? "evicting" : "removing";
-      Set<Map.Entry<String, OwnedSessionUpdate>> unloaded = 
-               unloadedSessions_.entrySet();
-      for (Iterator<Map.Entry<String, OwnedSessionUpdate>> it = unloaded.iterator(); it.hasNext();)
-      {
-         Map.Entry<String, OwnedSessionUpdate> entry = it.next();
-         String realId = entry.getKey();         
-         try
-         {
-            if (passivation)
-            {
-               OwnedSessionUpdate osu = entry.getValue();
-               // Ignore the marker entries for our passivated sessions
-               if (!osu.passivated)
-               {
-                  proxy_.evictSession(realId, osu.owner);
-               }
-            }
-            else
-            {
-               proxy_.removeSessionLocal(realId);           
-            }
-         }
-         catch (Exception e)
-         {
-            // Not as big a problem; we don't own the session
-            log_.debug("Problem " + action + " session " + realId + " -- " + e);
-         }
-         it.remove(); 
-      }
-   }
-   
-   // ------------------------------------------------------  Lifecyle Embedded
-   
-   /**
-    * Start this Manager when running embedded in JBoss AS.
-    *
-    * @throws org.apache.catalina.LifecycleException
-    */
-   private void startEmbedded() throws LifecycleException
-   {
-      super.start();
-      
-      initClusteredSessionNotificationPolicy();
-      
-      // Start the JBossCacheService
-      // Will need to pass the classloader that is associated with this 
-      // web app so de-serialization will work correctly.
-      tcl_ = super.getContainer().getLoader().getClassLoader();
-      
-      try
-      {
-         if (proxy_ == null)
-         {
-            initCacheProxy();
-         }
-         
-         proxy_.start();
-
-         batchingManager = proxy_.getBatchingManager();
-         if(batchingManager == null)
-         {
-            throw new LifecycleException("JBossCacheManager.start(): Obtain null batchingManager");
-         }
-         
-         initializeUnloadedSessions();
-         
-         // Setup our SnapshotManager
-         initSnapshotManager();
-         
-         // Add SnapshotValve and, if needed, JvmRouteValve and batch repl valve
-         installValves();
-
-         log_.debug("start(): JBossCacheService started");         
-      }
-      catch (LifecycleException le)
-      {
-         throw le;
-      }
-      catch (Exception e)
-      {
-         log_.error("Unable to start manager.", e);
-         throw new LifecycleException(e);
-      }
-   }
-
-   // -------------------------------------------------------------------- Misc
-   
-   /**
-    * Gets the session id with any jvmRoute removed.
-    * 
-    * @param id a session id with or without an appended jvmRoute.
-    *           Cannot be <code>null</code>.
-    */
-   private String getRealId(String id)
-   {
-      return (getUseJK() ? Util.getRealId(id) : id);
-   }
-   
-   private String reportSessionIds(Set<String> ids)
-   {
-      StringBuffer sb = new StringBuffer();
-      boolean added = false;
-      for (String id : ids)
-      {
-         if (added)
-         {
-            sb.append(',');
-         }
-         else
-         {
-            added = true;
-         }
-         
-         sb.append(id);
-      }
-      return sb.toString();
-   }   
-   
-   @SuppressWarnings("unchecked")
-   private static ContextClassLoaderSwitcher getContextClassLoaderSwitcher()
-   {
-      return (ContextClassLoaderSwitcher) AccessController.doPrivileged(ContextClassLoaderSwitcher.INSTANTIATOR);
-   }
-   
-   // ------------------------------------------------------------ Inner Classes
-   
-   private class OwnedSessionUpdate
-   {
-      String owner;
-      long updateTime;
-      int maxInactive;
-      boolean passivated;
-      
-      OwnedSessionUpdate(String owner, long updateTime, int maxInactive, boolean passivated)
-      {
-         this.owner = owner;
-         this.updateTime = updateTime;
-         this.maxInactive = maxInactive;
-         this.passivated = passivated;
-      }
-   }
-   
-   private class PassivationCheck implements Comparable<PassivationCheck>
-   {
-      private final String realId;
-      private final OwnedSessionUpdate osu;
-      private final ClusteredSession session;
-      
-      private PassivationCheck(String realId, OwnedSessionUpdate osu)
-      {
-         assert osu != null : "osu is null";
-         assert realId != null : "realId is null";
-         
-         this.realId = realId;
-         this.osu = osu;
-         this.session = null;
-      }
-      
-      private PassivationCheck(ClusteredSession session)
-      {
-         assert session != null : "session is null";
-         
-         this.realId = session.getRealId();
-         this.session = session;
-         this.osu = null;
-      }
-      
-      private long getLastUpdate()
-      {
-         return osu == null ? session.getLastAccessedTimeInternal() : osu.updateTime;
-      }
-      
-      private void passivate()
-      {
-         if (osu == null)
-         {
-            JBossCacheManager.this.processSessionPassivation(realId);
-         }
-         else
-         {
-            JBossCacheManager.this.processUnloadedSessionPassivation(realId, osu);
-         }
-      }
-      
-      private String getRealId()
-      {
-         return realId;
-      }
-      
-      private boolean isUnloaded()
-      {
-         return osu != null;
-      }
-
-      // This is what causes sorting based on lastAccessed
-      public int compareTo(PassivationCheck o)
-      {
-         long thisVal = getLastUpdate();
-         long anotherVal = o.getLastUpdate();
-         return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
-      }
-      
-      
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.session;
+
+import java.security.AccessController;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Session;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.ContainerBase;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.jboss.ReplicationConfig;
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.metadata.web.jboss.SnapshotMode;
+import org.jboss.util.loading.ContextClassLoaderSwitcher;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.BatchingManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionData;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactoryFactory;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCapability;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
+import org.jboss.web.tomcat.service.session.notification.LegacyClusteredSessionNotificationPolicy;
+
+/**
+ * Implementation of a clustered session manager for
+ * catalina using JBossCache replication.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @author Hany Mesha
+ * @version $Revision: 58587 $
+ */
+public class JBossCacheManager
+   extends JBossManager
+   implements JBossCacheManagerMBean, LocalDistributableSessionManager, ClusteredManager
+{
+   // --------------------------------------------------------------- Constants
+   
+   /**
+    * Informational name for this Catalina component
+    */
+   private static final String info_ = "JBossCacheManager/1.0";
+
+   // ------------------------------------------------------------------ Fields
+
+   /** The transaction manager. */
+   private BatchingManager batchingManager;
+
+   /** Proxy-object for the JBossCache */
+   private DistributedCacheManager proxy_;
+
+   /** The factory for our distributed cache manager */
+   private final DistributedCacheManagerFactory distributedCacheManagerFactory;
+   
+   /** Id/timestamp of sessions in distributedcache that we haven't loaded locally*/
+   private Map<String, OwnedSessionUpdate> unloadedSessions_ = 
+         new ConcurrentHashMap<String, OwnedSessionUpdate>();
+   
+   /** Number of passivated sessions */
+   private AtomicInteger passivatedCount_ = new AtomicInteger();
+   
+   /** Maximum number of concurrently passivated sessions */
+   private AtomicInteger maxPassivatedCount_ = new AtomicInteger();
+   
+   /** If set to true, will add a JvmRouteFilter to the request. */
+   private Boolean useJK_;
+
+   /** Are we running embedded in JBoss? */
+   private boolean embedded_ = false;
+
+   /** Our ClusteredSessionValve's snapshot mode. */
+   private SnapshotMode snapshotMode_ = null;
+
+   /** Our ClusteredSessionValve's snapshot interval. */
+   private int snapshotInterval_ = 0;
+   
+   /** Replication granularity. */
+   private ReplicationGranularity replicationGranularity_;
+
+   /** Policy to determine if a session is dirty */
+   private ReplicationTrigger replicationTrigger_;
+
+   /**
+    * Whether we use batch mode replication for field level granularity.
+    * We store this in a Boolean rather than a primitive so JBossCacheCluster
+    * can determine if this was set via a <Manager> element.
+    */
+   private Boolean replicationFieldBatchMode_;
+   
+   /** Class loader for this web app. */
+   private ClassLoader tcl_;
+   
+   /** The snapshot manager we are using. */
+   private SnapshotManager snapshotManager_;
+   
+   /** The name of our cache's configuration */
+   private String cacheConfigName_;
+   
+   private int maxUnreplicatedInterval_ = -1;
+
+   private String notificationPolicyClass_;
+   private ClusteredSessionNotificationPolicy notificationPolicy_;
+   
+   private ReplicationConfig replicationConfig_;
+
+   //  ----------------------------------------------------------  Constructors
+
+   public JBossCacheManager() throws ClusteringNotSupportedException
+   {
+      this(DistributedCacheManagerFactoryFactory.getInstance().getDistributedCacheManagerFactory());
+   }
+   
+   public JBossCacheManager(DistributedCacheManagerFactory distributedManagerFactory)
+   {
+      assert distributedManagerFactory != null : "distributedManagerFactory is null";
+      
+      this.distributedCacheManagerFactory = distributedManagerFactory;
+   }
+
+   // ---------------------------------------------------- AbstractJBossManager
+
+   /**
+    * {@inheritDoc}
+    * <p>
+    * <strong>NOTE:</strong> This method should not be called when
+    * running unembedded.
+    * </p>
+    */
+   @Override
+   public void init(String name, JBossWebMetaData webMetaData)
+      throws ClusteringNotSupportedException
+   {
+      super.init(name, webMetaData);
+      
+      this.replicationConfig_ = webMetaData.getReplicationConfig();
+      this.replicationTrigger_ = replicationConfig_.getReplicationTrigger();
+      this.replicationGranularity_ = replicationConfig_.getReplicationGranularity();
+      
+      // Only configure JK usage if it was explicitly set; otherwise
+      // wait until we're starting when we can check for a jvmRoute
+      // in our containing Engine
+      Boolean jk = replicationConfig_.getUseJK();
+      if (jk != null)
+      {
+         this.useJK_ = jk;
+      }
+      
+      Boolean batch = replicationConfig_.getReplicationFieldBatchMode();
+      this.replicationFieldBatchMode_ = (batch == null ? Boolean.TRUE : batch);
+      setSnapshotMode(replicationConfig_.getSnapshotMode());
+      Integer snapshotInt = replicationConfig_.getSnapshotInterval();
+      setSnapshotInterval(snapshotInt == null ? 0 : snapshotInt.intValue());
+      
+      Integer maxUnrep = replicationConfig_.getMaxUnreplicatedInterval();
+      if (maxUnrep != null)
+      {
+         this.maxUnreplicatedInterval_ = maxUnrep.intValue();
+      }
+      
+      log_.debug("init(): replicationGranularity_ is " + replicationGranularity_ +
+         " and replicationTrigger is " + replicationTrigger_ +
+         " and replicationFieldBatchMode is " + replicationFieldBatchMode_ +
+         " and useJK is " + useJK_ +
+         " and snapshotMode is " + snapshotMode_ +
+         " and snapshotInterval is " + snapshotInterval_);     
+      
+      this.cacheConfigName_ = replicationConfig_.getCacheName();
+      
+      this.notificationPolicyClass_ = replicationConfig_.getSessionNotificationPolicy();
+      
+      // Initing the proxy would be better in start, but we do it here so we
+      // can detect ClusteringNotSupportedException at this deploy stage
+      initCacheProxy();
+
+      embedded_ = true;
+   }
+
+   /**
+    * {@inheritDoc}
+    * <p>
+    * Removes the session from this Manager's collection of actively managed
+    * sessions.  Also removes the session from this server's copy of the
+    * distributed cache (but does not remove it from other servers'
+    * distributed cache).
+    * </p>
+    */
+   public void removeLocal(Session session)
+   {
+      ClusteredSession clusterSess = (ClusteredSession) session;
+      synchronized (clusterSess)
+      {
+         String realId = clusterSess.getRealId();
+         if (realId == null) return;
+
+         if (trace_)
+         {
+            log_.trace("Removing session from local store with id: " + realId);
+         }
+
+         try {
+            // Ignore any cache notifications that our own work generates
+            SessionReplicationContext.startCacheActivity();
+            clusterSess.removeMyselfLocal();
+         }
+         finally
+         {
+            SessionReplicationContext.finishCacheActivity();
+            
+            // We don't want to replicate this session at the end
+            // of the request; the removal process took care of that
+            SessionReplicationContext.sessionExpired(clusterSess, realId, snapshotManager_);
+            
+            sessions_.remove(realId);
+            stats_.removeStats(realId);
+
+            // Compute how long this session has been alive, and update
+            // our statistics accordingly
+            int timeAlive = (int) ((System.currentTimeMillis() - clusterSess.getCreationTimeInternal())/1000);
+            sessionExpired(timeAlive);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean storeSession(Session baseSession)
+   {
+      boolean stored = false;
+      if(baseSession != null && started_)
+      {
+         ClusteredSession session = (ClusteredSession) baseSession;
+
+         synchronized (session)
+         {
+            if (trace_)
+            {
+               log_.trace("check to see if needs to store and replicate " +
+                          "session with id " + session.getIdInternal());
+            }
+
+            if (session.isValid() &&
+                  (session.isSessionDirty() || session.getMustReplicateTimestamp()))
+            {
+               String realId = session.getRealId();
+
+               // Notify all session attributes that they get serialized (SRV 7.7.2)
+               long begin = System.currentTimeMillis();
+               session.notifyWillPassivate(ClusteredSessionNotificationCause.REPLICATION);
+               long elapsed = System.currentTimeMillis() - begin;
+               stats_.updatePassivationStats(realId, elapsed);
+
+               // Do the actual replication
+               begin = System.currentTimeMillis();
+               processSessionRepl(session);
+               elapsed = System.currentTimeMillis() - begin;
+               stored = true;
+               stats_.updateReplicationStats(realId, elapsed);
+            }
+            else if (trace_)
+            {
+               log_.trace("Session " + session.getIdInternal() + 
+                          " did not require replication.");
+            }
+         }
+      }
+
+      return stored;
+   }
+
+   // ----------------------------------------------------------------- Manager
+
+   /**
+    * {@inheritDoc}
+    */
+   public void add(Session session)
+   {
+      if (session == null)
+         return;
+
+      if (!(session instanceof ClusteredSession))
+      {
+         throw new IllegalArgumentException("You can only add instances of " +
+               "type ClusteredSession to this Manager. Session class name: " +
+               session.getClass().getName());
+      }
+
+//      add((ClusteredSession) session, true);
+      add((ClusteredSession) session, false); // wait to replicate until req end
+   }
+
+   // Satisfy the Manager interface.  Internally we use
+   // createEmptyClusteredSession to avoid a cast
+   public Session createEmptySession()
+   {
+      if (trace_)
+      {
+         log_.trace("Creating an empty ClusteredSession");
+      }
+      
+      return createEmptyClusteredSession();
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public Session createSession()
+   {
+      return createSession(null);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Session createSession(String sessionId)
+   {      
+      // First check if we've reached the max allowed sessions, 
+      // then try to expire/passivate sessions to free memory
+      // maxActiveAllowed_ -1 is unlimited
+      // We check here for maxActive instead of in add().  add() gets called
+      // when we load an already existing session from the distributed cache
+      // (e.g. in a failover) and we don't want to fail in that situation.
+
+      if(maxActiveAllowed_ != -1 && calcActiveSessions() >= maxActiveAllowed_)
+      {
+         if (trace_)
+         {
+            log_.trace("createSession(): active sessions = " + calcActiveSessions() +
+                       " and max allowed sessions = " + maxActiveAllowed_);
+         }
+         
+         processExpirationPassivation();
+         
+         if (calcActiveSessions() >= maxActiveAllowed_)
+         {
+            // Exceeds limit. We need to reject it.
+            rejectedCounter_.incrementAndGet();
+            // Catalina api does not specify what happens
+            // but we will throw a runtime exception for now.
+            String msgEnd = (sessionId == null) ? "" : " id " + sessionId;
+            throw new IllegalStateException("createSession(): number of " +
+                   "active sessions exceeds the maximum limit: " +
+                   maxActiveAllowed_ + " when trying to create session" + msgEnd);
+         }
+      }
+
+      ClusteredSession session = createEmptyClusteredSession();
+
+      session.setNew(true);
+      session.setCreationTime(System.currentTimeMillis());
+      session.setMaxInactiveInterval(this.maxInactiveInterval_);
+      session.setValid(true);
+
+      if (sessionId == null)
+      {
+          sessionId = this.getNextId();
+
+          // We are using mod_jk for load balancing. Append the JvmRoute.
+          if (getUseJK())
+          {
+              if (trace_)
+              {
+                  log_.trace("createSession(): useJK is true. Will append JvmRoute: " + this.getJvmRoute());
+              }
+              sessionId += "." + this.getJvmRoute();
+          }
+      }
+
+      session.setId(sessionId); // Setting the id leads to a call to add()
+      
+      getDistributedCacheManager().sessionCreated(session);
+      
+      session.tellNew(ClusteredSessionNotificationCause.CREATE);
+
+      if (trace_)
+      {
+         log_.trace("Created a ClusteredSession with id: " + sessionId);
+      }
+
+      createdCounter_.incrementAndGet(); // the call to add() handles the other counters 
+      
+      // Add this session to the set of those potentially needing replication
+      SessionReplicationContext.bindSession(session, snapshotManager_);
+      
+      return session;
+   }
+
+   /**
+    * Attempts to find the session in the collection of those being managed
+    * locally, and if not found there, in the distributed cache of sessions.
+    * <p>
+    * If a session is found in the distributed cache, it is added to the
+    * collection of those being managed locally.
+    * </p>
+    *
+    * @param id the session id, which may include an appended jvmRoute
+    *
+    * @return the session, or <code>null</code> if no such session could
+    *         be found
+    */
+   public Session findSession(String id)
+   {
+      String realId = getRealId(id);
+      // Find it from the local store first
+      ClusteredSession session = findLocalSession(realId);
+      
+      // If we didn't find it locally, only check the distributed cache
+      // if we haven't previously handled this session id on this request.
+      // If we handled it previously but it's no longer local, that means
+      // it's been invalidated. If we request an invalidated session from
+      // the distributed cache, it will be missing from the local cache but
+      // may still exist on other nodes (i.e. if the invalidation hasn't 
+      // replicated yet because we are running in a tx). With buddy replication,
+      // asking the local cache for the session will cause the out-of-date
+      // session from the other nodes to be gravitated, thus resuscitating
+      // the session.
+      if (session == null 
+            && !SessionReplicationContext.isSessionBoundAndExpired(realId, snapshotManager_))
+      {
+         if (trace_)
+            log_.trace("Checking for session " + realId + " in the distributed cache");
+         
+         session = loadSession(realId);
+//       if (session != null)
+//       {
+//          add(session);
+//          // We now notify, since we've added a policy to allow listeners 
+//          // to discriminate. But the default policy will not allow the 
+//          // notification to be emitted for FAILOVER, so the standard
+//          // behavior is unchanged.
+//          session.tellNew(ClusteredSessionNotificationCause.FAILOVER);
+//       }
+      }
+      else if (session != null && session.isOutdated())
+      {
+         if (trace_)
+            log_.trace("Updating session " + realId + " from the distributed cache");
+         
+         // Need to update it from the cache
+         loadSession(realId);
+      }
+
+      if (session != null)
+      {
+         // Add this session to the set of those potentially needing replication
+         SessionReplicationContext.bindSession(session, snapshotManager_);
+         
+         // If we previously called passivate() on the session due to
+         // replication, we need to make an offsetting activate() call
+         if (session.getNeedsPostReplicateActivation())
+         {
+            session.notifyDidActivate(ClusteredSessionNotificationCause.REPLICATION);
+         }
+      }
+
+      return session;
+   }
+
+   /**
+    * Return the sessions. Note that this will return not only the local
+    * in-memory sessions, but also any sessions that are in the distributed
+    * cache but have not previously been accessed on this server.  Invoking
+    * this method will bring all such sessions into local memory and can
+    * potentially be quite expensive.
+    *
+    * <p>
+    * Note also that when sessions are loaded from the distributed cache, no
+    * check is made as to whether the number of local sessions will thereafter
+    * exceed the maximum number allowed on this server.
+    * </p>
+    *
+    * @return an array of all the sessions
+    */
+   public Session[] findSessions()
+   {
+      // Need to load all the unloaded sessions
+      if(unloadedSessions_.size() > 0)
+      {
+         // Make a thread-safe copy of the new id list to work with
+         Set<String> ids = new HashSet<String>(unloadedSessions_.keySet());
+
+         if(trace_) {
+            log_.trace("findSessions: loading sessions from distributed cache: " + ids);
+         }
+
+         for(String id :  ids) {
+            loadSession(id);
+         }
+      }
+
+      // All sessions are now "local" so just return the local sessions
+      return findLocalSessions();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getInfo()
+   {
+      return info_;
+   }
+
+   /**
+    * Removes the session from this Manager's collection of actively managed
+    * sessions.  Also removes the session from the distributed cache, both
+    * on this server and on all other server to which this one replicates.
+    */
+   public void remove(Session session)
+   {
+      ClusteredSession clusterSess = (ClusteredSession) session;
+      synchronized (clusterSess)
+      {
+         String realId = clusterSess.getRealId();
+         if (realId == null)
+            return;
+
+         if (trace_)
+         {
+            log_.trace("Removing session from store with id: " + realId);
+         }
+
+         try {
+            // Ignore any cache notifications that our own work generates
+            SessionReplicationContext.startCacheActivity();
+            clusterSess.removeMyself();
+         }
+         finally {
+            SessionReplicationContext.finishCacheActivity();
+            
+            // We don't want to replicate this session at the end
+            // of the request; the removal process took care of that
+            SessionReplicationContext.sessionExpired(clusterSess, realId, snapshotManager_);
+            
+            sessions_.remove(realId);
+            stats_.removeStats(realId);
+
+            // Compute how long this session has been alive, and update
+            // our statistics accordingly
+            int timeAlive = (int) ((System.currentTimeMillis() - clusterSess.getCreationTimeInternal())/1000);
+            sessionExpired(timeAlive);
+         }
+      }
+   }
+
+   // -------------------------------------------------------  ClusteredManager
+
+   /**
+    * Gets the <code>JBossCacheService</code> through which we interact
+    * with the <code>Cache</code>.
+    */
+   public DistributedCacheManager getDistributedCacheManager()
+   {
+      return proxy_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getMaxUnreplicatedInterval()
+   {
+      return maxUnreplicatedInterval_;
+   }
+
+   public ClusteredSessionNotificationPolicy getNotificationPolicy()
+   {
+      return notificationPolicy_;
+   }    
+   
+   /**
+    * {@inheritDoc}
+    */
+   public ReplicationTrigger getReplicationTrigger()
+   {
+      return this.replicationTrigger_;
+   }
+
+   // --------------------------------------------------------------- Lifecycle
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void start() throws LifecycleException
+   {
+      // Identify ourself more clearly
+      log_ = Logger.getLogger(getClass().getName() + "." + 
+                              getContainer().getName().replaceAll("/", ""));
+      
+      if (embedded_)
+      {
+         startEmbedded();
+      }
+      else
+      {
+         startUnembedded();
+      }
+      
+      log_.debug("Started");
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void stop() throws LifecycleException
+   {
+      if (!started_)
+      {
+         throw new IllegalStateException("Manager not started");
+      }
+      
+      log_.debug("Stopping");
+      
+      // Block for any ongoing backgroundProcess, then disable
+      synchronized (backgroundProcessAllowed)
+      {
+         backgroundProcessAllowed.set(false);
+      }
+      
+      resetStats();
+      
+      // Notify our interested LifecycleListeners
+      lifecycle_.fireLifecycleEvent(BEFORE_STOP_EVENT, this);
+      
+      clearSessions();
+      
+      // Don't leak the classloader
+      tcl_ = null;
+      
+      proxy_.stop();
+      proxy_ = null;
+      
+      batchingManager = null;
+      
+      snapshotManager_.stop();
+      
+      // Clean up maps
+      sessions_.clear();
+      unloadedSessions_.clear();
+      
+      passivatedCount_.set(0);
+      
+      started_ = false;
+      
+      // Notify our interested LifecycleListeners
+      lifecycle_.fireLifecycleEvent(AFTER_STOP_EVENT, this);
+      
+      unregisterManagerMBean();
+   }
+   
+
+   // -------------------------------------------------- JBossCacheManagerMBean
+
+   /**
+    * {@inheritDoc}
+    */
+   public void expireSession(String sessionId)
+   {
+      Session session = findSession(sessionId);
+      if (session != null)
+         session.expire();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getCacheConfigName()
+   {
+      return cacheConfigName_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getCreationTime(String sessionId)
+   {
+      Session session = findSession(sessionId);
+      if(session == null) 
+      {
+         log_.info("getCreationTime(): Session " + sessionId + 
+                       " not found");
+         return "";
+      }
+     return new Date(session.getCreationTime()).toString();
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public int getDuplicates()
+   {
+      return duplicates_.get();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getLastAccessedTime(String sessionId)
+   {
+      Session session = findSession(sessionId);
+      if(session == null) {
+         log_.info("getLastAccessedTime(): Session " + sessionId + 
+                   " not found");
+         return "";
+      }
+     return new Date(session.getLastAccessedTime()).toString();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getSessionAttribute(String sessionId, String key)
+   {
+      Object attr = null;
+      ClusteredSession session = (ClusteredSession) findSession(sessionId);
+      if (session != null)
+      {
+         attr = session.getAttribute(key);
+      }
+      
+      return attr == null ? null : attr.toString();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public long getMaxPassivatedSessionCount()
+   {
+      return maxPassivatedCount_.get();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setMaxUnreplicatedInterval(int maxUnreplicatedInterval)
+   {
+      this.maxUnreplicatedInterval_ = maxUnreplicatedInterval;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public long getPassivatedSessionCount()
+   {
+      return passivatedCount_.get();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public long getPassivationMaxIdleTime()
+   {
+      return passivationMaxIdleTime_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public long getPassivationMinIdleTime()
+   {
+      return passivationMinIdleTime_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ReplicationGranularity getReplicationGranularity()
+   {
+      return replicationGranularity_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getSnapshotInterval()
+   {
+      return snapshotInterval_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public SnapshotMode getSnapshotMode()
+   {
+      return snapshotMode_;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean getUseJK()
+   {
+      return useJK_ == null ? false : useJK_.booleanValue();
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isPassivationEnabled()
+   {
+      return (passivationMode_ && proxy_.isPassivationEnabled());
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Boolean isReplicationFieldBatchMode()
+   {
+      return replicationFieldBatchMode_;
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public String listLocalSessionIds()
+   {
+      return reportSessionIds(sessions_.keySet());
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public String listSessionIds()
+   {
+      Set<String> ids = new HashSet<String>(sessions_.keySet());
+      ids.addAll(unloadedSessions_.keySet());
+      return reportSessionIds(ids);
+   }
+   
+   // --------------------------------------- LocalDistributableSessionManager
+
+   public String getContextName()
+   {
+      return getContainer().getName();
+   }
+   
+   public String getHostName()
+   {
+      return getContainer().getParent().getName();
+   }
+   
+   public ClassLoader getApplicationClassLoader()
+   {
+      return tcl_;
+   }
+   
+   public ReplicationConfig getReplicationConfig()
+   {
+      return replicationConfig_;
+   }
+   
+   /**
+    * Notifies the manager that a session in the distributed cache has
+    * been invalidated
+    * 
+    * @param realId the session id excluding any jvmRoute
+    */
+   public void notifyRemoteInvalidation(String realId)
+   {
+      // Remove the session from our local map
+      ClusteredSession session = (ClusteredSession) sessions_.remove(realId);
+      if (session == null)
+      {
+         // We weren't managing the session anyway.  But remove it
+         // from the list of cached sessions we haven't loaded
+         if (unloadedSessions_.remove(realId) != null)
+         {
+            if (trace_)
+               log_.trace("Removed entry for session " + realId + " from unloaded session map");
+         }
+      }
+      else
+      {
+         // Expire the session
+         // DON'T SYNCHRONIZE ON SESSION HERE -- isValid() and
+         // expire() are meant to be multi-threaded and synchronize
+         // properly internally; synchronizing externally can lead
+         // to deadlocks!!
+         boolean notify = false; // Don't notify listeners. SRV.10.7
+                                 // allows this, and sending notifications
+                                 // leads to all sorts of issues; e.g.
+                                 // circular calls with ClusteredSSO
+         boolean localCall = false; // this call originated from the cache;
+                                    // we have already removed session
+         boolean localOnly = true; // Don't pass attr removals to cache
+         
+         // Ensure the correct TCL is in place
+         ContextClassLoaderSwitcher.SwitchContext switcher = null;
+         try
+         {
+            switcher = getContextClassLoaderSwitcher().getSwitchContext();
+            switcher.setClassLoader(tcl_);
+            session.expire(notify, localCall, localOnly, ClusteredSessionNotificationCause.INVALIDATE);
+         }
+         finally
+         {
+            if (switcher != null)
+            {
+               switcher.reset();
+            }
+         }
+
+         // Remove any stats for this session
+         stats_.removeStats(realId);
+      }
+   }
+   
+   /**
+    * Callback from the distributed cache notifying of a local modification
+    * to a session's attributes.  Meant for use with FIELD granularity,
+    * where the session may not be aware of modifications.
+    * 
+    * @param realId the session id excluding any jvmRoute
+    */
+   public void notifyLocalAttributeModification(String realId)
+   {
+      ClusteredSession session = (ClusteredSession) sessions_.get(realId);
+      if (session != null)
+      {
+         session.sessionAttributesDirty();
+      }
+      else
+      {
+         log_.warn("Received local attribute notification for " + realId + 
+               " but session is not locally active");
+      }
+   }
+   
+   public void sessionActivated()
+   {
+      int pc = passivatedCount_.decrementAndGet();
+      // Correct for drift since we don't know the true passivation
+      // count when we started.  We can get activations of sessions
+      // we didn't know were passivated.
+      // FIXME -- is the above statement still correct? Is this needed?
+      if (pc < 0) 
+      {
+         // Just reverse our decrement.
+         passivatedCount_.incrementAndGet();
+      }
+   }
+   
+   /**
+    * Callback from the distributed cache to notify us that a session
+    * has been modified remotely.
+    * 
+    * @param realId the session id, without any trailing jvmRoute
+    * @param dataOwner  the owner of the session.  Can be <code>null</code> if
+    *                   the owner is unknown.
+    * @param distributedVersion the session's version per the distributed cache
+    * @param timestamp the session's timestamp per the distributed cache
+    * @param metadata the session's metadata per the distributed cache
+    */
+   public boolean sessionChangedInDistributedCache(String realId, 
+                                         String dataOwner,
+                                         int distributedVersion,
+                                         long timestamp, 
+                                         DistributableSessionMetadata metadata)
+   {
+      boolean updated = true;
+      
+      ClusteredSession session = findLocalSession(realId);
+      if (session != null)
+      {
+         // Need to invalidate the loaded session. We get back whether
+         // this an actual version increment
+         updated = session.setVersionFromDistributedCache(distributedVersion);
+         if (updated && trace_)      
+         {            
+            log_.trace("session in-memory data is invalidated for id: " + realId + 
+                       " new version: " + distributedVersion);
+         }         
+      }
+      else
+      {
+         int maxLife = metadata == null ? getMaxInactiveInterval() : metadata.getMaxInactiveInterval();
+         
+         Object existing = unloadedSessions_.put(realId, new OwnedSessionUpdate(dataOwner, timestamp, maxLife, false));
+         if (existing == null)
+         {
+            calcActiveSessions();
+            if (trace_)
+            {
+               log_.trace("New session " + realId + " added to unloaded session map");
+            }
+         }
+         else if (trace_)
+         {
+            log_.trace("Updated timestamp for unloaded session " + realId);
+         }
+      }
+      
+      return updated;
+   }
+   
+   // ----------------------------------------------- JBossCacheCluster Support
+
+   /**
+    * Sets how often session changes should be replicated to other nodes.
+    *
+    * @param snapshotInterval the number of milliseconds between
+    *                         session replications.
+    */
+   public void setSnapshotInterval(int snapshotInterval)
+   {
+      this.snapshotInterval_ = snapshotInterval;
+   }
+
+   /**
+    * Sets when sessions are replicated to the other nodes. Valid values are:
+    * <ul>
+    * <li>instant</li>
+    * <li>interval</li>
+    * </ul>
+    */
+   public void setSnapshotMode(SnapshotMode snapshotMode)
+   {
+      this.snapshotMode_ = snapshotMode;
+   }
+
+   /**
+    * Sets whether the <code>Engine</code> in which we are running
+    * uses <code>mod_jk</code>.
+    */
+   public void setUseJK(boolean useJK)
+   {
+      this.useJK_ = Boolean.valueOf(useJK);
+   }
+
+   /**
+    * Sets the granularity of session data replicated across the cluster.
+    * Valid values are:
+    * <ul>
+    * <li>SESSION</li>
+    * <li>ATTRIBUTE</li>
+    * <li>FIELD</li>
+    * </ul>
+    */
+   public void setReplicationGranularity(ReplicationGranularity granularity)
+   {
+      this.replicationGranularity_ = granularity;
+   }
+
+   /**
+    * Returns the replication granularity.
+    *
+    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_ATTRIBUTE
+    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_FIELD
+    *  @see JBossWebMetaData#REPLICATION_GRANULARITY_SESSION
+    */
+   public String getReplicationGranularityString()
+   {
+      return replicationGranularity_ == null ? null : replicationGranularity_.toString();
+   }
+
+   /**
+    * Sets the granularity of session data replicated across the cluster.
+    * Valid values are:
+    * <ul>
+    * <li>SESSION</li>
+    * <li>ATTRIBUTE</li>
+    * <li>FIELD</li>
+    * </ul>
+    */
+   public void setReplicationGranularityString(String granularity)
+   {
+      setReplicationGranularity(granularity == null ? null : 
+                  ReplicationGranularity.fromString(granularity.toUpperCase()));
+   } 
+   
+   /**
+    * Sets the type of operations on a <code>HttpSession</code> that
+    * trigger replication.  Valid values are:
+    * <ul>
+    * <li>SET_AND_GET</li>
+    * <li>SET_AND_NON_PRIMITIVE_GET</li>
+    * <li>SET</li>
+    * </ul>
+    */
+   public void setReplicationTrigger(ReplicationTrigger trigger)
+   {
+      this.replicationTrigger_ = trigger;
+   }
+
+   public String getReplicationTriggerString()
+   {      
+      return replicationTrigger_ == null ? null : replicationTrigger_.toString();
+   }
+
+   public void setReplicationTriggerString(String trigger)
+   {      
+      setReplicationTrigger(trigger == null ? null : ReplicationTrigger.fromString(trigger.toUpperCase()));
+   }
+
+   /**
+    * Sets whether, if replication granularity is set to <code>FIELD</code>,
+    * replication should be done in batch mode.  Ignored if field-level
+    * granularity is not used.
+    */
+   public void setReplicationFieldBatchMode(boolean replicationFieldBatchMode)
+   {
+      this.replicationFieldBatchMode_ = Boolean.valueOf(replicationFieldBatchMode);
+   }
+
+   // --------------------------------------------------------------- Overrides
+
+   /**
+    * {@inheritDoc}
+    * <p>
+    * Overrides the superclass version to ensure that the generated id
+    * does not duplicate the id of any other session this manager is aware of.
+    * </p>
+    */
+   @Override
+   protected String getNextId()
+   {
+      while (true)
+      {
+         String id = super.getNextId();
+         if (sessions_.containsKey(id) || unloadedSessions_.containsKey(id))
+         {
+            duplicates_.incrementAndGet();
+         }
+         else
+         {
+            return id;
+         }
+      }
+   }
+
+   protected int getTotalActiveSessions()
+   {
+      return localActiveCounter_.get() + unloadedSessions_.size() - passivatedCount_.get();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   protected void processExpirationPassivation()
+   {      
+      boolean expire = maxInactiveInterval_ >= 0;
+      boolean passivate = isPassivationEnabled();
+      
+      long passivationMax = passivationMaxIdleTime_ * 1000L;
+      long passivationMin = passivationMinIdleTime_ * 1000L;
+
+      if (trace_)
+      { 
+         log_.trace("processExpirationPassivation(): Looking for sessions that have expired ...");
+         log_.trace("processExpirationPassivation(): active sessions = " + calcActiveSessions());
+         log_.trace("processExpirationPassivation(): expired sessions = " + expiredCounter_);
+         if (passivate)
+         {
+            log_.trace("processExpirationPassivation(): passivated count = " + getPassivatedSessionCount());
+         }
+      }
+      
+      // Holder for sessions or OwnedSessionUpdates that survive expiration,
+      // sorted by last acccessed time
+      TreeSet<PassivationCheck> passivationChecks = new TreeSet<PassivationCheck>();
+      
+      try
+      {
+         // First, handle the sessions we are actively managing
+         Session sessions[] = findLocalSessions();
+         for (int i = 0; i < sessions.length; ++i)
+         {
+            try
+            {
+               ClusteredSession session = (ClusteredSession) sessions[i];
+               if(session == null)
+               {
+                  log_.warn("processExpirationPassivation(): processing null session at index " +i);
+                  continue;
+               }
+
+               if (expire)
+               {
+                  // JBAS-2403. Check for outdated sessions where we think
+                  // the local copy has timed out.  If found, refresh the
+                  // session from the cache in case that might change the timeout
+                  if (session.isOutdated() && !(session.isValid(false)))
+                  {
+                     // JBAS-2792 don't assign the result of loadSession to session
+                     // just update the object from the cache or fall through if
+                     // the session has been removed from the cache
+                     loadSession(session.getRealId());
+                  }
+   
+                  // Do a normal invalidation check that will expire the
+                  // session if it has timed out
+                  // DON'T SYNCHRONIZE on session here -- isValid() and
+                  // expire() are meant to be multi-threaded and synchronize
+                  // properly internally; synchronizing externally can lead
+                  // to deadlocks!!
+                  if (!session.isValid()) continue;
+               }
+                
+               // we now have a valid session; store it so we can check later
+               // if we need to passivate it
+               if (passivate)
+               {
+                  passivationChecks.add(new PassivationCheck(session));
+               }
+               
+            }
+            catch (Exception ex)
+            {
+               log_.error("processExpirationPassivation(): failed handling " + 
+                          sessions[i].getIdInternal() + " with exception: " + 
+                          ex, ex);
+            }
+         }
+
+         // Next, handle any unloaded sessions
+
+         
+         // We may have not gotten replication of a timestamp for requests 
+         // that occurred w/in maxUnreplicatedInterval_ of the previous
+         // request. So we add a grace period to avoid flushing a session early
+         // and permanently losing part of its node structure in JBoss Cache.
+         long maxUnrep = maxUnreplicatedInterval_ < 0 ? 60 : maxUnreplicatedInterval_;
+         
+         Map<String, OwnedSessionUpdate> unloaded = new HashMap<String, OwnedSessionUpdate>(unloadedSessions_);
+         for (Map.Entry<String, OwnedSessionUpdate> entry : unloaded.entrySet())
+         {
+            String realId = entry.getKey();
+            OwnedSessionUpdate osu = entry.getValue();
+            
+            long now = System.currentTimeMillis();
+            long elapsed = (now - osu.updateTime);
+            try
+            {
+               if (expire && osu.maxInactive >= 1 && elapsed >= (osu.maxInactive + maxUnrep) * 1000L)
+               {
+                  if (osu.passivated)
+                  {
+                     // Passivated session needs to be expired. A call to 
+                     // findSession will bring it out of passivation
+                     Session session = findSession(realId);
+                     if (session != null)
+                     {
+                        session.isValid(); // will expire
+                        continue;
+                     }
+                  }
+                  
+                  // If we get here either !osu.passivated, or the session
+                  // couldn't be reactivated (invalidated by user). 
+                  // Either way, do a cleanup
+                  proxy_.removeSessionLocal(realId, osu.owner);
+                  unloadedSessions_.remove(realId);
+                  
+               }
+               else if (passivate && !osu.passivated)
+               {  
+                  // we now have a valid session; store it so we can check later
+                  // if we need to passivate it
+                  passivationChecks.add(new PassivationCheck(realId, osu));
+               }
+            } 
+            catch (Exception ex)
+            {
+               log_.error("processExpirationPassivation(): failed handling unloaded session " + 
+                       realId, ex);
+            }
+         }
+         
+         // Now, passivations
+         if (passivate)
+         {
+            // Iterate through sessions, earliest lastAccessedTime to latest
+            for (PassivationCheck passivationCheck : passivationChecks)
+            {               
+               try
+               {
+                  long timeNow = System.currentTimeMillis();
+                  long timeIdle = timeNow - passivationCheck.getLastUpdate();
+                  // if maxIdle time configured, means that we need to passivate sessions that have
+                  // exceeded the max allowed idle time
+                  if (passivationMax >= 0 
+                        && timeIdle > passivationMax)
+                  {
+                     passivationCheck.passivate();
+                  }
+                  // If the session didn't exceed the passivationMaxIdleTime_, see   
+                  // if the number of sessions managed by this manager greater than the max allowed 
+                  // active sessions, passivate the session if it exceed passivationMinIdleTime_ 
+                  else if (maxActiveAllowed_ > 0 
+                              && passivationMin > 0 
+                              && calcActiveSessions() >= maxActiveAllowed_ 
+                              && timeIdle > passivationMin)
+                  {
+                     passivationCheck.passivate();
+                  }
+                  else
+                  {
+                     // the entries are ordered by lastAccessed, so once
+                     // we don't passivate one, we won't passivate any
+                     break;
+                  }
+               }
+               catch (Exception e)
+               {
+                  String unloadMark = passivationCheck.isUnloaded() ? "unloaded " : "";
+                  log_.error("processExpirationPassivation(): failed passivating " + unloadMark + "session " + 
+                        passivationCheck.getRealId(), e);
+               }                  
+            }
+         }
+      }
+      catch (Exception ex)
+      {
+         log_.error("processExpirationPassivation(): failed with exception: " + ex, ex);
+      }
+      
+      if (trace_)
+      { 
+         log_.trace("processExpirationPassivation(): Completed ...");
+         log_.trace("processExpirationPassivation(): active sessions = " + calcActiveSessions());
+         log_.trace("processExpirationPassivation(): expired sessions = " + expiredCounter_);
+         if (passivate)
+         {
+            log_.trace("processExpirationPassivation(): passivated count = " + getPassivatedSessionCount());
+         }
+      }
+   }
+   
+   @Override
+   public void resetStats()
+   {
+      super.resetStats();
+      
+      this.maxPassivatedCount_.set(this.passivatedCount_.get());
+   }
+   
+   // ------------------------------------------------------ Session Management
+
+   private ClusteredSession createEmptyClusteredSession()
+   {     
+
+      ClusteredSession session = null;
+      switch (replicationGranularity_)
+      {
+         case ATTRIBUTE:
+         session = new AttributeBasedClusteredSession(this);
+            break;
+         case FIELD:
+            session = new FieldBasedClusteredSession(this);
+            break;
+         default:
+            session = new SessionBasedClusteredSession(this);
+            break;
+      }
+      return session;
+   }
+
+   /**
+    * Adds the given session to the collection of those being managed by this
+    * Manager.
+    *
+    * @param session   the session. Cannot be <code>null</code>.
+    * @param replicate whether the session should be replicated
+    *
+    * @throws NullPointerException if <code>session</code> is <code>null</code>.
+    */
+   private void add(ClusteredSession session, boolean replicate)
+   {
+      // TODO -- why are we doing this check? The request checks session 
+      // validity and will expire the session; this seems redundant
+      if (!session.isValid())
+      {
+         // Not an error; this can happen if a failover request pulls in an
+         // outdated session from the distributed cache (see TODO above)
+         log_.debug("Cannot add session with id=" + session.getIdInternal() +
+                    " because it is invalid");
+         return;
+      }
+
+      String realId = session.getRealId();
+      Object existing = sessions_.put(realId, session);
+      unloadedSessions_.remove(realId);
+
+      if (!session.equals(existing))
+      {
+         if (replicate)
+         {
+            storeSession(session);
+         }
+
+         // Update counters
+         calcActiveSessions();
+         
+         if (trace_)
+         {
+            log_.trace("Session with id=" + session.getIdInternal() + " added. " +
+                       "Current active sessions " + localActiveCounter_.get());
+         }
+      }
+   }
+   
+   /**
+    * Loads a session from the distributed store.  If an existing session with
+    * the id is already under local management, that session's internal state
+    * will be updated from the distributed store.  Otherwise a new session
+    * will be created and added to the collection of those sessions under
+    * local management.
+    *
+    * @param realId  id of the session-id with any jvmRoute removed
+    *
+    * @return the session or <code>null</code> if the session cannot be found
+    *         in the distributed store
+    */
+   private ClusteredSession loadSession(String realId)
+   {
+      if (realId == null)
+      {
+         return null;
+      }
+
+      long begin = System.currentTimeMillis();
+      boolean mustAdd = false;
+      boolean passivated = false;
+      
+      ClusteredSession session = sessions_.get(realId);
+      
+      if (session == null)
+      {                 
+         // This is either the first time we've seen this session on this
+         // server, or we previously expired it and have since gotten
+         // a replication message from another server
+         mustAdd = true;
+         session = createEmptyClusteredSession();
+         
+         OwnedSessionUpdate osu = unloadedSessions_.get(realId);
+         passivated = (osu != null && osu.passivated);
+      }
+
+      synchronized (session)
+      {
+         ContextClassLoaderSwitcher.SwitchContext switcher = null; 
+         boolean doTx = false; 
+         try
+         {
+            // We need transaction so any data gravitation replication 
+            // is sent in batch.
+            // Don't do anything if there is already transaction context
+            // associated with this thread.
+            if (batchingManager.isBatchInProgress() == false)
+            {
+               batchingManager.startBatch();
+               doTx = true;
+            }
+            
+            // Ignore cache notifications we may generate for this 
+            // session if data gravitation occurs. 
+            SessionReplicationContext.startCacheActivity();
+            
+            // Tomcat calls Manager.findSession before setting the tccl,
+            // so we need to do it :(
+            switcher = getContextClassLoaderSwitcher().getSwitchContext();
+            switcher.setClassLoader(tcl_);
+            
+            session = proxy_.loadSession(realId, session);
+            
+            if (session != null)
+            {
+               ClusteredSessionNotificationCause cause = passivated ? ClusteredSessionNotificationCause.ACTIVATION 
+                                                                    : ClusteredSessionNotificationCause.FAILOVER;
+               session.notifyDidActivate(cause);
+            }
+         }
+         catch (Exception ex)
+         {
+            try
+            {
+//                  if(doTx)
+               // Let's set it no matter what.
+               batchingManager.setBatchRollbackOnly();
+            }
+            catch (Exception exn)
+            {
+               log_.error("Caught exception rolling back transaction", exn);
+            }
+            // We will need to alert Tomcat of this exception.
+            if (ex instanceof RuntimeException)
+               throw (RuntimeException) ex;
+            
+            throw new RuntimeException("loadSession(): failed to load session " +
+                                       realId, ex);
+         }
+         finally
+         {
+            try {
+               if(doTx)
+               {
+                  batchingManager.endBatch();
+               }
+            }
+            finally {
+               if (switcher != null)
+               {
+                  switcher.reset();
+               }
+               SessionReplicationContext.finishCacheActivity();
+            }
+         }
+
+         if (session != null)
+         {            
+            if (mustAdd)
+            {
+               add(session, false); // don't replicate
+               if (!passivated)
+               {
+                  session.tellNew(ClusteredSessionNotificationCause.FAILOVER);
+               }
+            }
+            long elapsed = System.currentTimeMillis() - begin;
+            stats_.updateLoadStats(realId, elapsed);
+
+            if (trace_)
+            {
+               log_.trace("loadSession(): id= " + realId + ", session=" + session);
+            }
+         }
+         else if (trace_)
+         {
+            log_.trace("loadSession(): session " + realId +
+                       " not found in distributed cache");
+         }
+      }
+
+      return session;
+   }
+
+   /**
+    * Places the current session contents in the distributed cache and
+    * replicates them to the cluster
+    *
+    * @param session  the session.  Cannot be <code>null</code>.
+    */
+   private void processSessionRepl(ClusteredSession session)
+   {
+      // If we are using SESSION granularity, we don't want to initiate a TX
+      // for a single put
+      boolean notSession = (replicationGranularity_ != ReplicationGranularity.SESSION);
+      boolean doTx = false;
+      try
+      {
+         // We need transaction so all the replication are sent in batch.
+         // Don't do anything if there is already transaction context
+         // associated with this thread.
+         if(notSession && batchingManager.isBatchInProgress() == false)
+         {
+            batchingManager.startBatch();
+            doTx = true;
+         }
+
+         // Tell the proxy to ignore cache notifications we are about
+         // to generate for this session. We have to do this
+         // at this level because we don't want to resume handling
+         // notifications until any compensating changes resulting
+         // from a tx rollback are done.
+         SessionReplicationContext.startCacheActivity();
+
+         session.processSessionReplication();
+      }
+      catch (Exception ex)
+      {
+         log_.debug("processSessionRepl(): failed with exception", ex);
+         
+         try
+         {
+            //if(doTx)
+            // Let's setRollbackOnly no matter what.
+            // (except if there's no tx due to SESSION (JBAS-3840))
+            if (notSession)
+               batchingManager.setBatchRollbackOnly();
+         }
+         catch (Exception exn)
+         {
+            log_.error("Caught exception rolling back transaction", exn);
+         }
+         
+         // We will need to alert Tomcat of this exception.
+         if (ex instanceof RuntimeException)
+            throw (RuntimeException) ex;
+         
+         throw new RuntimeException("JBossCacheManager.processSessionRepl(): " +
+                                    "failed to replicate session.", ex);
+      }
+      finally
+      {
+         try {
+            if(doTx)
+            {
+               batchingManager.endBatch();
+            }
+         }
+         finally {
+            SessionReplicationContext.finishCacheActivity();
+         }
+      }
+   }
+   
+   /**
+    * Session passivation logic for an actively managed session.
+    * 
+    * @param realId the session id, minus any jvmRoute
+    */
+   private void processSessionPassivation(String realId)
+   {
+      // get the session from the local map
+      ClusteredSession session = findLocalSession(realId);
+      // Remove actively managed session and add to the unloaded sessions
+      // if it's already unloaded session (session == null) don't do anything, 
+      if (session != null)
+      {
+         synchronized (session)
+         {
+            if (trace_)
+            {
+               log_.trace("Passivating session with id: " + realId);
+            }
+
+            try {
+               // Tell the proxy to ignore cache notifications we are about
+               // to generate for this session.
+               SessionReplicationContext.startCacheActivity();
+               session.notifyWillPassivate(ClusteredSessionNotificationCause.PASSIVATION);
+               proxy_.evictSession(realId);
+               sessionPassivated();
+            }
+            finally {
+               SessionReplicationContext.finishCacheActivity();
+            }
+            
+            // Put the session in the unloadedSessions map. This will
+            // expose the session to regular invalidation.
+            Object obj = unloadedSessions_.put(realId, 
+                  new OwnedSessionUpdate(null, session.getLastAccessedTime(), session.getMaxInactiveInterval(), true));
+            if (trace_)
+            {
+               if (obj == null)
+               {
+                  log_.trace("New session " + realId + " added to unloaded session map");
+               }
+               else
+               {
+                  log_.trace("Updated timestamp for unloaded session " + realId);
+               }
+            }
+            sessions_.remove(realId);
+         }
+      }
+      else if (trace_)
+      {
+         log_.trace("processSessionPassivation():  could not find session " + realId);
+      }
+   }
+   
+   /**
+    * Session passivation logic for sessions only in the distributed store.
+    * 
+    * @param realId the session id, minus any jvmRoute
+    */
+   private void processUnloadedSessionPassivation(String realId, OwnedSessionUpdate osu)
+   {
+      if (trace_)
+      {
+         log_.trace("Passivating session with id: " + realId);
+      }
+
+      try {
+         // Tell the proxy to ignore cache notifications we are about
+         // to generate for this session.
+         SessionReplicationContext.startCacheActivity();
+         proxy_.evictSession(realId, osu.owner);
+         osu.passivated = true;
+         sessionPassivated();
+      }
+      finally {
+         SessionReplicationContext.finishCacheActivity();
+      }
+      
+   }
+   
+   private void sessionPassivated()
+   {
+      int pc = passivatedCount_.incrementAndGet();
+      int max = maxPassivatedCount_.get();
+      while (pc > max)
+      {
+         if (!maxPassivatedCount_ .compareAndSet(max, pc))
+         {
+            max = maxPassivatedCount_.get();
+         }
+      }
+   }
+   
+   // -----------------------------------------------  Lifecyle When Unembedded
+
+   /**
+    * Start this Manager when running in standalone Tomcat.
+    */
+   private void startUnembedded() throws LifecycleException
+   {
+      if (started_)
+      {
+         return;
+      }
+      
+      log_.info("Manager is about to start");      
+
+      // Notify our interested LifecycleListeners
+      lifecycle_.fireLifecycleEvent(BEFORE_START_EVENT, this);
+      
+      if (snapshotMode_ == null) 
+      {
+         // We were not instantiated by a JBossCacheCluster, so we need to
+         // find one and let it configure our cluster-wide properties
+         try 
+         {
+            JBossCacheCluster cluster = (JBossCacheCluster) container_.getCluster();
+            cluster.configureManager(this);
+         }
+         catch (ClassCastException e)
+         {
+            String msg = "Cluster is not an instance of JBossCacheCluster";
+            log_.error(msg, e);
+            throw new LifecycleException(msg, e);
+         }
+      }      
+      
+      initClusteredSessionNotificationPolicy();
+      
+      // Create the JBossCacheService
+      try
+      {
+         if (replicationConfig_ == null)
+         {
+            synthesizeReplicationConfig();
+         }
+         
+         if (proxy_ == null)
+         {
+            initCacheProxy();
+         }
+         
+         // We need to pass the classloader that is associated with this 
+         // web app so de-serialization will work correctly.
+         tcl_ = container_.getLoader().getClassLoader();
+         proxy_.start();
+      }
+      catch (Throwable t)
+      {
+         String str = "Problem starting JBossCacheService for Tomcat clustering";
+         log_.error(str, t);
+         throw new LifecycleException(str, t);
+      }
+
+      batchingManager = proxy_.getBatchingManager();
+      if(batchingManager == null)
+      {
+         throw new LifecycleException("JBossCacheManager.start(): Obtain null batchingManager");
+      }
+      
+      try
+      {
+         initializeUnloadedSessions();
+
+         // Add SnapshotValve and, if needed, JvmRouteValve and batch repl valve
+         installValves();
+
+         started_ = true;
+         
+         // Notify our interested LifecycleListeners
+         lifecycle_.fireLifecycleEvent(AFTER_START_EVENT, this);
+         
+         log_.debug("start(): JBossCacheService started");
+      } 
+      catch (Exception e)
+      {
+         log_.error("Unable to start manager.", e);
+         throw new LifecycleException(e);
+      }
+      
+      registerManagerMBean();
+   }
+
+   /**
+    * Accesses the underlying cache and creates the proxy
+    * 
+    * @throws ClusteringNotSupportedException
+    */
+   private void initCacheProxy() throws ClusteringNotSupportedException
+   {
+      proxy_ = distributedCacheManagerFactory.getDistributedCacheManager(this);
+   }
+   
+   private void synthesizeReplicationConfig()
+   {
+      ReplicationConfig cfg = new ReplicationConfig();
+      cfg.setReplicationGranularity(replicationGranularity_);
+      cfg.setReplicationTrigger(replicationTrigger_);
+      cfg.setUseJK(useJK_);
+      cfg.setCacheName(cacheConfigName_);
+      cfg.setSnapshotMode(snapshotMode_);
+      cfg.setSnapshotInterval(Integer.valueOf(snapshotInterval_));
+      cfg.setMaxUnreplicatedInterval(Integer.valueOf(maxUnreplicatedInterval_));
+      cfg.setSessionNotificationPolicy(notificationPolicyClass_);      
+      this.replicationConfig_ = cfg;
+   }
+
+   private void initClusteredSessionNotificationPolicy()
+   {
+      if (this.notificationPolicyClass_ == null || this.notificationPolicyClass_.length() == 0)
+      {
+         this.notificationPolicyClass_ = System.getProperty("jboss.web.clustered.session.notification.policy",
+                                                            LegacyClusteredSessionNotificationPolicy.class.getName());
+      }
+      
+      try
+      {
+         this.notificationPolicy_ = (ClusteredSessionNotificationPolicy) Thread.currentThread().getContextClassLoader().loadClass(this.notificationPolicyClass_).newInstance();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Failed to instantiate " + 
+               ClusteredSessionNotificationPolicy.class.getName() + 
+               " " + this.notificationPolicyClass_, e);
+      }
+      
+      this.notificationPolicy_.setClusteredSessionNotificationCapability(new ClusteredSessionNotificationCapability());      
+   }
+   
+   /**
+    * Gets the ids of all sessions in the distributed cache and adds
+    * them to the unloaded sessions map, along with their lastAccessedTime
+    * and their maxInactiveInterval. Passivates overage or excess sessions.
+    */
+   private void initializeUnloadedSessions()
+   {      
+      Map<String, String> sessions = proxy_.getSessionIds();
+      if (sessions != null)
+      {
+         boolean passivate = isPassivationEnabled();
+
+         long passivationMax = passivationMaxIdleTime_ * 1000L;
+         long passivationMin = passivationMinIdleTime_ * 1000L;
+         
+         for (Map.Entry<String, String> entry : sessions.entrySet())
+         {
+            String realId = entry.getKey();
+            String owner = entry.getValue();
+
+            long ts = -1;
+            DistributableSessionMetadata md = null;
+            try
+            {
+               DistributableSessionData sessionData = proxy_.getSessionData(realId, owner, false);
+               ts = sessionData.getTimestamp();
+               md = sessionData.getMetadata();
+            }
+            catch (Exception e)
+            {
+               // most likely a lock conflict if the session is being updated remotely; 
+               // ignore it and use default values for timstamp and maxInactive
+               log_.debug("Problem reading metadata for session " + realId + " -- " + e.toString());               
+            }
+            
+            long lastMod = ts == -1 ? System.currentTimeMillis() : ts;
+            int maxLife = md == null ? getMaxInactiveInterval() : md.getMaxInactiveInterval();
+            
+            OwnedSessionUpdate osu = new OwnedSessionUpdate(owner, lastMod, maxLife, false);
+            unloadedSessions_.put(realId, osu);
+            if (passivate)
+            {
+               try
+               {
+                  long elapsed = System.currentTimeMillis() - lastMod;
+                  // if maxIdle time configured, means that we need to passivate sessions that have
+                  // exceeded the max allowed idle time
+                  if (passivationMax >= 0 
+                        && elapsed > passivationMax)
+                  {
+                     if (trace_)
+                     {
+                        log_.trace("Elapsed time of " + elapsed + " for session "+ 
+                              realId + " exceeds max of " + passivationMax + "; passivating");
+                     }
+                     processUnloadedSessionPassivation(realId, osu);
+                  }
+                  // If the session didn't exceed the passivationMaxIdleTime_, see   
+                  // if the number of sessions managed by this manager greater than the max allowed 
+                  // active sessions, passivate the session if it exceed passivationMinIdleTime_ 
+                  else if (maxActiveAllowed_ > 0 
+                              && passivationMin >= 0 
+                              && calcActiveSessions() > maxActiveAllowed_ 
+                              && elapsed >= passivationMin)
+                  {
+                     if (trace_)
+                     {
+                        log_.trace("Elapsed time of " + elapsed + " for session "+ 
+                              realId + " exceeds min of " + passivationMin + "; passivating");
+                     }
+                     processUnloadedSessionPassivation(realId, osu);
+                  }
+               }
+               catch (Exception e)
+               {
+                  // most likely a lock conflict if the session is being updated remotely; ignore it
+                  log_.debug("Problem passivating session " + realId + " -- " + e.toString());
+               }
+            }
+         }
+      }
+   }
+
+   /**
+    * Instantiate a SnapshotManager and ClusteredSessionValve and add 
+    * the valve to our parent Context's pipeline.  
+    * Add a JvmRouteValve and BatchReplicationClusteredSessionValve if needed.
+    */
+   private void installValves()
+   {      
+      // If JK usage wasn't explicitly configured, default to enabling
+      // it if jvmRoute is set on our containing Engine
+      if (useJK_ == null)
+      {
+         useJK_ = Boolean.valueOf(getJvmRoute() != null);
+      }
+      
+      if (getUseJK())
+      {
+         log_.debug("We are using JK for load-balancing. Adding JvmRouteValve.");         
+         installContextValve(new JvmRouteValve(this));         
+      }   
+      
+      // Handle batch replication if needed.
+      // TODO -- should we add this even if not FIELD in case a cross-context
+      // call traverses a field-based webapp?   
+      BatchingManager valveBM = null;
+      if (replicationGranularity_ == ReplicationGranularity.FIELD
+            && Boolean.TRUE.equals(replicationFieldBatchMode_))
+      {
+         valveBM = this.batchingManager;
+         log_.debug("Including transaction manager in ClusteredSessionValve to support batch replication.");
+      }
+
+      // Add clustered session valve
+      ClusteredSessionValve valve = new ClusteredSessionValve(this, valveBM);
+      log_.debug("Adding ClusteredSessionValve");
+      installContextValve(valve);
+   }
+
+   /**
+    * Create and start a snapshot manager.
+    */
+   private void initSnapshotManager()
+   {
+      String ctxPath = ((Context) container_).getPath();
+      if (SnapshotMode.INSTANT == snapshotMode_)
+      {
+         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);
+      }
+      else if (snapshotMode_ == null)
+      {
+         log_.warn("Snapshot mode must be 'instant' or 'interval' - " +
+                   "using 'instant'");
+         snapshotMode_ = SnapshotMode.INSTANT;
+         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);
+      }
+      else if (ReplicationGranularity.FIELD == replicationGranularity_)
+      {
+         throw new IllegalStateException("Property snapshotMode must be " + 
+               SnapshotMode.INTERVAL + " when FIELD granularity is used");
+      }
+      else if (snapshotInterval_ < 1)
+      {
+         log_.warn("Snapshot mode set to 'interval' but snapshotInterval is < 1 " +
+                   "using 'instant'");
+         snapshotMode_ = SnapshotMode.INSTANT;
+         snapshotManager_ = new InstantSnapshotManager(this, ctxPath);         
+      }
+      else
+      {
+         snapshotManager_ = new IntervalSnapshotManager(this, ctxPath, snapshotInterval_);
+      }
+      
+      snapshotManager_.start();
+   }
+   
+   private void installContextValve(Valve valve)
+   {
+      boolean installed = false;
+      
+      // In embedded mode, install the valve via JMX to be consistent
+      // with the way the overall context is created in TomcatDeployer.
+      // We can't do this in unembedded mode because we are called
+      // before our Context is registered with the MBean server
+      if (embedded_ && getContextObjectName() != null) {
+         try
+         {
+            getMBeanServer().invoke(getContextObjectName(), "addValve",
+                                    new Object[]{valve},
+                                    new String[]{"org.apache.catalina.Valve"});
+            installed = true;
+         }
+         catch (Exception e)
+         {
+            // JBAS-2422.  If the context is restarted via JMX, the above
+            // JMX call will fail as the context will not be registered
+            // when it's made.  So we catch the exception and fall back
+            // to adding the valve directly.
+            // TODO consider skipping adding via JMX and just do it directly
+            log_.debug("Caught exception installing valve to Context", e);
+         }
+      }
+      
+      if (!installed)
+      {
+         // If possible install via the ContainerBase.addValve() API.
+         if (container_ instanceof ContainerBase)
+         {            
+            ((ContainerBase) container_).addValve(valve);
+         }
+         else
+         {
+            // No choice; have to add it to the context's pipeline
+            container_.getPipeline().addValve(valve);
+         }
+      }
+   }
+   
+   private ObjectName getContextObjectName()
+   {
+      String oname = container_.getObjectName();
+      try
+      {         
+         return (oname == null) ? null : new ObjectName(oname);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         log_.warn("Error creating object name from string " + oname, e);
+         return null;
+      }
+   }
+
+   /**
+    * Clear the underlying cache store.
+    */
+   private void clearSessions()
+   {
+      boolean passivation = isPassivationEnabled();
+      // First, the sessions we have actively loaded
+      ClusteredSession[] sessions = findLocalSessions();
+      for(int i=0; i < sessions.length; i++)
+      {
+         ClusteredSession ses = sessions[i];
+         
+         if (trace_)
+         {
+             log_.trace("clearSessions(): clear session by expiring or passivating: " + ses);
+         }
+         try
+         {
+            // if session passivation is enabled, passivate sessions instead of expiring them which means
+            // they'll be available to the manager for activation after a restart. 
+            if(passivation && ses.isValid())
+            {               
+               processSessionPassivation(ses.getRealId());
+            }
+            else
+            {               
+               boolean notify = true;
+               boolean localCall = true;
+               boolean localOnly = true;
+               ses.expire(notify, localCall, localOnly, ClusteredSessionNotificationCause.UNDEPLOY);               
+            }
+         }
+         catch (Throwable t)
+         {
+            log_.warn("clearSessions(): Caught exception expiring or passivating session " +
+                     ses.getIdInternal(), t);
+         }
+         finally
+         {
+            // Guard against leaking memory if anything is holding a
+            // ref to the session by clearing its internal state
+            ses.recycle();
+         }
+      }      
+      
+      String action = passivation ? "evicting" : "removing";
+      Set<Map.Entry<String, OwnedSessionUpdate>> unloaded = 
+               unloadedSessions_.entrySet();
+      for (Iterator<Map.Entry<String, OwnedSessionUpdate>> it = unloaded.iterator(); it.hasNext();)
+      {
+         Map.Entry<String, OwnedSessionUpdate> entry = it.next();
+         String realId = entry.getKey();         
+         try
+         {
+            if (passivation)
+            {
+               OwnedSessionUpdate osu = entry.getValue();
+               // Ignore the marker entries for our passivated sessions
+               if (!osu.passivated)
+               {
+                  proxy_.evictSession(realId, osu.owner);
+               }
+            }
+            else
+            {
+               proxy_.removeSessionLocal(realId);           
+            }
+         }
+         catch (Exception e)
+         {
+            // Not as big a problem; we don't own the session
+            log_.debug("Problem " + action + " session " + realId + " -- " + e);
+         }
+         it.remove(); 
+      }
+   }
+   
+   // ------------------------------------------------------  Lifecyle Embedded
+   
+   /**
+    * Start this Manager when running embedded in JBoss AS.
+    *
+    * @throws org.apache.catalina.LifecycleException
+    */
+   private void startEmbedded() throws LifecycleException
+   {
+      super.start();
+      
+      initClusteredSessionNotificationPolicy();
+      
+      // Start the JBossCacheService
+      // Will need to pass the classloader that is associated with this 
+      // web app so de-serialization will work correctly.
+      tcl_ = super.getContainer().getLoader().getClassLoader();
+      
+      try
+      {
+         if (proxy_ == null)
+         {
+            initCacheProxy();
+         }
+         
+         proxy_.start();
+
+         batchingManager = proxy_.getBatchingManager();
+         if(batchingManager == null)
+         {
+            throw new LifecycleException("JBossCacheManager.start(): Obtain null batchingManager");
+         }
+         
+         initializeUnloadedSessions();
+         
+         // Setup our SnapshotManager
+         initSnapshotManager();
+         
+         // Add SnapshotValve and, if needed, JvmRouteValve and batch repl valve
+         installValves();
+
+         log_.debug("start(): JBossCacheService started");         
+      }
+      catch (LifecycleException le)
+      {
+         throw le;
+      }
+      catch (Exception e)
+      {
+         log_.error("Unable to start manager.", e);
+         throw new LifecycleException(e);
+      }
+   }
+
+   // -------------------------------------------------------------------- Misc
+   
+   /**
+    * Gets the session id with any jvmRoute removed.
+    * 
+    * @param id a session id with or without an appended jvmRoute.
+    *           Cannot be <code>null</code>.
+    */
+   private String getRealId(String id)
+   {
+      return (getUseJK() ? Util.getRealId(id) : id);
+   }
+   
+   private String reportSessionIds(Set<String> ids)
+   {
+      StringBuffer sb = new StringBuffer();
+      boolean added = false;
+      for (String id : ids)
+      {
+         if (added)
+         {
+            sb.append(',');
+         }
+         else
+         {
+            added = true;
+         }
+         
+         sb.append(id);
+      }
+      return sb.toString();
+   }   
+   
+   @SuppressWarnings("unchecked")
+   private static ContextClassLoaderSwitcher getContextClassLoaderSwitcher()
+   {
+      return (ContextClassLoaderSwitcher) AccessController.doPrivileged(ContextClassLoaderSwitcher.INSTANTIATOR);
+   }
+   
+   // ------------------------------------------------------------ Inner Classes
+   
+   private class OwnedSessionUpdate
+   {
+      String owner;
+      long updateTime;
+      int maxInactive;
+      boolean passivated;
+      
+      OwnedSessionUpdate(String owner, long updateTime, int maxInactive, boolean passivated)
+      {
+         this.owner = owner;
+         this.updateTime = updateTime;
+         this.maxInactive = maxInactive;
+         this.passivated = passivated;
+      }
+   }
+   
+   private class PassivationCheck implements Comparable<PassivationCheck>
+   {
+      private final String realId;
+      private final OwnedSessionUpdate osu;
+      private final ClusteredSession session;
+      
+      private PassivationCheck(String realId, OwnedSessionUpdate osu)
+      {
+         assert osu != null : "osu is null";
+         assert realId != null : "realId is null";
+         
+         this.realId = realId;
+         this.osu = osu;
+         this.session = null;
+      }
+      
+      private PassivationCheck(ClusteredSession session)
+      {
+         assert session != null : "session is null";
+         
+         this.realId = session.getRealId();
+         this.session = session;
+         this.osu = null;
+      }
+      
+      private long getLastUpdate()
+      {
+         return osu == null ? session.getLastAccessedTimeInternal() : osu.updateTime;
+      }
+      
+      private void passivate()
+      {
+         if (osu == null)
+         {
+            JBossCacheManager.this.processSessionPassivation(realId);
+         }
+         else
+         {
+            JBossCacheManager.this.processUnloadedSessionPassivation(realId, osu);
+         }
+      }
+      
+      private String getRealId()
+      {
+         return realId;
+      }
+      
+      private boolean isUnloaded()
+      {
+         return osu != null;
+      }
+
+      // This is what causes sorting based on lastAccessed
+      public int compareTo(PassivationCheck o)
+      {
+         long thisVal = getLastUpdate();
+         long anotherVal = o.getLastUpdate();
+         return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
+      }
+      
+      
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,227 +1,227 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.session;
-
-import org.jboss.metadata.web.jboss.ReplicationGranularity;
-import org.jboss.metadata.web.jboss.ReplicationTrigger;
-import org.jboss.metadata.web.jboss.SnapshotMode;
-
-public interface JBossCacheManagerMBean extends JBossManagerMBean
-{
-   /**
-    * Gets the value of the attribute with the given key from the given
-    * session.  If the session is in the distributed store but hasn't been
-    * loaded on this node, invoking this method will cause it to be loaded.
-    * 
-    * @param sessionId the id of the session
-    * @param key       the attribute key
-    * @return          the value, converted to a String via toString(), 
-    *                  or <code>null</code> if the session or key does not exist.
-    */
-   String getSessionAttribute(String sessionId, String key);
-   
-   /**
-    * Expires the given session. If the session is in the distributed store 
-    * but hasn't been loaded on this node, invoking this method will cause it 
-    * to be loaded.
-    * 
-    * @param sessionId the id of the session
-    */
-   void expireSession(String sessionId);
-   
-   /**
-    * Gets the last time the given session was accessed.  If the session is in 
-    * the distributed store but hasn't been loaded on this node, invoking this 
-    * method will cause it to be loaded.
-    * 
-    * @param sessionId
-    * @return the last accessed time, or the empty string if the session
-    *         doesn't exist.
-    */
-   String getLastAccessedTime(String sessionId);
-   
-   /**
-    * Gets the creation time of the given session.  If the session is in 
-    * the distributed store but hasn't been loaded on this node, invoking this 
-    * method will cause it to be loaded.
-    * 
-    * @param sessionId
-    * @return the creation time, or or the empty string if the session
-    *         doesn't exist.
-    */
-   String getCreationTime(String sessionId);
-   
-   /**
-    * Gets the cache config name used to get the underlying cache
-    * from a cache manager.
-    * 
-    * @return the config name, or <code>null</code> if this has not yet been
-    *         configured or the cache was directly injected.
-    */
-   String getCacheConfigName();
-   
-   /**
-    * Gets the replication granularity.
-    * 
-    * @return SESSION, ATTRIBUTE or FIELD, or <code>null</code> if this
-    *         has not yet been configured.
-    */
-   ReplicationGranularity getReplicationGranularity();
-
-   /**
-    * Gets the replication trigger.
-    * 
-    * @return SET, SET_AND_GET, SET_AND_NON_PRIMITIVE_GET or <code>null</code> 
-    *         if this has not yet been configured.
-    */
-   ReplicationTrigger getReplicationTrigger();
-   
-   /**
-    * Gets whether batching of field granularity changes will be done.  Only
-    * relevant with replication granularity FIELD.
-    * 
-    * @return <code>true</code> if per-request batching will be done, 
-    *         <code>false</code> if not, <code>null</code> if not configured
-    */
-   Boolean isReplicationFieldBatchMode();
-   
-   /**
-    * Gets whether JK is being used and special handling of a jvmRoute
-    * portion of session ids is needed.
-    */
-   boolean getUseJK();
-   
-   /**
-    * Gets the snapshot mode.
-    * 
-    * @return "instant" or "interval"
-    */
-   SnapshotMode getSnapshotMode();
-   
-   /**
-    * Gets the number of milliseconds between replications if "interval" mode
-    * is used.
-    */
-   int getSnapshotInterval();
-
-   /**
-    * Get the maximum interval between requests, in seconds, after which a
-    * request will trigger replication of the session's metadata regardless
-    * of whether the request has otherwise made the session dirty. Such 
-    * replication ensures that other nodes in the cluster are aware of a 
-    * relatively recent value for the session's timestamp and won't incorrectly
-    * expire an unreplicated session upon failover.
-    * <p/>
-    * Default value is <code>-1</code>.
-    * <p/>
-    * The cost of the metadata replication depends on the configured
-    * {@link #setReplicationGranularityString(String) replication granularity}.
-    * With <code>SESSION</code>, the sesssion's attribute map is replicated 
-    * along with the metadata, so it can be fairly costly.  With other 
-    * granularities, the metadata object is replicated separately from the
-    * attributes and only contains a String, and a few longs, ints and booleans.
-    * 
-    * @return the maximum interval since last replication after which a request
-    *         will trigger session metadata replication. A value of 
-    *         <code>0</code> means replicate metadata on every request; a value 
-    *         of <code>-1</code> means never replicate metadata unless the 
-    *         session is otherwise dirty.
-    */
-   int getMaxUnreplicatedInterval();
-
-   /**
-    * Sets the maximum interval between requests, in seconds, after which a
-    * request will trigger replication of the session's metadata regardless
-    * of whether the request has otherwise made the session dirty.
-    * 
-    * @param  maxUnreplicatedInterval  
-    *         the maximum interval since last replication after which a request
-    *         will trigger session metadata replication. A value of 
-    *         <code>0</code> means replicate metadata on every request; a value 
-    *         of <code>-1</code> means never replicate metadata unless the 
-    *         session is otherwise dirty.
-    */
-   void setMaxUnreplicatedInterval(int maxUnreplicatedInterval);
-   
-   /**
-    * Lists all session ids known to this manager, including those in the 
-    * distributed store that have not been accessed on this node.
-    * 
-    * @return a comma-separated list of session ids
-    */
-   String listSessionIds();
-   
-   /**
-    * Lists all session ids known to this manager, excluding those in the 
-    * distributed store that have not been accessed on this node.
-    * 
-    * @return a comma-separated list of session ids
-    */
-   String listLocalSessionIds();
-   
-   /**
-    * Gets whether passivation was enabled in jboss-web.xml and in the
-    * underlying cache.
-    * 
-    * @return <code>true</code> if passivation is enabled in both
-    *         jboss-web.xml and in the cache; <code>false</code> otherwise
-    */
-   boolean isPassivationEnabled();
-   
-   /**
-    * Gets the number of passivated sessions
-    * 
-    * @return
-    */
-   long getPassivatedSessionCount();
-   
-   /**
-    * Gets the highest number of passivated sessions seen.
-    * 
-    * @return
-    */
-   long getMaxPassivatedSessionCount();
-   
-   /**
-    * Elapsed time after which an inactive session will be passivated 
-    * to persistent storage if {@link #isPassivationEnabled() passivation is
-    * enabled}.
-    * 
-    * @return
-    */
-   long getPassivationMaxIdleTime();
-   
-   /**
-    * Elapsed time after which an inactive session will be passivated 
-    * to persistent storage if {@link #isPassivationEnabled() passivation is
-    * enabled} and the manager needs to passivate sessions early in order to
-    * comply with a {@link JBossManagerMBean#getMaxActiveAllowed()} setting.
-    * 
-    * @return
-    */
-   long getPassivationMinIdleTime();
-   
-   /**
-    * Gets the number of duplicated session ids generated.
-    */
-   int getDuplicates();
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.session;
+
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.metadata.web.jboss.SnapshotMode;
+
+public interface JBossCacheManagerMBean extends JBossManagerMBean
+{
+   /**
+    * Gets the value of the attribute with the given key from the given
+    * session.  If the session is in the distributed store but hasn't been
+    * loaded on this node, invoking this method will cause it to be loaded.
+    * 
+    * @param sessionId the id of the session
+    * @param key       the attribute key
+    * @return          the value, converted to a String via toString(), 
+    *                  or <code>null</code> if the session or key does not exist.
+    */
+   String getSessionAttribute(String sessionId, String key);
+   
+   /**
+    * Expires the given session. If the session is in the distributed store 
+    * but hasn't been loaded on this node, invoking this method will cause it 
+    * to be loaded.
+    * 
+    * @param sessionId the id of the session
+    */
+   void expireSession(String sessionId);
+   
+   /**
+    * Gets the last time the given session was accessed.  If the session is in 
+    * the distributed store but hasn't been loaded on this node, invoking this 
+    * method will cause it to be loaded.
+    * 
+    * @param sessionId
+    * @return the last accessed time, or the empty string if the session
+    *         doesn't exist.
+    */
+   String getLastAccessedTime(String sessionId);
+   
+   /**
+    * Gets the creation time of the given session.  If the session is in 
+    * the distributed store but hasn't been loaded on this node, invoking this 
+    * method will cause it to be loaded.
+    * 
+    * @param sessionId
+    * @return the creation time, or or the empty string if the session
+    *         doesn't exist.
+    */
+   String getCreationTime(String sessionId);
+   
+   /**
+    * Gets the cache config name used to get the underlying cache
+    * from a cache manager.
+    * 
+    * @return the config name, or <code>null</code> if this has not yet been
+    *         configured or the cache was directly injected.
+    */
+   String getCacheConfigName();
+   
+   /**
+    * Gets the replication granularity.
+    * 
+    * @return SESSION, ATTRIBUTE or FIELD, or <code>null</code> if this
+    *         has not yet been configured.
+    */
+   ReplicationGranularity getReplicationGranularity();
+
+   /**
+    * Gets the replication trigger.
+    * 
+    * @return SET, SET_AND_GET, SET_AND_NON_PRIMITIVE_GET or <code>null</code> 
+    *         if this has not yet been configured.
+    */
+   ReplicationTrigger getReplicationTrigger();
+   
+   /**
+    * Gets whether batching of field granularity changes will be done.  Only
+    * relevant with replication granularity FIELD.
+    * 
+    * @return <code>true</code> if per-request batching will be done, 
+    *         <code>false</code> if not, <code>null</code> if not configured
+    */
+   Boolean isReplicationFieldBatchMode();
+   
+   /**
+    * Gets whether JK is being used and special handling of a jvmRoute
+    * portion of session ids is needed.
+    */
+   boolean getUseJK();
+   
+   /**
+    * Gets the snapshot mode.
+    * 
+    * @return "instant" or "interval"
+    */
+   SnapshotMode getSnapshotMode();
+   
+   /**
+    * Gets the number of milliseconds between replications if "interval" mode
+    * is used.
+    */
+   int getSnapshotInterval();
+
+   /**
+    * Get the maximum interval between requests, in seconds, after which a
+    * request will trigger replication of the session's metadata regardless
+    * of whether the request has otherwise made the session dirty. Such 
+    * replication ensures that other nodes in the cluster are aware of a 
+    * relatively recent value for the session's timestamp and won't incorrectly
+    * expire an unreplicated session upon failover.
+    * <p/>
+    * Default value is <code>-1</code>.
+    * <p/>
+    * The cost of the metadata replication depends on the configured
+    * {@link #setReplicationGranularityString(String) replication granularity}.
+    * With <code>SESSION</code>, the sesssion's attribute map is replicated 
+    * along with the metadata, so it can be fairly costly.  With other 
+    * granularities, the metadata object is replicated separately from the
+    * attributes and only contains a String, and a few longs, ints and booleans.
+    * 
+    * @return the maximum interval since last replication after which a request
+    *         will trigger session metadata replication. A value of 
+    *         <code>0</code> means replicate metadata on every request; a value 
+    *         of <code>-1</code> means never replicate metadata unless the 
+    *         session is otherwise dirty.
+    */
+   int getMaxUnreplicatedInterval();
+
+   /**
+    * Sets the maximum interval between requests, in seconds, after which a
+    * request will trigger replication of the session's metadata regardless
+    * of whether the request has otherwise made the session dirty.
+    * 
+    * @param  maxUnreplicatedInterval  
+    *         the maximum interval since last replication after which a request
+    *         will trigger session metadata replication. A value of 
+    *         <code>0</code> means replicate metadata on every request; a value 
+    *         of <code>-1</code> means never replicate metadata unless the 
+    *         session is otherwise dirty.
+    */
+   void setMaxUnreplicatedInterval(int maxUnreplicatedInterval);
+   
+   /**
+    * Lists all session ids known to this manager, including those in the 
+    * distributed store that have not been accessed on this node.
+    * 
+    * @return a comma-separated list of session ids
+    */
+   String listSessionIds();
+   
+   /**
+    * Lists all session ids known to this manager, excluding those in the 
+    * distributed store that have not been accessed on this node.
+    * 
+    * @return a comma-separated list of session ids
+    */
+   String listLocalSessionIds();
+   
+   /**
+    * Gets whether passivation was enabled in jboss-web.xml and in the
+    * underlying cache.
+    * 
+    * @return <code>true</code> if passivation is enabled in both
+    *         jboss-web.xml and in the cache; <code>false</code> otherwise
+    */
+   boolean isPassivationEnabled();
+   
+   /**
+    * Gets the number of passivated sessions
+    * 
+    * @return
+    */
+   long getPassivatedSessionCount();
+   
+   /**
+    * Gets the highest number of passivated sessions seen.
+    * 
+    * @return
+    */
+   long getMaxPassivatedSessionCount();
+   
+   /**
+    * Elapsed time after which an inactive session will be passivated 
+    * to persistent storage if {@link #isPassivationEnabled() passivation is
+    * enabled}.
+    * 
+    * @return
+    */
+   long getPassivationMaxIdleTime();
+   
+   /**
+    * Elapsed time after which an inactive session will be passivated 
+    * to persistent storage if {@link #isPassivationEnabled() passivation is
+    * enabled} and the manager needs to passivate sessions early in order to
+    * comply with a {@link JBossManagerMBean#getMaxActiveAllowed()} setting.
+    * 
+    * @return
+    */
+   long getPassivationMinIdleTime();
+   
+   /**
+    * Gets the number of duplicated session ids generated.
+    */
+   int getDuplicates();
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,163 +1,163 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.web.tomcat.service.session;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Diagnostic tool to help identify when non-serializable objects are
- * placed in a web session.  To use, place this class on the webapp's
- * classpath and add the following to <code>web.xml</code>:
- * <p>
- * <code><listener><listener-class>org.jboss.web.tomcat.service.session.NonSerializableAttributeTester</listener-class></listener></code>
- * </p>
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class NonSerializableAttributeTester 
-   implements HttpSessionAttributeListener
-{
-
-   public NonSerializableAttributeTester()
-   {
-      super();
-   }
-
-   public void attributeAdded(HttpSessionBindingEvent event)
-   {
-      testAttributeSerializability(event.getName(), event.getValue());
-   }
-
-   public void attributeRemoved(HttpSessionBindingEvent event)
-   {
-      // do nothing
-   }
-
-   public void attributeReplaced(HttpSessionBindingEvent event)
-   {
-      testAttributeSerializability(event.getName(), event.getValue());
-   }
-   
-   private void testAttributeSerializability(String name, Object value)
-   {
-      if (!testSerializability(value))
-      {
-         System.out.println(name + " of type " + value.getClass() + 
-                            " cannot be serialized");
-         testRecursively(value);
-      }
-      
-   }
-   
-   private boolean testSerializability(Object obj)
-   {
-      if (obj == null)
-         return true;
-      
-      if (!(obj instanceof Serializable))
-      {
-         return false;
-      }
-      else
-      {
-         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-         try
-         {
-            ObjectOutputStream oos = new ObjectOutputStream(baos);
-            oos.writeObject(obj);
-            oos.close();
-         }
-         catch (NotSerializableException io)
-         {
-            return false;
-         }
-         catch (IOException io)
-         {
-            System.out.println("Unexpected IOException");
-            io.printStackTrace(System.out);
-         }
-      }
-      
-      return true;
-   }
-   
-   private void testRecursively(Object obj)
-   {
-      if (obj instanceof Collection<?>)
-      {
-         testCollectionSerializability((Collection<?>) obj);
-      }
-      else if (obj instanceof Map<?, ?>)
-      {
-         testMapSerializability((Map<?, ?>) obj);
-      }
-      
-   }
-   
-   private void testCollectionSerializability(Collection<?> coll)
-   {
-      System.out.println("Testing Collection elements");
-      int i = 0;
-      for (Iterator<?> iter = coll.iterator(); iter.hasNext(); i++)
-      {
-         Object obj = iter.next();
-         if (!(testSerializability(obj)))
-         {
-            System.out.println("Element " + i + " of type " + obj.getClass() +
-                               " cannot be serialized");
-            testRecursively(obj);
-         }
-      }
-   }
-   
-   private void testMapSerializability(Map<?, ?> map)
-   {
-      System.out.println("Testing Map entries");
-      for (Map.Entry<?, ?> entry : map.entrySet())
-      {
-         if (!testSerializability(entry.getKey()))
-         {
-            System.out.println("Map Key " + entry.getKey() + " of type " +
-                  entry.getKey().getClass() + " cannot be serialized");
-            testRecursively(entry.getKey());
-         }
-         else if (!testSerializability(entry.getValue()))
-         {
-            System.out.println("Map value under Key " + entry.getKey() + " of type " +
-                  entry.getValue().getClass() + " cannot be serialized");
-            testRecursively(entry.getValue());
-         }
-      }
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.service.session;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+/**
+ * Diagnostic tool to help identify when non-serializable objects are
+ * placed in a web session.  To use, place this class on the webapp's
+ * classpath and add the following to <code>web.xml</code>:
+ * <p>
+ * <code><listener><listener-class>org.jboss.web.tomcat.service.session.NonSerializableAttributeTester</listener-class></listener></code>
+ * </p>
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class NonSerializableAttributeTester 
+   implements HttpSessionAttributeListener
+{
+
+   public NonSerializableAttributeTester()
+   {
+      super();
+   }
+
+   public void attributeAdded(HttpSessionBindingEvent event)
+   {
+      testAttributeSerializability(event.getName(), event.getValue());
+   }
+
+   public void attributeRemoved(HttpSessionBindingEvent event)
+   {
+      // do nothing
+   }
+
+   public void attributeReplaced(HttpSessionBindingEvent event)
+   {
+      testAttributeSerializability(event.getName(), event.getValue());
+   }
+   
+   private void testAttributeSerializability(String name, Object value)
+   {
+      if (!testSerializability(value))
+      {
+         System.out.println(name + " of type " + value.getClass() + 
+                            " cannot be serialized");
+         testRecursively(value);
+      }
+      
+   }
+   
+   private boolean testSerializability(Object obj)
+   {
+      if (obj == null)
+         return true;
+      
+      if (!(obj instanceof Serializable))
+      {
+         return false;
+      }
+      else
+      {
+         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+         try
+         {
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(obj);
+            oos.close();
+         }
+         catch (NotSerializableException io)
+         {
+            return false;
+         }
+         catch (IOException io)
+         {
+            System.out.println("Unexpected IOException");
+            io.printStackTrace(System.out);
+         }
+      }
+      
+      return true;
+   }
+   
+   private void testRecursively(Object obj)
+   {
+      if (obj instanceof Collection<?>)
+      {
+         testCollectionSerializability((Collection<?>) obj);
+      }
+      else if (obj instanceof Map<?, ?>)
+      {
+         testMapSerializability((Map<?, ?>) obj);
+      }
+      
+   }
+   
+   private void testCollectionSerializability(Collection<?> coll)
+   {
+      System.out.println("Testing Collection elements");
+      int i = 0;
+      for (Iterator<?> iter = coll.iterator(); iter.hasNext(); i++)
+      {
+         Object obj = iter.next();
+         if (!(testSerializability(obj)))
+         {
+            System.out.println("Element " + i + " of type " + obj.getClass() +
+                               " cannot be serialized");
+            testRecursively(obj);
+         }
+      }
+   }
+   
+   private void testMapSerializability(Map<?, ?> map)
+   {
+      System.out.println("Testing Map entries");
+      for (Map.Entry<?, ?> entry : map.entrySet())
+      {
+         if (!testSerializability(entry.getKey()))
+         {
+            System.out.println("Map Key " + entry.getKey() + " of type " +
+                  entry.getKey().getClass() + " cannot be serialized");
+            testRecursively(entry.getKey());
+         }
+         else if (!testSerializability(entry.getValue()))
+         {
+            System.out.println("Map value under Key " + entry.getKey() + " of type " +
+                  entry.getValue().getClass() + " cannot be serialized");
+            testRecursively(entry.getValue());
+         }
+      }
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/NonSerializableAttributeTester.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,127 +1,127 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * Encapsulates the status of how the local container is managing the
- * given session.
- * 
- * @author Brian Stansberry
- */
-public class ClusteredSessionManagementStatus 
-{
-   private final String  realId;
-   private final boolean locallyUsed;
-   private final Boolean locallyActive;
-   private final Boolean locallyOwned;
-   
-   /**
-    * Create a new ClusteredSessionManagementStatus.
-    * 
-    * @param realId the id of the session, excluding any jvmRoute.
-    * @param locallyUsed whether the session has been provided to the 
-    *                    application on this node.
-    * @param locallyActive whether this node is the most recent one to 
-    *                      handle a request for the session; <code>null</code>
-    *                      if unknown
-    * @param locallyOwned  whether this node is the "owner" of the session,
-    *                      <code>null</code> if unknown or the concept of
-    *                      ownership is unsupported.
-    */
-   public ClusteredSessionManagementStatus(String realId,
-                                           boolean locallyUsed, 
-                                           Boolean locallyActive, 
-                                           Boolean locallyOwned)
-   {
-      if (realId == null)
-         throw new IllegalArgumentException("realId is null");
-      
-      this.realId = realId;
-      this.locallyUsed = locallyUsed;
-      // If we haven't been locallyUsed, we can't be locallyActive
-      this.locallyActive = (locallyUsed ? locallyActive : Boolean.FALSE);
-      // If we are locallyActive, we are locally owned
-      this.locallyOwned = (Boolean.TRUE.equals(locallyActive) ? Boolean.TRUE : locallyOwned);
-   }
-   
-   /**
-    * Gets the id of the session, excluding any jvmRoute that may have
-    * been appended if JK is used.
-    * 
-    * @return the id. Will not return <code>null</code>. 
-    */
-   public String getRealId()
-   {
-      return realId;
-   }
-
-   /**
-    * Gets whether an HttpSession object for the given session has been
-    * returned from the container to the application on this node.
-    * 
-    * @return <code>true</code> if the session has been used locally, 
-    *         <code>false</code> if not.
-    */
-   public boolean isLocallyUsed()
-   {
-      return locallyUsed;
-   }
-
-   /**
-    * Gets whether an HttpSession object for the given session has been
-    * returned from the container to the application on this node AND
-    * this node is the last one to handle a request for the session.
-    * 
-    * @return <code>true</code> if the above conditions are true and the 
-    *         container is sure of this, <code>false</code> if they are not
-    *         true and the container knows this, or <code>null</code> if the
-    *         container is unsure if this node is the last one to handle a 
-    *         request for the session.
-    *         
-    * @see ClusteredSessionNotificationCapability#isLocallyActiveAware()
-    */
-   public Boolean getLocallyActive()
-   {
-      return locallyActive;
-   }
-
-   /**
-    * Gets whether this node considers itself to be the "owner" of the session;
-    * i.e. the one primarily responsible for managing its lifecycle. Note that
-    * a node that is undeploying a war will always give up ownership of its
-    * sessions if it is aware of other nodes in the cluster that still have
-    * the war deployed.
-    * 
-    * @return <code>true</code> if the container knows it is the owner,
-    *         <code>false</code> if it knows it is not the owner, or 
-    *         <code>null</code> if the container is unsure about ownership
-    *         or does not recognize the concept of ownership.
-    *         
-    * @see ClusteredSessionNotificationCapability#isLocallyOwnedAware()
-    */
-   public Boolean getLocallyOwned()
-   {
-      return locallyOwned;
-   }   
-   
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Encapsulates the status of how the local container is managing the
+ * given session.
+ * 
+ * @author Brian Stansberry
+ */
+public class ClusteredSessionManagementStatus 
+{
+   private final String  realId;
+   private final boolean locallyUsed;
+   private final Boolean locallyActive;
+   private final Boolean locallyOwned;
+   
+   /**
+    * Create a new ClusteredSessionManagementStatus.
+    * 
+    * @param realId the id of the session, excluding any jvmRoute.
+    * @param locallyUsed whether the session has been provided to the 
+    *                    application on this node.
+    * @param locallyActive whether this node is the most recent one to 
+    *                      handle a request for the session; <code>null</code>
+    *                      if unknown
+    * @param locallyOwned  whether this node is the "owner" of the session,
+    *                      <code>null</code> if unknown or the concept of
+    *                      ownership is unsupported.
+    */
+   public ClusteredSessionManagementStatus(String realId,
+                                           boolean locallyUsed, 
+                                           Boolean locallyActive, 
+                                           Boolean locallyOwned)
+   {
+      if (realId == null)
+         throw new IllegalArgumentException("realId is null");
+      
+      this.realId = realId;
+      this.locallyUsed = locallyUsed;
+      // If we haven't been locallyUsed, we can't be locallyActive
+      this.locallyActive = (locallyUsed ? locallyActive : Boolean.FALSE);
+      // If we are locallyActive, we are locally owned
+      this.locallyOwned = (Boolean.TRUE.equals(locallyActive) ? Boolean.TRUE : locallyOwned);
+   }
+   
+   /**
+    * Gets the id of the session, excluding any jvmRoute that may have
+    * been appended if JK is used.
+    * 
+    * @return the id. Will not return <code>null</code>. 
+    */
+   public String getRealId()
+   {
+      return realId;
+   }
+
+   /**
+    * Gets whether an HttpSession object for the given session has been
+    * returned from the container to the application on this node.
+    * 
+    * @return <code>true</code> if the session has been used locally, 
+    *         <code>false</code> if not.
+    */
+   public boolean isLocallyUsed()
+   {
+      return locallyUsed;
+   }
+
+   /**
+    * Gets whether an HttpSession object for the given session has been
+    * returned from the container to the application on this node AND
+    * this node is the last one to handle a request for the session.
+    * 
+    * @return <code>true</code> if the above conditions are true and the 
+    *         container is sure of this, <code>false</code> if they are not
+    *         true and the container knows this, or <code>null</code> if the
+    *         container is unsure if this node is the last one to handle a 
+    *         request for the session.
+    *         
+    * @see ClusteredSessionNotificationCapability#isLocallyActiveAware()
+    */
+   public Boolean getLocallyActive()
+   {
+      return locallyActive;
+   }
+
+   /**
+    * Gets whether this node considers itself to be the "owner" of the session;
+    * i.e. the one primarily responsible for managing its lifecycle. Note that
+    * a node that is undeploying a war will always give up ownership of its
+    * sessions if it is aware of other nodes in the cluster that still have
+    * the war deployed.
+    * 
+    * @return <code>true</code> if the container knows it is the owner,
+    *         <code>false</code> if it knows it is not the owner, or 
+    *         <code>null</code> if the container is unsure about ownership
+    *         or does not recognize the concept of ownership.
+    *         
+    * @see ClusteredSessionNotificationCapability#isLocallyOwnedAware()
+    */
+   public Boolean getLocallyOwned()
+   {
+      return locallyOwned;
+   }   
+   
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionManagementStatus.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,133 +1,133 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-
-/**
- * Encapsulates information about the container's capability to issue
- * servlet spec notifications under different condititions. Implementations of
- * {@link ClusteredSessionNotificationPolicy} can use this 
- * information to get a sense of the capabilities of the container.
- * 
- * @author Brian Stansberry
- */
-public class ClusteredSessionNotificationCapability
-{
-
-   /**
-    * Does the container support invoking <code>HttpSessionListener</code>
-    * callbacks under the given conditions?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is supported, 
-    *         <code>false</code> if not
-    */
-   public boolean isHttpSessionListenerInvocationSupported(ClusteredSessionManagementStatus status, 
-                                                           ClusteredSessionNotificationCause cause, 
-                                                           boolean local)
-   {
-      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
-   }
-
-   /**
-    * Under the given conditions, does the container support invoking 
-    * <code>HttpSessionAttributeListener</code> callbacks?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is supported, 
-    *         <code>false</code> if not
-    */
-   public boolean isHttpSessionAttributeListenerInvocationSupported(ClusteredSessionManagementStatus status, 
-                                                           ClusteredSessionNotificationCause cause, 
-                                                           boolean local)
-   {
-      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
-   }
-
-   /**
-    * Under the given conditions, does the container support invoking 
-    * <code>HttpSessionBindingListener</code> callbacks?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is supported, 
-    *         <code>false</code> if not
-    */
-   public boolean isHttpSessionBindingListenerInvocationSupported(ClusteredSessionManagementStatus status, 
-                                                           ClusteredSessionNotificationCause cause, 
-                                                           boolean local)
-   {
-      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
-   }
-   
-   /**
-    * Is the container able to distinguish whether a session that has been
-    * {@link ClusteredSessionManagementStatus#isLocallyUsed() locally used}
-    * is also {@link ClusteredSessionManagementStatus#getLocallyActive() locally active}?
-    * 
-    * @return <code>true</code> if the container is able to make this distinction;
-    *         <code>false</code> if not
-    */
-   public boolean isLocallyActiveAware()
-   {
-      return false;
-   }
-   
-   /**
-    * Is the container able to distinguish whether a session is
-    * {@link ClusteredSessionManagementStatus#getLocallyOwned() locally owned}?
-    * 
-    * @return <code>true</code> if the container is able to make this distinction;
-    *         <code>false</code> if not
-    */
-   public boolean isLocallyOwnedAware()
-   {
-      return false;
-   }
-   
-   /**
-    * Returns whether the local container is aware of events on remote nodes 
-    * that could give rise to notifications.
-    * 
-    * @param cause the cause
-    * @return <code>true</code> if the local container is aware of the
-    *         remote event, <code>false</code> if not.
-    */
-   public boolean isRemoteCauseAware(ClusteredSessionNotificationCause cause)
-   {
-      return ClusteredSessionNotificationCause.CREATE.equals(cause) 
-                || ClusteredSessionNotificationCause.MODIFY.equals(cause) 
-                || ClusteredSessionNotificationCause.INVALIDATE.equals(cause);
-   }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+
+/**
+ * Encapsulates information about the container's capability to issue
+ * servlet spec notifications under different condititions. Implementations of
+ * {@link ClusteredSessionNotificationPolicy} can use this 
+ * information to get a sense of the capabilities of the container.
+ * 
+ * @author Brian Stansberry
+ */
+public class ClusteredSessionNotificationCapability
+{
+
+   /**
+    * Does the container support invoking <code>HttpSessionListener</code>
+    * callbacks under the given conditions?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+
+   /**
+    * Under the given conditions, does the container support invoking 
+    * <code>HttpSessionAttributeListener</code> callbacks?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionAttributeListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+
+   /**
+    * Under the given conditions, does the container support invoking 
+    * <code>HttpSessionBindingListener</code> callbacks?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is supported, 
+    *         <code>false</code> if not
+    */
+   public boolean isHttpSessionBindingListenerInvocationSupported(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           boolean local)
+   {
+      return local && status.isLocallyUsed() && !ClusteredSessionNotificationCause.STATE_TRANSFER.equals(cause);
+   }
+   
+   /**
+    * Is the container able to distinguish whether a session that has been
+    * {@link ClusteredSessionManagementStatus#isLocallyUsed() locally used}
+    * is also {@link ClusteredSessionManagementStatus#getLocallyActive() locally active}?
+    * 
+    * @return <code>true</code> if the container is able to make this distinction;
+    *         <code>false</code> if not
+    */
+   public boolean isLocallyActiveAware()
+   {
+      return false;
+   }
+   
+   /**
+    * Is the container able to distinguish whether a session is
+    * {@link ClusteredSessionManagementStatus#getLocallyOwned() locally owned}?
+    * 
+    * @return <code>true</code> if the container is able to make this distinction;
+    *         <code>false</code> if not
+    */
+   public boolean isLocallyOwnedAware()
+   {
+      return false;
+   }
+   
+   /**
+    * Returns whether the local container is aware of events on remote nodes 
+    * that could give rise to notifications.
+    * 
+    * @param cause the cause
+    * @return <code>true</code> if the local container is aware of the
+    *         remote event, <code>false</code> if not.
+    */
+   public boolean isRemoteCauseAware(ClusteredSessionNotificationCause cause)
+   {
+      return ClusteredSessionNotificationCause.CREATE.equals(cause) 
+                || ClusteredSessionNotificationCause.MODIFY.equals(cause) 
+                || ClusteredSessionNotificationCause.INVALIDATE.equals(cause);
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCapability.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,115 +1,115 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * Reasons why a servlet spec notification for a clustered session is being 
- * generated.
- * 
- * @author Brian Stansberry
- */
-public enum ClusteredSessionNotificationCause 
-{ 
-   /**
-    * Session has been newly created.
-    */
-   CREATE, 
-   
-   /**
-    * Session has been modified by the application.
-    */
-   MODIFY, 
-   
-   /**
-    * Session has failed over and is now in use on the local node.
-    */
-   FAILOVER,
-   
-   /**
-    * Session has failed over and is no longer active on the local node.
-    */
-   FAILAWAY,
-   
-   /**
-    * Session is being invalidated by the application.
-    */
-   INVALIDATE, 
-   
-   /**
-    * Session is being expired by the container due to timeout.
-    */
-   TIMEOUT, 
-   
-   /**
-    * Session is being expired by the container due to undeploy of the
-    * web application.
-    */
-   UNDEPLOY,
-   
-   /** 
-    * Local node became aware of a session active on another node as
-    * a result of the local node receiving a bulk state transfer due to
-    * its being elected to provide backup for that other node's sessions. 
-    */
-   STATE_TRANSFER,
-   
-   /**
-    * The session is being passivated.
-    */
-   PASSIVATION,
-   
-   /**
-    * The session is being activated.
-    */
-   ACTIVATION,
-   
-   /**
-    * The session is being replicated.
-    */
-   REPLICATION//, 
-   
-//   /**
-//    * Local node has taken "ownership" of a session for a reason other than
-//    * failover; i.e. the session hasn't become active on the local node. In this
-//    * case the local node would have become aware of the session earlier (i.e.
-//    * via {@link #CREATE} or {@link #STATE_TRANSFER}) and these notifications
-//    * would signal the local node taking greater responsibility for the session.
-//    * Typically a policy implementation would not allow notifications for a
-//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
-//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
-//    * notifications would be received for the same session.
-//    */
-//   TAKE_OWNERSHIP,
-//   
-//   /**
-//    * Local node has relinquised "ownership" of a session for a reason other than
-//    * {@link #FAILAWAY} {@link #INVALIDATE}, {@link #TIMEOUT} or {@link #UNDEPLOY}; 
-//    * i.e. some other node is taking over as the owner of session.
-//    * Typically a policy implementation would not allow notifications for a
-//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
-//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
-//    * notifications would be received for the same session.
-//    */
-//   RELINQUISH_OWNERSHIP
-   
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Reasons why a servlet spec notification for a clustered session is being 
+ * generated.
+ * 
+ * @author Brian Stansberry
+ */
+public enum ClusteredSessionNotificationCause 
+{ 
+   /**
+    * Session has been newly created.
+    */
+   CREATE, 
+   
+   /**
+    * Session has been modified by the application.
+    */
+   MODIFY, 
+   
+   /**
+    * Session has failed over and is now in use on the local node.
+    */
+   FAILOVER,
+   
+   /**
+    * Session has failed over and is no longer active on the local node.
+    */
+   FAILAWAY,
+   
+   /**
+    * Session is being invalidated by the application.
+    */
+   INVALIDATE, 
+   
+   /**
+    * Session is being expired by the container due to timeout.
+    */
+   TIMEOUT, 
+   
+   /**
+    * Session is being expired by the container due to undeploy of the
+    * web application.
+    */
+   UNDEPLOY,
+   
+   /** 
+    * Local node became aware of a session active on another node as
+    * a result of the local node receiving a bulk state transfer due to
+    * its being elected to provide backup for that other node's sessions. 
+    */
+   STATE_TRANSFER,
+   
+   /**
+    * The session is being passivated.
+    */
+   PASSIVATION,
+   
+   /**
+    * The session is being activated.
+    */
+   ACTIVATION,
+   
+   /**
+    * The session is being replicated.
+    */
+   REPLICATION//, 
+   
+//   /**
+//    * Local node has taken "ownership" of a session for a reason other than
+//    * failover; i.e. the session hasn't become active on the local node. In this
+//    * case the local node would have become aware of the session earlier (i.e.
+//    * via {@link #CREATE} or {@link #STATE_TRANSFER}) and these notifications
+//    * would signal the local node taking greater responsibility for the session.
+//    * Typically a policy implementation would not allow notifications for a
+//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
+//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
+//    * notifications would be received for the same session.
+//    */
+//   TAKE_OWNERSHIP,
+//   
+//   /**
+//    * Local node has relinquised "ownership" of a session for a reason other than
+//    * {@link #FAILAWAY} {@link #INVALIDATE}, {@link #TIMEOUT} or {@link #UNDEPLOY}; 
+//    * i.e. some other node is taking over as the owner of session.
+//    * Typically a policy implementation would not allow notifications for a
+//    * remotely originated CREATE or for a STATE_TRANSFER if it allows 
+//    * notifications for TAKE_OWNERSHIP, and vice versa. Otherwise, multiple
+//    * notifications would be received for the same session.
+//    */
+//   RELINQUISH_OWNERSHIP
+   
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationCause.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,132 +1,132 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * Policy for determining whether the servlet spec notifications related
- * to session events are allowed to be emitted on the local cluster node.
- * <p>
- * <strong>Note:</strong> The use of the word <strong>allowed</strong> above
- * is intentional; if a given policy implementation returns <code>true</code>
- * from one of the methods in this interface, that does not mean the listener
- * will be invoked by the container, nor does the presence of a method in this 
- * interface imply that it will be invoked by the container in all cases. The
- * only contract this interface creates is that before invoking a listener
- * method, the container will invoke an implementation of this policy to 
- * get permission and will not invoke the listeners if this policy returns
- * <code>false</code>. If the container does not support emitting notifications
- * in certain cases, it may not bother checking if the notification is allowed,
- * and even if it checks, it still will not emit the notification.
- * </p>
- * <p>
- * An example of a case where the container may not support emitting a 
- * notification is for a session that has never been used locally.
- * </p>
- * 
- * @author Brian Stansberry
- */
-public interface ClusteredSessionNotificationPolicy
-{
-   /**
-    * Are invocations of <code>HttpSessionListener</code> callbacks
-    * allowed under the given conditions?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is allowed, 
-    *         <code>false</code> if not
-    */
-   boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
-                                                  ClusteredSessionNotificationCause cause, 
-                                                  boolean local);
-
-
-   /**
-    * Under the given conditions, are invocations of
-    * <code>HttpSessionAttributeListener</code> callbacks allowed?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param attributeName value that would be passed to the <code>name</code>
-    *                      param of the <code>HttpSessionBindingEvent</code> if
-    *                      the listener were invoked
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is allowed, 
-    *         <code>false</code> if not
-    */
-   boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
-                                                           ClusteredSessionNotificationCause cause, 
-                                                           String attributeName,
-                                                           boolean local);
-   
-   /**
-    * Under the given conditions, are invocations of
-    * <code>HttpSessionBindingListener</code> callbacks allowed?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param attributeName value that would be passed to the <code>name</code>
-    *                      param of the <code>HttpSessionBindingEvent</code> if
-    *                      the listener were invoked
-    * @param local  <code>true</code> if the event driving the notification 
-    *               originated on this node; <code>false</code> otherwise
-    *               
-    * @return <code>true</code> if the notification is allowed, 
-    *         <code>false</code> if not
-    */
-   boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
-                                                         ClusteredSessionNotificationCause cause,  
-                                                         String attributeName,
-                                                         boolean local);
-
-   /**
-    * Under the given conditions, are invocations of
-    * <code>HttpSessionActivationListener</code> callbacks allowed?
-    * 
-    * @param status the status of the session
-    * @param cause  the cause of the session notification
-    * @param attributeName value that would be passed to the <code>name</code>
-    *                      param of the <code>HttpSessionEvent</code> if
-    *                      the listener were invoked
-    *               
-    * @return <code>true</code> if the notification is allowed, 
-    *         <code>false</code> if not
-    */
-   boolean isHttpSessionActivationListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
-                                                           ClusteredSessionNotificationCause cause, 
-                                                           String attributeName);
-   
-   /**
-    * Provides the policy information about the container's capabilities with
-    * respect to issuing notifications. Will be invoked by the container before
-    * the first invocation of any of the other methods in this interface.
-    * 
-    * @param capability the capability, Will not be <code>null</code>.
-    */
-   void setClusteredSessionNotificationCapability(ClusteredSessionNotificationCapability capability);
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Policy for determining whether the servlet spec notifications related
+ * to session events are allowed to be emitted on the local cluster node.
+ * <p>
+ * <strong>Note:</strong> The use of the word <strong>allowed</strong> above
+ * is intentional; if a given policy implementation returns <code>true</code>
+ * from one of the methods in this interface, that does not mean the listener
+ * will be invoked by the container, nor does the presence of a method in this 
+ * interface imply that it will be invoked by the container in all cases. The
+ * only contract this interface creates is that before invoking a listener
+ * method, the container will invoke an implementation of this policy to 
+ * get permission and will not invoke the listeners if this policy returns
+ * <code>false</code>. If the container does not support emitting notifications
+ * in certain cases, it may not bother checking if the notification is allowed,
+ * and even if it checks, it still will not emit the notification.
+ * </p>
+ * <p>
+ * An example of a case where the container may not support emitting a 
+ * notification is for a session that has never been used locally.
+ * </p>
+ * 
+ * @author Brian Stansberry
+ */
+public interface ClusteredSessionNotificationPolicy
+{
+   /**
+    * Are invocations of <code>HttpSessionListener</code> callbacks
+    * allowed under the given conditions?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                  ClusteredSessionNotificationCause cause, 
+                                                  boolean local);
+
+
+   /**
+    * Under the given conditions, are invocations of
+    * <code>HttpSessionAttributeListener</code> callbacks allowed?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param attributeName value that would be passed to the <code>name</code>
+    *                      param of the <code>HttpSessionBindingEvent</code> if
+    *                      the listener were invoked
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           String attributeName,
+                                                           boolean local);
+   
+   /**
+    * Under the given conditions, are invocations of
+    * <code>HttpSessionBindingListener</code> callbacks allowed?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param attributeName value that would be passed to the <code>name</code>
+    *                      param of the <code>HttpSessionBindingEvent</code> if
+    *                      the listener were invoked
+    * @param local  <code>true</code> if the event driving the notification 
+    *               originated on this node; <code>false</code> otherwise
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                         ClusteredSessionNotificationCause cause,  
+                                                         String attributeName,
+                                                         boolean local);
+
+   /**
+    * Under the given conditions, are invocations of
+    * <code>HttpSessionActivationListener</code> callbacks allowed?
+    * 
+    * @param status the status of the session
+    * @param cause  the cause of the session notification
+    * @param attributeName value that would be passed to the <code>name</code>
+    *                      param of the <code>HttpSessionEvent</code> if
+    *                      the listener were invoked
+    *               
+    * @return <code>true</code> if the notification is allowed, 
+    *         <code>false</code> if not
+    */
+   boolean isHttpSessionActivationListenerInvocationAllowed(ClusteredSessionManagementStatus status, 
+                                                           ClusteredSessionNotificationCause cause, 
+                                                           String attributeName);
+   
+   /**
+    * Provides the policy information about the container's capabilities with
+    * respect to issuing notifications. Will be invoked by the container before
+    * the first invocation of any of the other methods in this interface.
+    * 
+    * @param capability the capability, Will not be <code>null</code>.
+    */
+   void setClusteredSessionNotificationCapability(ClusteredSessionNotificationCapability capability);
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicy.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,29 +1,29 @@
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * Base superclass for a {@link ClusteredSessionNotificationPolicy} implementation.
- * 
- * @author Brian Stansberry
- *
- */
-public class ClusteredSessionNotificationPolicyBase 
-{
-
-   private ClusteredSessionNotificationCapability capability;
-
-   public ClusteredSessionNotificationPolicyBase()
-   {
-      super();
-   }
-
-   public void setClusteredSessionNotificationCapability(ClusteredSessionNotificationCapability capability)
-   {
-      this.capability = capability;
-   }
-
-   public ClusteredSessionNotificationCapability getClusteredSessionNotificationCapability()
-   {
-      return this.capability;
-   }
-
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Base superclass for a {@link ClusteredSessionNotificationPolicy} implementation.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class ClusteredSessionNotificationPolicyBase 
+{
+
+   private ClusteredSessionNotificationCapability capability;
+
+   public ClusteredSessionNotificationPolicyBase()
+   {
+      super();
+   }
+
+   public void setClusteredSessionNotificationCapability(ClusteredSessionNotificationCapability capability)
+   {
+      this.capability = capability;
+   }
+
+   public ClusteredSessionNotificationCapability getClusteredSessionNotificationCapability()
+   {
+      return this.capability;
+   }
+
 }
\ No newline at end of file


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/ClusteredSessionNotificationPolicyBase.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,64 +1,64 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * Does not allow invocation of HttpSessionListener or HttpSessionAttributeListener
- * during session expiration due to undeploy.
- * 
- * @author Brian Stansberry
- */
-public class IgnoreUndeployLegacyClusteredSessionNotificationPolicy 
-   extends LegacyClusteredSessionNotificationPolicy
-{
-   /**
-    * Overrides superclass to return <code>false</code> if the cause of the
-    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
-    *  
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code> and the cause of the notification is not
-    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
-    */
-   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
-   {
-      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
-               && super.isHttpSessionAttributeListenerInvocationAllowed(status, cause, attributeName, local);
-   }
-
-   /**
-    * Overrides superclass to return <code>false</code> if the cause of the
-    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
-    *  
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code> and the cause of the notification is not
-    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
-    */
-   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, boolean local)
-   {
-      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
-               && isHttpSessionListenerInvocationAllowed(status, cause, local);
-   }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * Does not allow invocation of HttpSessionListener or HttpSessionAttributeListener
+ * during session expiration due to undeploy.
+ * 
+ * @author Brian Stansberry
+ */
+public class IgnoreUndeployLegacyClusteredSessionNotificationPolicy 
+   extends LegacyClusteredSessionNotificationPolicy
+{
+   /**
+    * Overrides superclass to return <code>false</code> if the cause of the
+    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    *  
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code> and the cause of the notification is not
+    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    */
+   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
+               && super.isHttpSessionAttributeListenerInvocationAllowed(status, cause, attributeName, local);
+   }
+
+   /**
+    * Overrides superclass to return <code>false</code> if the cause of the
+    * notification is {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    *  
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code> and the cause of the notification is not
+    *         {@link ClusteredSessionNotificationCause.UNDEPLOY}.
+    */
+   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, boolean local)
+   {
+      return !ClusteredSessionNotificationCause.UNDEPLOY.equals(cause) 
+               && isHttpSessionListenerInvocationAllowed(status, cause, local);
+   }
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/IgnoreUndeployLegacyClusteredSessionNotificationPolicy.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,87 +1,87 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.web.tomcat.service.session.notification;
-
-/**
- * {@link ClusteredSessionNotificationPolicy} implementation that
- * describes the behavior of JBoss AS releases prior to 4.2.4.
- * 
- * @author Brian Stansberry
- */
-public class LegacyClusteredSessionNotificationPolicy 
-   extends ClusteredSessionNotificationPolicyBase 
-   implements ClusteredSessionNotificationPolicy
-{
-   // -------------------------------------- ClusteredSessionNotificationPolicy
-   
-   /**
-    * {@inheritDoc}
-    * 
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code>.
-    */
-   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
-   {
-      return status.isLocallyUsed();
-   }
-
-   /**
-    * {@inheritDoc}
-    * 
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code>.
-    */
-   public boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
-   {
-      return status.isLocallyUsed();
-   }
-
-   /**
-    * {@inheritDoc}
-    * 
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code>.
-    */
-   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, boolean local)
-   {
-      return status.isLocallyUsed() && !ClusteredSessionNotificationCause.FAILOVER.equals(cause);
-   }
-
-   /**
-    * {@inheritDoc}
-    * 
-    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
-    *         is <code>true</code>.
-    */
-   public boolean isHttpSessionActivationListenerInvocationAllowed(ClusteredSessionManagementStatus status,
-         ClusteredSessionNotificationCause cause, String attributeName)
-   {
-      return status.isLocallyUsed();
-   }
-   
-   
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.notification;
+
+/**
+ * {@link ClusteredSessionNotificationPolicy} implementation that
+ * describes the behavior of JBoss AS releases prior to 4.2.4.
+ * 
+ * @author Brian Stansberry
+ */
+public class LegacyClusteredSessionNotificationPolicy 
+   extends ClusteredSessionNotificationPolicyBase 
+   implements ClusteredSessionNotificationPolicy
+{
+   // -------------------------------------- ClusteredSessionNotificationPolicy
+   
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return status.isLocallyUsed();
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      return status.isLocallyUsed();
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, boolean local)
+   {
+      return status.isLocallyUsed() && !ClusteredSessionNotificationCause.FAILOVER.equals(cause);
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return <code>true</code> if <code>status.isLocallyUsed()</code>
+    *         is <code>true</code>.
+    */
+   public boolean isHttpSessionActivationListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName)
+   {
+      return status.isLocallyUsed();
+   }
+   
+   
+
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/notification/LegacyClusteredSessionNotificationPolicy.java
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/resources/jboss-beans.xml
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/resources/jboss-structure-sar.xml
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/resources/jboss-structure.xml
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/resources/test/metadata/server.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/tests/org/jboss/test/deployers/jboss-web24-ex1.xml
===================================================================
--- trunk/tomcat/src/tests/org/jboss/test/deployers/jboss-web24-ex1.xml	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/tests/org/jboss/test/deployers/jboss-web24-ex1.xml	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,9 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE jboss-web PUBLIC
-        "-//JBoss//DTD Web Application 2.3V2//EN"
-    "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
-
-<jboss-web>
-    <context-root>testWebAppJBossWebApp</context-root>
-</jboss-web>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC
+        "-//JBoss//DTD Web Application 2.3V2//EN"
+    "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+    <context-root>testWebAppJBossWebApp</context-root>
+</jboss-web>


Property changes on: trunk/tomcat/src/tests/org/jboss/test/deployers/jboss-web24-ex1.xml
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/tomcat/src/tests/org/jboss/test/web/metadata/ServerMetaDataUniTestCase.java
===================================================================
--- trunk/tomcat/src/tests/org/jboss/test/web/metadata/ServerMetaDataUniTestCase.java	2008-11-14 17:02:25 UTC (rev 81078)
+++ trunk/tomcat/src/tests/org/jboss/test/web/metadata/ServerMetaDataUniTestCase.java	2008-11-14 17:02:59 UTC (rev 81079)
@@ -1,66 +1,66 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.web.metadata;
-
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.web.tomcat.metadata.ListenerMetaData;
-import org.jboss.web.tomcat.metadata.ServerMetaData;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.builder.JBossXBBuilder;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ServerMetaDataUniTestCase extends TestCase
-{
-
-   public void test() throws Exception
-   {
-      SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
-      Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
-      u.setSchemaValidation(false);
-      u.setValidation(false);
-      u.setEntityResolver(new JBossEntityResolver());
-
-      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test/metadata/server.xml");
-
-      ServerMetaData m = ServerMetaData.class.cast(u.unmarshal(is, schema));
-      assertNotNull(m);
-      assertNotNull(m.getListeners());
-      assertNotNull(m.getServices());
-      
-      assertEquals(2, m.getListeners().size());
-      ListenerMetaData l = m.getListeners().get(0);
-      assertNotNull(l);
-      assertEquals(l.getClassName(), "org.apache.catalina.core.AprLifecycleListener");
-      assertEquals("on", l.getAttributes().get("SSLEngine"));
-   }
-   
-}
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.web.metadata;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.web.tomcat.metadata.ListenerMetaData;
+import org.jboss.web.tomcat.metadata.ServerMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.builder.JBossXBBuilder;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ServerMetaDataUniTestCase extends TestCase
+{
+
+   public void test() throws Exception
+   {
+      SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
+      Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
+      u.setSchemaValidation(false);
+      u.setValidation(false);
+      u.setEntityResolver(new JBossEntityResolver());
+
+      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test/metadata/server.xml");
+
+      ServerMetaData m = ServerMetaData.class.cast(u.unmarshal(is, schema));
+      assertNotNull(m);
+      assertNotNull(m.getListeners());
+      assertNotNull(m.getServices());
+      
+      assertEquals(2, m.getListeners().size());
+      ListenerMetaData l = m.getListeners().get(0);
+      assertNotNull(l);
+      assertEquals(l.getClassName(), "org.apache.catalina.core.AprLifecycleListener");
+      assertEquals("on", l.getAttributes().get("SSLEngine"));
+   }
+   
+}
+


Property changes on: trunk/tomcat/src/tests/org/jboss/test/web/metadata/ServerMetaDataUniTestCase.java
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: trunk/tomcat/src/webapps/ROOT.war/favicon.ico
___________________________________________________________________
Name: svn:mime-type
   - application/octet-stream
   + image/x-icon


Property changes on: trunk/tomcat/src/webapps/ROOT.war/images/logo.gif
___________________________________________________________________
Name: svn:mime-type
   - application/octet-stream
   + image/gif




More information about the jboss-cvs-commits mailing list