[jboss-cvs] JBossAS SVN: r57302 - in trunk/tomcat: . src/main/org/jboss/web/tomcat src/main/org/jboss/web/tomcat/deployers src/tests/org/jboss/test src/tests/org/jboss/test/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Sep 30 00:31:25 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-09-30 00:31:20 -0400 (Sat, 30 Sep 2006)
New Revision: 57302

Added:
   trunk/tomcat/src/main/org/jboss/web/tomcat/deployers/
   trunk/tomcat/src/main/org/jboss/web/tomcat/deployers/WebAppParsingDeployer.java
   trunk/tomcat/src/tests/org/jboss/test/deployers/
   trunk/tomcat/src/tests/org/jboss/test/deployers/WebAppParsingDeployerTestCase.java
   trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml
   trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml
Modified:
   trunk/tomcat/.classpath
   trunk/tomcat/build.xml
Log:
First pass at the metadata deployer

Modified: trunk/tomcat/.classpath
===================================================================
--- trunk/tomcat/.classpath	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/.classpath	2006-09-30 04:31:20 UTC (rev 57302)
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/main"/>
+	<classpathentry output="output/eclipse-test-classes" kind="src" path="src/tests"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
 	<classpathentry kind="src" path="/server"/>
 	<classpathentry kind="src" path="/system"/>
 	<classpathentry kind="src" path="/cluster"/>
@@ -37,6 +38,9 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/jsp-api.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/servlet-api.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/system-jmx"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-deployers.jar"/>
+	<classpathentry sourcepath="/home/svn/JBossMC/jbossmc/deployers/src/main" kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-deployers.jar"/>
+	<classpathentry sourcepath="/home/svn/JBossMC/jbossmc/container/src/main" kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-container.jar"/>
+	<classpathentry sourcepath="/home/svn/JBossHead/projects/test/trunk/test/src/main" kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/build.xml	2006-09-30 04:31:20 UTC (rev 57302)
@@ -87,6 +87,7 @@
       <path refid="jboss.ejb3.classpath"/>
       <path refid="jboss.jca.classpath"/>
       <path refid="jboss.transaction.classpath"/>
+      <path refid="jboss.test.classpath" />
     </path>
 
     <!-- The combined thirdparty classpath -->

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/deployers/WebAppParsingDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/deployers/WebAppParsingDeployer.java	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/deployers/WebAppParsingDeployer.java	2006-09-30 04:31:20 UTC (rev 57302)
@@ -0,0 +1,51 @@
+package org.jboss.web.tomcat.deployers;
+
+import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.metadata.web.WebMetaDataObjectFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+public class WebAppParsingDeployer extends ObjectModelFactoryDeployer<WebMetaData>
+{
+   private String webXmlPath = "WEB-INF/web.xml";
+
+   public WebAppParsingDeployer()
+   {
+      super(WebMetaData.class);
+   }
+
+   public String getWebXmlPath()
+   {
+      return webXmlPath;
+   }
+   public void setWebXmlPath(String webXmlPath)
+   {
+      this.webXmlPath = webXmlPath;
+   }
+
+   @Override
+   protected void init(DeploymentUnit unit, WebMetaData metaData, VirtualFile file) throws Exception
+   {
+      // TODO Auto-generated method stub
+      super.init(unit, metaData, file);
+   }
+
+   @Override
+   protected ObjectModelFactory getObjectModelFactory()
+   {
+      return new WebMetaDataObjectFactory();
+   }
+
+   /**
+    * 
+    */
+   @Override
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      createMetaData(unit, webXmlPath, null);
+   }
+
+}

Added: trunk/tomcat/src/tests/org/jboss/test/deployers/WebAppParsingDeployerTestCase.java
===================================================================
--- trunk/tomcat/src/tests/org/jboss/test/deployers/WebAppParsingDeployerTestCase.java	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/src/tests/org/jboss/test/deployers/WebAppParsingDeployerTestCase.java	2006-09-30 04:31:20 UTC (rev 57302)
@@ -0,0 +1,61 @@
+package org.jboss.test.deployers;
+
+import java.net.URL;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.web.tomcat.deployers.WebAppParsingDeployer;
+
+public class WebAppParsingDeployerTestCase extends BaseTestCase
+{
+
+   public WebAppParsingDeployerTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * 
+    * @throws Exception
+    */
+   public void testWebApp24Ex1()
+      throws Exception
+   {
+      DeploymentUnit unit = createDeploymentUnit("org/jboss/test/deployers");
+      WebAppParsingDeployer deployer = new WebAppParsingDeployer();
+      deployer.setWebXmlPath("web24-ex1.xml");
+      deployer.deploy(unit);
+      Object dd = unit.getTransientManagedObjects().getAttachment("web24-ex1.xml");
+      log.debug("web.xml DD: "+dd);
+   }
+
+   /**
+    * 
+    * @param root
+    * @param path
+    * @return
+    * @throws Exception
+    */
+   protected VirtualFile getVirtualFile(String path) throws Exception
+   {
+      URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
+      log.debug("CodeSource: "+url);
+      return VFS.getVirtualFile(url, path);
+   }
+   protected DeploymentUnit createDeploymentUnit(String path)
+      throws Exception
+   {
+      VirtualFile file = getVirtualFile(path);
+      log.debug("Resolved path to: "+file);
+      AbstractDeploymentContext context = new AbstractDeploymentContext(file);
+      // Use the path as the metadata location
+      context.setMetaDataPath("/");
+      AbstractDeploymentUnit unit = new AbstractDeploymentUnit(context);
+      return unit;
+   }
+
+}

