Author: alessio.soldano(a)jboss.com
Date: 2012-01-27 09:27:49 -0500 (Fri, 27 Jan 2012)
New Revision: 15537
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
Log:
[JBWS-3420] Solving AS7 ws endpoint deployment performance regression
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java 2012-01-26
18:15:11 UTC (rev 15536)
+++
common/trunk/src/main/java/org/jboss/ws/common/deployment/EndpointAddressDeploymentAspect.java 2012-01-27
14:27:49 UTC (rev 15537)
@@ -67,9 +67,9 @@
// TODO: remove this hack - review API
String protocol = (String)dep.getService().getProperty("protocol");
String host = (String)dep.getService().getProperty("host");
- Integer port = (Integer)dep.getService().getProperty("port");
- Integer securePort = null;
+ PortValue port = new
PortValue((Integer)dep.getService().getProperty("port"), null);
+
if (protocol == null)
{
SPIProvider provider = SPIProviderResolver.getInstance().getProvider();
@@ -77,8 +77,7 @@
ServerConfig serverConfig = spi.getServerConfig();
host = serverConfig.getWebServiceHost();
- port = serverConfig.getWebServicePort();
- securePort = serverConfig.getWebServiceSecurePort();
+ port.setServerConfig(serverConfig);
}
Map<String, Endpoint> endpointsMap = new HashMap<String, Endpoint>();
List<Endpoint> deleteList = new LinkedList<Endpoint>();
@@ -87,7 +86,7 @@
if (ep instanceof HttpEndpoint)
{
boolean confidential = isConfidentialTransportGuarantee(dep, ep);
- int currentPort = confidential ? securePort : port;
+ int currentPort = port.getValue(confidential);
String hostAndPort = host + (currentPort > 0 ? ":" + currentPort
: "");
HttpEndpoint httpEp = (HttpEndpoint)ep;
@@ -121,6 +120,7 @@
}
}
+
protected boolean isConfidentialTransportGuarantee(final Deployment dep, final
Endpoint ep)
{
if (isJaxrpcDeployment(dep)) return false;
@@ -182,4 +182,43 @@
return "CONFIDENTIAL".equals(transportGuarantee);
}
+ private class PortValue {
+ private ServerConfig config;
+ private Integer port;
+ private Integer securePort;
+
+ public PortValue(Integer port, Integer securePort) {
+ this.port = port;
+ this.securePort = securePort;
+ }
+
+ public void setServerConfig(ServerConfig config)
+ {
+ this.port = null;
+ this.securePort = null;
+ this.config = config;
+ }
+
+ public Integer getValue(boolean confidential) {
+ return confidential ? getSecurePortValue() : getPortValue();
+ }
+
+ public Integer getPortValue()
+ {
+ if (this.port == null && this.config != null)
+ {
+ this.port = this.config.getWebServicePort();
+ }
+ return this.port;
+ }
+
+ public Integer getSecurePortValue()
+ {
+ if (this.securePort == null && this.config != null)
+ {
+ this.securePort = this.config.getWebServiceSecurePort();
+ }
+ return this.securePort;
+ }
+ }
}
Modified:
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2012-01-26
18:15:11 UTC (rev 15536)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2012-01-27
14:27:49 UTC (rev 15537)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -27,10 +27,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
-import java.util.Set;
-import javax.management.AttributeNotFoundException;
-import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -153,31 +150,14 @@
public int getWebServicePort()
{
if (webServicePort <= 0)
- webServicePort = getConnectorPort("HTTP/1.1", false);
+ webServicePort = getConnectorPort(false);
int localPort = webServicePort;
if (localPort <= 0)
{
- ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
- SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
- try
- {
- WebServerInfo webServerInfo = spiProvider.getSPI(WebServerInfoFactory.class,
cl).newWebServerInfo();
- localPort = webServerInfo.getPort("HTTP/1.1", false);
- }
- catch (WSFException e)
- {
- log.debug("Can not get local webservice port from configured
WebServerInfo!");
- if (log.isTraceEnabled()) {
- log.trace("Ignoring exception: ", e);
- }
- }
- if (localPort <= 0)
- {
- // Do not initialize webServicePort with the default, the connector port may
become available later
- log.debug("Unable to calculate 'WebServicePort', using default
'8080'");
- localPort = 8080;
- }
+ // Do not initialize webServicePort with the default, the connector port may
become available later
+ log.debug("Unable to calculate 'WebServicePort', using default
'8080'");
+ localPort = 8080;
}
return localPort;
@@ -186,34 +166,34 @@
public int getWebServiceSecurePort()
{
if (webServiceSecurePort <= 0)
- webServiceSecurePort = getConnectorPort("HTTP/1.1", true);
+ webServiceSecurePort = getConnectorPort(true);
int localPort = webServiceSecurePort;
if (localPort <= 0)
{
- ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
- SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
- try
- {
- WebServerInfo webServerInfo = spiProvider.getSPI(WebServerInfoFactory.class,
cl).newWebServerInfo();
-
- localPort = webServerInfo.getPort("HTTP/1.1", true);
- }
- catch (WSFException e)
- {
- log.warn(BundleUtils.getMessage(bundle,
"COULD_NOT_GET_WEBSERVERINFO"));
- }
-
- if (localPort <= 0)
- {
- // Do not initialize webServiceSecurePort with the default, the connector
port may become available later
- log.debug("Unable to calculate 'WebServiceSecurePort', using
default '8443'");
- localPort = 8443;
- }
+ // Do not initialize webServiceSecurePort with the default, the connector port
may become available later
+ log.debug("Unable to calculate 'WebServiceSecurePort', using
default '8443'");
+ localPort = 8443;
}
return localPort;
}
+
+ private int getConnectorPort(boolean secure) {
+ ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
+ int port = 0;
+ try
+ {
+ WebServerInfo webServerInfo = spiProvider.getSPI(WebServerInfoFactory.class,
cl).newWebServerInfo();
+ port = webServerInfo.getPort("HTTP/1.1", secure);
+ }
+ catch (WSFException e)
+ {
+ log.warn(BundleUtils.getMessage(bundle,
"COULD_NOT_GET_WEBSERVERINFO"));
+ }
+ return port;
+ }
public void create() throws Exception
{
@@ -230,51 +210,6 @@
{
getMbeanServer().unregisterMBean(AbstractServerConfigMBean.OBJECT_NAME);
}
-
- @SuppressWarnings("rawtypes")
- private int getConnectorPort(final String protocol, final boolean secure)
- {
- int port = -1;
-
- try
- {
- ObjectName connectors = new ObjectName("jboss.web:type=Connector,*");
-
- Set connectorNames = getMbeanServer().queryNames(connectors, null);
- for (Object current : connectorNames)
- {
- ObjectName currentName = (ObjectName)current;
-
- try
- {
- int connectorPort = (Integer)getMbeanServer().getAttribute(currentName,
"port");
- boolean connectorSecure =
(Boolean)getMbeanServer().getAttribute(currentName, "secure");
- String connectorProtocol =
(String)getMbeanServer().getAttribute(currentName, "protocol");
-
- if (protocol.equals(connectorProtocol) && secure ==
connectorSecure)
- {
- if (port > -1)
- {
- log.warn(BundleUtils.getMessage(bundle,
"FOUND_MULTIPLE_CONNECTORS", new Object[]{ protocol, secure, port }));
- }
- else
- {
- port = connectorPort;
- }
- }
- }
- catch (AttributeNotFoundException ignored)
- {
- }
- }
-
- return port;
- }
- catch (JMException e)
- {
- return -1;
- }
- }
public String getImplementationTitle()
{