Skip to main content

[webtier] revised valve-patch

12 replies [Last post]
Anonymous

Hi,

I have added the patches for the web and deployment projects as
diff-files. Also I have added the two new classes
com.sun.enterprise.deployment.node.runtime.web.ValveNode and
com.sun.enterprise.deployment.runtime.web.Valve that belong into the dol
project of the deployment projects.

Due to the new DTD (sun-web-app_3_0-0.dtd) some minor changes had to be
added to the DTDRegistry (dol project) and WebBundleRuntimeNode. These
changes have not been part of my first patch.

Jan, you mentioned in one of your earlier mails that I should deprecate
property-based valve handling. This actually only applied to the
addValve(java.lang.String) method, if I am not mistaken. I did add a
deprecation-annotation and comment but I guess more relevant would be
the documentation which momentarily mentions the property usage.

Thanks for your help and comments to my first patch,

--
Wolfram Rittmeyer

Property changes on: javaee-core
___________________________________________________________________
Added: svn:ignore
+ target

Index: dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java
===================================================================
--- dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java (revision 24754)
+++ dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java (working copy)
@@ -62,7 +62,7 @@
public static final String IDEMPOTENT_URL_PATTERN = "IdempotentUrlPattern";
public static final String ERROR_URL = "ErrorUrl";
public static final String HTTPSERVLET_SECURITY_PROVIDER = "HttpServletSecurityProvider";
-
+ public static final String VALVE = "Valve";

public SunWebApp()
{
@@ -424,4 +424,47 @@
}
return ret.booleanValue();
}
+
+ // This attribute is a valve to be added at the specified index
+ public void setValve(int index, Valve value)
+ {
+ this.setValue(VALVE, index, value);
+ }
+
+ // The return value is the valve at the specified index
+ public Valve getValve(int index)
+ {
+ return (Valve)this.getValue(VALVE, index);
+ }
+
+ // This attribute is an array, possibly empty
+ public void setValve(Valve[] value)
+ {
+ this.setValue(VALVE, value);
+ }
+
+ // This return value is an array, possibly empty
+ public Valve[] getValve()
+ {
+ return (Valve[])this.getValues(VALVE);
+ }
+
+ // Return the number of valves
+ public int sizeValve()
+ {
+ return this.size(VALVE);
+ }
+
+ // Add a new element returning its index in the list
+ public int addValve(Valve value)
+ {
+ return this.addValue(VALVE, value);
+ }
+
+ // Remove an element using its reference
+ public int removeValve(Valve value)
+ {
+ return this.removeValue(VALVE, value);
+ }
+
}
Index: dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java
===================================================================
--- dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java (revision 24754)
+++ dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java (working copy)
@@ -108,6 +108,7 @@
//common
register(new XMLElement(RuntimeTagNames.PRINCIPAL_NAME), PrincipalNameDescriptor.class);
register(new XMLElement(RuntimeTagNames.SECURITY_ROLE_MAPPING), SecurityRoleMapping.class);
+ register(new XMLElement(RuntimeTagNames.VALVE), Valve.class);
}
/**
* register a new descriptor class handling a particular XPATH in the DTD.
Index: dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java
===================================================================
--- dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java (revision 24754)
+++ dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java (working copy)
@@ -131,6 +131,9 @@
MessageDestinationRuntimeNode.class);
registerElementHandler(new XMLElement(WebServicesTagNames.WEB_SERVICE),
WebServiceRuntimeNode.class);
+ registerElementHandler(new XMLElement(RuntimeTagNames.VALVE),
+ ValveNode.class);
+
}

/**
@@ -144,14 +147,14 @@
* @return the DOCTYPE that should be written to the XML file
*/
public String getDocType() {
- return DTDRegistry.SUN_WEBAPP_250_DTD_PUBLIC_ID;
+ return DTDRegistry.SUN_WEBAPP_300_DTD_PUBLIC_ID;
}

/**
* @return the SystemID of the XML file
*/
public String getSystemID() {
- return DTDRegistry.SUN_WEBAPP_250_DTD_SYSTEM_ID;
+ return DTDRegistry.SUN_WEBAPP_300_DTD_SYSTEM_ID;
}

