[jboss-cvs] JBossAS SVN: r104614 - in trunk/tomcat/src: main/java/org/jboss/web/tomcat/service/deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 10 13:25:53 EDT 2010
Author: remy.maucherat at jboss.com
Date: 2010-05-10 13:25:52 -0400 (Mon, 10 May 2010)
New Revision: 104614
Added:
trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/NamingListener.java
Modified:
trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
trunk/tomcat/src/resources/context.xml
Log:
- Add a shell instance listener which could push/pop the naming context.
Added: trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/NamingListener.java
===================================================================
--- trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/NamingListener.java (rev 0)
+++ trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/NamingListener.java 2010-05-10 17:25:52 UTC (rev 104614)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+import org.apache.catalina.InstanceEvent;
+import org.apache.catalina.InstanceListener;
+import org.jboss.logging.Logger;
+
+/**
+ * An InstanceListener used to push/pop the application naming context.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 81037 $
+ */
+public class NamingListener implements InstanceListener
+{
+ private static Logger log = Logger.getLogger(NamingListener.class);
+ public static ThreadLocal<Object> idLocal = new ThreadLocal<Object>();
+
+ private Object id;
+
+ public NamingListener()
+ {
+ id = idLocal.get();
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public void setId(Object id)
+ {
+ this.id = id;
+ }
+
+ public void instanceEvent(InstanceEvent event)
+ {
+ String type = event.getType();
+ // Push the identity on the before init/destroy
+ if ( type.equals(InstanceEvent.BEFORE_REQUEST_EVENT)
+ || type.equals(InstanceEvent.BEFORE_DISPATCH_EVENT) )
+ {
+ // Push naming id
+ //TODO
+ }
+ // Pop the identity on the after init/destroy
+ else if ( type.equals(InstanceEvent.AFTER_REQUEST_EVENT)
+ || type.equals(InstanceEvent.AFTER_DISPATCH_EVENT) )
+ {
+ // Pop naming id
+ //TODO
+ }
+ }
+
+}
Modified: trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2010-05-10 17:07:29 UTC (rev 104613)
+++ trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2010-05-10 17:25:52 UTC (rev 104614)
@@ -69,6 +69,7 @@
import org.jboss.web.tomcat.security.RunAsListener;
import org.jboss.web.tomcat.security.SecurityAssociationValve;
import org.jboss.web.tomcat.security.SecurityContextEstablishmentValve;
+import org.jboss.web.tomcat.service.NamingListener;
import org.jboss.web.tomcat.service.TomcatInjectionContainer;
import org.jboss.web.tomcat.service.WebCtxLoader;
import org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve;
@@ -291,12 +292,14 @@
// Set listener
context.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
context.addLifecycleListener(new EncListener(loader, webLoader, injectionContainer, webApp));
-
+
// Pass the metadata to the RunAsListener via a thread local
RunAsListener.metaDataLocal.set(metaData);
JBossContextConfig.metaDataLocal.set(metaData);
JBossContextConfig.deployerConfig.set(config);
JBossContextConfig.tldMetaDataMapLocal.set(tldMetaDataMap);
+ // TODO: acquire the component ID
+ NamingListener.idLocal.set(null);
JBossContextConfig.kernelLocal.set(kernel);
JBossContextConfig.deploymentUnitLocal.set(unit);
@@ -317,6 +320,7 @@
JBossContextConfig.metaDataLocal.set(null);
JBossContextConfig.deployerConfig.set(null);
JBossContextConfig.tldMetaDataMapLocal.set(null);
+ NamingListener.idLocal.set(null);
JBossContextConfig.kernelLocal.set(null);
JBossContextConfig.deploymentUnitLocal.set(null);
Modified: trunk/tomcat/src/resources/context.xml
===================================================================
--- trunk/tomcat/src/resources/context.xml 2010-05-10 17:07:29 UTC (rev 104613)
+++ trunk/tomcat/src/resources/context.xml 2010-05-10 17:25:52 UTC (rev 104614)
@@ -13,5 +13,9 @@
role for servlet init/destroy events.
-->
<InstanceListener>org.jboss.web.tomcat.security.RunAsListener</InstanceListener>
+ <!-- Install an InstanceListener to handle the establishment of the naming
+ context.
+ -->
+ <InstanceListener>org.jboss.web.tomcat.service.NamingListener</InstanceListener>
</Context>
More information about the jboss-cvs-commits
mailing list