You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by jb...@apache.org on 2013/08/09 08:21:56 UTC

svn commit: r1512148 - in /tomcat/trunk: java/org/apache/tomcat/util/descriptor/tld/ test/org/apache/tomcat/util/descriptor/tld/

Author: jboynes
Date: Fri Aug  9 06:21:56 2013
New Revision: 1512148

URL: http://svn.apache.org/r1512148
Log:
Start adding model for loading complete TLDs using Digester.
This will unify Jasper's model, which is mostly complete but uses a separate DOM model, 
and Catalina's, which is Digester based but only handles listener entries.

Basic top-level entries are handled but not child elements for tags etc

Added:
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java   (with props)
    tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/
    tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java   (with props)

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import java.util.List;
+
+/**
+ *
+ */
+public class Tag {
+    private String name;
+    private String tagClass;
+    private String teiClass;
+    private String bodyContent;
+    private String displayName;
+    private String smallIcon;
+    private String largeIcon;
+    private String info;
+    private boolean dynamicAttributes;
+    private List<Variable> variables;
+    private List<Attribute> attributes;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTagClass() {
+        return tagClass;
+    }
+
+    public void setTagClass(String tagClass) {
+        this.tagClass = tagClass;
+    }
+
+    public String getTeiClass() {
+        return teiClass;
+    }
+
+    public void setTeiClass(String teiClass) {
+        this.teiClass = teiClass;
+    }
+
+    public String getBodyContent() {
+        return bodyContent;
+    }
+
+    public void setBodyContent(String bodyContent) {
+        this.bodyContent = bodyContent;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getSmallIcon() {
+        return smallIcon;
+    }
+
+    public void setSmallIcon(String smallIcon) {
+        this.smallIcon = smallIcon;
+    }
+
+    public String getLargeIcon() {
+        return largeIcon;
+    }
+
+    public void setLargeIcon(String largeIcon) {
+        this.largeIcon = largeIcon;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    public boolean hasDynamicAttributes() {
+        return dynamicAttributes;
+    }
+
+    public void setDynamicAttributes(boolean dynamicAttributes) {
+        this.dynamicAttributes = dynamicAttributes;
+    }
+
+    public static class Variable {
+        private String nameGiven;
+        private String nameFromAttribute;
+        private String className;
+        private boolean declare;
+        private int scope;
+
+        public String getNameGiven() {
+            return nameGiven;
+        }
+
+        public void setNameGiven(String nameGiven) {
+            this.nameGiven = nameGiven;
+        }
+
+        public String getNameFromAttribute() {
+            return nameFromAttribute;
+        }
+
+        public void setNameFromAttribute(String nameFromAttribute) {
+            this.nameFromAttribute = nameFromAttribute;
+        }
+
+        public String getClassName() {
+            return className;
+        }
+
+        public void setClassName(String className) {
+            this.className = className;
+        }
+
+        public boolean isDeclare() {
+            return declare;
+        }
+
+        public void setDeclare(boolean declare) {
+            this.declare = declare;
+        }
+
+        public int getScope() {
+            return scope;
+        }
+
+        public void setScope(int scope) {
+            this.scope = scope;
+        }
+    }
+
+    public static class Attribute {
+        private String name;
+        private boolean required;
+        private String type;
+        private boolean requestTime;
+        private boolean fragment;
+        private String description;
+        private boolean deferredValue;
+        private boolean deferredMethod;
+        private String expectedTypeName;
+        private String methodSignature;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public boolean isRequired() {
+            return required;
+        }
+
+        public void setRequired(boolean required) {
+            this.required = required;
+        }
+
+        public String getType() {
+            return type;
+        }
+
+        public void setType(String type) {
+            this.type = type;
+        }
+
+        public boolean isRequestTime() {
+            return requestTime;
+        }
+
+        public void setRequestTime(boolean requestTime) {
+            this.requestTime = requestTime;
+        }
+
+        public boolean isFragment() {
+            return fragment;
+        }
+
+        public void setFragment(boolean fragment) {
+            this.fragment = fragment;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public void setDescription(String description) {
+            this.description = description;
+        }
+
+        public boolean isDeferredValue() {
+            return deferredValue;
+        }
+
+        public void setDeferredValue(boolean deferredValue) {
+            this.deferredValue = deferredValue;
+        }
+
+        public boolean isDeferredMethod() {
+            return deferredMethod;
+        }
+
+        public void setDeferredMethod(boolean deferredMethod) {
+            this.deferredMethod = deferredMethod;
+        }
+
+        public String getExpectedTypeName() {
+            return expectedTypeName;
+        }
+
+        public void setExpectedTypeName(String expectedTypeName) {
+            this.expectedTypeName = expectedTypeName;
+        }
+
+        public String getMethodSignature() {
+            return methodSignature;
+        }
+
+        public void setMethodSignature(String methodSignature) {
+            this.methodSignature = methodSignature;
+        }
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+/**
+ *
+ */
+public class TagFile {
+    private String name;
+    private String path;
+    private String displayName;
+    private String smallIcon;
+    private String largeIcon;
+    private String info;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getSmallIcon() {
+        return smallIcon;
+    }
+
+    public void setSmallIcon(String smallIcon) {
+        this.smallIcon = smallIcon;
+    }
+
+    public String getLargeIcon() {
+        return largeIcon;
+    }
+
+    public void setLargeIcon(String largeIcon) {
+        this.largeIcon = largeIcon;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TagFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.jsp.tagext.FunctionInfo;
+
+/**
+ * Common representation of a Tag Library Descriptor (TLD) XML file.
+ * <p/>
+ * This stores the raw result of parsing an TLD XML file, flattening different
+ * version of the descriptors to a common format. This is different to a
+ * TagLibraryInfo instance that would be passed to a tag validator in that it
+ * does not contain the uri and prefix values used by a JSP to reference this
+ * tag library.
+ */
+public class TaglibXml {
+    private String tlibVersion;
+    private String jspVersion;
+    private String shortName;
+    private String uri;
+    private String info;
+    private Validator validator;
+    private List<Tag> tags;
+    private List<String> listeners;
+    private List<FunctionInfo> functions;
+
+    public String getTlibVersion() {
+        return tlibVersion;
+    }
+
+    public void setTlibVersion(String tlibVersion) {
+        this.tlibVersion = tlibVersion;
+    }
+
+    public String getJspVersion() {
+        return jspVersion;
+    }
+
+    public void setJspVersion(String jspVersion) {
+        this.jspVersion = jspVersion;
+    }
+
+    public String getShortName() {
+        return shortName;
+    }
+
+    public void setShortName(String shortName) {
+        this.shortName = shortName;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    public Validator getValidator() {
+        return validator;
+    }
+
+    public void setValidator(Validator validator) {
+        this.validator = validator;
+    }
+
+    public void addTag(Tag tag) {
+        if (tags == null) {
+            tags = new ArrayList<>();
+        }
+        tags.add(tag);
+    }
+
+    public List<Tag> getTags() {
+        return tags;
+    }
+
+    public void addListener(String listener) {
+        if (listeners == null) {
+            listeners = new ArrayList<>();
+        }
+        listeners.add(listener);
+    }
+
+    public List<String> getListeners() {
+        return listeners;
+    }
+
+    public void addFunction(FunctionInfo functionInfo) {
+        if (functions == null) {
+            functions = new ArrayList<>();
+        }
+        functions.add(functionInfo);
+    }
+
+    public List<FunctionInfo> getFunctions() {
+        return functions;
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TaglibXml.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
+import org.apache.tomcat.util.digester.Digester;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Parses a Tag Library Descriptor.
+ */
+public class TldParser {
+    private static final Log LOG = LogFactory.getLog(TldParser.class);
+
+    private final Digester digester;
+
+    public TldParser(boolean namespaceAware, boolean validation) {
+        TldRuleSet ruleSet = new TldRuleSet();
+        digester = DigesterFactory.newDigester(validation, namespaceAware, ruleSet);
+    }
+
+    public TaglibXml parse(URL url) throws IOException, SAXException {
+        InputSource source = new InputSource(url.toExternalForm());
+        source.setByteStream(url.openStream());
+        return parse(source);
+    }
+
+    public TaglibXml parse(InputSource source) throws IOException, SAXException {
+        try {
+            XmlErrorHandler handler = new XmlErrorHandler();
+            digester.setErrorHandler(handler);
+
+            TaglibXml taglibXml = new TaglibXml();
+            digester.push(taglibXml);
+            digester.parse(source);
+            if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) {
+                handler.logFindings(LOG, source.getSystemId());
+            }
+            return taglibXml;
+        } finally {
+            digester.reset();
+        }
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.digester.Rule;
+import org.apache.tomcat.util.digester.RuleSetBase;
+import org.xml.sax.Attributes;
+
+/**
+ * RulesSet for digesting TLD files.
+ */
+public class TldRuleSet extends RuleSetBase {
+    private static final String PREFIX = "taglib";
+    private static final String TAG_PREFIX = PREFIX + "/tag";
+
+    @Override
+    public void addRuleInstances(Digester digester) {
+
+        digester.addCallMethod(PREFIX + "/tlibversion", "setTlibVersion", 0);
+        digester.addCallMethod(PREFIX + "/tlib-version", "setTlibVersion", 0);
+        digester.addCallMethod(PREFIX + "/jspversion", "setJspVersion", 0);
+        digester.addCallMethod(PREFIX + "/jsp-version", "setJspVersion", 0);
+        digester.addRule(PREFIX, new Rule() {
+            // for TLD 2.0 and later, jsp-version is set by version attribute
+            @Override
+            public void begin(String namespace, String name, Attributes attributes) {
+                TaglibXml taglibXml = (TaglibXml) digester.peek();
+                taglibXml.setJspVersion(attributes.getValue("version"));
+            }
+        });
+        digester.addCallMethod(PREFIX + "/shortname", "setShortName", 0);
+        digester.addCallMethod(PREFIX + "/short-name", "setShortName", 0);
+
+        // common rules
+        digester.addCallMethod(PREFIX + "/uri", "setUri", 0);
+        digester.addCallMethod(PREFIX + "/info", "setInfo", 0);
+        digester.addCallMethod(PREFIX + "/description", "setInfo", 0);
+        digester.addCallMethod(PREFIX + "/listener/listener-class", "addListener", 0);
+
+        // tag
+        digester.addObjectCreate(TAG_PREFIX, Tag.class.getName());
+        digester.addCallMethod(TAG_PREFIX + "/name", "setName", 0);
+        digester.addCallMethod(TAG_PREFIX + "/tagclass", "setTagClass", 0);
+        digester.addCallMethod(TAG_PREFIX + "/tag-class", "setTagClass", 0);
+        digester.addCallMethod(TAG_PREFIX + "/teiclass", "setTeiClass", 0);
+        digester.addCallMethod(TAG_PREFIX + "/tei-class", "setTeiClass", 0);
+        digester.addCallMethod(TAG_PREFIX + "/bodycontent", "setBodyContent", 0);
+        digester.addCallMethod(TAG_PREFIX + "/body-content", "setBodyContent", 0);
+        digester.addSetNext(TAG_PREFIX, "addTag", Tag.class.getName());
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/TldRuleSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Model of a Tag Library Validator from the XML descriptor.
+ */
+public class Validator {
+    private String validationClass;
+    private Map<String, String> initParams;
+
+    public String getValidationClass() {
+        return validationClass;
+    }
+
+    public void setValidationClass(String validationClass) {
+        this.validationClass = validationClass;
+    }
+
+    public void addInitParam(String name, String value) {
+        if (initParams == null) {
+            initParams = new HashMap<>();
+        }
+        initParams.put(name, value);
+    }
+
+    public Map<String, String> getInitParams() {
+        return initParams;
+    }
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Validator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Package containing a Java model of the XML for a Tag Library Descriptor.
+ */
+package org.apache.tomcat.util.descriptor.tld;
\ No newline at end of file

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java?rev=1512148&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java (added)
+++ tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java Fri Aug  9 06:21:56 2013
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.tld;
+
+import java.io.FileInputStream;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.xml.sax.InputSource;
+
+public class TestTldParser {
+    private static final String WEBAPP = "test/webapp-3.1/WEB-INF/";
+    private TldParser parser;
+
+    @Before
+    public void init() {
+        parser = new TldParser(true, true);
+    }
+
+    @Test
+    public void testParseTld21() throws Exception {
+        try (FileInputStream is = new FileInputStream(WEBAPP + "tags21.tld")) {
+            InputSource source = new InputSource(is);
+            TaglibXml xml = parser.parse(source);
+            Assert.assertEquals("1.0", xml.getTlibVersion());
+            Assert.assertEquals("2.1", xml.getJspVersion());
+            Assert.assertEquals("Tags21", xml.getShortName());
+            Assert.assertEquals("http://tomcat.apache.org/tags21", xml.getUri());
+            verifyTags(xml.getTags());
+        }
+    }
+
+    @Test
+    public void testParseTld20() throws Exception {
+        try (FileInputStream is = new FileInputStream(WEBAPP + "tags20.tld")) {
+            InputSource source = new InputSource(is);
+            TaglibXml xml = parser.parse(source);
+            Assert.assertEquals("1.0", xml.getTlibVersion());
+            Assert.assertEquals("2.0", xml.getJspVersion());
+            Assert.assertEquals("Tags20", xml.getShortName());
+            Assert.assertEquals("http://tomcat.apache.org/tags20", xml.getUri());
+            verifyTags(xml.getTags());
+        }
+    }
+
+    @Test
+    public void testParseTld12() throws Exception {
+        try (FileInputStream is = new FileInputStream(WEBAPP + "tags12.tld")) {
+            InputSource source = new InputSource(is);
+            TaglibXml xml = parser.parse(source);
+            Assert.assertEquals("1.0", xml.getTlibVersion());
+            Assert.assertEquals("1.2", xml.getJspVersion());
+            Assert.assertEquals("Tags12", xml.getShortName());
+            Assert.assertEquals("http://tomcat.apache.org/tags12", xml.getUri());
+            verifyTags(xml.getTags());
+        }
+    }
+
+    @Test
+    public void testParseTld11() throws Exception {
+        try (FileInputStream is = new FileInputStream(WEBAPP + "tags11.tld")) {
+            InputSource source = new InputSource(is);
+            TaglibXml xml = parser.parse(source);
+            Assert.assertEquals("1.0", xml.getTlibVersion());
+            Assert.assertEquals("1.1", xml.getJspVersion());
+            Assert.assertEquals("Tags11", xml.getShortName());
+            Assert.assertEquals("http://tomcat.apache.org/tags11", xml.getUri());
+            verifyTags(xml.getTags());
+        }
+    }
+
+    private void verifyTags(List<Tag> tags) {
+        Assert.assertEquals(1, tags.size());
+        Tag tag = tags.get(0);
+        Assert.assertEquals("Echo", tag.getName());
+        Assert.assertEquals("org.apache.jasper.compiler.TestValidator$Echo",
+                tag.getTagClass());
+        Assert.assertEquals("empty", tag.getBodyContent());
+    }
+
+    @Test
+    public void testListener() throws Exception {
+        try (FileInputStream is = new FileInputStream("test/webapp-3.0/WEB-INF/listener.tld")) {
+            InputSource source = new InputSource(is);
+            TaglibXml xml = parser.parse(source);
+            Assert.assertEquals("1.0", xml.getTlibVersion());
+            List<String> listeners = xml.getListeners();
+            Assert.assertEquals(1, listeners.size());
+            Assert.assertEquals("org.apache.catalina.core.TesterTldListener", listeners.get(0));
+        }
+    }
+
+}

Propchange: tomcat/trunk/test/org/apache/tomcat/util/descriptor/tld/TestTldParser.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1512148 - in /tomcat/trunk: java/org/apache/tomcat/util/descriptor/tld/ test/org/apache/tomcat/util/descriptor/tld/

Posted by Jeremy Boynes <jb...@apache.org>.
On Aug 12, 2013, at 8:16 AM, Mark Thomas <ma...@apache.org> wrote:

> On 09/08/2013 07:21, jboynes@apache.org wrote:
>> Author: jboynes
>> Date: Fri Aug  9 06:21:56 2013
>> New Revision: 1512148
>> 
>> URL: http://svn.apache.org/r1512148
>> Log:
>> Start adding model for loading complete TLDs using Digester.
>> This will unify Jasper's model, which is mostly complete but uses a separate DOM model, 
>> and Catalina's, which is Digester based but only handles listener entries.
> 
> <snip/>
> 
>> Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java
>> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java?rev=1512148&view=auto
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java (added)
>> +++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java Fri Aug  9 06:21:56 2013
> 
> <snip/>
> 
>> +    private List<Variable> variables;
>> +    private List<Attribute> attributes;
> 
> These two are still showing as unused but from the commit messages I'd
> expect them to be used.

I'm not quite finished with loading the full descriptors. These were not needed for the listener processing but will be needed for the next step where we use them within Jasper. I needed to pause to consider the memory concurrency issues as whilst the listener code is single threaded, the translation side can be access by multiple threads.

I wanted to checkpoint what I'd been able to finish this weekend rather than sit on it for another week and have a bigger commit.
Thanks
Jeremy


Re: svn commit: r1512148 - in /tomcat/trunk: java/org/apache/tomcat/util/descriptor/tld/ test/org/apache/tomcat/util/descriptor/tld/

Posted by Mark Thomas <ma...@apache.org>.
On 09/08/2013 07:21, jboynes@apache.org wrote:
> Author: jboynes
> Date: Fri Aug  9 06:21:56 2013
> New Revision: 1512148
> 
> URL: http://svn.apache.org/r1512148
> Log:
> Start adding model for loading complete TLDs using Digester.
> This will unify Jasper's model, which is mostly complete but uses a separate DOM model, 
> and Catalina's, which is Digester based but only handles listener entries.

<snip/>

> Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java?rev=1512148&view=auto
> ==============================================================================
> --- tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java (added)
> +++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/tld/Tag.java Fri Aug  9 06:21:56 2013

<snip/>

> +    private List<Variable> variables;
> +    private List<Attribute> attributes;

These two are still showing as unused but from the commit messages I'd
expect them to be used.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org