[jboss-cvs] JBossAS SVN: r77363 - in branches/JBPAPP_4_2_0_GA_CP: tomcat/src/main/org/jboss/web/tomcat/service and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 22 12:24:39 EDT 2008
Author: mmoyses
Date: 2008-08-22 12:24:38 -0400 (Fri, 22 Aug 2008)
New Revision: 77363
Modified:
branches/JBPAPP_4_2_0_GA_CP/management/src/main/org/jboss/management/j2ee/LocalJBossServerDomain.java
branches/JBPAPP_4_2_0_GA_CP/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java
Log:
JBPAPP-1117: changed hard coded "localhost" MBean names
Modified: branches/JBPAPP_4_2_0_GA_CP/management/src/main/org/jboss/management/j2ee/LocalJBossServerDomain.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/management/src/main/org/jboss/management/j2ee/LocalJBossServerDomain.java 2008-08-22 15:09:04 UTC (rev 77362)
+++ branches/JBPAPP_4_2_0_GA_CP/management/src/main/org/jboss/management/j2ee/LocalJBossServerDomain.java 2008-08-22 16:24:38 UTC (rev 77363)
@@ -21,6 +21,18 @@
*/
package org.jboss.management.j2ee;
+import java.net.InetAddress;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.JMException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.MainDeployerConstants;
import org.jboss.deployment.SubDeployer;
@@ -32,17 +44,6 @@
import org.jboss.system.ServiceMBean;
import org.jboss.system.ServiceMBeanSupport;
-import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import java.net.InetAddress;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
/**
* The integration MBean for the local JBoss server management domain. This
* bridges between the core JBoss JSR-77 agnostic code to the JSR-77
@@ -53,7 +54,9 @@
* @version $Revision$
*/
public class LocalJBossServerDomain extends ServiceMBeanSupport
- implements NotificationListener, LocalJBossServerDomainMBean
+ implements
+ NotificationListener,
+ LocalJBossServerDomainMBean
{
/**
* Class logger.
@@ -66,66 +69,82 @@
* The name of the MainDeployer
*/
private ObjectName mainDeployer;
+
/**
* The name of the SARDeployer
*/
private ObjectName sarDeployer;
+
/**
* The name of the EARDeployer
*/
private ObjectName earDeployer;
+
/**
* The name of the EJBDeployer
*/
private ObjectName ejbDeployer;
+
/**
* The name of the RARDeployer
*/
private ObjectName rarDeployer;
+
/**
* The name of the JCA connection manager deployer
*/
private ObjectName jcaCMDeployer;
+
/**
* The name of the WARDeployer
*/
private ObjectName warDeployer;
+
/**
* The client application deployer
- */
+ */
private ObjectName carDeployer;
+
/**
* The name of the JMS service
*/
private ObjectName jmsService;
+
/**
* The name of the JNDI service
*/
private ObjectName jndiService;
+
/**
* The name of the JTA service
*/
private ObjectName jtaService;
+
/**
* The name of the UserTransaction service
*/
private ObjectName userTxService;
+
/**
* The name of the JavaMail service
*/
private ObjectName mailService;
+
/**
* The name of the RMI_IIOP service
*/
private ObjectName rmiiiopService;
+
/**
* The name of the service which emites URL binding events
*/
private ObjectName jndiBindingService;
+
/**
* A mapping of JMX notifications to ManagedObjectFactory instances
*/
private ManagedObjectFactoryMap managedObjFactoryMap;
+
private Class managedObjFactoryMapClass = DefaultManagedObjectFactoryMap.class;
// -------------------------------------------------------------------------
@@ -274,6 +293,7 @@
{
return carDeployer;
}
+
/**
* @param name The CARDeployer mbean name
* @jmx:managed-attribute
@@ -631,10 +651,10 @@
{
// Ignore when host address is not accessible (localhost is used instead)
}
- JVM jvm = new JVM("localhost", lServer,
- System.getProperty("java.version"),
- System.getProperty("java.vendor"),
- hostName);
+ String vmVendor = System.getProperty("java.vendor");
+ String vmVersion = System.getProperty("java.version");
+ String name = vmVendor + " " + vmVersion;
+ JVM jvm = new JVM(name, lServer, vmVersion, vmVendor, hostName);
ObjectName jvmName = jvm.getObjectName();
mbeanServer.registerMBean(jvm, jvmName);
}
@@ -657,8 +677,7 @@
{
try
{
- mbeanServer.addNotificationListener(ServiceControllerMBean.OBJECT_NAME,
- this, null, null);
+ mbeanServer.addNotificationListener(ServiceControllerMBean.OBJECT_NAME, this, null, null);
log.debug("Registered as listener of: " + ServiceControllerMBean.OBJECT_NAME);
}
catch (JMException jme)
@@ -700,8 +719,7 @@
* @throws Exception thrown on failure to register as a listener of the
* MainDeployer or to obtain the list of deployers
*/
- private void registerWithCurrentDeployers(MBeanServer mbeanServer)
- throws Exception
+ private void registerWithCurrentDeployers(MBeanServer mbeanServer) throws Exception
{
log.debug("Registering with all deployers, mainDeployer=" + mainDeployer);
mbeanServer.addNotificationListener(mainDeployer, this, null, null);
@@ -710,8 +728,7 @@
log.debug("Getting current deployers");
Object[] args = {};
String[] sig = {};
- Collection deployers = (Collection) mbeanServer.invoke(mainDeployer,
- "listDeployers", args, sig);
+ Collection deployers = (Collection) mbeanServer.invoke(mainDeployer, "listDeployers", args, sig);
Iterator iter = deployers.iterator();
while (iter.hasNext())
{
@@ -727,8 +744,7 @@
* @throws Exception thrown on failure to unregister as a listener of the
* MainDeployer or to obtain the list of deployers
*/
- private void unregisterWithCurrentDeployers(MBeanServer mbeanServer)
- throws Exception
+ private void unregisterWithCurrentDeployers(MBeanServer mbeanServer) throws Exception
{
log.debug("Unregistering with all deployers, mainDeployer=" + mainDeployer);
mbeanServer.removeNotificationListener(mainDeployer, this);
@@ -737,8 +753,7 @@
log.debug("Getting current deployers");
Object[] args = {};
String[] sig = {};
- Collection deployers = (Collection) mbeanServer.invoke(mainDeployer,
- "listDeployers", args, sig);
+ Collection deployers = (Collection) mbeanServer.invoke(mainDeployer, "listDeployers", args, sig);
Iterator iter = deployers.iterator();
while (iter.hasNext())
{
Modified: branches/JBPAPP_4_2_0_GA_CP/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java 2008-08-22 15:09:04 UTC (rev 77362)
+++ branches/JBPAPP_4_2_0_GA_CP/tomcat/src/main/org/jboss/web/tomcat/service/TomcatDeployer.java 2008-08-22 16:24:38 UTC (rev 77363)
@@ -47,7 +47,6 @@
import org.jboss.web.AbstractWebContainer;
import org.jboss.web.AbstractWebDeployer;
import org.jboss.web.WebApplication;
-import org.jboss.web.tomcat.security.CustomPrincipalValve;
import org.jboss.web.tomcat.security.JaccContextValve;
import org.jboss.web.tomcat.security.RunAsListener;
import org.jboss.web.tomcat.security.SecurityAssociationValve;
@@ -70,9 +69,15 @@
private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
private DeployerConfig config;
- private String[] javaVMs =
- {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
+
+ private String vmName = System.getProperty("java.vendor");
+
+ private String vmVersion = System.getProperty("java.version");
+
+ private String[] javaVMs = {"jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=" + vmName + " " + vmVersion};
+
private String serverName = "jboss";
+
private HashMap vhostToHostNames = new HashMap();
public void init(Object containerConfig) throws Exception
@@ -88,8 +93,7 @@
* Perform the tomcat specific deployment steps.
*/
protected void performDeploy(WebApplication appInfo, String warUrl,
- AbstractWebContainer.WebDescriptorParser webAppParser)
- throws Exception
+ AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception
{
WebMetaData metaData = appInfo.getMetaData();
String hostName = null;
@@ -109,10 +113,8 @@
}
}
- protected void performDeployInternal(String hostName,
- WebApplication appInfo, String warUrl,
- AbstractWebContainer.WebDescriptorParser webAppParser)
- throws Exception
+ protected void performDeployInternal(String hostName, WebApplication appInfo, String warUrl,
+ AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception
{
WebMetaData metaData = appInfo.getMetaData();
@@ -162,22 +164,25 @@
appInfo.setClassLoader(loader);
appInfo.setURL(url);
- String objectNameS = config.getCatalinaDomain()
- + ":j2eeType=WebModule,name=//" +
- ((hostName == null) ? "localhost" : hostName)
- + ctxPath + ",J2EEApplication=none,J2EEServer=none";
+ String defaultHost = hostName;
+ if (defaultHost == null)
+ {
+ String objName = config.getCatalinaDomain() + ":type=Engine";
+ defaultHost = (String) server.getAttribute(new ObjectName(objName), "defaultHost");
+ }
+ String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + defaultHost + 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.invoke(objectName, "destroy", new Object[]{}, new String[]{});
}
- Registry.getRegistry().registerComponent(Class.forName(config.getContextClassName()).newInstance(),
- objectName, "org.apache.catalina.core.StandardContext");
+ Registry.getRegistry().registerComponent(Class.forName(config.getContextClassName()).newInstance(), objectName,
+ "org.apache.catalina.core.StandardContext");
// Find and set config file on the context
// If WAR is packed, expand config file to temp folder
@@ -195,31 +200,25 @@
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("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));
+ server.setAttribute(objectName, new Attribute("saveConfig", Boolean.FALSE));
if (webLoader != null)
{
- server.setAttribute(objectName, new Attribute
- ("loader", webLoader));
+ server.setAttribute(objectName, new Attribute("loader", webLoader));
}
else
{
- server.setAttribute(objectName, new Attribute
- ("parentClassLoader", loader));
+ server.setAttribute(objectName, new Attribute("parentClassLoader", loader));
}
- server.setAttribute(objectName, new Attribute
- ("delegate", new Boolean(getJava2ClassLoadingCompliance())));
+ server.setAttribute(objectName, new Attribute("delegate", new Boolean(getJava2ClassLoadingCompliance())));
String[] jspCP = getCompileClasspath(loader);
StringBuffer classpath = new StringBuffer();
@@ -246,7 +245,7 @@
// avoid opening .xml files
if (fp.getName().toLowerCase().endsWith(".xml"))
continue;
-
+
ZipFile zip = new ZipFile(fp);
zip.close();
}
@@ -261,23 +260,20 @@
classpath.append(repository);
}
- server.setAttribute(objectName, new Attribute
- ("compilerClasspath", classpath.toString()));
+ 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)));
+ 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)));
+ case WebMetaData.SESSION_COOKIES_DISABLED :
+ server.setAttribute(objectName, new Attribute("cookies", new Boolean(false)));
log.debug("Disabling session cookies");
break;
- default:
+ default :
log.debug("Using session cookies default setting");
}
@@ -285,13 +281,11 @@
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"});
+ server.invoke(objectName, "addValve", new Object[]{jaccValve}, new String[]{"org.apache.catalina.Valve"});
//Set the meta data on the JaccContextValve
jaccValve.setWebMetaData(metaData);
-
+
// Pass the metadata to the RunAsListener via a thread local
RunAsListener.metaDataLocal.set(metaData);
@@ -307,7 +301,7 @@
// 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");
+ Loader ctxLoader = (Loader) server.getAttribute(objectName, "loader");
metaData.setContextLoader(ctxLoader.getClassLoader());
// Clustering
@@ -322,7 +316,7 @@
manager = (AbstractJBossManager) managerClass.newInstance();
if (manager instanceof JBossCacheManager)
- {
+ {
// TODO either deprecate snapshot mode or move its config
// into jboss-web.xml.
String snapshotMode = config.getSnapshotMode();
@@ -331,37 +325,36 @@
jbcm.setSnapshotMode(snapshotMode);
jbcm.setSnapshotInterval(snapshotInterval);
}
-
+
// JBAS-5706 -- use the DeployerConfig value as a default for
// WebMetaData.maxUnreplicatedInterval
if (metaData.getMaxUnreplicatedInterval() == null)
{
metaData.setMaxUnreplicatedInterval(new Integer(config.getMaxUnreplicatedInterval()));
}
-
- String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
+
+ String name = "//" + defaultHost + ctxPath;
manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
-
+
// Don't assign the manager to the context until all config
// is done, or else the manager will be started without the config
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());
+ 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());
+ log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " + ncdf.getMessage());
}
- catch(Throwable t)
+ catch (Throwable t)
{
// TODO consider letting this through and fail the deployment
log.error("Failed to setup clustering, clustering disabled. Exception: ", t);
@@ -372,12 +365,9 @@
valves so that the authenticated user may be associated with the
request thread/session.
*/
- SecurityAssociationValve valve = new SecurityAssociationValve(metaData,
- config.getSecurityManagerService());
+ SecurityAssociationValve valve = new SecurityAssociationValve(metaData, config.getSecurityManagerService());
valve.setSubjectAttributeName(config.getSubjectAttributeName());
- server.invoke(objectName, "addValve",
- new Object[]{valve},
- new String[]{"org.apache.catalina.Valve"});
+ 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");
@@ -391,9 +381,8 @@
// Create mbeans for the servlets
DeploymentInfo di = webAppParser.getDeploymentInfo();
di.deployedObject = objectName;
- ObjectName servletQuery = new ObjectName
- (config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule="
- + objectName.getKeyProperty("name") + ",*");
+ ObjectName servletQuery = new ObjectName(config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule="
+ + objectName.getKeyProperty("name") + ",*");
Iterator iterator = server.queryMBeans(servletQuery, null).iterator();
while (iterator.hasNext())
{
@@ -404,23 +393,20 @@
}
-
/**
* 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
+ protected void performUndeploy(String warUrl, WebApplication appInfo) throws Exception
{
if (appInfo == null)
{
- log.debug("performUndeploy, no WebApplication found for URL "
- + warUrl);
+ log.debug("performUndeploy, no WebApplication found for URL " + warUrl);
return;
}
- log.info("undeploy, ctxPath=" + appInfo.getMetaData().getContextRoot()
- + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
+ log.info("undeploy, ctxPath=" + appInfo.getMetaData().getContextRoot() + ", warUrl="
+ + shortWarUrlFromServerHome(warUrl));
WebMetaData metaData = appInfo.getMetaData();
String hostName = null;
@@ -438,9 +424,7 @@
}
- protected void performUndeployInternal(String hostName, String warUrl,
- WebApplication appInfo)
- throws Exception
+ protected void performUndeployInternal(String hostName, String warUrl, WebApplication appInfo) throws Exception
{
WebMetaData metaData = appInfo.getMetaData();
@@ -450,16 +434,19 @@
if (server == null)
return;
- ObjectName objectName = new ObjectName(config.getCatalinaDomain()
- + ":j2eeType=WebModule,name=//" +
- ((hostName == null) ? "localhost" : hostName)
- + ctxPath + ",J2EEApplication=none,J2EEServer=none");
+ String defaultHost = hostName;
+ if (defaultHost == null)
+ {
+ String objName = config.getCatalinaDomain() + ":type=Engine";
+ defaultHost = (String) server.getAttribute(new ObjectName(objName), "defaultHost");
+ }
+ ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + defaultHost
+ + 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[]{});
+ server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
}
}
@@ -469,28 +456,26 @@
* @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
+ */
+ protected synchronized Iterator mapVirtualHosts(Iterator vhostNames) throws Exception
{
- if( vhostToHostNames.size() == 0 )
+ 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() )
+ while (iter.hasNext())
{
ObjectName host = (ObjectName) iter.next();
String name = host.getKeyProperty("host");
- if( name != null )
+ if (name != null)
{
vhostToHostNames.put(name, name);
- String[] aliases = (String[])
- server.invoke(host, "findAliases", null, null);
+ String[] aliases = (String[]) server.invoke(host, "findAliases", null, null);
int count = aliases != null ? aliases.length : 0;
- for(int n = 0;n < count; n ++)
+ for (int n = 0; n < count; n++)
{
vhostToHostNames.put(aliases[n], name);
}
@@ -500,13 +485,13 @@
// Map the virtual host names to the hosts
HashSet hosts = new HashSet();
- while( vhostNames.hasNext() )
+ while (vhostNames.hasNext())
{
String vhost = (String) vhostNames.next();
String host = (String) vhostToHostNames.get(vhost);
- if( host == null )
+ if (host == null)
{
- log.warn("Failed to map vhost: "+vhost);
+ log.warn("Failed to map vhost: " + vhost);
// This will cause a new host to be created
host = vhost;
}
@@ -523,7 +508,8 @@
if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
{
File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
- if (webDD.exists() == true) result = webDD.getAbsolutePath();
+ if (webDD.exists() == true)
+ result = webDD.getAbsolutePath();
}
else
{
@@ -548,17 +534,17 @@
return result;
}
- private String shortWarUrlFromServerHome(String warUrl)
- {
- String serverHomeUrl = System.getProperty(org.jboss.system.server.ServerConfig.SERVER_HOME_URL);
+ 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 == null || serverHomeUrl == null)
+ return warUrl;
- if (warUrl.startsWith(serverHomeUrl))
- return ".../" + warUrl.substring(serverHomeUrl.length());
- else
- return warUrl;
+ if (warUrl.startsWith(serverHomeUrl))
+ return ".../" + warUrl.substring(serverHomeUrl.length());
+ else
+ return warUrl;
}
}
More information about the jboss-cvs-commits
mailing list