/**
@@ -173,6 +176,7 @@
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_240_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_240_DTD_SYSTEM_ID);
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_241_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_241_DTD_SYSTEM_ID);
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_250_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_250_DTD_SYSTEM_ID);
+ publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_300_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_300_DTD_SYSTEM_ID);
if (!restrictDTDDeclarations()) {
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_240beta_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_240beta_DTD_SYSTEM_ID);
}
@@ -296,6 +300,9 @@
} else if (newDescriptor instanceof WebProperty) {
descriptor.getSunDescriptor().addWebProperty(
(WebProperty)newDescriptor);
+ } else if (newDescriptor instanceof Valve) {
+ descriptor.getSunDescriptor().addValve(
+ (Valve)newDescriptor);
}
else super.addDescriptor(descriptor);
}
@@ -501,6 +508,12 @@
props.writeDescriptor(web, RuntimeTagNames.PROPERTY, sunWebApp.getWebProperty());
}

+ // valve*
+ if (sunWebApp.getValve()!=null) {
+ ValveNode valve = new ValveNode();
+ valve.writeDescriptor(web, RuntimeTagNames.VALVE, sunWebApp.getValve());
+ }
+
// message-destination*
RuntimeDescriptorNode.writeMessageDestinationInfo(web, bundleDescriptor);

Index: dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java
===================================================================
--- dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java (revision 24754)
+++ dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java (working copy)
@@ -286,6 +286,8 @@
public static final String JAVA_METHOD = "java-method";
public final static String METHOD_PARAMS = "method-params";
public final static String METHOD_PARAM = "method-param";
+
+ public final static String VALVE = "valve";

// Java Web Start-support related
public final static String JAVA_WEB_START_ACCESS = "java-web-start-access";
Index: dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java
===================================================================
--- dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java (revision 24754)
+++ dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java (working copy)
@@ -223,6 +223,10 @@
public static final String SUN_WEBAPP_250_DTD_SYSTEM_ID =
"http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd";

+ public static final String SUN_WEBAPP_300_DTD_PUBLIC_ID =
+ "-//Sun Microsystems, Inc.//DTD GlassFish v3 Servlet 3.0//EN";
+ public static final String SUN_WEBAPP_300_DTD_SYSTEM_ID =
+ "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd";

/**
* Application Client Container: Sun ONE App Server specific dtd info.
Index: dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd
===================================================================
--- dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd (revision 24754)
+++ dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd (working copy)
@@ -17,7 +17,7 @@
ejb-ref*, resource-ref*, resource-env-ref*, service-ref*,
message-destination-ref*, cache?, class-loader?,
jsp-config?, locale-charset-info?, parameter-encoding?,
- property*, message-destination*, webservice-description*)>
+ property*, valve*, message-destination*, webservice-description*)>

@@ -321,6 +321,9 @@
-->

+
+

0) {
+ com.sun.enterprise.deployment.runtime.web.Valve[] valves = iasBean.getValve();
+ for (com.sun.enterprise.deployment.runtime.web.Valve valve: valves) {
+ addValve(valve);
+ }
+ }
+
+ }
+
+ /**
* Configure the

WebModule</code< properties.
      */
     protected void configureCatalinaProperties(){
@@ -921,8 +940,9 @@
    

     /**
-     * Add a <code>Valve
to a VirtualServer pipeline.
- * @param valveName the fully qualified class name of the Valve.
+ * Constructs a Valve and adds it to the
+ * Pipeline of this WebModule.
+ * @param valveName the fully qualified class name of the Valve.
*/
protected void addValve(String valveName) {
Object valve = loadInstance(valveName);
@@ -937,7 +957,74 @@
}
}

