geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r374212 - in /geronimo/trunk/modules: jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ jetty-builder/src/schema/ jetty/src/java/org/apache/geronimo/jetty/
Date Thu, 02 Feb 2006 00:26:22 GMT
Author: djencks
Date: Wed Feb  1 16:26:18 2006
New Revision: 374212

URL: http://svn.apache.org/viewcvs?rev=374212&view=rev
Log:
GERONIMO-1570, GERONIMO-1460 Provide jetty gbean for specifying bouth hosts and virtual hosts:
actually use virtual hosts to set virtual hosts, not hosts.  This has a provisional schema
change, and the schema version needs to be updated

Added:
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/Host.java
Modified:
    geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-1.0.xsd
    geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-config-1.0.xsd
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java

Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=374212&r1=374211&r2=374212&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Wed Feb  1 16:26:18 2006
@@ -43,6 +43,7 @@
 import org.apache.geronimo.jetty.JettyServletHolder;
 import org.apache.geronimo.jetty.JettyWebAppContext;
 import org.apache.geronimo.jetty.NonAuthenticator;
+import org.apache.geronimo.jetty.Host;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -473,12 +474,24 @@
 
             webModuleData.setAttribute("uri", URI.create(module.getTargetPath() + "/"));
 
-            String[] hosts = jettyWebApp.getVirtualHostArray();
+            String[] hosts = jettyWebApp.getHostArray();
             for (int i = 0; i < hosts.length; i++) {
                 hosts[i] = hosts[i].trim();
             }
-            webModuleData.setAttribute("virtualHosts", hosts);
-            
+            String[] virtualHosts = jettyWebApp.getVirtualHostArray();
+            for (int i = 0; i < virtualHosts.length; i++) {
+                virtualHosts[i] = virtualHosts[i].trim();
+            }
+            if (hosts.length > 0 || virtualHosts.length > 0) {
+                //use name same as module
+                ObjectName hostName = NameFactory.getComponentName(null, null, null, null,
null, "Host", "Host", moduleJ2eeContext);
+                GBeanData hostData = new GBeanData(hostName, Host.GBEAN_INFO);
+                hostData.setAttribute("hosts", hosts);
+                hostData.setAttribute("virtualHosts", virtualHosts);
+                earContext.addGBean(hostData);
+                webModuleData.setReferencePattern("Host", hostName);
+            }
+
             //Add dependencies on managed connection factories and ejbs in this app
             //This is overkill, but allows for people not using java:comp context (even though
we don't support it)
             //and sidesteps the problem of circular references between ejbs.
@@ -524,8 +537,8 @@
 
             webModuleData.setAttribute("sessionTimeoutSeconds",
                     (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout()
!= null) ?
-                    new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60) :
-                    defaultSessionTimeoutSeconds);
+                            new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60) :
+                            defaultSessionTimeoutSeconds);
 
             MimeMappingType[] mimeMappingArray = webApp.getMimeMappingArray();
             Map mimeMappingMap = new HashMap();
