[jboss-cvs] JBossAS SVN: r94617 - in trunk: server/src/main/java/org/jboss/web/deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 9 13:57:17 EDT 2009
Author: remy.maucherat at jboss.com
Date: 2009-10-09 13:57:17 -0400 (Fri, 09 Oct 2009)
New Revision: 94617
Modified:
trunk/component-matrix/pom.xml
trunk/server/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
Log:
- Hook up some of the type and servlet instance based annotation processing.
Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml 2009-10-09 17:45:56 UTC (rev 94616)
+++ trunk/component-matrix/pom.xml 2009-10-09 17:57:17 UTC (rev 94617)
@@ -44,7 +44,7 @@
<version.jboss.jbossws>3.2.1.Beta1</version.jboss.jbossws>
<version.jboss.jms-integration-tests>1.0.1.GA</version.jboss.jms-integration-tests>
<version.jboss.messaging>1.4.1.GA</version.jboss.messaging>
- <version.jboss.web>3.0.0.alpha-5</version.jboss.web>
+ <version.jboss.web>3.0.0.alpha-7</version.jboss.web>
<version.jgroups>2.6.13.GA</version.jgroups>
<version.junit>3.8.2</version.junit>
<version.org.hibernate.annotations>3.4.0.GA</version.org.hibernate.annotations>
@@ -93,7 +93,7 @@
<version.org.jboss.metadata.ear>2.0.0.Alpha</version.org.jboss.metadata.ear>
<version.org.jboss.metadata.ejb>2.0.0.Alpha</version.org.jboss.metadata.ejb>
<version.org.jboss.metadata.rar>2.0.0.Alpha</version.org.jboss.metadata.rar>
- <version.org.jboss.metadata.war>2.0.0.Alpha3</version.org.jboss.metadata.war>
+ <version.org.jboss.metadata.war>2.0.0.Alpha4</version.org.jboss.metadata.war>
<version.org.jboss.microcontainer>2.0.8.GA</version.org.jboss.microcontainer>
<version.org.jboss.mx>6.0.0.Beta1</version.org.jboss.mx>
<version.org.jboss.naming>5.0.3.GA</version.org.jboss.naming>
Modified: trunk/server/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-10-09 17:45:56 UTC (rev 94616)
+++ trunk/server/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java 2009-10-09 17:57:17 UTC (rev 94617)
@@ -344,8 +344,17 @@
}
key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar;
annotatedMetaData = unit.getAttachment(key, WebMetaData.class);
- if (!webFragmentMetaData.isMetadataComplete() && annotatedMetaData != null)
+ if (webFragmentMetaData.isMetadataComplete() && annotatedMetaData != null)
{
+ // Discard @WebFilter, @WebListener and @WebServlet
+ annotatedMetaData.setFilters(null);
+ annotatedMetaData.setFilterMappings(null);
+ annotatedMetaData.setListeners(null);
+ annotatedMetaData.setServlets(null);
+ annotatedMetaData.setServletMappings(null);
+ }
+ if (annotatedMetaData != null)
+ {
// Merge annotation corresponding to the JAR
AnnotationMergedView.merge(webJarMetaData, webFragmentMetaData, annotatedMetaData);
}
Modified: trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
===================================================================
--- trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-10-09 17:45:56 UTC (rev 94616)
+++ trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-10-09 17:57:17 UTC (rev 94617)
@@ -25,9 +25,10 @@
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -36,12 +37,19 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.servlet.HttpConstraintElement;
+import javax.servlet.HttpMethodConstraintElement;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
+import javax.servlet.ServletSecurityElement;
+import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
+import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.xml.namespace.QName;
+import org.apache.catalina.Container;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ContextJarRepository;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.deploy.Multipart;
@@ -53,7 +61,6 @@
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;
@@ -68,9 +75,11 @@
import org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData;
import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData;
import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossAnnotationsMetaData;
import org.jboss.metadata.web.jboss.JBossServletMetaData;
import org.jboss.metadata.web.jboss.JBossServletsMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.AnnotationMetaData;
import org.jboss.metadata.web.spec.AttributeMetaData;
import org.jboss.metadata.web.spec.AuthConstraintMetaData;
import org.jboss.metadata.web.spec.CookieConfigMetaData;
@@ -80,6 +89,7 @@
import org.jboss.metadata.web.spec.FilterMetaData;
import org.jboss.metadata.web.spec.FiltersMetaData;
import org.jboss.metadata.web.spec.FunctionMetaData;
+import org.jboss.metadata.web.spec.HttpMethodConstraintMetaData;
import org.jboss.metadata.web.spec.JspConfigMetaData;
import org.jboss.metadata.web.spec.JspPropertyGroupMetaData;
import org.jboss.metadata.web.spec.ListenerMetaData;
@@ -90,6 +100,7 @@
import org.jboss.metadata.web.spec.MultipartConfigMetaData;
import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.ServletSecurityMetaData;
import org.jboss.metadata.web.spec.SessionConfigMetaData;
import org.jboss.metadata.web.spec.SessionTrackingModeType;
import org.jboss.metadata.web.spec.TagMetaData;
@@ -1040,6 +1051,89 @@
// Do nothing here
}
+ protected void resolveAnnotations(JBossAnnotationsMetaData annotations)
+ {
+ if (annotations != null)
+ {
+ for (AnnotationMetaData annotation : annotations)
+ {
+ String className = annotation.getClassName();
+ Container wrappers[] = context.findChildren();
+ for (int i = 0; i < wrappers.length; i++) {
+ Wrapper wrapper = (Wrapper) wrappers[i];
+ if (className.equals(wrapper.getServletClass()))
+ {
+
+ // Merge @RunAs
+ if (annotation.getRunAs() != null && wrapper.getRunAs() == null)
+ {
+ wrapper.setRunAs(annotation.getRunAs().getRoleName());
+ }
+ // Merge @MultipartConfig
+ if (annotation.getMultipartConfig() != null && wrapper.getMultipartConfig() == null)
+ {
+ MultipartConfigMetaData multipartConfigMetaData = annotation.getMultipartConfig();
+ Multipart multipartConfig = new Multipart();
+ multipartConfig.setLocation(multipartConfigMetaData.getLocation());
+ multipartConfig.setMaxRequestSize(multipartConfigMetaData.getMaxRequestSize());
+ multipartConfig.setMaxFileSize(multipartConfigMetaData.getMaxFileSize());
+ multipartConfig.setFileSizeThreshold(multipartConfigMetaData.getFileSizeThreshold());
+ wrapper.setMultipartConfig(multipartConfig);
+ }
+ // Merge @ServletSecurity
+ if (annotation.getServletSecurity() != null && wrapper.getServletSecurity() == null)
+ {
+ ServletSecurityMetaData servletSecurityAnnotation = annotation.getServletSecurity();
+ Collection<HttpMethodConstraintElement> methodConstraints = null;
+
+ EmptyRoleSemantic emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
+ if (servletSecurityAnnotation.getEmptyRoleSemantic() != null)
+ {
+ emptyRoleSemantic = EmptyRoleSemantic.valueOf(servletSecurityAnnotation.getEmptyRoleSemantic().toString());
+ }
+ TransportGuarantee transportGuarantee = TransportGuarantee.NONE;
+ if (servletSecurityAnnotation.getTransportGuarantee() != null)
+ {
+ transportGuarantee = TransportGuarantee.valueOf(servletSecurityAnnotation.getTransportGuarantee().toString());
+ }
+ String[] roleNames = servletSecurityAnnotation.getRolesAllowed().toArray(new String[0]);
+ HttpConstraintElement constraint = new HttpConstraintElement(emptyRoleSemantic, transportGuarantee, roleNames);
+
+ if (servletSecurityAnnotation.getHttpMethodConstraints() != null)
+ {
+ methodConstraints = new HashSet<HttpMethodConstraintElement>();
+ for (HttpMethodConstraintMetaData annotationMethodConstraint :
+ servletSecurityAnnotation.getHttpMethodConstraints())
+ {
+ emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
+ if (servletSecurityAnnotation.getEmptyRoleSemantic() != null)
+ {
+ emptyRoleSemantic = EmptyRoleSemantic.valueOf(servletSecurityAnnotation.getEmptyRoleSemantic().toString());
+ }
+ transportGuarantee = TransportGuarantee.NONE;
+ if (servletSecurityAnnotation.getTransportGuarantee() != null)
+ {
+ transportGuarantee = TransportGuarantee.valueOf(servletSecurityAnnotation.getTransportGuarantee().toString());
+ }
+ roleNames = servletSecurityAnnotation.getRolesAllowed().toArray(new String[0]);
+ HttpConstraintElement constraint2 =
+ new HttpConstraintElement(emptyRoleSemantic, transportGuarantee, roleNames);
+ HttpMethodConstraintElement methodConstraint =
+ new HttpMethodConstraintElement(annotationMethodConstraint.getMethod(), constraint2);
+ methodConstraints.add(methodConstraint);
+ }
+ }
+
+ ServletSecurityElement servletSecurity = new ServletSecurityElement(constraint, methodConstraints);
+ wrapper.setServletSecurity(servletSecurity);
+ }
+
+ }
+ }
+ }
+ }
+ }
+
protected void completeConfig() {
JBossWebMetaData metaData = metaDataLocal.get();
@@ -1048,20 +1142,25 @@
if (ok && !context.getIgnoreAnnotations())
{
// Resolve type specific annotations to their corresponding Servlet components
- // TODO: metaData.resolveAnnotations();
+ metaData.resolveAnnotations();
// Same process for Catalina
- // TODO: JBossAnnotationsMetaData annotations = metaData.getAnnotations();
+ resolveAnnotations(metaData.getAnnotations());
}
-
+
if (ok)
{
+ resolveServletSecurity();
+ }
+
+ if (ok)
+ {
validateSecurityRoles();
}
if (ok)
{
// Resolve run as
- // TODO: metaData.resolveRunAs();
+ metaData.resolveRunAs();
}
// Configure an authenticator if we need one
More information about the jboss-cvs-commits
mailing list