+ /**
+ * Constructs a Valve from the given valveDescriptor
+ * and adds it to the Pipeline of this WebModule.
+ * @param valveDescriptor the object containing the information to create the valve.
+ */
+ protected void addValve(com.sun.enterprise.deployment.runtime.web.Valve valveDescriptor) {
+ String valveName = valveDescriptor.getAttributeValue(
+ com.sun.enterprise.deployment.runtime.web.Valve.NAME);
+ String className = valveDescriptor.getAttributeValue(
+ com.sun.enterprise.deployment.runtime.web.Valve.CLASS_NAME);
+ if (valveName == null) {
+ logger.log(Level.WARNING, "webmodule.valve.missingName", getName());
+ return;
+ }
+ if (className == null) {
+ logger.log(Level.WARNING, "webmodule.valve.missingClassname", new Object[]{valveName, getName()});
+ return;
+ }
+ Object valve = loadInstance(className);
+ if (valve == null) {
+ return;
+ }
+ if (!(valve instanceof GlassFishValve) &&
+ !(valve instanceof Valve)) {
+ logger.log(Level.WARNING,
+ "Object of type classname " + className +
+ " not an instance of Valve or GlassFishValve");
+ }
+ WebProperty[] props = valveDescriptor.getWebProperty();
+ if (props != null && props.length > 0) {
+ for (WebProperty property: props) {
+ String propName = getSetterName(property.getAttributeValue(WebProperty.NAME));
+ if (propName != null && propName.length() != 0) {
+ String value = property.getAttributeValue(WebProperty.VALUE);
+ try {
+ Method method = valve.getClass().getMethod(propName, String.class);
+ method.invoke(valve, value);
+ } catch (NoSuchMethodException ex) {
+ String msg = rb.getString("webmodule.valve.specifiedMethodMissing");
+ msg = MessageFormat.format(msg, new Object[] { propName,
+ valveName,
+ getName()});
+ logger.log(Level.SEVERE, msg, ex);
+ } catch (Throwable t) {
+ String msg = rb.getString("webmodule.valve.setterCausedException");
+ msg = MessageFormat.format(msg, new Object[] { propName,
+ valveName,
+ getName()});
+ logger.log(Level.SEVERE, msg, t);
+ }
+ }
+ else {
+ String msg = rb.getString("webmodule.valve.missingPropertyName");
+ msg = MessageFormat.format(msg, new Object[] {valveName});
+ logger.log(Level.WARNING, "webmodule.valve.missingPropertyName", new Object[]{valveName, getName()});
+ return;
+ }
+ }
+ }
+ if (valve instanceof Valve) {
+ super.addValve((Valve) valve);
+ } else if (valve instanceof GlassFishValve) {
+ super.addValve((GlassFishValve) valve);
+ }
+ }

+
+
/**
* Add a Catalina listener to a ContractProvider
* @param listenerName the fully qualified class name of the listener.
@@ -973,6 +1060,19 @@
return null;
}

+
+ private String getSetterName(String propName) {
+ if (propName != null) {
+ if (propName.length() > 1) {
+ propName = "set" + Character.toUpperCase(propName.charAt(0)) +
+ propName.substring(1);
+ }
+ else {
+ propName = "set" + Character.toUpperCase(propName.charAt(0));
+ }
+ }
+ return propName;
+ }

public com.sun.enterprise.config.serverbeans.WebModule getBean() {
return bean;
package com.sun.enterprise.deployment.node.runtime.web;

import com.sun.enterprise.deployment.node.XMLElement;
import com.sun.enterprise.deployment.runtime.web.Valve;
import com.sun.enterprise.deployment.runtime.web.WebProperty;
import com.sun.enterprise.deployment.xml.RuntimeTagNames;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
* Node representing a valve tag.
*/
public class ValveNode extends WebRuntimeNode {

public ValveNode() {
registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY),
WebPropertyNode.class, "addWebProperty");
}

@Override
protected boolean setAttributeValue(XMLElement elementName, XMLElement attributeName, String value) {
Valve descriptor = (Valve) getRuntimeDescriptor();
if (descriptor == null) {
throw new RuntimeException("Trying to set values on a null descriptor");
}
if (attributeName.getQName().equals(RuntimeTagNames.NAME)) {
descriptor.setAttributeValue(Valve.NAME, value);
return true;
} else if (attributeName.getQName().equals(RuntimeTagNames.CLASS_NAME)) {
descriptor.setAttributeValue(Valve.CLASS_NAME, value);
return true;
}
return false;
}