@@ -637,8 +650,8 @@
             for (int i = 0; i < servletMappingArray.length; i++) {
                 ServletMappingType servletMappingType = servletMappingArray[i];
                 String servletName = servletMappingType.getServletName().getStringValue().trim();
-                if(!knownServlets.contains(servletName)) {
-                    throw new DeploymentException("Servlet mapping refers to servlet '"+servletName+"'
but no such servlet was found!");
+                if (!knownServlets.contains(servletName)) {
+                    throw new DeploymentException("Servlet mapping refers to servlet '" +
servletName + "' but no such servlet was found!");
                 }
                 String urlPattern = servletMappingType.getUrlPattern().getStringValue().trim();
                 if (!knownServletMappings.contains(urlPattern)) {
@@ -802,7 +815,7 @@
 
             if (jettyWebApp.isSetSecurityRealmName()) {
                 if (earContext.getSecurityConfiguration() == null) {
-                     throw new DeploymentException("You have specified a login security realm
for the webapp " + webModuleName + " but no security configuration is supplied in the application
plan");
+                    throw new DeploymentException("You have specified a login security realm
for the webapp " + webModuleName + " but no security configuration is supplied in the application
plan");
                 }
                 String securityRealmName = jettyWebApp.getSecurityRealmName().trim();
                 webModuleData.setAttribute("securityRealmName", securityRealmName);
@@ -1336,9 +1349,12 @@
     }
 
     private static void checkMultiplicities(WebAppType webApp) throws DeploymentException
{
-        if (webApp.getSessionConfigArray().length > 1) throw new DeploymentException("Multiple
<session-config> elements found");
-        if (webApp.getJspConfigArray().length > 1) throw new DeploymentException("Multiple
<jsp-config> elements found");
-        if (webApp.getLoginConfigArray().length > 1) throw new DeploymentException("Multiple
<login-config> elements found");
+        if (webApp.getSessionConfigArray().length > 1)
+            throw new DeploymentException("Multiple <session-config> elements found");
+        if (webApp.getJspConfigArray().length > 1)
+            throw new DeploymentException("Multiple <jsp-config> elements found");
+        if (webApp.getLoginConfigArray().length > 1)
+            throw new DeploymentException("Multiple <login-config> elements found");
     }
 
     class UncheckedItem {
@@ -1410,18 +1426,18 @@
         infoBuilder.addInterface(ModuleBuilder.class);
 
         infoBuilder.setConstructor(new String[]{
-            "defaultParentId",
-            "defaultSessionTimeoutSeconds",
-            "defaultContextPriorityClassloader",
-            "defaultWelcomeFiles",
-            "jettyContainerObjectName",
-            "DefaultServlets",
-            "DefaultFilters",
-            "DefaultFilterMappings",
-            "PojoWebServiceTemplate",
-            "WebServiceBuilder",
-            "Repository",
-            "kernel"});
+                "defaultParentId",
+                "defaultSessionTimeoutSeconds",
+                "defaultContextPriorityClassloader",
+                "defaultWelcomeFiles",
+                "jettyContainerObjectName",
+                "DefaultServlets",
+                "DefaultFilters",
+                "DefaultFilterMappings",
+                "PojoWebServiceTemplate",
+                "WebServiceBuilder",
+                "Repository",
+                "kernel"});
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 

Modified: geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-1.0.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-1.0.xsd?rev=374212&r1=374211&r2=374212&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-1.0.xsd (original)
+++ geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-1.0.xsd Wed Feb  1 16:26:18
2006
@@ -44,6 +44,7 @@
                                                        
             <xs:element name="context-root" type="xs:string" minOccurs="0"/>
             <xs:element name="context-priority-classloader" type="xs:boolean" minOccurs="0"/>
+            <xs:element name="host" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="virtual-host" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="session-manager" type="xs:string" minOccurs="0"/>
 

Modified: geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-config-1.0.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-config-1.0.xsd?rev=374212&r1=374211&r2=374212&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-config-1.0.xsd (original)
+++ geronimo/trunk/modules/jetty-builder/src/schema/geronimo-jetty-config-1.0.xsd Wed Feb
 1 16:26:18 2006
@@ -28,6 +28,7 @@
 
     <xs:complexType name="jetty-configType">
         <xs:sequence>
+            <xs:element name="host" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="virtual-host" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="session-manager" type="xs:string" minOccurs="0"/>
         </xs:sequence>

Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/Host.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/Host.java?rev=374212&view=auto
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/Host.java (added)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/Host.java Wed Feb  1 16:26:18
2006
@@ -0,0 +1,45 @@
+package org.apache.geronimo.jetty;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+/**
+ * Host gbean for jetty containing an array of hosts and virtual hosts
+ */
+public class Host {
+
+    private final String[] hosts;
+    private final String[] virtualHosts;
+
+    public Host() {
+        hosts = null;
+        virtualHosts = null;
+    }
+
+    public Host(String[] hosts, String[] virtualHosts) {
+        this.hosts = hosts;
+        this.virtualHosts = virtualHosts;
+    }
+
+    public String[] getHosts() {
+        return hosts;
+    }
+
+    public String[] getVirtualHosts() {
+        return virtualHosts;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(Host.class, "Host");
+        infoBuilder.addAttribute("hosts", String[].class, true);
+        infoBuilder.addAttribute("virtualHosts", String[].class, true);
+        infoBuilder.setConstructor(new String[] {"hosts", "virtualHosts"});
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?rev=374212&r1=374211&r2=374212&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Wed Feb  1 16:26:18 2006
@@ -166,7 +166,6 @@
     public JettyWebAppContext(String objectName,
                               String originalSpecDD,
                               URI uri,
-                              String[] virtualHosts,
                               String sessionManager,
                               Map componentContext,
                               OnlineUserTransaction userTransaction,
@@ -196,6 +195,7 @@
                               PermissionCollection checkedPermissions,
                               PermissionCollection excludedPermissions,
 
+                              Host host,
                               TransactionContextManager transactionContextManager,
                               TrackedConnectionAssociator trackedConnectionAssociator,
                               JettyContainer jettyContainer,
@@ -247,7 +247,10 @@
         this.webClassLoader = new JettyClassLoader(urls, webAppRootURL, classLoader, contextPriorityClassLoader);
         setClassLoader(this.webClassLoader);
 
-        setHosts(virtualHosts);
+        if (host != null) {
+            setHosts(host.getHosts());
+            setVirtualHosts(host.getVirtualHosts());
+        }
 
         handler = new WebApplicationHandler();
         addHandler(handler);
@@ -621,7 +624,6 @@
 
 
         infoBuilder.addAttribute("uri", URI.class, true);
-        infoBuilder.addAttribute("virtualHosts", String[].class, true);
         infoBuilder.addAttribute("sessionManager", String.class, true);
         infoBuilder.addAttribute("componentContext", Map.class, true);
         infoBuilder.addAttribute("userTransaction", OnlineUserTransaction.class, true);
@@ -634,6 +636,7 @@
 
         infoBuilder.addAttribute("contextPath", String.class, true);
 
+        infoBuilder.addReference("Host", Host.class, "Host");
         infoBuilder.addReference("TransactionContextManager", TransactionContextManager.class,
NameFactory.TRANSACTION_CONTEXT_MANAGER);
         infoBuilder.addReference("TrackedConnectionAssociator", TrackedConnectionAssociator.class,
NameFactory.JCA_CONNECTION_TRACKER);
         infoBuilder.addReference("JettyContainer", JettyContainer.class, NameFactory.GERONIMO_SERVICE);
@@ -664,7 +667,6 @@
                 "objectName",
                 "deploymentDescriptor",
                 "uri",
-                "virtualHosts",
                 "sessionManager",
                 "componentContext",
                 "userTransaction",
@@ -695,6 +697,7 @@
                 "checkedPermissions",
                 "excludedPermissions",
 
+                "Host",
                 "TransactionContextManager",
                 "TrackedConnectionAssociator",
                 "JettyContainer",



Mime
View raw message