[jboss-cvs] JBossAS SVN: r93303 - in trunk: tomcat/src/main/org/jboss/web/tomcat/service/deployers and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 8 18:33:31 EDT 2009
Author: remy.maucherat at jboss.com
Date: 2009-09-08 18:33:31 -0400 (Tue, 08 Sep 2009)
New Revision: 93303
Modified:
trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
Log:
- Add overlays (did not test).
- Use ServiceLoader to scan for ServletContainerInitializer. That's the easy part.
- I think I'll keep Catalina's configuration annotations scanning, as with AS 5, for the time being.
Modified: trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-09-08 22:16:13 UTC (rev 93302)
+++ trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-09-08 22:33:31 UTC (rev 93303)
@@ -29,8 +29,12 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.ServiceLoader;
import java.util.Set;
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.annotation.HandlesTypes;
+
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
@@ -62,6 +66,7 @@
{
public static final String WEB_MERGED_ATTACHMENT_NAME = "merged."+JBossWebMetaData.class.getName();
public static final String WEB_ORDER_ATTACHMENT_NAME = "order."+WebMetaData.class.getName();
+ public static final String WEB_OVERLAYS_ATTACHMENT_NAME = "overlays."+WebMetaData.class.getName();
/**
* Create a new MergedJBossWebMetaDataDeployer.
@@ -80,6 +85,7 @@
//
addOutput(WEB_MERGED_ATTACHMENT_NAME);
addOutput(WEB_ORDER_ATTACHMENT_NAME);
+ addOutput(WEB_OVERLAYS_ATTACHMENT_NAME);
}
public void deploy(DeploymentUnit unit) throws DeploymentException
@@ -95,6 +101,7 @@
LinkedList<String> order = new LinkedList<String>();
List<WebOrdering> orderings = new ArrayList<WebOrdering>();
HashSet<String> jarsSet = new HashSet<String>();
+ Set<VirtualFile> overlays = new HashSet<VirtualFile>();
VirtualFile webInfLib = null;
boolean fragmentFound = false;
HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>();
@@ -110,6 +117,12 @@
for (VirtualFile jar : jars)
{
jarsSet.add(jar.getName());
+ // Find overlays
+ VirtualFile overlay = jar.getChild("META-INF/resources");
+ if (overlay != null)
+ {
+ overlays.add(overlay);
+ }
}
}
catch (IOException e)
@@ -267,7 +280,31 @@
}
unit.addAttachment(WEB_ORDER_ATTACHMENT_NAME, order);
+ unit.addAttachment(WEB_OVERLAYS_ATTACHMENT_NAME, overlays);
+ // Load the ServletContainerInitializer services
+ ServiceLoader<ServletContainerInitializer> serviceLoader =
+ ServiceLoader.load(ServletContainerInitializer.class, unit.getClassLoader());
+ HashMap<Class<?>, ServletContainerInitializer> handlesTypes =
+ new HashMap<Class<?>, ServletContainerInitializer>();
+ for (ServletContainerInitializer service : serviceLoader)
+ {
+ if (service.getClass().isAnnotationPresent(HandlesTypes.class))
+ {
+ HandlesTypes handlesTypesAnnotation = service.getClass().getAnnotation(HandlesTypes.class);
+ Class<?>[] typesArray = handlesTypesAnnotation.value();
+ if (typesArray != null)
+ {
+ for (Class<?> type : typesArray)
+ {
+ handlesTypes.put(type, service);
+ }
+ }
+ }
+ }
+
+ // FIXME: Find classes which extend, implement, or are annotated by HandlesTypes
+
// The fragments and corresponding annotations will need to be merged in order
// 1: Merge specMetaData into mergedMetaData
// 2: For each JAR in the order:
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-09-08 22:16:13 UTC (rev 93302)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-09-08 22:33:31 UTC (rev 93303)
@@ -48,6 +48,8 @@
import org.apache.catalina.deploy.jsp.TagLibraryValidatorInfo;
import org.apache.catalina.deploy.jsp.TagVariableInfo;
import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.WebAnnotationSet;
+import org.apache.naming.resources.ProxyDirContext;
import org.apache.tomcat.util.IntrospectionUtils;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -94,6 +96,7 @@
import org.jboss.util.StringPropertyReplacer;
import org.jboss.util.xml.JBossEntityResolver;
import org.jboss.virtual.VirtualFile;
+import org.jboss.web.deployers.MergedJBossWebMetaDataDeployer;
import org.jboss.web.tomcat.metadata.ContextMetaData;
import org.jboss.web.tomcat.metadata.ParameterMetaData;
import org.jboss.xb.binding.Unmarshaller;
@@ -493,8 +496,7 @@
{
for (SessionTrackingModeType stmt : scmd.getSessionTrackingModes())
{
- // FIXME: woops, I forgot to expose it in Context
- ((org.apache.catalina.core.StandardContext) context).addSessionTrackingMode(stmt.toString());
+ context.addSessionTrackingMode(stmt.toString());
}
}
if (scmd.getCookieConfig() != null)
@@ -720,6 +722,7 @@
}
// Context/Manager
+ // FIXME: add store
if (contextMetaData.getManager() != null)
{
context.setManager((org.apache.catalina.Manager)TomcatService.getInstance(contextMetaData.getManager(),
@@ -983,4 +986,55 @@
// Do nothing here
}
+ protected void completeConfig() {
+
+ // FIXME:
+ // It is possible it will be done elsewhere in the future, but these annotations
+ // are harder to deal with in AS, and pass to the servlet container; redoing it is cheap,
+ // but takes away some overriding capabilities
+ // Scan all Servlet API related annotations
+ if (ok && !context.getIgnoreAnnotations())
+ {
+ WebAnnotationSet.loadApplicationAnnotations(context);
+ }
+
+ if (ok)
+ {
+ validateSecurityRoles();
+ }
+
+ // Configure an authenticator if we need one
+ if (ok)
+ {
+ authenticatorConfig();
+ }
+
+ // Find and configure overlays
+ if (ok) {
+ if (context.getResources() instanceof ProxyDirContext) {
+ Set<VirtualFile> overlays = (Set<VirtualFile>)
+ deploymentUnitLocal.get().getAttachment(MergedJBossWebMetaDataDeployer.WEB_OVERLAYS_ATTACHMENT_NAME);
+ ProxyDirContext resources = (ProxyDirContext) context.getResources();
+ for (VirtualFile overlay : overlays)
+ {
+ VFSDirContext vfsDirContext = new VFSDirContext(overlay);
+ resources.addOverlay(vfsDirContext);
+ }
+ }
+ else
+ {
+ // Error, overlays need a ProxyDirContext to compose results
+ log.error(sm.getString("contextConfig.noOverlay", context.getName()));
+ ok = false;
+ }
+ }
+
+ // Make our application unavailable if problems were encountered
+ if (!ok) {
+ log.error(sm.getString("contextConfig.unavailable"));
+ context.setConfigured(false);
+ }
+
+ }
+
}
More information about the jboss-cvs-commits
mailing list