/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param node name
* @param the descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node parent, String nodeName, Valve descriptor) {

Element valve = (Element) super.writeDescriptor(parent, nodeName, descriptor);

WebPropertyNode wpn = new WebPropertyNode();

// sub-element property*
wpn.writeDescriptor(valve, RuntimeTagNames.PROPERTY, descriptor.getWebProperty());

// attributes classname and name
setAttribute(valve, RuntimeTagNames.NAME, (String) descriptor.getAttributeValue(Valve.NAME));
setAttribute(valve, RuntimeTagNames.CLASS_NAME, (String) descriptor.getAttributeValue(Valve.CLASS_NAME));

return valve;
}
}
package com.sun.enterprise.deployment.runtime.web;

public class Valve extends WebPropertyContainer {

static public final String CLASS_NAME = "ClassName";

}

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Lincoln Baxter, III

Seems like if the JSF form attribute "prependId" is set to "false", the
UIViewRoot cannot find any Components within the form.

When prependId is left on (defaults to true), this works.

This also seems to be having trouble in nested tables. (I havent tried
just one table yet.)

--Lincoln
[att1.html]

Ryan Lubke

Lincoln Baxter, III wrote:
> Seems like if the JSF form attribute "prependId" is set to "false",
> the UIViewRoot cannot find any Components within the form.
>
> When prependId is left on (defaults to true), this works.
>
> This also seems to be having trouble in nested tables. (I havent tried
> just one table yet.)
I believe this is working as intended. UIComponent.findComponent()
operates on naming containers.
When you have prependId set to false, then the naming container
information is lost.

You could probably still get this to work, but you'd have to break it
into a couple of steps (basically
doing what the default findComponent() does when NamingContainer
information is present):

1. Call findComponent() for the top level form ID (assuming it's a
child of UIViewRoot and not nested
within another naming container)
2. Using the form component found in step 1, search for the child of
interest.

>
> --Lincoln

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Lincoln Baxter, III

Hey Ryan,

Is this to prevent duplicate IDs in the view? ID is always supposed to
be unique in HTML/HTTP anyway, so I don't see a problem in enabling this
from a convention standpoint.

I'm trying to figure out the use case that would cause problems here. If
you have a second could you give me your thoughts?

I'm thinking maybe this is behavior that could be enhanced for JSF2? I
feel that it may be a little counter-intuitive, even though there is a
workaround. Is this documented?

What do you think?

--Lincoln

On Tue, 2009-02-17 at 08:52 -0800, Ryan Lubke wrote:

> Lincoln Baxter, III wrote:
> > Seems like if the JSF form attribute "prependId" is set to "false",
> > the UIViewRoot cannot find any Components within the form.
> >
> > When prependId is left on (defaults to true), this works.
> >
> > This also seems to be having trouble in nested tables. (I havent tried
> > just one table yet.)
> I believe this is working as intended. UIComponent.findComponent()
> operates on naming containers.
> When you have prependId set to false, then the naming container
> information is lost.
>
> You could probably still get this to work, but you'd have to break it
> into a couple of steps (basically
> doing what the default findComponent() does when NamingContainer
> information is present):
>
> 1. Call findComponent() for the top level form ID (assuming it's a
> child of UIViewRoot and not nested
> within another naming container)
> 2. Using the form component found in step 1, search for the child of
> interest.
>
>
> >
> > --Lincoln
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
[att1.html]

Ryan Lubke

Lincoln Baxter, III wrote:
> Hey Ryan,
>
> Is this to prevent duplicate IDs in the view? ID is always supposed to
> be unique in HTML/HTTP anyway, so I don't see a problem in enabling
> this from a convention standpoint.
>
> I'm trying to figure out the use case that would cause problems here.
> If you have a second could you give me your thoughts?
>
> I'm thinking maybe this is behavior that could be enhanced for JSF2? I
> feel that it may be a little counter-intuitive, even though there is a
> workaround. Is this documented?
I agree that it is a counter-intuitive. I will speak to the spec leads
about it next time I can corner them.
As to documented, I can't recall anything formal.

