[jbossws-commits] JBossWS SVN: r1221 - in branches/jbossws-1.0/src: main/java/org/jboss/ws/integration/jboss main/java/org/jboss/ws/integration/tomcat main/java/org/jboss/ws/server main/resources/jbossws.beans/META-INF test/java/org/jboss/test/ws/jaxrpc test/java/org/jboss/test/ws/jaxrpc/jbws1115
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Sun Oct 15 12:57:58 EDT 2006
Author: darran.lofthouse at jboss.com
Date: 2006-10-15 12:57:51 -0400 (Sun, 15 Oct 2006)
New Revision: 1221
Added:
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/JBWS1115TestCase.java
Modified:
branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/jboss/ServerConfigImpl.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/tomcat/ServerConfigImpl.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServerConfig.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServiceEndpointManager.java
branches/jbossws-1.0/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
Log:
JBWS-1115 - Automatically detect the connector ports if none specified in jboss-beans.xml
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/jboss/ServerConfigImpl.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/jboss/ServerConfigImpl.java 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/jboss/ServerConfigImpl.java 2006-10-15 16:57:51 UTC (rev 1221)
@@ -24,11 +24,14 @@
//$Id: ServiceEndpointManagerFactoryImpl.java 294 2006-05-08 16:33:42Z thomas.diesler at jboss.com $
import java.io.File;
+import java.util.Set;
+import javax.management.AttributeNotFoundException;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.ws.server.ServerConfig;
import org.jboss.ws.utils.ObjectNameFactory;
@@ -37,10 +40,14 @@
* JBoss specific implementation of a ServerConfig
*
* @author Thomas.Diesler at jboss.org
+ * @author darran.lofthouse at jboss.com
* @since 08-May-2006
*/
public class ServerConfigImpl implements ServerConfig
{
+
+ private static final Logger log = Logger.getLogger(ServerConfigImpl.class);
+
public File getServerTempDir()
{
try
@@ -70,4 +77,74 @@
return null;
}
}
+
+ public int getWebServicePort()
+ {
+ int port = getConnectorPort("HTTP/1.1", false);
+ if (port > -1)
+ {
+ return port;
+ }
+
+ log.warn("Unable to calculate 'WebServicePort', using default '8080'");
+ return 8080;
+ }
+
+ public int getWebServiceSecurePort()
+ {
+ int port = getConnectorPort("HTTP/1.1", true);
+ if (port > -1)
+ {
+ return port;
+ }
+
+ log.warn("Unable to calculate 'WebServiceSecurePort', using default '8443'");
+ return 8443;
+ }
+
+ private int getConnectorPort(final String protocol, final boolean secure)
+ {
+ int port = -1;
+
+ try
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ ObjectName connectors = new ObjectName("jboss.web:type=Connector,*");
+
+ Set connectorNames = server.queryNames(connectors, null);
+ for (Object current : connectorNames)
+ {
+ ObjectName currentName = (ObjectName)current;
+
+ try
+ {
+ int connectorPort = (Integer)server.getAttribute(currentName, "port");
+ boolean connectorSecure = (Boolean)server.getAttribute(currentName, "secure");
+ String connectorProtocol = (String)server.getAttribute(currentName, "protocol");
+
+ if (protocol.equals(connectorProtocol) && secure == connectorSecure)
+ {
+ if (port > -1)
+ {
+ log.warn("Found multiple connectors for protocol='" + protocol + "' and secure='" + secure + "', using first port found '" + port + "'");
+ }
+ else
+ {
+ port = connectorPort;
+ }
+ }
+ }
+ catch (AttributeNotFoundException ignored)
+ {
+ }
+ }
+
+ return port;
+ }
+ catch (JMException e)
+ {
+ return -1;
+ }
+
+ }
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/tomcat/ServerConfigImpl.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/tomcat/ServerConfigImpl.java 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/integration/tomcat/ServerConfigImpl.java 2006-10-15 16:57:51 UTC (rev 1221)
@@ -61,4 +61,15 @@
return null;
}
}
+
+ public int getWebServicePort()
+ {
+ return 8080;
+ }
+
+ public int getWebServiceSecurePort()
+ {
+ return 8443;
+ }
+
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServerConfig.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServerConfig.java 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServerConfig.java 2006-10-15 16:57:51 UTC (rev 1221)
@@ -38,4 +38,9 @@
File getServerTempDir();
File getServerDataDir();
+
+ int getWebServicePort();
+
+ int getWebServiceSecurePort();
+
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServiceEndpointManager.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServiceEndpointManager.java 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/server/ServiceEndpointManager.java 2006-10-15 16:57:51 UTC (rev 1221)
@@ -63,7 +63,6 @@
import org.jboss.ws.metadata.HandlerMetaData;
import org.jboss.ws.metadata.ServerEndpointMetaData;
import org.jboss.ws.metadata.UnifiedMetaData;
-import org.jboss.ws.metadata.EndpointMetaData.Type;
import org.jboss.ws.metadata.HandlerMetaData.HandlerType;
import org.jboss.ws.soap.MessageContextAssociation;
import org.jboss.ws.soap.SOAPConnectionImpl;
@@ -111,12 +110,26 @@
}
public int getWebServicePort()
- {
+ {
+ if (webServicePort <= 0)
+ {
+ ServerConfigFactory factory = ServerConfigFactory.getInstance();
+ ServerConfig config = factory.getServerConfig();
+ webServicePort = config.getWebServicePort();
+ }
+
return webServicePort;
}
public int getWebServiceSecurePort()
{
+ if (webServiceSecurePort <= 0)
+ {
+ ServerConfigFactory factory = ServerConfigFactory.getInstance();
+ ServerConfig config = factory.getServerConfig();
+ webServiceSecurePort = config.getWebServiceSecurePort();
+ }
+
return webServiceSecurePort;
}
@@ -339,7 +352,6 @@
// Get the type of the endpoint
ServerEndpointMetaData sepMetaData = wsEndpoint.getServiceEndpointInfo().getServerEndpointMetaData();
- Type type = sepMetaData.getType();
HttpSession httpSession = context.getHttpSession();
ServletContext servletContext = context.getServletContext();
Modified: branches/jbossws-1.0/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
--- branches/jbossws-1.0/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2006-10-15 16:57:51 UTC (rev 1221)
@@ -14,9 +14,14 @@
If 'webServiceHost' is an empty string, JBossWS uses requesters host when rewriting the <soap:address>.
-->
- <property name="webServiceHost">${jboss.bind.address}</property>
- <property name="webServiceSecurePort">8443</property>
- <property name="webServicePort">8080</property>
+ <property name="webServiceHost">${jboss.bind.address}</property>
+
+ <!-- If these two properties are not set the ports will be identified by querying the -->
+ <!-- list of installed connectors, if multiple connectors are found the port of the -->
+ <!-- first connector is used. -->
+ <!--<property name="webServiceSecurePort">8443</property>-->
+ <!--<property name="webServicePort">8080</property>-->
+
<property name="alwaysModifySOAPAddress">true</property>
<property name="serviceEndpointInvokerJSE">org.jboss.ws.server.ServiceEndpointInvokerJSE</property>
Added: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/JBWS1115TestCase.java
===================================================================
--- branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/JBWS1115TestCase.java 2006-10-14 02:04:09 UTC (rev 1220)
+++ branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/JBWS1115TestCase.java 2006-10-15 16:57:51 UTC (rev 1221)
@@ -0,0 +1,60 @@
+/*
+ * 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.test.ws.jaxrpc.jbws1115;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.test.ws.JBossWSTest;
+import org.jboss.ws.utils.ObjectNameFactory;
+
+/**
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 15-October-2006
+ */
+public class JBWS1115TestCase extends JBossWSTest
+{
+
+ private final ObjectName manager = ObjectNameFactory.create("jboss.ws:service=ServiceEndpointManager");
+
+ public void testDiscoverWebServicePort() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ Attribute attribute = new Attribute("WebServicePort", new Integer(0));
+ server.setAttribute(manager, attribute);
+ Integer port = (Integer)server.getAttribute(manager, "WebServicePort");
+
+ assertEquals("WebServicePort", 8080, port.intValue());
+ }
+
+ public void testDiscoverWebServiceSecurePort() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ Attribute attribute = new Attribute("WebServiceSecurePort", new Integer(0));
+ server.setAttribute(manager, attribute);
+ Integer port = (Integer)server.getAttribute(manager, "WebServiceSecurePort");
+
+ assertEquals("WebServiceSecurePort", 8443, port.intValue());
+ }
+}
Property changes on: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/jaxrpc/jbws1115/JBWS1115TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbossws-commits
mailing list