[jboss-cvs] JBossAS SVN: r58434 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 15 23:15:58 EST 2006
Author: scott.stark at jboss.org
Date: 2006-11-15 23:15:57 -0500 (Wed, 15 Nov 2006)
New Revision: 58434
Removed:
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6MBean.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java
Log:
Drop the legacy deployers
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java 2006-11-16 04:14:57 UTC (rev 58433)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java 2006-11-16 04:15:57 UTC (rev 58434)
@@ -1,745 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ArrayList;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.security.jacc.PolicyContext;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.deployment.SubDeployerExt;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
-import org.jboss.system.ServiceControllerMBean;
-import org.jboss.system.server.Server;
-import org.jboss.system.server.ServerImplMBean;
-import org.jboss.web.AbstractWebContainer;
-import org.jboss.web.AbstractWebDeployer;
-import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
-import org.jboss.web.tomcat.tc6.session.SessionIDGenerator;
-
-
-/**
- * An implementation of the AbstractWebContainer for the Jakarta Tomcat6
- * servlet container. It has no code dependency on tomcat - only the new JMX
- * model is used.
- * <p/>
- * Tomcat6 is organized as a set of mbeans - just like jboss.
- *
- * @deprecated see
- *
- * @author Scott.Stark at jboss.org
- * @author Costin Manolache
- * @author Wonne.Keysers at realsoftware.be
- * @author Dimitris.Andreadis at jboss.org
- * @version $Revision$
- * @see org.jboss.web.AbstractWebContainer
- */
-public class Tomcat6 extends AbstractWebContainer
- implements Tomcat6MBean, NotificationListener
-{
- // Constants -----------------------------------------------------
- public static final String NAME = "Tomcat6";
-
- /**
- * Default value for property <code>cacheName</code>. This name will be used by JBossCache exclusively
- * for Tomcat clustering, e.g., session and sso replication.
- */
- public static final String DEFAULT_CACHE_NAME =
- "jboss.cache:service=TomcatClusteringCache";
-
- // XXX We could make this configurable - so it can support other containers
- // that provide JMX-based deployment.
- private String contextClassName =
- "org.apache.catalina.core.StandardContext";
-
- /**
- * Configurable map of tomcat authenticators
- * Keyed in by the http auth method that gets
- * plugged into the Context Config and then into the StandardContext
- */
- private Properties authenticators = null;
-
- /**
- * Domain for tomcat6 mbeans
- */
- private String catalinaDomain = "Catalina";
-
- /**
- * ObjectName of a shared TreeCache used for clustered session replication
- * and clustered single-sign-on
- */
- private String cacheName = DEFAULT_CACHE_NAME;
-
- /**
- * The fully qualified name of the class that will be used for session
- * management if <tt>distributable</tt> is set to true.
- */
- protected String managerClass = "org.jboss.web.tomcat.tc6.session.JBossCacheManager";
-
- /**
- * With IntervalSnapshotManager use this interval (in ms)
- * for snapshotting
- */
- private int snapshotInterval = 1000;
-
- /**
- * Which snapshot mode should be used in clustered environment?
- * Default: instant
- */
- private String snapshotMode = "instant"; // instant or interval
-
- /**
- * Should the clustering code use a local cache for the sessions?
- */
- private boolean useLocalCache = true;
-
- /**
- * Whether we are using Apache MOD_JK(2) module or not
- */
- private boolean useJK = false;
-
- /**
- * A flag indicating if the JBoss Loader should be used
- */
- private boolean useJBossWebLoader = true;
-
- /**
- * JBAS-3358: Work directory shouldn't be deleted on Context Destroy
- */
- private boolean deleteWorkDirOnContextDestroy = false;
-
- /**
- * JBAS-2283: Provide custom header based auth support
- */
- private String httpHeaderForSSOAuth = null;
- private String sessionCookieForSSOAuth = null;
-
-
- /**
- * The server xml configuration file name
- */
- private String serverConfigFile = "server.xml";
-
- /**
- * Get the request attribute name under which the JAAS Subject is store
- */
- private String subjectAttributeName = null;
-
- /**
- * Flag indicating whether web-app specific context xmls may set the privileged flag.
- */
- private boolean allowSelfPrivilegedWebApps = false;
-
- /** The service used to flush authentication cache on session invalidation. */
- private JaasSecurityManagerServiceMBean secMgrService;
-
- /** */
- private String[] filteredPackages;
-
- /** Hold a proxy reference to myself, used when registering to MainDeployer */
- private SubDeployerExt thisProxy;
-
- public Tomcat6()
- {
- }
-
- public String getName()
- {
- return NAME;
- }
-
-
- public String getManagerClass()
- {
- return managerClass;
- }
-
- public void setManagerClass(String managerClass)
- {
- this.managerClass = managerClass;
- }
-
-
- public String getDomain()
- {
- return this.catalinaDomain;
- }
-
- public Properties getAuthenticators()
- {
- return this.authenticators;
- }
-
- public void setAuthenticators(Properties prop)
- {
- this.authenticators = prop;
- log.debug("Passed set of authenticators=" + prop);
- }
-
- /**
- * The most important atteribute - defines the managed domain.
- * A catalina instance (engine) corresponds to a JMX domain, that's
- * how we know where to deploy webapps.
- *
- * @param catalinaDomain the domain portion of the JMX ObjectNames
- */
- public void setDomain(String catalinaDomain)
- {
- this.catalinaDomain = catalinaDomain;
- }
-
- public void setContextMBeanCode(String className)
- {
- this.contextClassName = className;
- }
-
- public String getContextMBeanCode()
- {
- return contextClassName;
- }
-
- /**
- * Set the snapshot interval in milliseconds for snapshot mode = interval
- */
- public void setSnapshotInterval(int interval)
- {
- this.snapshotInterval = interval;
- }
-
- /**
- * Get the snapshot interval
- */
- public int getSnapshotInterval()
- {
- return this.snapshotInterval;
- }
-
- /**
- * Set the snapshot mode. Currently supported: instant or interval
- */
- public void setSnapshotMode(String mode)
- {
- this.snapshotMode = mode;
- }
-
- /**
- * Get the snapshot mode
- */
- public String getSnapshotMode()
- {
- return this.snapshotMode;
- }
-
- /**
- * Gets the JMX object name of a shared TreeCache to be used for clustered
- * single-sign-on.
- *
- * @see #DEFAULT_CACHE_NAME
- * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
- */
- public String getCacheName()
- {
- return cacheName;
- }
-
- /**
- * Gets the JMX object name of a shared TreeCache to be used for clustered
- * single-sign-on.
- * <p/>
- * <b>NOTE:</b> TreeCache must be deployed before this service.
- *
- * @see #DEFAULT_CACHE_NAME
- * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
- */
- public void setCacheName(String cacheName)
- {
- this.cacheName = cacheName;
- }
-
- public boolean isUseLocalCache()
- {
- return useLocalCache;
- }
-
- public void setUseLocalCache(boolean useLocalCache)
- {
- this.useLocalCache = useLocalCache;
- }
-
- public boolean isUseJK()
- {
- return useJK;
- }
-
- public void setUseJK(boolean useJK)
- {
- this.useJK = useJK;
- }
-
- public boolean getDeleteWorkDirOnContextDestroy()
- {
- return deleteWorkDirOnContextDestroy;
- }
-
- public void setDeleteWorkDirOnContextDestroy(boolean deleteFlag)
- {
- this.deleteWorkDirOnContextDestroy = deleteFlag;
- }
-
- public String getHttpHeaderForSSOAuth()
- {
- return httpHeaderForSSOAuth;
- }
-
- public void setHttpHeaderForSSOAuth(String httpHeader)
- {
- this.httpHeaderForSSOAuth = httpHeader;
- }
-
- public String getSessionCookieForSSOAuth()
- {
- return sessionCookieForSSOAuth;
- }
-
- public void setSessionCookieForSSOAuth(String sessionC)
- {
- this.sessionCookieForSSOAuth = sessionC;
- }
-
- /**
- * The SessionIdAlphabet is the set of characters used to create a session Id
- */
- public void setSessionIdAlphabet(String sessionIdAlphabet)
- {
- SessionIDGenerator.getInstance().setSessionIdAlphabet(sessionIdAlphabet);
- }
-
- /**
- * The SessionIdAlphabet is the set of characters used to create a session Id
- */
- public String getSessionIdAlphabet()
- {
- return SessionIDGenerator.getInstance().getSessionIdAlphabet();
- }
-
- public boolean getUseJBossWebLoader()
- {
- return useJBossWebLoader;
- }
-
- public void setUseJBossWebLoader(boolean flag)
- {
- this.useJBossWebLoader = flag;
- }
-
- public String getConfigFile()
- {
- return serverConfigFile;
- }
-
- public void setConfigFile(String configFile)
- {
- this.serverConfigFile = configFile;
- }
-
- public String getSubjectAttributeName()
- {
- return this.subjectAttributeName;
- }
-
- public void setSubjectAttributeName(String name)
- {
- this.subjectAttributeName = name;
- }
-
- public boolean isAllowSelfPrivilegedWebApps()
- {
- return allowSelfPrivilegedWebApps;
- }
-
- public void setAllowSelfPrivilegedWebApps(boolean allowSelfPrivilegedWebApps)
- {
- this.allowSelfPrivilegedWebApps = allowSelfPrivilegedWebApps;
- }
-
- public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
- {
- this.secMgrService = mgr;
- }
-
- public String[] getFilteredPackages()
- {
- return filteredPackages;
- }
- public void setFilteredPackages(String[] pkgs)
- {
- this.filteredPackages = pkgs;
- }
-
- @Override
- protected void processMetaData(DeploymentInfo di)
- {
- }
-
- public void startService()
- throws Exception
- {
-
- System.setProperty("catalina.ext.dirs",
- (System.getProperty("jboss.server.home.dir")
- + File.separator + "lib"));
-
- String objectNameS = catalinaDomain + ":type=server";
- ObjectName objectName = new ObjectName(objectNameS);
-
- // Set the modeler Registry MBeanServer to the that of the tomcat service
- Registry.getRegistry().setMBeanServer(server);
-
- Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(),
- objectName, "org.apache.catalina.startup.Catalina");
- /*
- server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
- objectName,
- new Object[]{"org.apache.catalina.startup.Catalina"},
- new String[]{"java.lang.String"});
- */
-
- server.setAttribute(objectName, new Attribute
- ("catalinaHome",
- System.getProperty("jboss.server.home.dir")));
- server.setAttribute(objectName, new Attribute
- ("configFile", serverConfigFile));
- server.setAttribute(objectName, new Attribute
- ("useNaming", new Boolean(false)));
- server.setAttribute(objectName, new Attribute
- ("useShutdownHook", new Boolean(false)));
- server.setAttribute(objectName, new Attribute
- ("await", new Boolean(false)));
- server.setAttribute(objectName, new Attribute
- ("redirectStreams", new Boolean(false)));
-
- server.invoke(objectName, "create", new Object[]{},
- new String[]{});
-
- server.invoke(objectName, "start", new Object[]{},
- new String[]{});
-
- // Configure any SingleSignOn valves
-
- ObjectName ssoQuery = new ObjectName(catalinaDomain + ":type=Valve,*");
- Iterator iterator = server.queryMBeans(ssoQuery, null).iterator();
- while (iterator.hasNext())
- {
- ObjectName ssoObjectName =
- ((ObjectInstance) iterator.next()).getObjectName();
- String name = ssoObjectName.getKeyProperty("name");
-
- /* Ensure that the SingleSignOn valve requires that each
- request be reauthenticated to the security mgr. Should not
- be neccessary now that we cache the principal in the session.
- if ((name != null) && (name.indexOf("SingleSignOn") >= 0))
- {
- log.info("Turning on reauthentication of each request on " +
- ssoObjectName);
- server.setAttribute(ssoObjectName, new Attribute
- ("requireReauthentication", Boolean.TRUE));
- }
- */
-
- // If the valve is a ClusteredSingleSignOn and we have a shared
- // TreeCache configured, configure the valve to use the shared one
- if (cacheName != null && "ClusteredSingleSignOn".equals(name))
- {
- String tcName = (String) server.getAttribute(ssoObjectName,
- "treeCacheName");
- tcName = (tcName != null ? tcName : DEFAULT_CACHE_NAME);
- ObjectName ssoCacheName = new ObjectName(tcName);
- // Only override if the valve's cacheName property was not
- // explicitly set in server.xml to a non-default value
- if (ssoCacheName.equals(new ObjectName(DEFAULT_CACHE_NAME)))
- {
- log.info("Setting the cache name to " + cacheName +
- " on " + ssoObjectName);
- server.setAttribute(ssoObjectName,
- new Attribute("treeCacheName", cacheName));
- }
- }
- }
-
- // Register the web container JACC PolicyContextHandlers
- HttpServletRequestPolicyContextHandler handler = new HttpServletRequestPolicyContextHandler();
- PolicyContext.registerHandler(HttpServletRequestPolicyContextHandler.WEB_REQUEST_KEY,
- handler, true);
-
- // The ServiceController used to control web app startup dependencies
- serviceController = (ServiceControllerMBean)
- MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME, server);
-
- // make a proxy to myself, so that calls from the MainDeployer
- // can go through the MBeanServer, so interceptors can be added
- thisProxy = (SubDeployerExt)
- MBeanProxyExt.create(SubDeployerExt.class, super.getServiceName(), super.getServer());
-
- // Register with the main deployer
- mainDeployer.addDeployer(thisProxy);
-
- // If we are hot-deployed *after* the overall server is started
- // we'll never receive Server.START_NOTIFICATION_TYPE, so check
- // with the Server and start the connectors immediately, if this is the case.
- // Otherwise register to receive the server start-up notification.
- Boolean started = (Boolean)server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
- if (started.booleanValue() == true)
- {
- log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
- "' already started, starting connectors now");
-
- startConnectors();
- }
- else
- {
- // Register for notification of the overall server startup
- log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
- "' not started, registering for start-up notification");
-
- server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
- }
- }
-
-
- public void stopService()
- throws Exception
- {
-
- String objectNameS = catalinaDomain + ":type=server";
- ObjectName objectName = new ObjectName(objectNameS);
-
- server.invoke(objectName, "stop", new Object[]{},
- new String[]{});
-
- server.invoke(objectName, "destroy", new Object[]{},
- new String[]{});
-
- server.unregisterMBean(objectName);
-
- MBeanServer server2 = server;
-
- // deregister with MainDeployer
- mainDeployer.removeDeployer(thisProxy);
-
- // Unregister any remaining jboss.web or Catalina MBeans
- ObjectName queryObjectName = new ObjectName
- (catalinaDomain + ":*");
- Iterator iterator =
- server2.queryMBeans(queryObjectName, null).iterator();
- while (iterator.hasNext())
- {
- ObjectInstance oi = (ObjectInstance) iterator.next();
- ObjectName toRemove = oi.getObjectName();
- // Exception: Don't unregister the service right now
- if (!"WebServer".equals(toRemove.getKeyProperty("service")))
- {
- if (server2.isRegistered(toRemove))
- {
- server2.unregisterMBean(toRemove);
- }
- }
- }
- queryObjectName = new ObjectName("Catalina:*");
- iterator = server2.queryMBeans(queryObjectName, null).iterator();
- while (iterator.hasNext())
- {
- ObjectInstance oi = (ObjectInstance) iterator.next();
- ObjectName name = oi.getObjectName();
- server2.unregisterMBean(name);
- }
-
- }
-
- public void startConnectors() throws Exception
- {
- ObjectName service = new ObjectName(catalinaDomain + ":type=Service,serviceName=jboss.web");
- Object[] args = {};
- String[] sig = {};
- Connector[] connectors = (Connector[]) server.invoke(service,
- "findConnectors", args, sig);
- for (int n = 0; n < connectors.length; n++)
- {
- Lifecycle lc = (Lifecycle) connectors[n];
- lc.start();
- }
- // Notify listeners that connectors have started processing requests
- sendNotification(new Notification(TOMCAT_CONNECTORS_STARTED,
- this, getNextNotificationSequenceNumber()));
- }
-
- public void stopConnectors() throws Exception
- {
- ObjectName service = new ObjectName(catalinaDomain + ":type=Service,serviceName=jboss.web");
- Object[] args = {};
- String[] sig = {};
- Connector[] connectors = (Connector[]) server.invoke(service,
- "findConnectors", args, sig);
- for (int n = 0; n < connectors.length; n++)
- {
- Lifecycle lc = (Lifecycle) connectors[n];
- lc.stop();
- }
- }
-
- public void handleNotification(Notification msg, Object handback)
- {
- String type = msg.getType();
- if (type.equals(Server.START_NOTIFICATION_TYPE))
- {
- log.debug("Saw " + type + " notification, starting connectors");
- try
- {
- startConnectors();
- }
- catch (Exception e)
- {
- log.warn("Failed to startConnectors", e);
- }
- }
- }
-
- /**
- * A trival extension of URLClassLoader that uses an empty URL[] as its
- * classpath so that all work is delegated to its parent.
- */
- static class ENCLoader extends URLClassLoader
- {
- private boolean parentFirst;
-
- ENCLoader(URL[] urls, ClassLoader parent, boolean parentFirst)
- {
- super(urls, parent);
- this.parentFirst = parentFirst;
- }
-
- protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
- {
- if (parentFirst) return super.loadClass(name, resolve);
- try
- {
- Class clazz = findClass(name);
- if (resolve) {
- resolveClass(clazz);
- }
- return clazz;
- }
- catch (ClassNotFoundException e)
- {
- return getParent().loadClass(name);
- }
- }
-
- }
-
- public static ClassLoader getTmpLoader(URL warURL, ClassLoader parent, boolean parentFirst) throws Exception
- {
-
- String path = warURL.getFile();
- ArrayList<URL> list = new ArrayList<URL>();
- File classesDir = new File(path, "WEB-INF/classes");
- if (classesDir.exists())
- {
- list.add(classesDir.toURL());
- }
- File libDir = new File(path, "WEB-INF/lib");
- if (libDir.exists())
- {
- File[] jars = libDir.listFiles();
- int length = jars != null ? jars.length : 0;
- for (int j = 0; j < length; j++)
- {
- File jar = jars[j];
- if(jar.getAbsolutePath().endsWith(".jar"))
- {
- list.add(jar.toURL());
- }
- }
- }
- ENCLoader loader = new ENCLoader(list.toArray(new URL[list.size()]), parent, parentFirst);
- return loader;
-
- }
-
-
- public AbstractWebDeployer getDeployer(DeploymentInfo di) throws Exception
- {
- TomcatDeployer deployer = new TomcatDeployer();
- DeployerConfig config = new DeployerConfig();
- config.setDefaultSecurityDomain(this.defaultSecurityDomain);
- config.setSubjectAttributeName(this.subjectAttributeName);
- config.setServiceClassLoader(getClass().getClassLoader());
- config.setManagerClass(this.managerClass);
- config.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
- config.setUnpackWars(this.unpackWars);
- config.setLenientEjbLink(this.lenientEjbLink);
- config.setCatalinaDomain(catalinaDomain);
- config.setContextClassName(contextClassName);
- config.setServiceName(serviceName);
- config.setSnapshotInterval(this.snapshotInterval);
- config.setSnapshotMode(this.snapshotMode);
- config.setUseLocalCache(this.useLocalCache);
- config.setUseJK(this.useJK);
- config.setSubjectAttributeName(this.subjectAttributeName);
- config.setUseJBossWebLoader(this.useJBossWebLoader);
- config.setAllowSelfPrivilegedWebApps(this.allowSelfPrivilegedWebApps);
- config.setSecurityManagerService(this.secMgrService);
- config.setFilteredPackages(filteredPackages);
- deployer.setServer(server);
- deployer.init(config);
-
- /*
- // new JavaEE5 stuff
- WebMetaData metadata = (WebMetaData)di.metaData;
- TomcatInjectionContainer ic = new TomcatInjectionContainer(di);
- URL warURL = di.localUrl != null ? di.localUrl : di.url;
- ClassLoader parent = di.ucl;
- if (di.parent != null) parent = di.parent.ucl;
- ClassLoader tmpLoader = getTmpLoader(warURL, parent, java2ClassLoadingCompliance);
- ic.setClassLoader(tmpLoader);
-
- ic.processMetadata();
- JmxDependencyPolicy dependencyPolicy = (JmxDependencyPolicy)ic.getDependencyPolicy();
- metadata.setDepends(dependencyPolicy.getDependencies(metadata.getDepends()));
- */
- return deployer;
- }
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6MBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6MBean.java 2006-11-16 04:14:57 UTC (rev 58433)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6MBean.java 2006-11-16 04:15:57 UTC (rev 58434)
@@ -1,216 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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;
-
-import org.jboss.web.AbstractWebContainerMBean;
-import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
-
-/**
- * An implementation of the AbstractWebContainer for the Jakarta Tomcat5
- * servlet container. It has no code dependency on tomcat - only the new JMX
- * model is used.
- * <p/>
- * Tomcat5 is organized as a set of mbeans - just like jboss.
- *
- * @author Scott.Stark at jboss.org
- * @author Costin Manolache
- * @version $Revision$
- * @see AbstractWebContainerMBean
- */
-public interface Tomcat6MBean extends AbstractWebContainerMBean
-{
- /** JMX notification type to signal after-start connector event */
- public final String TOMCAT_CONNECTORS_STARTED = "jboss.tomcat.connectors.started";
-
- /**
- * @return the jmx domain for the tomcat management mbeans
- */
- public String getDomain();
-
- /**
- * The most important attribute - defines the managed domain.
- * A catalina instance (engine) corresponds to a JMX domain, that's
- * how we know where to deploy webapps.
- *
- * @param domainName the jmx domain under which tc registers
- */
- public void setDomain(String domainName);
-
- /**
- * Set the snapshot mode in a clustered environment
- */
- public void setSnapshotMode(String mode);
-
- /**
- * Get the snapshot mode in a clustered environment
- */
- public String getSnapshotMode();
-
- /**
- * Set the snapshot interval in ms for the interval snapshot mode
- */
- public void setSnapshotInterval(int interval);
-
- /**
- * Get the snapshot interval
- */
- public int getSnapshotInterval();
-
- /**
- * Get the clustering code cache behaviour
- */
- public boolean isUseLocalCache();
-
- /**
- * Set the clustering code cache behaviour
- */
- public void setUseLocalCache(boolean useLocalCache);
-
- /**
- * Get the clustering code failover behaviour whether MOD_JK(2) is used or not.
- */
- public boolean isUseJK();
-
- /**
- * Set the clustering code failover behaviour whether MOD_JK(2) is used or not.
- */
- public void setUseJK(boolean useJK);
-
- /**
- * The SessionIdAlphabet is the set of characters used to create a session Id
- */
- public void setSessionIdAlphabet(String sessionIdAlphabet);
-
- /**
- * The SessionIdAlphabet is the set of characters used to create a session Id
- */
- public String getSessionIdAlphabet();
-
- /**
- * Gets the JMX object name of a shared TreeCache to be used for clustered
- * single-sign-on.
- *
- * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
- */
- public String getCacheName();
-
- /**
- * Gets the JMX object name of a shared TreeCache to be used for clustered
- * single-sign-on.
- * <p/>
- * <b>NOTE:</b> TreeCache must be deployed before this service.
- *
- * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
- */
- public void setCacheName(String cacheName);
-
- /**
- * Get the JBoss UCL use flag
- */
- public boolean getUseJBossWebLoader();
-
- /**
- * Set the JBoss UCL use flag
- */
- public void setUseJBossWebLoader(boolean flag);
-
- public String getManagerClass();
-
- public void setManagerClass(String managerClass);
-
- /** */
- public String getContextMBeanCode();
-
- /** */
- public void setContextMBeanCode(String className);
-
- /**
- * Get the name of the external tomcat server configuration file.
- *
- * @return the config file name, server.xml for example
- */
- public String getConfigFile();
-
- /**
- * Set the name of the external tomcat server configuration file.
- *
- * @param configFile - the config file name, server.xml for example
- */
- public void setConfigFile(String configFile);
-
- /**
- * Get the request attribute name under which the JAAS Subject is store
- */
- public String getSubjectAttributeName();
-
- /**
- * Set the request attribute name under which the JAAS Subject will be
- * stored when running with a security mgr that supports JAAS. If this is
- * empty then the Subject will not be store in the request.
- *
- * @param name the HttpServletRequest attribute name to store the Subject
- */
- public void setSubjectAttributeName(String name);
-
- /**
- * Start all connectors of the Domain + ":type=Service,serviceName=jboss.web"
- * service.
- *
- * @throws Exception
- */
- public void startConnectors() throws Exception;
-
- /**
- * Stop all connectors of the Domain + ":type=Service,serviceName=jboss.web"
- * service.
- *
- * @throws Exception
- */
- public void stopConnectors() throws Exception;
-
- /**
- * Get whether web-apps are able to control the privileged flag
- */
- public boolean isAllowSelfPrivilegedWebApps();
-
- /**
- * Set whether web-apps are able to control the privileged flag
- */
- public void setAllowSelfPrivilegedWebApps(boolean flag);
-
- /** Set the SecurityManagerService binding. This is used to flush any
- * associated authentication cache on session invalidation.
- * @param mgr the JaasSecurityManagerServiceMBean
- */
- public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr);
-
- /**
- *
- * @return
- */
- public String[] getFilteredPackages();
- /**
- *
- * @param pkgs
- */
- public void setFilteredPackages(String[] pkgs);
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java 2006-11-16 04:14:57 UTC (rev 58433)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java 2006-11-16 04:15:57 UTC (rev 58434)
@@ -1,634 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.security.CodeSource;
-import java.security.cert.Certificate;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.management.Attribute;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.apache.catalina.Loader;
-import org.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.metadata.WebMetaData;
-import org.jboss.security.AuthorizationManager;
-import org.jboss.security.Util;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.web.AbstractWebContainer;
-import org.jboss.web.AbstractWebDeployer;
-import org.jboss.web.WebApplication;
-import org.jboss.web.tomcat.security.JaccContextValve;
-import org.jboss.web.tomcat.security.RunAsListener;
-import org.jboss.web.tomcat.security.SecurityAssociationValve;
-import org.jboss.web.tomcat.tc6.session.AbstractJBossManager;
-import org.jboss.web.tomcat.tc6.session.ClusteringNotSupportedException;
-import org.jboss.web.tomcat.tc6.session.JBossCacheManager;
-import org.apache.tomcat.util.modeler.Registry;
-
-/**
- * The tomcat web application deployer
- * @deprecated see org.jboss.web.tomcat.tc6.deployers.TomcatDeployment
- *
- * @author Scott.Stark at jboss.org
- * @author Costin Manolache
- * @version $Revision$
- */
-public class TomcatDeployer extends AbstractWebDeployer
-{
- /**
- * The name of the war level context configuration descriptor
- */
- private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
-
- /**
- * Optional XACML Policy File
- */
- private static final String XACML_POLICY_FILE = "WEB-INF/jboss-xacml-policy.xml";
-
- private DeployerConfig config;
- private String[] javaVMs =
- {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
- private String serverName = "jboss";
- private HashMap vhostToHostNames = new HashMap();
- private TomcatInjectionContainer injectionContainer;
-
- public void init(Object containerConfig) throws Exception
- {
- this.config = (DeployerConfig)containerConfig;
- super.setJava2ClassLoadingCompliance(config.isJava2ClassLoadingCompliance());
- super.setUnpackWars(config.isUnpackWars());
- super.setLenientEjbLink(config.isLenientEjbLink());
- super.setDefaultSecurityDomain(config.getDefaultSecurityDomain());
- }
-
- @Override
- protected void processEncReferences(WebMetaData metaData, Context envCtx, DeploymentInfo di) throws ClassNotFoundException, NamingException, DeploymentException
- {
- if (injectionContainer == null)
- {
- super.processEncReferences(metaData, envCtx, di);
- }
- else
- {
- injectionContainer.populateEnc();
- }
- }
-
- /**
- * Perform the tomcat specific deployment steps.
- */
- protected void performDeploy(WebApplication appInfo, String warUrl,
- AbstractWebContainer.WebDescriptorParser webAppParser)
- throws Exception
- {
- WebMetaData metaData = appInfo.getMetaData();
- String hostName = null;
- // Get any jboss-web/virtual-hosts
- Iterator vhostNames = metaData.getVirtualHosts();
- // Map the virtual hosts onto the configured hosts
- Iterator hostNames = mapVirtualHosts(vhostNames);
- if (hostNames.hasNext())
- {
- hostName = hostNames.next().toString();
- }
- performDeployInternal(hostName, appInfo, warUrl, webAppParser);
- while (hostNames.hasNext())
- {
- String additionalHostName = hostNames.next().toString();
- performDeployInternal(additionalHostName, appInfo, warUrl, webAppParser);
- }
- }
-
- protected void performDeployInternal(String hostName,
- WebApplication appInfo, String warUrl,
- AbstractWebContainer.WebDescriptorParser webAppParser)
- throws Exception
- {
-
- WebMetaData metaData = appInfo.getMetaData();
- String ctxPath = metaData.getContextRoot();
- if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
- {
- log.debug("deploy root context=" + ctxPath);
- ctxPath = "/";
- metaData.setContextRoot(ctxPath);
- }
-
- log.info("deploy, ctxPath=" + ctxPath + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
-
- URL url = new URL(warUrl);
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- injectionContainer = new TomcatInjectionContainer(webAppParser, appInfo, null);
- Loader webLoader = getWebLoader(loader, url);
-
- appInfo.setName(url.getPath());
- appInfo.setClassLoader(loader);
- appInfo.setURL(url);
-
- String objectNameS = config.getCatalinaDomain()
- + ":j2eeType=WebModule,name=//" +
- ((hostName == null) ? "localhost" : hostName)
- + ctxPath + ",J2EEApplication=none,J2EEServer=none";
-
- ObjectName objectName = new ObjectName(objectNameS);
-
- if (server.isRegistered(objectName))
- {
- log.debug("Already exists, destroying " + objectName);
- server.invoke(objectName, "destroy", new Object[]{},
- new String[]{});
- }
-
- /*
- server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
- objectName, new Object[]{config.getContextClassName()},
- new String[]{"java.lang.String"});
- */
- Registry.getRegistry().registerComponent(Class.forName(config.getContextClassName()).newInstance(),
- objectName, config.getContextClassName());
-
- // Find and set config file on the context
- // If WAR is packed, expand config file to temp folder
- String ctxConfig = null;
- try
- {
- ctxConfig = findConfig(url);
- }
- catch (IOException e)
- {
- log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
- }
-
- if (injectionContainer != null)
- {
- server.setAttribute(objectName, new Attribute("annotationProcessor", injectionContainer));
- }
-
- server.setAttribute(objectName, new Attribute("docBase", url.getFile()));
-
- server.setAttribute(objectName, new Attribute("configFile", ctxConfig));
-
- server.setAttribute(objectName, new Attribute
- ("defaultContextXml", "context.xml"));
- server.setAttribute(objectName, new Attribute
- ("defaultWebXml", "conf/web.xml"));
-
- server.setAttribute(objectName, new Attribute("javaVMs", javaVMs));
-
- server.setAttribute(objectName, new Attribute("server", serverName));
-
- server.setAttribute(objectName, new Attribute
- ("saveConfig", Boolean.FALSE));
-
- if (webLoader != null)
- {
- server.setAttribute(objectName, new Attribute
- ("loader", webLoader));
- }
- else
- {
- server.setAttribute(objectName, new Attribute
- ("parentClassLoader", loader));
- }
-
- server.setAttribute(objectName, new Attribute
- ("delegate", new Boolean(getJava2ClassLoadingCompliance())));
-
- 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);
- }
-
- server.setAttribute(objectName, new Attribute
- ("compilerClasspath", classpath.toString()));
-
- // Set the session cookies flag according to metadata
- switch (metaData.getSessionCookies())
- {
- case WebMetaData.SESSION_COOKIES_ENABLED:
- server.setAttribute(objectName, new Attribute
- ("cookies", new Boolean(true)));
- log.debug("Enabling session cookies");
- break;
- case WebMetaData.SESSION_COOKIES_DISABLED:
- server.setAttribute(objectName, new Attribute
- ("cookies", new Boolean(false)));
- log.debug("Disabling session cookies");
- break;
- default:
- log.debug("Using session cookies default setting");
- }
-
- // Add a valve to estalish the JACC context before authorization valves
- Certificate[] certs = null;
- CodeSource cs = new CodeSource(url, certs);
- JaccContextValve jaccValve = new JaccContextValve(metaData.getJaccContextID(), cs);
- server.invoke(objectName, "addValve",
- new Object[]{jaccValve},
- new String[]{"org.apache.catalina.Valve"}
- );
-
- // Pass the metadata to the RunAsListener via a thread local
- RunAsListener.metaDataLocal.set(metaData);
- try
- {
- // Init the container; this will also start it
- server.invoke(objectName, "init", new Object[]{}, new String[]{});
- }
- finally
- {
- RunAsListener.metaDataLocal.set(null);
- }
-
- // make the context class loader known to the WebMetaData, ws4ee needs it
- // to instanciate service endpoint pojos that live in this webapp
- Loader ctxLoader = (Loader)server.getAttribute(objectName, "loader");
- metaData.setContextLoader(ctxLoader.getClassLoader());
-
- // Clustering
- if (metaData.getDistributable())
- {
- // Try to initate clustering, fallback to standard if no clustering is available
- try
- {
- AbstractJBossManager manager = null;
- String managerClassName = config.getManagerClass();
- Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
- manager = (AbstractJBossManager) managerClass.newInstance();
- String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
- manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
-
- if (manager instanceof JBossCacheManager)
- {
- String snapshotMode = config.getSnapshotMode();
- int snapshotInterval = config.getSnapshotInterval();
- JBossCacheManager jbcm = (JBossCacheManager) manager;
- jbcm.setSnapshotMode(snapshotMode);
- jbcm.setSnapshotInterval(snapshotInterval);
- }
-
- server.setAttribute(objectName, new Attribute("manager", manager));
-
- log.debug("Enabled clustering support for ctxPath=" + ctxPath);
- }
- catch (ClusteringNotSupportedException e)
- {
- // JBAS-3513 Just log a WARN, not an ERROR
- log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: " +
- e.getMessage());
- }
- catch (NoClassDefFoundError ncdf)
- {
- // JBAS-3513 Just log a WARN, not an ERROR
- log.debug("Classes needed for clustered webapp unavailable", ncdf);
- log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " +
- ncdf.getMessage());
- }
- catch(Throwable t)
- {
- // TODO consider letting this through and fail the deployment
- log.error("Failed to setup clustering, clustering disabled. Exception: ", t);
- }
- }
-
- /* Add security association valve after the authorization
- valves so that the authenticated user may be associated with the
- request thread/session.
- */
- SecurityAssociationValve valve = new SecurityAssociationValve(metaData,
- config.getSecurityManagerService());
- valve.setSubjectAttributeName(config.getSubjectAttributeName());
- server.invoke(objectName, "addValve",
- new Object[]{valve},
- new String[]{"org.apache.catalina.Valve"});
-
- // Retrieve the state, and throw an exception in case of a failure
- Integer state = (Integer) server.getAttribute(objectName, "state");
- if (state.intValue() != 1)
- {
- throw new DeploymentException("URL " + warUrl + " deployment failed");
- }
-
- appInfo.setAppData(objectName);
-
- // Create mbeans for the servlets
- DeploymentInfo di = webAppParser.getDeploymentInfo();
- di.deployedObject = objectName;
- ObjectName servletQuery = new ObjectName
- (config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule="
- + objectName.getKeyProperty("name") + ",*");
- Iterator iterator = server.queryMBeans(servletQuery, null).iterator();
- while (iterator.hasNext())
- {
- di.mbeans.add(((ObjectInstance)iterator.next()).getObjectName());
- }
-
- if(metaData.getSecurityDomain() != null)
- {
- String secDomain = Util.unprefixSecurityDomain(metaData.getSecurityDomain());
- //Associate the Context Id with the Security Domain
- String contextID = metaData.getJaccContextID();
-
- //Check if xacml policy is available
- URL xacmlPolicyFile = null;
- try
- {
- xacmlPolicyFile = this.findXACMLFile(url);
- if(xacmlPolicyFile != null)
- {
- AuthorizationManager authzmgr= Util.getAuthorizationManager(secDomain);
- if(authzmgr instanceof PolicyRegistration)
- {
- PolicyRegistration xam = (PolicyRegistration)authzmgr;
- xam.registerPolicy(contextID,xacmlPolicyFile);
- }
- }
- }
- catch(IOException ioe)
- {
- //Ignore
- }
- }
-
- log.debug("Initialized: " + appInfo + " " + objectName);
- }
-
- public Loader getWebLoader(ClassLoader loader, URL url)
- throws MalformedURLException
- {
- Loader webLoader = null;
- /* If we are using the jboss class loader we need to augment its path
- to include the WEB-INF/{lib,classes} dirs or else scoped class loading
- does not see the war level overrides. The call to setWarURL adds these
- paths to the deployment UCL.
- */
-
- if (config.isUseJBossWebLoader())
- {
- WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
- jbossLoader.setWarURL(url);
- webLoader = jbossLoader;
- }
- else
- {
- String[] pkgs = config.getFilteredPackages();
- WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs, injectionContainer);
- jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
- webLoader = jbossLoader;
- }
- return webLoader;
- }
-
- public void setInjectionContainer(TomcatInjectionContainer container)
- {
- this.injectionContainer = container;
- }
-
-
- /**
- * Called as part of the undeploy() method template to ask the
- * subclass for perform the web container specific undeployment steps.
- */
- protected void performUndeploy(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=" + shortWarUrlFromServerHome(warUrl));
-
- WebMetaData metaData = appInfo.getMetaData();
- String hostName = null;
- Iterator hostNames = metaData.getVirtualHosts();
- if (hostNames.hasNext())
- {
- hostName = hostNames.next().toString();
- }
- performUndeployInternal(hostName, warUrl, appInfo);
- while (hostNames.hasNext())
- {
- String additionalHostName = hostNames.next().toString();
- performUndeployInternal(additionalHostName, warUrl, appInfo);
- }
-
- }
-
- protected void performUndeployInternal(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(config.getCatalinaDomain()
- + ":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[]{});
- }
-
- }
-
- /**
- * 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(Iterator vhostNames)
- throws Exception
- {
- if (vhostToHostNames.size() == 0)
- {
- // Query the configured Host mbeans
- String hostQuery = config.getCatalinaDomain() + ":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();
- }
-
- private String findConfig(URL warURL) throws IOException
- {
- String result = null;
- // See if the warUrl is a dir or a file
- File warFile = new File(warURL.getFile());
- if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
- {
- File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
- if (webDD.exists() == true) result = webDD.getAbsolutePath();
- }
- else
- {
- ZipFile zipFile = new ZipFile(warFile);
- ZipEntry entry = zipFile.getEntry(CONTEXT_CONFIG_FILE);
- if (entry != null)
- {
- InputStream zipIS = zipFile.getInputStream(entry);
- byte[] buffer = new byte[512];
- int bytes;
- result = warFile.getAbsolutePath() + "-context.xml";
- FileOutputStream fos = new FileOutputStream(result);
- while ((bytes = zipIS.read(buffer)) > 0)
- {
- fos.write(buffer, 0, bytes);
- }
- zipIS.close();
- fos.close();
- }
- zipFile.close();
- }
- return result;
- }
-
- /**
- * Locate a XACMl Policy file packaged in the war
- * @param warURL
- * @return
- * @throws IOException
- */
- private URL findXACMLFile(URL warURL) throws IOException
- {
- URL result = null;
- // See if the warUrl is a dir or a file
- File warFile = new File(warURL.getFile());
- if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
- {
- File webDD = new File(warFile, XACML_POLICY_FILE);
- if (webDD.exists() == true)
- result = webDD.toURL();
- }
- return result;
- }
-
- private String shortWarUrlFromServerHome(String warUrl)
- {
- String serverHomeUrl = System.getProperty(org.jboss.system.server.ServerConfig.SERVER_HOME_URL);
-
- if (warUrl == null || serverHomeUrl == null)
- return warUrl;
-
- if (warUrl.startsWith(serverHomeUrl))
- return ".../" + warUrl.substring(serverHomeUrl.length());
- else
- return warUrl;
- }
-}
More information about the jboss-cvs-commits
mailing list