Will follow up once I know more.
>
> What do you think?
>
> --Lincoln
>
> On Tue, 2009-02-17 at 08:52 -0800, Ryan Lubke wrote:
>> Lincoln Baxter, III wrote:
>> > Seems like if the JSF form attribute "prependId" is set to "false",
>> > the UIViewRoot cannot find any Components within the form.
>> >
>> > When prependId is left on (defaults to true), this works.
>> >
>> > This also seems to be having trouble in nested tables. (I havent tried
>> > just one table yet.)
>> I believe this is working as intended. UIComponent.findComponent()
>> operates on naming containers.
>> When you have prependId set to false, then the naming container
>> information is lost.
>>
>> You could probably still get this to work, but you'd have to break it
>> into a couple of steps (basically
>> doing what the default findComponent() does when NamingContainer
>> information is present):
>>
>> 1. Call findComponent() for the top level form ID (assuming it's a
>> child of UIViewRoot and not nested
>> within another naming container)
>> 2. Using the form component found in step 1, search for the child of
>> interest.
>>
>>
>> >
>> > --Lincoln
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Jan Luehe

Hi Wolfram,

> Your patch looks just perfect!
>
> I was able to apply your diffs just fine.
>
> I have sent the DOL related changes to the deployment lead (Hong
> Zhang), so she gets a chance to review them also before I commit them
> on your behalf.

You got the green light from Hong as well. :)
This was her comment:

The changes look really good, I am actually a little surprised to see
that he made all the necessary changes in one round. :-)

I've filed a new issue that is specific to valve support in sun-web.xml,
see:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=7177
("Add valve configuration support to sun-web.xml")

and cross-linked it with the domain.xml related issue that you had
originally filed, see:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=4006

I just committed your changes under IT 7177 (see commit notification below),
and reassigned the issue to docs, so that the new and improved configuration
approach can be documented, and the old one deprecated.

Again, congrats on your patch! Very nice work!

Jan

-------- Original Message --------
Subject: svn commit: r24777 - trunk/v3:
deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime
deployment/dol/src/main/java/com/sun/enterpr...
Date: Fri, 13 Feb 2009 18:42:20 +0000
From: jluehe@dev.java.net
Reply-To: commits@glassfish-svn.dev.java.net
To: commits@glassfish-svn.dev.java.net

Author: jluehe
Date: 2009-02-13 18:42:18+0000
New Revision: 24777

Added:
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/ValveNode.java
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/Valve.java
Modified:
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java
trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java
trunk/v3/deployment/dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd
trunk/v3/web/war-util/src/main/resources/com/sun/logging/enterprise/system/container/web/LogStrings.properties
trunk/v3/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java

Log:
Fix for https://glassfish.dev.java.net/issues/show_bug.cgi?id=7177 ("Add valve configuration support to sun-web.xml")

Patch provided by: writtmeyer

Reviewed by: jluehe, hzhang_jn

Tests run: QL

