Author: darran.lofthouse(a)jboss.com
Date: 2008-07-16 13:11:47 -0400 (Wed, 16 Jul 2008)
New Revision: 7833
Added:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
Modified:
framework/trunk/pom.xml
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3Bean.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3RemoteInterface.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EndpointInterface.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/JBWS981TestCase.java
Log:
[JBWS-981] Virtual host configuration for EJB endpoints.
Modified: framework/trunk/pom.xml
===================================================================
--- framework/trunk/pom.xml 2008-07-16 17:08:06 UTC (rev 7832)
+++ framework/trunk/pom.xml 2008-07-16 17:11:47 UTC (rev 7833)
@@ -26,7 +26,7 @@
<!-- Properties -->
<properties>
<jbossws.common.version>1.0.5.GA</jbossws.common.version>
- <jbossws.spi.version>1.0.4.GA</jbossws.spi.version>
+ <jbossws.spi.version>1.0.5-SNAPSHOT</jbossws.spi.version>
<jboss.common.version>1.2.1.GA</jboss.common.version>
<jbossxb.version>1.0.0.SP1</jbossxb.version>
</properties>
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java 2008-07-16
17:08:06 UTC (rev 7832)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -45,6 +45,7 @@
private Deployment dep;
private List<Endpoint> endpoints = new LinkedList<Endpoint>();
private String contextRoot;
+ private String[] virtualHosts;
DefaultService()
{
@@ -94,4 +95,15 @@
{
this.contextRoot = contextRoot;
}
+
+ public String[] getVirtualHosts()
+ {
+ return virtualHosts;
+ }
+
+ public void setVirtualHosts(String[] virtualHosts)
+ {
+ this.virtualHosts = virtualHosts;
+ }
+
}
Added:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
(rev 0)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.wsf.framework.deployment;
+
+//$Id:$
+
+import java.util.Arrays;
+
+import org.jboss.wsf.spi.WSFRuntime;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * A deployer that assigns the virtual hosts to the service
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 10-Jul-2008
+ */
+public class VirtualHostDeploymentAspect extends DeploymentAspect
+{
+
+ @Override
+ public void create(Deployment dep, WSFRuntime runtime)
+ {
+ String[] virtualHosts = dep.getService().getVirtualHosts();
+ if (virtualHosts == null)
+ {
+ dep.getService().setVirtualHosts(getExplicitVirtualHosts(dep));
+ }
+
+ }
+
+ protected String[] getExplicitVirtualHosts(Deployment dep)
+ {
+ String[] virtualHosts = null;
+
+ // Use the virtual hosts from @WebContext.virtualHosts
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ Class implClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)implClass.getAnnotation(WebContext.class);
+ if (anWebContext != null && anWebContext.virtualHosts() != null
&& anWebContext.virtualHosts().length > 0)
+ {
+ String[] anVirtualHosts = anWebContext.virtualHosts();
+ // Avoid modifying the annotation values.
+ String[] temp = new String[anVirtualHosts.length];
+ System.arraycopy(anVirtualHosts, 0, temp, 0, anVirtualHosts.length);
+ Arrays.sort(temp);
+
+ if (virtualHosts == null)
+ {
+ virtualHosts = temp;
+ }
+ else
+ {
+ if (Arrays.equals(virtualHosts, temp) == false)
+ {
+ throw new IllegalStateException("virtualHosts must be the same for
all deployed endpoints");
+ }
+ }
+ }
+ }
+ return virtualHosts;
+ }
+}
Property changes on:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3Bean.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3Bean.java 2008-07-16
17:08:06 UTC (rev 7832)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3Bean.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -28,6 +28,7 @@
import javax.management.ObjectName;
import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.annotation.WebContext;
/**
*
@@ -36,6 +37,7 @@
*/
@Stateless
@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.jbws981.EndpointInterface", targetNamespace =
"http://www.jboss.org/test/ws/jaxws/jbws981", serviceName =
"EndpointService")
+@WebContext(virtualHosts = { "localhost", "www.jboss.org" })
public class EJB3Bean implements EJB3RemoteInterface
{
@@ -45,13 +47,13 @@
{
try
{
- MBeanServer mbeanServer =
(MBeanServer)MBeanServerFactory.findMBeanServer("jboss").get(0);
+ MBeanServer mbeanServer =
(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName on = new
ObjectName("jboss.web:J2EEApplication=none,J2EEServer=none,WebModule...;
mbeanServer.getMBeanInfo(on);
}
catch (Exception e)
{
- log.error(e);
+ log.error("Unable to lookup deployment", e);
return "Unable to get WebModule MBean for virtual host - virtual-host not
handled from @WebContext";
}
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3RemoteInterface.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3RemoteInterface.java 2008-07-16
17:08:06 UTC (rev 7832)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EJB3RemoteInterface.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws.jaxws.jbws981;
-
/**
*
* @author darran.lofthouse(a)jboss.com
@@ -31,5 +30,5 @@
{
public String hello(final String message);
-
+
}
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EndpointInterface.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EndpointInterface.java 2008-07-16
17:08:06 UTC (rev 7832)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/EndpointInterface.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -12,11 +12,8 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import org.jboss.wsf.spi.annotation.WebContext;
-
@WebService(targetNamespace = "http://www.jboss.org/test/ws/jaxws/jbws981")
@SOAPBinding(style = SOAPBinding.Style.RPC)
-@WebContext(virtualHosts = { "localhost", "www.jboss.org" })
public interface EndpointInterface
{
String hello(String msg);
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/JBWS981TestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/JBWS981TestCase.java 2008-07-16
17:08:06 UTC (rev 7832)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws981/JBWS981TestCase.java 2008-07-16
17:11:47 UTC (rev 7833)
@@ -50,7 +50,6 @@
protected void setUp() throws Exception
{
super.setUp();
- if (true) return;
if (port == null)
{
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-jbws981/EJB3Bean?wsdl");
@@ -63,10 +62,7 @@
public void testCall() throws Exception
{
- System.out.println("FIXME [JBWS-981] Virtual host configuration for EJB
endpoints");
- if (true) return;
-
- String message = "hello";
+ String message = "Web service mapped to virtual host.";
assertEquals("Web service mapped to virtual host.",
port.hello(message));
}
}
\ No newline at end of file