commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1293698 - in /commons/proper/digester/trunk: ./ annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/ core/src/main/java/org/apache/commons/digester3/ core/src/test/java/org/apache/commons/digester3/ core/...
Date Sat, 25 Feb 2012 21:48:02 GMT
Author: simonetripodi
Date: Sat Feb 25 21:48:02 2012
New Revision: 1293698

URL: http://svn.apache.org/viewvc?rev=1293698&view=rev
Log:
[DIGESTER-162] ObjectCreateRule doesn't allow create objects wich type is specified in attributeName
only

Added:
    commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
  (with props)
    commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
  (with props)
Modified:
    commons/proper/digester/trunk/RELEASE-NOTES.txt
    commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/DigesterAnnotationsProcessor.java
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
    commons/proper/digester/trunk/dist/pom.xml
    commons/proper/digester/trunk/src/changes/changes.xml

Modified: commons/proper/digester/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/RELEASE-NOTES.txt?rev=1293698&r1=1293697&r2=1293698&view=diff
==============================================================================
--- commons/proper/digester/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/digester/trunk/RELEASE-NOTES.txt Sat Feb 25 21:48:02 2012
@@ -54,6 +54,7 @@ BUGS FIXED SINCE PREVIOUS RELEASE
 ===========================
 
  * [DIGESTER-161] Document thread-safety in javadoc of Rule class.
+ * [DIGESTER-162] ObjectCreateRule doesn't allow create objects wich type is specified in
attributeName only
 
 IMPROVEMENTS OVER PREVIOUS RELEASE
 ===================================

Modified: commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/DigesterAnnotationsProcessor.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/DigesterAnnotationsProcessor.java?rev=1293698&r1=1293697&r2=1293698&view=diff
==============================================================================
--- commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/DigesterAnnotationsProcessor.java
(original)
+++ commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/DigesterAnnotationsProcessor.java
Sat Feb 25 21:48:02 2012
@@ -19,13 +19,19 @@ package org.apache.commons.digester3.ann
  * under the License.
  */
 
+import static java.lang.String.format;
+
+import static javax.tools.Diagnostic.Kind.*;
+
 import static java.util.Arrays.asList;
 
 import java.util.HashSet;
 import java.util.Set;
 
 import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
 import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 
 import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
@@ -72,7 +78,21 @@ public class DigesterAnnotationsProcesso
     @Override
     public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment
environment )
     {
-        return false;
+        // processingEnv is a predefined member in AbstractProcessor class
+        // Messager allows the processor to output messages to the environment
+        Messager messager = processingEnv.getMessager();
+
+        // Loop through the annotations that we are going to process
+        for (TypeElement annotation: annotations) {
+            // Get the members
+            for ( Element element : environment.getElementsAnnotatedWith( annotation ) )
+            {
+                System.out.println( format( "Processing @%s %s", annotation, element ) );
+                messager.printMessage( OTHER, format( "Processing @%s %s", annotation, element
) );
+            }
+        }
+
+        return true;
     }
 
 }

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java?rev=1293698&r1=1293697&r2=1293698&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
Sat Feb 25 21:48:02 2012
@@ -229,7 +229,7 @@ public class ObjectCreateRule
      */
     public ObjectCreateRule( String attributeName, Class<?> clazz )
     {
-        this( clazz.getName(), attributeName );
+        this( clazz != null ? clazz.getName() : null, attributeName );
         this.clazz = clazz;
     }
 

Added: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java?rev=1293698&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
(added)
+++ commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
Sat Feb 25 21:48:02 2012
@@ -0,0 +1,53 @@
+package org.apache.commons.digester3;
+
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.assertTrue;
+
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.binder.AbstractRulesModule;
+import org.junit.Test;
+
+public final class Digester162TestCase
+{
+
+    @Test
+    public void allowCreateObjectsWichTypesAreSpecifiedInAttributeNameOnly()
+        throws Exception
+    {
+        Digester digester = newLoader( new AbstractRulesModule()
+        {
+
+            @Override
+            protected void configure()
+            {
+                forPattern( "toplevel" ).createObject().ofTypeSpecifiedByAttribute( "type"
);
+            }
+
+        })
+        .newDigester();
+
+        Object object = digester.parse( getClass().getResource( "digester-162.xml" ) );
+
+        assertTrue( BetaBean.class.isInstance( object ) );
+    }
+
+}

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/Digester162TestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml?rev=1293698&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
(added)
+++ commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
Sat Feb 25 21:48:02 2012
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<toplevel type="org.apache.commons.digester3.BetaBean" />

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/digester-162.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: commons/proper/digester/trunk/dist/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/dist/pom.xml?rev=1293698&r1=1293697&r2=1293698&view=diff
==============================================================================
--- commons/proper/digester/trunk/dist/pom.xml (original)
+++ commons/proper/digester/trunk/dist/pom.xml Sat Feb 25 21:48:02 2012
@@ -84,4 +84,13 @@
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>rc</id>
+      <build>
+        
+      </build>
+    </profile>
+  </profiles>
+
 </project>

Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1293698&r1=1293697&r2=1293698&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Sat Feb 25 21:48:02 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="3.3" date="201?-??-??" description="Maintenance release.">
+    <action dev="simonetripodi" type="fix" issue="DIGESTER-162">
+      ObjectCreateRule doesn't allow create objects wich type is specified in attributeName
only
+    </action>
     <action dev="simonetripodi" type="fix" issue="DIGESTER-161" due-to="Eduard Papa">
       Document thread-safety in javadoc of Rule class
     </action>



Mime
View raw message