Modified: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java (original)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/RuntimeDescriptorFactory.java 2009-02-13 18:42:18+0000
@@ -108,7 +108,9 @@
//common
register(new XMLElement(RuntimeTagNames.PRINCIPAL_NAME), PrincipalNameDescriptor.class);
register(new XMLElement(RuntimeTagNames.SECURITY_ROLE_MAPPING), SecurityRoleMapping.class);
- }
+ register(new XMLElement(RuntimeTagNames.VALVE), Valve.class);
+ }
+
/**
* register a new descriptor class handling a particular XPATH in the DTD.
*

Added: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/ValveNode.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- (empty file)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/ValveNode.java 2009-02-13 18:42:18+0000
@@ -0,0 +1,102 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.enterprise.deployment.node.runtime.web;
+
+import com.sun.enterprise.deployment.node.XMLElement;
+import com.sun.enterprise.deployment.runtime.web.Valve;
+import com.sun.enterprise.deployment.runtime.web.WebProperty;
+import com.sun.enterprise.deployment.xml.RuntimeTagNames;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Node representing a valve tag.
+ */
+public class ValveNode extends WebRuntimeNode {
+
+ public ValveNode() {
+ registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY),
+ WebPropertyNode.class, "addWebProperty");
+ }
+
+ @Override
+ protected boolean setAttributeValue(XMLElement elementName,
+ XMLElement attributeName,
+ String value) {
+ Valve descriptor = (Valve) getRuntimeDescriptor();
+ if (descriptor == null) {
+ throw new RuntimeException("Trying to set values on a null descriptor");
+ }
+ if (attributeName.getQName().equals(RuntimeTagNames.NAME)) {
+ descriptor.setAttributeValue(Valve.NAME, value);
+ return true;
+ } else if (attributeName.getQName().equals(RuntimeTagNames.CLASS_NAME)) {
+ descriptor.setAttributeValue(Valve.CLASS_NAME, value);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Writes the descriptor class to a DOM tree and returns it
+ *
+ * @param parent node for the DOM tree
+ * @param node name
+ * @param the descriptor to write
+ * @return the DOM tree top node
+ */
+ public Node writeDescriptor(Node parent, String nodeName,
+ Valve descriptor) {
+
+ Element valve = (Element) super.writeDescriptor(
+ parent, nodeName, descriptor);
+
+ WebPropertyNode wpn = new WebPropertyNode();
+
+ // sub-element property*
+ wpn.writeDescriptor(valve, RuntimeTagNames.PROPERTY,
+ descriptor.getWebProperty());
+
+ // attributes classname and name
+ setAttribute(valve, RuntimeTagNames.NAME,
+ (String) descriptor.getAttributeValue(Valve.NAME));
+ setAttribute(valve, RuntimeTagNames.CLASS_NAME,
+ (String) descriptor.getAttributeValue(Valve.CLASS_NAME));
+
+ return valve;
+ }
+}

Modified: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java (original)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/node/runtime/web/WebBundleRuntimeNode.java 2009-02-13 18:42:18+0000
@@ -131,6 +131,9 @@
MessageDestinationRuntimeNode.class);
registerElementHandler(new XMLElement(WebServicesTagNames.WEB_SERVICE),
WebServiceRuntimeNode.class);
+ registerElementHandler(new XMLElement(RuntimeTagNames.VALVE),
+ ValveNode.class);
+
}

/**
@@ -144,15 +147,15 @@
* @return the DOCTYPE that should be written to the XML file
*/
public String getDocType() {
- return DTDRegistry.SUN_WEBAPP_250_DTD_PUBLIC_ID;
+ return DTDRegistry.SUN_WEBAPP_300_DTD_PUBLIC_ID;
}

/**
* @return the SystemID of the XML file
*/
public String getSystemID() {
- return DTDRegistry.SUN_WEBAPP_250_DTD_SYSTEM_ID;
- }
+ return DTDRegistry.SUN_WEBAPP_300_DTD_SYSTEM_ID;
+ }

