[jboss-cvs] JBossAS SVN: r93215 - in trunk: server/src/main/org/jboss/web/deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 4 13:18:23 EDT 2009
Author: remy.maucherat at jboss.com
Date: 2009-09-04 13:18:23 -0400 (Fri, 04 Sep 2009)
New Revision: 93215
Modified:
trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java
trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
Log:
- Start adding some TLD processing code.
Modified: trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2009-09-04 16:55:32 UTC (rev 93214)
+++ trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -174,6 +174,9 @@
try
{
+ // FIXME: Actually investigate to see when this deployer is run
+ // FIXME: Actually, process classpath elements one by one according to the order,
+ // producing a separate WebMetaData for each one (only for web metadata)
processMetaData(unit, webMetaData, clientMetaData, classpath);
}
catch (Exception e)
Modified: trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java 2009-09-04 16:55:32 UTC (rev 93214)
+++ trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -22,6 +22,7 @@
package org.jboss.deployment;
import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.metadata.web.spec.TldMetaData;
import org.jboss.virtual.VirtualFile;
@@ -44,4 +45,10 @@
setSuffix(".tld");
setAllowMultipleFiles(true);
}
+
+ protected void init(VFSDeploymentUnit unit, TldMetaData metaData, VirtualFile file) throws Exception
+ {
+ unit.addAttachment(file.toURL().toString(), metaData, getOutput());
+ }
+
}
Modified: trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java 2009-09-04 16:55:32 UTC (rev 93214)
+++ trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -22,7 +22,9 @@
package org.jboss.deployment;
import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.metadata.web.spec.WebFragmentMetaData;
+import org.jboss.virtual.VirtualFile;
/**
* An ObjectModelFactoryDeployer for translating web-fragment.xml descriptors into
@@ -64,4 +66,9 @@
setName(WebFragmentMetaData);
}
+ protected void init(VFSDeploymentUnit unit, WebFragmentMetaData metaData, VirtualFile file) throws Exception
+ {
+ unit.addAttachment(file.toURL().toString(), metaData, getOutput());
+ }
+
}
Modified: trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-09-04 16:55:32 UTC (rev 93214)
+++ trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -71,6 +71,9 @@
if(specMetaData == null && metaData == null)
return;
+ // FIXME: Check for a deployment order
+
+
// Check for an annotated view
String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME;
Web25MetaData annotatedMetaData = unit.getAttachment(key, Web25MetaData.class);
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-04 16:55:32 UTC (rev 93214)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -43,6 +44,7 @@
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.deploy.JspPropertyGroup;
import org.apache.catalina.deploy.SessionCookie;
+import org.apache.catalina.deploy.jsp.TagLibraryInfo;
import org.apache.catalina.startup.ContextConfig;
import org.apache.catalina.startup.WebAnnotationSet;
import org.apache.tomcat.util.IntrospectionUtils;
@@ -82,6 +84,7 @@
import org.jboss.metadata.web.spec.SessionConfigMetaData;
import org.jboss.metadata.web.spec.SessionTrackingModeType;
import org.jboss.metadata.web.spec.TaglibMetaData;
+import org.jboss.metadata.web.spec.TldMetaData;
import org.jboss.metadata.web.spec.TransportGuaranteeType;
import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
@@ -103,11 +106,13 @@
public static ThreadLocal<JBossWebMetaData> metaDataShared = new ThreadLocal<JBossWebMetaData>();
- public static ThreadLocal<DeployerConfig> deployerConfig = new ThreadLocal<DeployerConfig>();
+ public static ThreadLocal<Map<String, TldMetaData>> tldMetaDataMapLocal = new ThreadLocal<Map<String, TldMetaData>>();
public static ThreadLocal<Kernel> kernelLocal = new ThreadLocal<Kernel>();
public static ThreadLocal<DeploymentUnit> deploymentUnitLocal = new ThreadLocal<DeploymentUnit>();
+ public static ThreadLocal<DeployerConfig> deployerConfig = new ThreadLocal<DeployerConfig>();
+
private static Logger log = Logger.getLogger(JBossContextConfig.class);
private boolean runDestroy = false;
@@ -772,4 +777,72 @@
}
}
+ /**
+ * Migrate TLD metadata to Catalina. This is separate, and is not subject to the order defined.
+ */
+ protected void applicationTldConfig()
+ {
+
+ // BEGIN TEMP CODE
+ super.applicationTldConfig();
+ tldMetaDataMapLocal.set(null);
+ // END TEMP CODE
+
+ Map<String, TldMetaData> tldMetaDataMap = tldMetaDataMapLocal.get();
+ if (tldMetaDataMap == null)
+ {
+ return;
+ }
+
+ ArrayList<TagLibraryInfo> tagLibraries = new ArrayList<TagLibraryInfo>();
+
+ String base = deploymentUnitLocal.get().getName();
+
+ Iterator<String> locationInterator = tldMetaDataMap.keySet().iterator();
+ while (locationInterator.hasNext())
+ {
+ String location = locationInterator.next();
+ if (!location.startsWith(base))
+ {
+ // If there is only one TLD, it will also get mapped as this attachement
+ continue;
+ }
+ TldMetaData tldMetaData = tldMetaDataMap.get(location);
+ String relativeLocation = "/" + location.substring(base.length());
+ String jarPath = null;
+ if (relativeLocation.startsWith("/WEB-INF/lib/"))
+ {
+ int pos = relativeLocation.indexOf('/', "/WEB-INF/lib/".length());
+ if (pos > 0)
+ {
+ jarPath = relativeLocation.substring(pos);
+ relativeLocation = relativeLocation.substring(0, pos);
+ }
+ }
+ System.out.println("Add TLD: " + relativeLocation + " " + jarPath + " [" + tldMetaData + "]");
+ }
+
+ // Add additional TLDs URIs from explicit web config
+ String taglibs[] = context.findTaglibs();
+ for (int i = 0; i < taglibs.length; i++) {
+ String uri = taglibs[i];
+ String path = context.findTaglib(taglibs[i]);
+ String location = "";
+ if (path.indexOf(':') == -1 && !path.startsWith("/")) {
+ path = "/WEB-INF/" + path;
+ }
+ if (path.endsWith(".jar")) {
+ location = path;
+ path = "META-INF/taglib.tld";
+ }
+ for (int j = 0; j < tagLibraries.size(); j++) {
+ TagLibraryInfo tagLibraryInfo = tagLibraries.get(j);
+ if (tagLibraryInfo.getLocation().equals(location) && tagLibraryInfo.getPath().equals(path)) {
+ context.addJspTagLibrary(uri, tagLibraryInfo);
+ }
+ }
+ }
+
+ }
+
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-09-04 16:55:32 UTC (rev 93214)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-09-04 17:18:23 UTC (rev 93215)
@@ -41,6 +41,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.zip.ZipFile;
@@ -56,6 +57,7 @@
import org.jboss.injection.Injector;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.TldMetaData;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.naming.NonSerializableFactory;
import org.jboss.security.SecurityUtil;
@@ -172,6 +174,20 @@
StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
DeploymentUnit depUnit = webApp.getDeploymentUnit();
+
+ // Find all TLDs that have been processed by deployers, and place them in a map keyed by location
+ Map<String, TldMetaData> tldMetaDataMap = new HashMap<String, TldMetaData>();
+ Map<String, Object> attachements = depUnit.getAttachments();
+ Iterator<String> attachementNames = attachements.keySet().iterator();
+ while (attachementNames.hasNext()) {
+ String name = attachementNames.next();
+ Object attachement = depUnit.getAttachment(name);
+ if (attachement != null && attachement instanceof TldMetaData)
+ {
+ tldMetaDataMap.put(name, (TldMetaData) attachement);
+ }
+ }
+
TomcatInjectionContainer injectionContainer = new TomcatInjectionContainer(webApp, depUnit, context, getPersistenceUnitDependencyResolver());
if (kernel != null) {
@@ -230,48 +246,6 @@
}
context.setDelegate(webApp.getJava2ClassLoadingCompliance());
- // Javac compatibility whenever possible
- String[] jspCP = getCompileClasspath(loader);
- StringBuffer classpath = new StringBuffer();
- for (int u = 0; u < jspCP.length; u++)
- {
- String repository = jspCP[u];
- if (repository == null)
- continue;
- if (repository.startsWith("file://"))
- repository = repository.substring(7);
- else if (repository.startsWith("file:"))
- repository = repository.substring(5);
- else
- continue;
- if (repository == null)
- continue;
- // ok it is a file. Make sure that is is a directory or jar file
- File fp = new File(repository);
- if (!fp.isDirectory())
- {
- // if it is not a directory, try to open it as a zipfile.
- try
- {
- // avoid opening .xml files
- if (fp.getName().toLowerCase().endsWith(".xml"))
- continue;
-
- ZipFile zip = new ZipFile(fp);
- zip.close();
- }
- catch (IOException e)
- {
- continue;
- }
-
- }
- if (u > 0)
- classpath.append(File.pathSeparator);
- classpath.append(repository);
- }
- context.setCompilerClasspath(classpath.toString());
-
// Set the session cookies flag according to metadata
switch (metaData.getSessionCookies())
{
@@ -311,6 +285,7 @@
JBossContextConfig.metaDataLocal.set(metaData);
JBossContextConfig.metaDataShared.set(config.getSharedMetaData());
JBossContextConfig.deployerConfig.set(config);
+ JBossContextConfig.tldMetaDataMapLocal.set(tldMetaDataMap);
JBossContextConfig.kernelLocal.set(kernel);
JBossContextConfig.deploymentUnitLocal.set(unit);
@@ -331,6 +306,7 @@
JBossContextConfig.metaDataLocal.set(null);
JBossContextConfig.metaDataShared.set(null);
JBossContextConfig.deployerConfig.set(null);
+ JBossContextConfig.tldMetaDataMapLocal.set(null);
JBossContextConfig.kernelLocal.set(null);
JBossContextConfig.deploymentUnitLocal.set(null);
More information about the jboss-cvs-commits
mailing list