Applies standard layout
git-svn-id: https://svn.apache.org/repos/asf/struts/maven/trunk@1648168 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/struts-annotations/pom.xml b/struts-annotations/pom.xml
deleted file mode 100644
index 07327b0..0000000
--- a/struts-annotations/pom.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-master</artifactId>
- <version>4</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-annotations</artifactId>
- <version>1.0.6-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Struts Annotations</name>
- <url>http://struts.apache.org</url>
- <description>
- struts-annotations adds apt generation support for struts based annotated projetcs,
- such as TLD and documentation generation from annotated component classes as used in struts2
- </description>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/struts/maven/trunk/struts-annotations</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/maven/trunk/struts-annotations</developerConnection>
- <url>http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations</url>
- </scm>
-
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <tagBase>https://svn.apache.org/repos/asf/struts/maven/tags</tagBase>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>default-tools.jar</id>
- <activation>
- <property>
- <name>java.vendor</name>
- <value>Sun Microsystems Inc.</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.5.0</version>
- <scope>system</scope>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>release</id>
- <activation>
- <property>
- <name>release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-javadoc</id>
- <goals><goal>jar</goal></goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-source</id>
- <goals><goal>jar</goal></goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <distributionManagement>
- <repository>
- <id>struts-staging</id>
- <name>Apache Struts Staging Repository</name>
- <url>scp://people.apache.org/www/people.apache.org/builds/struts/struts-annotations-${pom.version}/m2-staging-repository</url>
- </repository>
- <site>
- <id>apache-site</id>
- <url>scp://people.apache.org/www/struts.apache.org/struts-annotations/</url>
- </site>
- </distributionManagement>
-
- <dependencies>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.11</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
deleted file mode 100644
index 663d6ed..0000000
--- a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $Id: $
- *
- * 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.struts.annotations.taglib.apt;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessors;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class TLDAnnotationProcessorFactory implements
- AnnotationProcessorFactory {
-
- /**
- * Returns a TLD annotation processor.
- *
- * @return An annotation processor for note annotations if requested,
- * otherwise, returns the NO_OP annotation processor.
- */
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> declarations,
- AnnotationProcessorEnvironment env) {
- AnnotationProcessor result;
- if (declarations.isEmpty()) {
- result = AnnotationProcessors.NO_OP;
- } else {
- result = new TagAnnotationProcessor(env);
- }
- return result;
- }
-
- /**
- * This factory builds a processor for Tag and TagAttribute
- *
- * @return a collection containing StutsTag and StrutsTagAttribute
- */
- public Collection<String> supportedAnnotationTypes() {
- return Arrays.asList(TagAnnotationProcessor.TAG,
- TagAnnotationProcessor.TAG_ATTRIBUTE,
- TagAnnotationProcessor.TAG_SKIP_HIERARCHY);
- }
-
- /**
- * Options used to generate the TLD
- *
- * @return an empty list.
- */
- public Collection<String> supportedOptions() {
- return Arrays.asList("-AoutFile", "-AtlibVersion", "-AjspVersion",
- "-AshortName", "-Auri", "-Adescription", "-AdisplayName",
- "-outTemplatesDir");
- }
-}
diff --git a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
deleted file mode 100644
index 175bd46..0000000
--- a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * $Id: $
- *
- * 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.struts.annotations.taglib.apt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Tag {
- private String name;
- private String tldBodyContent;
- private String tldTagClass;
- private String description;
- private boolean allowDynamicAttributes;
- private boolean include = true;
- private String declaredType;
- private Map<String, TagAttribute> attributes = new TreeMap<String, TagAttribute>();
- private List<String> skipAttributes = new ArrayList<String>();
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getTldBodyContent() {
- return tldBodyContent;
- }
-
- public void setTldBodyContent(String tldBodyContent) {
- this.tldBodyContent = tldBodyContent;
- }
-
- public String getTldTagClass() {
- return tldTagClass;
- }
-
- public void setTldTagClass(String tldTagClass) {
- this.tldTagClass = tldTagClass;
- }
-
- public void addTagAttribute(TagAttribute attribute) {
- if (!attributes.containsKey(attribute.getName()))
- attributes.put(attribute.getName(), attribute);
- }
-
- public Collection<TagAttribute> getAttributes() {
- return attributes.values();
- }
-
- public boolean isInclude() {
- return include;
- }
-
- public void setInclude(boolean include) {
- this.include = include;
- }
-
- public boolean isAllowDynamicAttributes() {
- return allowDynamicAttributes;
- }
-
- public void setAllowDynamicAttributes(boolean allowDynamicAttributes) {
- this.allowDynamicAttributes = allowDynamicAttributes;
- }
-
- public String getDeclaredType() {
- return declaredType;
- }
-
- public void setDeclaredType(String declaredType) {
- this.declaredType = declaredType;
- }
-
- public List<String> getSkipAttributes() {
- return skipAttributes;
- }
-
- public void addSkipAttribute(String name) {
- this.skipAttributes.add(name);
- }
-}
diff --git a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
deleted file mode 100644
index d3a1bbb..0000000
--- a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * $Id: $
- *
- * 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.struts.annotations.taglib.apt;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStreamWriter;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.TreeMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-import freemarker.template.Configuration;
-import freemarker.template.DefaultObjectWrapper;
-import freemarker.template.Template;
-
-public class TagAnnotationProcessor implements AnnotationProcessor {
- public static final String TAG = "org.apache.struts2.views.annotations.StrutsTag";
- public static final String TAG_ATTRIBUTE = "org.apache.struts2.views.annotations.StrutsTagAttribute";
- public static final String TAG_SKIP_HIERARCHY = "org.apache.struts2.views.annotations.StrutsTagSkipInheritance";
-
- private AnnotationProcessorEnvironment environment;
- private AnnotationTypeDeclaration tagDeclaration;
- private AnnotationTypeDeclaration tagAttributeDeclaration;
- private AnnotationTypeDeclaration skipDeclaration;
- private Map<String, Tag> tags = new TreeMap<String, Tag>();
-
- public TagAnnotationProcessor(AnnotationProcessorEnvironment env) {
- environment = env;
- tagDeclaration = (AnnotationTypeDeclaration) environment
- .getTypeDeclaration(TAG);
- tagAttributeDeclaration = (AnnotationTypeDeclaration) environment
- .getTypeDeclaration(TAG_ATTRIBUTE);
- skipDeclaration = (AnnotationTypeDeclaration) environment
- .getTypeDeclaration(TAG_SKIP_HIERARCHY);
- }
-
- public void process() {
- // make sure all paramters were set
- checkOptions();
-
- // tags
- Collection<Declaration> tagDeclarations = environment
- .getDeclarationsAnnotatedWith(tagDeclaration);
- Collection<Declaration> attributesDeclarations = environment
- .getDeclarationsAnnotatedWith(tagAttributeDeclaration);
- Collection<Declaration> skipDeclarations = environment
- .getDeclarationsAnnotatedWith(skipDeclaration);
-
- // find Tags
- for (Declaration declaration : tagDeclarations) {
- // type
- TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
- String typeName = typeDeclaration.getQualifiedName();
- Map<String, Object> values = getValues(typeDeclaration,
- tagDeclaration);
- // create Tag and apply values found
- Tag tag = new Tag();
- tag.setDescription((String) values.get("description"));
- tag.setName((String) values.get("name"));
- tag.setTldBodyContent((String) values.get("tldBodyContent"));
- tag.setTldTagClass((String) values.get("tldTagClass"));
- tag.setDeclaredType(typeName);
- tag.setAllowDynamicAttributes((Boolean) values.get("allowDynamicAttributes"));
- // add to map
- tags.put(typeName, tag);
- }
-
- //find attributes to be skipped
- for (Declaration declaration : skipDeclarations) {
- //types will be ignored when hierarchy is scanned
- if (declaration instanceof MethodDeclaration) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
- String typeName = methodDeclaration.getDeclaringType().getQualifiedName();
- String methodName = methodDeclaration.getSimpleName();
- String name = String.valueOf(Character.toLowerCase(methodName
- .charAt(3)))
- + methodName.substring(4);
- Tag tag = tags.get(typeName);
- if(tag != null) {
- //if it is on an abstract class, there is not tag for it at this point
- tags.get(typeName).addSkipAttribute(name);
- }
- }
- }
-
- // find Tags Attributes
- for (Declaration declaration : attributesDeclarations) {
- // type
- MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
- String typeName = methodDeclaration.getDeclaringType()
- .getQualifiedName();
- Map<String, Object> values = getValues(methodDeclaration,
- tagAttributeDeclaration);
- // create Attribute and apply values found
- TagAttribute attribute = new TagAttribute();
- String name = (String) values.get("name");
- if (name == null || name.length() == 0) {
- // get name from method
- String methodName = methodDeclaration.getSimpleName();
- name = String.valueOf(Character.toLowerCase(methodName
- .charAt(3)))
- + methodName.substring(4);
- }
- values.put("name", name);
- populateTagAttributes(attribute, values);
- // add to map
- Tag parentTag = tags.get(typeName);
- if (parentTag != null)
- tags.get(typeName).addTagAttribute(attribute);
- else {
- // an abstract or base class
- parentTag = new Tag();
- parentTag.setDeclaredType(typeName);
- parentTag.setInclude(false);
- parentTag.addTagAttribute(attribute);
- tags.put(typeName, parentTag);
- }
- }
-
- // we can't process the hierarchy on the first pass because
- // apt does not garantees that the base classes will be processed
- // before their subclasses
- for (Map.Entry<String, Tag> entry : tags.entrySet()) {
- processHierarchy(entry.getValue());
- }
-
- // save
- saveAsXml();
- saveTemplates();
- }
-
- private void populateTagAttributes(TagAttribute attribute, Map<String, Object> values) {
- attribute.setRequired((Boolean) values.get("required"));
- attribute.setRtexprvalue((Boolean) values.get("rtexprvalue"));
- attribute.setDefaultValue((String) values.get("defaultValue"));
- attribute.setType((String) values.get("type"));
- attribute.setDescription((String) values.get("description"));
- attribute.setName((String) values.get("name"));
- }
-
- private void processHierarchy(Tag tag) {
- try {
- Class clazz = Class.forName(tag.getDeclaredType());
- List<String> skipAttributes = tag.getSkipAttributes();
- //skip hierarchy processing if the class is marked with the skip annotation
- while(getAnnotation(TAG_SKIP_HIERARCHY, clazz.getAnnotations()) == null
- && ((clazz = clazz.getSuperclass()) != null)) {
- Tag parentTag = tags.get(clazz.getName());
- // copy parent annotations to this tag
- if(parentTag != null) {
- for(TagAttribute attribute : parentTag.getAttributes()) {
- if(!skipAttributes.contains(attribute.getName()))
- tag.addTagAttribute(attribute);
- }
- } else {
- // Maybe the parent class is already compiled
- addTagAttributesFromParent(tag, clazz);
- }
- }
- } catch(Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private void addTagAttributesFromParent(Tag tag, Class clazz) throws ClassNotFoundException {
- try {
- BeanInfo info = Introspector.getBeanInfo(clazz);
- PropertyDescriptor[] props = info.getPropertyDescriptors();
- List<String> skipAttributes = tag.getSkipAttributes();
-
- //iterate over class fields
- for(int i = 0; i < props.length; ++i) {
- PropertyDescriptor prop = props[i];
- Method writeMethod = prop.getWriteMethod();
-
- //make sure it is public
- if(writeMethod != null && Modifier.isPublic(writeMethod.getModifiers())) {
- //can't use the genertic getAnnotation 'cause the class it not on this jar
- Annotation annotation = getAnnotation(TAG_ATTRIBUTE, writeMethod.getAnnotations());
- if(annotation != null && !skipAttributes.contains(prop.getName())) {
- Map<String, Object> values = getValues(annotation);
- //create tag
- TagAttribute attribute = new TagAttribute();
- values.put("name", prop.getName());
- populateTagAttributes(attribute, values);
- tag.addTagAttribute(attribute);
- }
- }
-
- }
- } catch(Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private Annotation getAnnotation(String typeName, Annotation[] annotations) {
- for(int i = 0; i < annotations.length; i++) {
- if(annotations[i].annotationType().getName().equals(typeName))
- return annotations[i];
- }
- return null;
- }
-
- private void checkOptions() {
- if (getOption("tlibVersion") == null)
- throw new IllegalArgumentException("'tlibVersion' is missing");
- if (getOption("jspVersion") == null)
- throw new IllegalArgumentException("'jspVersion' is missing");
- if (getOption("shortName") == null)
- throw new IllegalArgumentException("'shortName' is missing");
- if (getOption("description") == null)
- throw new IllegalArgumentException("'description' is missing");
- if (getOption("displayName") == null)
- throw new IllegalArgumentException("'displayName' is missing");
- if (getOption("uri") == null)
- throw new IllegalArgumentException("'uri' is missing");
- if (getOption("outTemplatesDir") == null)
- throw new IllegalArgumentException("'outTemplatesDir' is missing");
- if (getOption("outFile") == null)
- throw new IllegalArgumentException("'outFile' is missing");
- }
-
- private void saveTemplates() {
- // freemarker configuration
- Configuration config = new Configuration();
- config.setClassForTemplateLoading(getClass(), "");
- config.setObjectWrapper(new DefaultObjectWrapper());
-
- try {
- // load template
- Template template = config.getTemplate("tag.ftl");
- String rootDir = (new File(getOption("outTemplatesDir")))
- .getAbsolutePath();
- for (Tag tag : tags.values()) {
- if (tag.isInclude()) {
- // model
- HashMap<String, Tag> root = new HashMap<String, Tag>();
- root.put("tag", tag);
-
- // save file
- BufferedWriter writer = new BufferedWriter(new FileWriter(
- new File(rootDir, tag.getName() + ".html")));
- try {
- template.process(root, writer);
- } finally {
- writer.close();
- }
- }
- }
- } catch (Exception e) {
- // oops we cannot throw checked exceptions
- throw new RuntimeException(e);
- }
- }
-
- private void saveAsXml() {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
-
- try {
- // create xml document
- builder = factory.newDocumentBuilder();
- Document document = builder.newDocument();
- document.setXmlVersion("1.0");
-
- // taglib
- Element tagLib = document.createElement("taglib");
- tagLib.setAttribute("xmlns", "http://java.sun.com/xml/ns/j2ee");
- tagLib.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- tagLib.setAttribute("xsi:schemaLocation", "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd");
- tagLib.setAttribute("version", getOption("jspVersion"));
- document.appendChild(tagLib);
- // tag lib attributes
- appendTextNode(document, tagLib, "description",
- getOption("description"), true);
- appendTextNode(document, tagLib, "display-name",
- getOption("displayName"), false);
- appendTextNode(document, tagLib, "tlib-version",
- getOption("tlibVersion"), false);
- appendTextNode(document, tagLib, "short-name",
- getOption("shortName"), false);
- appendTextNode(document, tagLib, "uri", getOption("uri"), false);
-
- // create tags
- for (Map.Entry<String, Tag> entry : tags.entrySet()) {
- Tag tag = entry.getValue();
- if (tag.isInclude())
- createElement(document, tagLib, tag);
- }
-
- // save to file
- TransformerFactory tf = TransformerFactory.newInstance();
- tf.setAttribute("indent-number", 2);
- Transformer transformer = tf.newTransformer();
- // if tiger would just format it :(
- // formatting bug in tiger
- // (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446)
-
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-
- //create output directory if it does not exists
- File outputFile = new File(getOption("outFile"));
- File parentDir = outputFile.getParentFile();
- if (!parentDir.exists())
- parentDir.mkdirs();
-
- Source source = new DOMSource(document);
- Result result = new StreamResult(new OutputStreamWriter(
- new FileOutputStream(outputFile)));
- transformer.transform(source, result);
- } catch (Exception e) {
- // oops we cannot throw checked exceptions
- throw new RuntimeException(e);
- }
- }
-
- private String getOption(String name) {
- // there is a bug in the 1.5 apt implementation:
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6258929
- // this is a hack-around
- if (environment.getOptions().containsKey(name))
- return environment.getOptions().get(name);
-
- for (Map.Entry<String, String> entry : environment.getOptions()
- .entrySet()) {
- String key = entry.getKey();
- String[] splitted = key.split("=");
- if (splitted[0].equals("-A" + name))
- return splitted[1];
- }
- return null;
- }
-
- private void createElement(Document doc, Element tagLibElement, Tag tag) {
- Element tagElement = doc.createElement("tag");
- tagLibElement.appendChild(tagElement);
- appendTextNode(doc, tagElement, "description", tag.getDescription(),
- true);
- appendTextNode(doc, tagElement, "name", tag.getName(), false);
- appendTextNode(doc, tagElement, "tag-class", tag.getTldTagClass(),
- false);
- appendTextNode(doc, tagElement, "body-content",
- tag.getTldBodyContent(), false);
-
- // save attributes
- for (TagAttribute attribute : tag.getAttributes()) {
- createElement(doc, tagElement, attribute);
- }
-
- appendTextNode(doc, tagElement, "dynamic-attributes", String.valueOf(tag.isAllowDynamicAttributes()), false);
- }
-
- private void createElement(Document doc, Element tagElement,
- TagAttribute attribute) {
- Element attributeElement = doc.createElement("attribute");
- tagElement.appendChild(attributeElement);
- appendTextNode(doc, attributeElement, "description", attribute
- .getDescription(), true);
- appendTextNode(doc, attributeElement, "name", attribute.getName(),
- false);
- appendTextNode(doc, attributeElement, "required", String
- .valueOf(attribute.isRequired()), false);
- appendTextNode(doc, attributeElement, "rtexprvalue", String
- .valueOf(attribute.isRtexprvalue()), false);
- }
-
- private void appendTextNode(Document doc, Element element, String name,
- String text, boolean cdata) {
- Text textNode = cdata ? doc.createCDATASection(text) : doc
- .createTextNode(text);
- Element newElement = doc.createElement(name);
- newElement.appendChild(textNode);
- element.appendChild(newElement);
- }
-
- /**
- * Get values of annotation
- *
- * @param declaration The annotation declaration
- * @param type
- * The type of the annotation
- * @return name->value map of annotation values
- */
- private Map<String, Object> getValues(Declaration declaration,
- AnnotationTypeDeclaration type) {
- Map<String, Object> values = new TreeMap<String, Object>();
- Collection<AnnotationMirror> annotations = declaration
- .getAnnotationMirrors();
- // iterate over the mirrors.
-
- for (AnnotationMirror mirror : annotations) {
- // if the mirror in this iteration is for our note declaration...
- if (mirror.getAnnotationType().getDeclaration().equals(type)) {
- for (AnnotationTypeElementDeclaration annotationType : mirror
- .getElementValues().keySet()) {
- Object value = mirror.getElementValues()
- .get(annotationType).getValue();
- Object defaultValue = annotationType.getDefaultValue();
- values.put(annotationType.getSimpleName(),
- value != null ? value : defaultValue);
- }
- }
- }
-
- // find default values...painful
- for (AnnotationTypeElementDeclaration annotationType : type
- .getMethods()) {
- AnnotationValue value = annotationType.getDefaultValue();
- if (value != null) {
- String name = annotationType.getSimpleName();
- if (!values.containsKey(name))
- values.put(name, value.getValue());
- }
- }
-
- return values;
- }
-
- /**
- * Get values of annotation
- *
- * @param annotation The annotation
- * @return name->value map of annotation values
- * @throws IntrospectionException
- * @throws InvocationTargetException
- * @throws IllegalAccessException
- * @throws IllegalArgumentException
- */
- private Map<String, Object> getValues(Annotation annotation) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- Map<String, Object> values = new TreeMap<String, Object>();
- //if the tag classes were on this project we could just cast to the right type
- //but they are needed on core
- Class annotationType = annotation.annotationType();
-
- Method[] methods = annotationType.getMethods();
- //iterate over class fields
- for(int i = 0; i < methods.length; ++i) {
- Method method = methods[i];
- if(method != null && method.getParameterTypes().length == 0) {
- Object value = method.invoke(annotation, new Object[0]);
- values.put(method.getName(), value);
- }
- }
-
- return values;
- }
-}
diff --git a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java
deleted file mode 100644
index 5bbed59..0000000
--- a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $Id: $
- *
- * 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.struts.annotations.taglib.apt;
-
-/**
- * Used to hold tag attribute information for TLD generation
- *
- */
-public class TagAttribute {
- private String name;
- private boolean required;
- private boolean rtexprvalue;
- private String description;
- private String defaultValue;
- private String type;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- 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 boolean isRtexprvalue() {
- return rtexprvalue;
- }
-
- public void setRtexprvalue(boolean rtexprvalue) {
- this.rtexprvalue = rtexprvalue;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-}
diff --git a/struts-annotations/src/main/resources/LICENSE.txt b/struts-annotations/src/main/resources/LICENSE.txt
deleted file mode 100644
index dd5b3a5..0000000
--- a/struts-annotations/src/main/resources/LICENSE.txt
+++ /dev/null
@@ -1,174 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
diff --git a/struts-annotations/src/main/resources/NOTICE.txt b/struts-annotations/src/main/resources/NOTICE.txt
deleted file mode 100644
index cd13ec4..0000000
--- a/struts-annotations/src/main/resources/NOTICE.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Struts
-Copyright 2000-2007 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
diff --git a/struts-annotations/src/main/resources/org/apache/struts/annotations/taglib/apt/tag.ftl b/struts-annotations/src/main/resources/org/apache/struts/annotations/taglib/apt/tag.ftl
deleted file mode 100644
index d7516fe..0000000
--- a/struts-annotations/src/main/resources/org/apache/struts/annotations/taglib/apt/tag.ftl
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
-This file is generated during the build by processing Component class annotations.
-Please do not edit it directly.
--->
-<html>
- <head>
- <title>${tag.name}</title>
- </head>
-
- <body>
- <h1>Tag Name: ${tag.name}</h1>
- <h2>Description</h2>
- <p>
- <!-- START SNIPPET: tagdescription -->
- ${tag.description}
- <!-- END SNIPPET: tagdescription -->
- </p>
-
- <h2>Attributes</h2>
- <!-- START SNIPPET: tagattributes -->
- <table width="100%">
- <tr>
- <td colspan="6"><h4>Dynamic Attributes Allowed:</h4> ${tag.allowDynamicAttributes?string}</td>
- </tr>
- <tr>
- <td colspan="6"> </td>
- </tr>
- <tr>
- <th align="left" valign="top"><h4>Name</h4></th>
- <th align="left" valign="top"><h4>Required</h4></th>
- <th align="left" valign="top"><h4>Default</h4></th>
- <th align="left" valign="top"><h4>Evaluated</h4></th>
- <th align="left" valign="top"><h4>Type</h4></th>
- <th align="left" valign="top"><h4>Description</h4></th>
- </tr>
- <#list tag.attributes as att>
- <tr>
- <td align="left" valign="top">${att.name}</td>
- <td align="left" valign="top"><#if att.required><strong>true</strong><#else>false</#if></td>
- <td align="left" valign="top">${att.defaultValue}</td>
- <td align="left" valign="top">${att.rtexprvalue?string}</td>
- <td align="left" valign="top">${att.type}</td>
- <td align="left" valign="top">${att.description}</td>
- </tr>
- </#list>
- </table>
- <!-- END SNIPPET: tagattributes -->
- </body>
-</html>
-