Author: darran.lofthouse(a)jboss.com
Date: 2008-07-31 06:52:18 -0400 (Thu, 31 Jul 2008)
New Revision: 7970
Added:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/WebAppGeneratorDeploymentAspect.java
framework/branches/jbossws-framework-2.0.1.GA_CP/version.properties
Log:
[JBPAPP-982] Virtual host configuration for EJB endpoints.
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java 2008-07-31
10:46:28 UTC (rev 7969)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java 2008-07-31
10:52:18 UTC (rev 7970)
@@ -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;
+ }
+
}
Copied:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
(from rev 7833,
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java)
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
(rev 0)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java 2008-07-31
10:52:18 UTC (rev 7970)
@@ -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.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)
+ {
+ 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;
+ }
+}
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/WebAppGeneratorDeploymentAspect.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/WebAppGeneratorDeploymentAspect.java 2008-07-31
10:46:28 UTC (rev 7969)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP/src/main/java/org/jboss/wsf/framework/deployment/WebAppGeneratorDeploymentAspect.java 2008-07-31
10:52:18 UTC (rev 7970)
@@ -84,7 +84,7 @@
URL webAppURL = generatWebDeployment((ArchiveDeployment)dep,
securityHandlerEJB3);
dep.setProperty("org.jboss.ws.webapp.url", webAppURL);
}
- else
+ else
{
URL webAppURL = generatWebDeployment((ArchiveDeployment)dep, null);
dep.setProperty("org.jboss.ws.webapp.url", webAppURL);
@@ -279,6 +279,15 @@
jbossWeb.addElement("context-root").addText(contextRoot);
+ String[] virtualHosts = dep.getService().getVirtualHosts();
+ if (virtualHosts != null)
+ {
+ for (String currentVirtualHost : virtualHosts)
+ {
+ jbossWeb.addElement("virtual-host").addText(currentVirtualHost);
+ }
+ }
+
return document;
}
}
\ No newline at end of file
Modified: framework/branches/jbossws-framework-2.0.1.GA_CP/version.properties
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/version.properties 2008-07-31
10:46:28 UTC (rev 7969)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/version.properties 2008-07-31
10:52:18 UTC (rev 7970)
@@ -14,8 +14,8 @@
implementation.vendor.id=http://www.jboss.org
# Thirdparty library versions
-jbossws-common=1.0.0.GA_CP01
-jbossws-spi=1.0.0.GA
+jbossws-common=1.0.0.GA_CP-SNAPSHOT
+jbossws-spi=1.0.0.GA_CP-SNAPSHOT
dom4j=1.6.1
jboss-common-core=2.0.2.GA