[jboss-cvs] JBossAS SVN: r58161 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 6 15:11:51 EST 2006


Author: scott.stark at jboss.org
Date: 2006-11-06 15:11:50 -0500 (Mon, 06 Nov 2006)
New Revision: 58161

Removed:
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/WarDeployer.java
Log:
Remove the WarDeployer prototype

Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/WarDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/WarDeployer.java	2006-11-06 20:04:47 UTC (rev 58160)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/WarDeployer.java	2006-11-06 20:11:50 UTC (rev 58161)
@@ -1,508 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt 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.tc6.deployers;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.Policy;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentUnit;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.ejb.Container;
-import org.jboss.metadata.WebMetaData;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.security.AuthorizationManager;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceConstructorMetaData;
-import org.jboss.system.metadata.ServiceInjectionValueMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.web.WebApplication;
-import org.jboss.web.WebPermissionMapping;
-import org.jboss.web.tomcat.tc6.DeployerConfig;
-
-/**
- * The war deployer that transforms a WebMetaData deployment type into a kernel bean
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.com
- * @version $Revision:$
- */
-public class WarDeployer extends AbstractSimpleRealDeployer<WebMetaData>
-{
-   /**
-    * The parent class loader first model flag
-    */
-   protected boolean java2ClassLoadingCompliance = false;
-   /**
-    * A flag indicating if war archives should be unpacked
-    */
-   protected boolean unpackWars = true;
-   /**
-    * If true, ejb-links that don't resolve don't cause an error (fallback to
-    * jndi-name)
-    */
-   protected boolean lenientEjbLink = false;
-
-   /**
-    * The default security-domain name to use
-    */
-   protected String defaultSecurityDomain;
-   private DeployerConfig config = new DeployerConfig();
-
-   public WarDeployer()
-   {
-      super(WebMetaData.class);
-   }
-
-   /**
-    * Get the flag indicating if the normal Java2 parent first class loading
-    * model should be used over the servlet 2.3 web container first model.
-    * @return true for parent first, false for the servlet 2.3 model
-    * @jmx.managed-attribute
-    */
-   public boolean getJava2ClassLoadingCompliance()
-   {
-      return java2ClassLoadingCompliance;
-   }
-
-   /**
-    * Set the flag indicating if the normal Java2 parent first class loading
-    * model should be used over the servlet 2.3 web container first model.
-    * @param flag true for parent first, false for the servlet 2.3 model
-    * @jmx.managed-attribute
-    */
-   public void setJava2ClassLoadingCompliance(boolean flag)
-   {
-      java2ClassLoadingCompliance = flag;
-   }
-
-   /**
-    * Get the flag indicating if war archives should be unpacked. This may need
-    * to be set to false as long extraction paths under deploy can show up as
-    * deployment failures on some platforms.
-    * @return true is war archives should be unpacked
-    * @jmx.managed-attribute
-    */
-   public boolean getUnpackWars()
-   {
-      return unpackWars;
-   }
-
-   /**
-    * Get the flag indicating if war archives should be unpacked. This may need
-    * to be set to false as long extraction paths under deploy can show up as
-    * deployment failures on some platforms.
-    * @param flag , true is war archives should be unpacked
-    * @jmx.managed-attribute
-    */
-   public void setUnpackWars(boolean flag)
-   {
-      this.unpackWars = flag;
-   }
-
-   /**
-    * Get the flag indicating if ejb-link errors should be ignored in favour of
-    * trying the jndi-name in jboss-web.xml
-    * @return a <code>boolean</code> value
-    * @jmx.managed-attribute
-    */
-   public boolean getLenientEjbLink()
-   {
-      return lenientEjbLink;
-   }
-
-   /**
-    * Set the flag indicating if ejb-link errors should be ignored in favour of
-    * trying the jndi-name in jboss-web.xml
-    * @jmx.managed-attribute
-    */
-   public void setLenientEjbLink(boolean flag)
-   {
-      lenientEjbLink = flag;
-   }
-
-   /**
-    * Get the default security domain implementation to use if a war does not
-    * declare a security-domain.
-    * @return jndi name of the security domain binding to use.
-    * @jmx.managed-attribute
-    */
-   public String getDefaultSecurityDomain()
-   {
-      return defaultSecurityDomain;
-   }
-
-   /**
-    * Set the default security domain implementation to use if a war does not
-    * declare a security-domain.
-    * @param defaultSecurityDomain - jndi name of the security domain binding to
-    * use.
-    * @jmx.managed-attribute
-    */
-   public void setDefaultSecurityDomain(String defaultSecurityDomain)
-   {
-      this.defaultSecurityDomain = defaultSecurityDomain;
-   }
-
-   /**
-    * Deploy a web app based on the WebMetaData.
-    * @param unit - the war for the deployment
-    * @param metaData - the metadata for the deployment
-    */
-   @Override
-   public void deploy(DeploymentUnit unit, WebMetaData metaData)
-      throws DeploymentException
-   {
-      String ctxPath = metaData.getContextRoot();
-      if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
-      {
-         log.debug("deploy root context=" + ctxPath);
-         ctxPath = "/";
-         metaData.setContextRoot(ctxPath);
-      }
-
-      Thread thread = Thread.currentThread();
-      ClassLoader appClassLoader = thread.getContextClassLoader();
-      WebApplication warInfo = null;
-      try
-      {
-         // Create a classloader for the war to ensure a unique ENC
-         URL[] empty = {};
-         ClassLoader ucl = unit.getClassLoader();
-         URLClassLoader warLoader1 = URLClassLoader.newInstance(empty, ucl);
-         URLClassLoader warLoader = warLoader1;
-         thread.setContextClassLoader(warLoader);
-         String webContext = null; // TODO
-         if (webContext != null && webContext.startsWith("/") == false)
-            webContext = "/" + webContext;
-
-         // Get the war URL
-         URL warURL = unit.getDeploymentContext().getRoot().toURL();
-
-         log.debug("webContext: " + webContext);
-         log.debug("warURL: " + warURL);
-
-         /* TODO: this needs to be coming from the metadata parsing
-         inherit the security setup from jboss-app.xml
-         if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
-         {
-            J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData) di.parent.metaData;
-
-            if (metaData.getSecurityDomain() == null)
-               metaData.setSecurityDomain(appMetaData.getSecurityDomain());
-
-            metaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
-         }
-         */
-
-         // Register the permissions with the JACC layer
-         String contextID = unit.getName();
-         metaData.setJaccContextID(contextID);
-         PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
-         PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
-         createPermissions(metaData, pc);
-         // Link this to the parent PC
-         DeploymentContext current = unit.getDeploymentContext();
-         while (current.getParent() != null)
-            current = current.getParent();
-         PolicyConfiguration parentPC =
-            current.getTransientAttachments().getAttachment(PolicyConfiguration.class);
-         if (parentPC != null && parentPC != pc)
-            parentPC.linkConfiguration(pc);
-
-         // Commit the policy configuration
-         pc.commit();
-         // Allow the policy to incorporate the policy configs
-         Policy.getPolicy().refresh();
-
-         warInfo = new WebApplication(metaData);
-         warInfo.setClassLoader(warLoader);
-         warInfo.setDeployerConfig(config);
-         performDeploy(unit, warInfo, warURL.toString());
-      }
-      catch (Exception e)
-      {
-         throw DeploymentException.rethrowAsDeploymentException("Error creating war deployment " + unit.getName(), e);
-      }
-      finally
-      {
-         thread.setContextClassLoader(appClassLoader);
-      }
-   }
-
-   protected void performDeploy(DeploymentUnit unit, WebApplication warInfo, String warUrl)
-      throws Exception
-   {
-      WebMetaData metaData = warInfo.getMetaData();
-      // TODO: Need to remove the dependency on MBeanServer
-      MBeanServer server = MBeanServerLocator.locateJBoss();
-      String hostName = null;
-      // Get any jboss-web/virtual-hosts
-      Iterator vhostNames = metaData.getVirtualHosts();
-      // Map the virtual hosts onto the configured hosts
-      Iterator hostNames = mapVirtualHosts(server, warInfo, vhostNames);
-      if (hostNames.hasNext())
-      {
-         hostName = hostNames.next().toString();
-      }
-      performDeployInternal(unit, hostName, warInfo, warUrl);
-      while (hostNames.hasNext())
-      {
-         String additionalHostName = hostNames.next().toString();
-         performDeployInternal(unit, additionalHostName, warInfo, warUrl);
-      }
-   }
-
-   protected void performDeployInternal(DeploymentUnit unit, String hostName,
-         WebApplication warInfo, String warUrl)
-      throws Exception
-   {
-      log.debug("performDeployInternal, hostName="+hostName);
-      try
-      {
-         ServiceMetaData warDeployment = new ServiceMetaData();
-         String name = getObjectName(warInfo, hostName);
-         ObjectName objectName = new ObjectName(name);
-         warDeployment.setObjectName(objectName);
-         warDeployment.setCode(TomcatDeployment.class.getName());
-         ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
-         constructor.setSignature(new String[] { WebApplication.class.getName(),
-               "java.lang.String", "java.lang.String"});
-         constructor.setParameters(new Object[] { warInfo, hostName, warUrl});
-         warDeployment.setConstructor(constructor);
-         
-         List<ServiceAttributeMetaData> attributes = new ArrayList<ServiceAttributeMetaData>();
-         ServiceAttributeMetaData attribute = null;
-         // ORB
-         {
-            attribute = new ServiceAttributeMetaData();
-            attribute.setName("ORB");
-            attribute.setValue(new ServiceInjectionValueMetaData(Container.ORB_NAME));
-            attributes.add(attribute);
-         }
-         if( attributes.isEmpty() == false )
-            warDeployment.setAttributes(attributes);
-
-         // TODO component
-         unit.addAttachment(ServiceMetaData.class, warDeployment);
-      }
-      catch (Exception e)
-      {
-         throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
-      }
-
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, WebMetaData deployment)
-   {
-      log.debug("undeploy, deployment="+deployment);
-      try
-      {
-         // TODO: Need to remove the dependency on MBeanServer
-         MBeanServer server = MBeanServerLocator.locateJBoss();
-         URL warURL = unit.getDeploymentContext().getRoot().toURL();
-         String warUrl = warURL.toString();
-         WebApplication webApp = unit.getAttachment(WebApplication.class);
-         performUndeploy(server, warUrl, webApp);
-         // Unregister the permissions with the JACC layer
-         WebMetaData metaData = webApp.getMetaData();
-         String contextID = metaData.getJaccContextID();
-         PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
-         PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
-         pc.delete();
-         //Unregister any xacml policies
-         String prefixedSecurityDomain = webApp.getMetaData().getSecurityDomain();
-         if(prefixedSecurityDomain != null)
-         {
-            AuthorizationManager authzmgr = 
-                org.jboss.security.Util.getAuthorizationManager(prefixedSecurityDomain);
-            if(authzmgr instanceof PolicyRegistration)
-            {
-               PolicyRegistration xam = (PolicyRegistration)authzmgr;
-               xam.deRegisterPolicy(contextID);
-            } 
-         } 
-      }
-      catch (Exception e)
-      {
-         log.error("Error during deploy", e);
-      }
-   }
-   /**
-    * Called as part of the undeploy() method template to ask the
-    * subclass for perform the web container specific undeployment steps.
-    */
-   protected void performUndeploy(MBeanServer server, String warUrl, WebApplication appInfo)
-      throws Exception
-   {
-      if (appInfo == null)
-      {
-         log.debug("performUndeploy, no WebApplication found for URL "
-            + warUrl);
-         return;
-      }
-
-      log.info("undeploy, ctxPath=" + appInfo.getMetaData().getContextRoot()
-         + ", warUrl=" + warUrl);
-
-      WebMetaData metaData = appInfo.getMetaData();
-      String hostName = null;
-      Iterator hostNames = metaData.getVirtualHosts();
-      if (hostNames.hasNext())
-      {
-         hostName = hostNames.next().toString();
-      }
-      performUndeployInternal(server, hostName, warUrl, appInfo);
-      while (hostNames.hasNext())
-      {
-         String additionalHostName = hostNames.next().toString();
-         performUndeployInternal(server, additionalHostName, warUrl, appInfo);
-      }
-
-   }
-
-    protected void performUndeployInternal(MBeanServer server, String hostName,
-          String warUrl, WebApplication appInfo)
-       throws Exception
-    {
-
-       WebMetaData metaData = appInfo.getMetaData();
-       String ctxPath = metaData.getContextRoot();
-
-       // If the server is gone, all apps were stopped already
-       if (server == null)
-          return;
-
-       ObjectName objectName = new ObjectName(appInfo.getDomain()
-          + ":j2eeType=WebModule,name=//" +
-          ((hostName == null) ? "localhost" : hostName)
-          + ctxPath + ",J2EEApplication=none,J2EEServer=none");
-
-       if (server.isRegistered(objectName))
-       {
-          // Contexts should be stopped by the host already
-          server.invoke(objectName, "destroy", new Object[]{},
-             new String[]{});
-       }
-
-    }
-
-
-   /**
-    * Create the JACC permission based on the security constraints obtained from
-    * the web.xml metadata.
-    * @param metaData
-    * @param pc
-    * @throws PolicyContextException
-    */
-   protected void createPermissions(WebMetaData metaData, PolicyConfiguration pc)
-      throws PolicyContextException
-   {
-      WebPermissionMapping.createPermissions(metaData, pc);
-   }
-
-   /**
-    * 
-    * @param unit
-    * @param cmd
-    * @return
-    */
-   protected String getObjectName(WebApplication warInfo, String hostName)
-   {
-      String ctxPath = warInfo.getMetaData().getContextRoot();
-      String objectName = warInfo.getDomain()
-      + ":j2eeType=WebModule,name=//" +
-      ((hostName == null) ? "localhost" : hostName)
-      + ctxPath + ",J2EEApplication=none,J2EEServer=none";
-
-      return objectName;
-   }
-
-   /**
-    * Resolve the input virtual host names to the names of the configured Hosts
-    * @param vhostNames Iterator<String> for the jboss-web/virtual-host elements 
-    * @return Iterator<String> of the unique Host names
-    * @throws Exception
-    */
-   protected synchronized Iterator mapVirtualHosts(MBeanServer server, WebApplication config, Iterator vhostNames)
-      throws Exception
-   {
-      Map vhostToHostNames = config.getVhostToHostNames();
-      if (vhostToHostNames.size() == 0)
-      {
-         // Query the configured Host mbeans
-         String hostQuery = config.getDomain() + ":type=Host,*";
-         ObjectName query = new ObjectName(hostQuery);
-         Set hosts = server.queryNames(query, null);
-         Iterator iter = hosts.iterator();
-         while (iter.hasNext())
-         {
-            ObjectName host = (ObjectName)iter.next();
-            String name = host.getKeyProperty("host");
-            if (name != null)
-            {
-               vhostToHostNames.put(name, name);
-               String[] aliases = (String[])
-                  server.invoke(host, "findAliases", null, null);
-               int count = aliases != null ? aliases.length : 0;
-               for (int n = 0; n < count; n++)
-               {
-                  vhostToHostNames.put(aliases[n], name);
-               }
-            }
-         }
-      }
-
-      // Map the virtual host names to the hosts
-      HashSet hosts = new HashSet();
-      while (vhostNames.hasNext())
-      {
-         String vhost = (String)vhostNames.next();
-         String host = (String)vhostToHostNames.get(vhost);
-         if (host == null)
-         {
-            log.warn("Failed to map vhost: " + vhost);
-            // This will cause a new host to be created
-            host = vhost;
-         }
-         hosts.add(host);
-      }
-      return hosts.iterator();
-   }
-
-}




More information about the jboss-cvs-commits mailing list