Added: trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml
===================================================================
--- trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/src/tests/org/jboss/test/deployers/web23-ex1.xml	2006-09-30 04:31:20 UTC (rev 57302)
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC
+"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+"http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+   <description>Security Tests Using FORM Authentication</description>
+   
+   <!-- ### Servlets -->
+   <servlet>
+       <servlet-name>SecureServlet</servlet-name>
+       <servlet-class>org.jboss.test.web.servlets.SecureServlet</servlet-class>
+   </servlet>
+   <servlet>
+       <servlet-name>SecuredPostServlet</servlet-name>
+       <servlet-class>org.jboss.test.web.servlets.SecuredPostServlet</servlet-class>
+   </servlet>
+   <servlet>
+       <servlet-name>LogoutServlet</servlet-name>
+       <servlet-class>org.jboss.test.web.servlets.LogoutServlet</servlet-class>
+   </servlet>
+   
+   <!-- The servlet and jsp page mappings -->
+   <servlet-mapping>
+       
+       <servlet-name>SecureServlet</servlet-name>
+       <url-pattern>/restricted/SecuredServlet</url-pattern>
+   </servlet-mapping>
+   <servlet-mapping>
+       <servlet-name>SecuredPostServlet</servlet-name>
+       <url-pattern>/restricted/SecuredPostServlet</url-pattern>
+   </servlet-mapping>
+   <servlet-mapping>
+       <servlet-name>LogoutServlet</servlet-name>
+       <url-pattern>/Logout</url-pattern>
+   </servlet-mapping>
+   
+   <!-- The Welcome File List -->
+   <welcome-file-list>
+       <welcome-file>index.html</welcome-file>
+   </welcome-file-list>
+   
+   <!-- ### Security -->
+   <security-constraint>
+       <web-resource-collection>
+           
+           <web-resource-name>Restricted</web-resource-name>
+           <description>Declarative security tests</description>
+           <url-pattern>/restricted/*</url-pattern>
+           <http-method>HEAD</http-method>
+           <http-method>GET</http-method>
+           <http-method>POST</http-method>
+           
+           <http-method>PUT</http-method>
+           <http-method>DELETE</http-method>
+       </web-resource-collection>
+       <auth-constraint>
+           <description>Only authenticated users can access secure content</description>
+           <role-name>AuthorizedUser</role-name>
+       </auth-constraint>
+       
+       <user-data-constraint>
+           <description>no description</description>
+           <transport-guarantee>NONE</transport-guarantee>
+       </user-data-constraint>
+   </security-constraint>
+   
+   <login-config>
+       <auth-method>FORM</auth-method>
+       
+       <form-login-config>
+           <form-login-page>/restricted/login.html</form-login-page>
+           <form-error-page>/restricted/errors.jsp</form-error-page>
+       </form-login-config>
+   </login-config>
+   
+   <security-role>
+       <description>An AuthorizedUser is one with a valid username and password</description>
+       
+       <role-name>AuthorizedUser</role-name>
+   </security-role>
+   
+</web-app>

Added: trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml
===================================================================
--- trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml	2006-09-30 04:28:23 UTC (rev 57301)
+++ trunk/tomcat/src/tests/org/jboss/test/deployers/web24-ex1.xml	2006-09-30 04:31:20 UTC (rev 57302)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.4"
+    xmlns="http://java.sun.com/xml/ns/j2ee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+    
+    <description>Web App 2.4 Descriptor</description>
+    <display-name>Web App 2.4 Descriptor on Display</display-name>
+
+    <context-param>
+        <description>A test context-param</description>
+        <param-name>contextParam1</param-name>
+        <param-value>contextParam1Value</param-value>
+    </context-param>
+    <distributable/>
+    
+    <ejb-local-ref>
+        <ejb-ref-name>SomeLocalEJB</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <local-home>org.jboss.ejb.ISomeLocalHome</local-home>
+        <local>org.jboss.ejb.ISomeLocal</local>
+    </ejb-local-ref>
+
+    <ejb-ref>
+        <ejb-ref-name>SomeEJB</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <home>org.jboss.ejb.ISomeRemoteHome</home>
+        <remote>org.jboss.ejb.ISomeRemote</remote>
+    </ejb-ref>
+
+    <env-entry>
+        <env-entry-name>aString</env-entry-name>
+        <env-entry-type>java.lang.String</env-entry-type>
+    </env-entry>
+
+    <!-- ### Security -->
+    <security-constraint>
+        <web-resource-collection>
+            <web-resource-name>Restricted</web-resource-name>
+            <description>All content is secured</description>
+            <url-pattern>/*</url-pattern>
+        </web-resource-collection>
+        <auth-constraint>
+            <description>Only authenticated users can access secure content</description>
+            <role-name>AuthorizedUser</role-name>
+        </auth-constraint>
+        <user-data-constraint>
+            <description>no description</description>
+            <transport-guarantee>NONE</transport-guarantee>
+        </user-data-constraint>
+    </security-constraint>
+    
+    <login-config>
+        <auth-method>HEADER</auth-method>
+        <realm-name>UserInRoleRealm</realm-name>
+    </login-config>
+    
+    <security-role>
+        <role-name>AuthorizedUser</role-name>
+    </security-role> 
+</web-app>




More information about the jboss-cvs-commits mailing list