/**
* @return NULL for all runtime nodes.
@@ -173,6 +176,7 @@
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_240_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_240_DTD_SYSTEM_ID);
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_241_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_241_DTD_SYSTEM_ID);
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_250_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_250_DTD_SYSTEM_ID);
+ publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_300_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_300_DTD_SYSTEM_ID);
if (!restrictDTDDeclarations()) {
publicIDToDTD.put(DTDRegistry.SUN_WEBAPP_240beta_DTD_PUBLIC_ID, DTDRegistry.SUN_WEBAPP_240beta_DTD_SYSTEM_ID);
}
@@ -296,6 +300,9 @@
} else if (newDescriptor instanceof WebProperty) {
descriptor.getSunDescriptor().addWebProperty(
(WebProperty)newDescriptor);
+ } else if (newDescriptor instanceof Valve) {
+ descriptor.getSunDescriptor().addValve(
+ (Valve)newDescriptor);
}
else super.addDescriptor(descriptor);
}
@@ -501,6 +508,13 @@
props.writeDescriptor(web, RuntimeTagNames.PROPERTY, sunWebApp.getWebProperty());
}

+ // valve*
+ if (sunWebApp.getValve()!=null) {
+ ValveNode valve = new ValveNode();
+ valve.writeDescriptor(web, RuntimeTagNames.VALVE,
+ sunWebApp.getValve());
+ }
+
// message-destination*
RuntimeDescriptorNode.writeMessageDestinationInfo(web, bundleDescriptor);

Modified: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java (original)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/SunWebApp.java 2009-02-13 18:42:18+0000
@@ -62,7 +62,7 @@
public static final String IDEMPOTENT_URL_PATTERN = "IdempotentUrlPattern";
public static final String ERROR_URL = "ErrorUrl";
public static final String HTTPSERVLET_SECURITY_PROVIDER = "HttpServletSecurityProvider";
-
+ public static final String VALVE = "Valve";

public SunWebApp()
{
@@ -424,4 +424,40 @@
}
return ret.booleanValue();
}
+
+ // This attribute is a valve to be added at the specified index
+ public void setValve(int index, Valve value) {
+ this.setValue(VALVE, index, value);
+ }
+
+ // The return value is the valve at the specified index
+ public Valve getValve(int index) {
+ return (Valve)this.getValue(VALVE, index);
+ }
+
+ // This attribute is an array, possibly empty
+ public void setValve(Valve[] value) {
+ this.setValue(VALVE, value);
+ }
+
+ // This return value is an array, possibly empty
+ public Valve[] getValve() {
+ return (Valve[])this.getValues(VALVE);
+ }
+
+ // Return the number of valves
+ public int sizeValve() {
+ return this.size(VALVE);
+ }
+
+ // Add a new element returning its index in the list
+ public int addValve(Valve value) {
+ return this.addValue(VALVE, value);
+ }
+
+ // Remove an element using its reference
+ public int removeValve(Valve value) {
+ return this.removeValue(VALVE, value);
+ }
+
}

Added: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/Valve.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- (empty file)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/runtime/web/Valve.java 2009-02-13 18:42:18+0000
@@ -0,0 +1,44 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.enterprise.deployment.runtime.web;
+
+public class Valve extends WebPropertyContainer {
+
+ static public final String CLASS_NAME = "ClassName";
+
+}
+

Modified: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java (original)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java 2009-02-13 18:42:18+0000
@@ -223,6 +223,10 @@
public static final String SUN_WEBAPP_250_DTD_SYSTEM_ID =
"http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd";

+ public static final String SUN_WEBAPP_300_DTD_PUBLIC_ID =
+ "-//Sun Microsystems, Inc.//DTD GlassFish v3 Servlet 3.0//EN";
+ public static final String SUN_WEBAPP_300_DTD_SYSTEM_ID =
+ "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd";

/**
* Application Client Container: Sun ONE App Server specific dtd info.

Modified: trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java (original)
+++ trunk/v3/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java 2009-02-13 18:42:18+0000
@@ -286,6 +286,8 @@
public static final String JAVA_METHOD = "java-method";
public final static String METHOD_PARAMS = "method-params";
public final static String METHOD_PARAM = "method-param";
+
+ public final static String VALVE = "valve";

// Java Web Start-support related
public final static String JAVA_WEB_START_ACCESS = "java-web-start-access";

Modified: trunk/v3/deployment/dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd
Url: https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/...
==============================================================================
--- trunk/v3/deployment/dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd (original)
+++ trunk/v3/deployment/dtds/src/main/resources/glassfish/lib/dtds/sun-web-app_3_0-0.dtd 2009-02-13 18:42:18+0000
@@ -17,7 +17,7 @@
ejb-ref*, resource-ref*, resource-env-ref*, service-ref*,
message-destination-ref*, cache?, class-loader?,
jsp-config?, locale-charset-info?, parameter-encoding?,
- property*, message-destination*, webservice-description*)>
+ property*, valve*, message-destination*, webservice-description*)>
httpservlet-security-provider CDATA #IMPLIED>

@@ -321,6 +321,9 @@
-->

+
+ + class-name CDATA #REQUIRED>