juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [juneau] branch master updated: Fix bug in AddressBookResource involving @Bean(typeName) on non-bean POJO.
Date Sun, 04 Mar 2018 18:52:53 GMT
This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 0951241  Fix bug in AddressBookResource involving @Bean(typeName) on non-bean POJO.
0951241 is described below

commit 0951241b26f16dfd13eddf9e426bfaf069d9068b
Author: JamesBognar <jamesbognar@apache.org>
AuthorDate: Sun Mar 4 13:52:45 2018 -0500

    Fix bug in AddressBookResource involving @Bean(typeName) on non-bean
    POJO.
---
 .../src/main/java/org/apache/juneau/ClassMeta.java |  10 ++++++++--
 .../org/apache/juneau/html/HtmlParserSession.java  |   4 ++--
 .../apache/juneau/xml/XmlSerializerSession.java    |   2 --
 ...u-examples-rest.AddressBookResource.Demo.05.png | Bin 79890 -> 302265 bytes
 ...u-examples-rest.AddressBookResource.Demo.06.png | Bin 385485 -> 342287 bytes
 juneau-doc/src/main/javadoc/overview.html          |  12 ++++++++++++
 .../rest/addressbook/AddressBookResource.java      |   6 ++++++
 7 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index f5576bb..c905094 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -656,8 +656,14 @@ public final class ClassMeta<T> implements Type {
 				invocationHandler = new BeanProxyInvocationHandler<T>(beanMeta);
 
 			Bean b = c.getAnnotation(Bean.class);
-			if (b != null && b.beanDictionary().length != 0)
-				beanRegistry = new BeanRegistry(beanContext, null, b.beanDictionary());
+			if (b != null) {
+				if (b.beanDictionary().length != 0)
+					beanRegistry = new BeanRegistry(beanContext, null, b.beanDictionary());
+				
+				// This could be a non-bean POJO with a type name.
+				if (dictionaryName == null && ! b.typeName().isEmpty())
+					dictionaryName = b.typeName();
+			}
 		}
 
 		private BeanFilter findBeanFilter() {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
index e4f22d3..23dc130 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
@@ -203,10 +203,10 @@ public final class HtmlParserSession extends XmlParserSession {
 
 			if (cm != null) {
 				sType = eType = cm;
-				typeName = sType.isArray() ? "array" : "object";
+				typeName = sType.isCollectionOrArray() ? "array" : "object";
 			} else if (! "array".equals(typeName)) {
 				// Type name could be a subtype name.
-				typeName = "object";
+				typeName = sType.isCollectionOrArray() ? "array" : "object";
 			}
 
 			if (typeName.equals("object")) {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index 81583ea..516f03c 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -695,8 +695,6 @@ public class XmlSerializerSession extends WriterSerializerSession {
 		c = sort(c);
 
 		String type2 = null;
-		if (sType != eType)
-			type2 = sType.getDictionaryName();
 
 		String eName = type2;
 		Namespace eNs = null;
diff --git a/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.05.png
b/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.05.png
index 6e504ee..9f8e66e 100644
Binary files a/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.05.png
and b/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.05.png
differ
diff --git a/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.06.png
b/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.06.png
index 75eabc8..67a7d32 100644
Binary files a/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.06.png
and b/juneau-doc/src/main/javadoc/doc-files/juneau-examples-rest.AddressBookResource.Demo.06.png
differ
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index 31dddd6..1c1b065 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -14289,6 +14289,12 @@
 			<jc>// Use single quotes.</jc>
 			<ja>@Property</ja>(name=<jsf>SERIALIZER_quoteChar</jsf>, value=<js>"'"</js>),
 	
+			<jc>// Enable XML namespaces.</jc>
+			<ja>@Property</ja>(name=<jsf>XML_enableNamespaces</jsf>, value=<js>"true"</js>),
+
+			<jc>// Add namespace URIs to root node.</jc>
+			<ja>@Property</ja>(name=<jsf>XML_addNamespaceUrisToRoot</jsf>,
value=<js>"true"</js>),
+
 			<jc>// Make RDF/XML readable.</jc>
 			<ja>@Property</ja>(name=<jsf>RDF_rdfxml_tab</jsf>, value=<js>"5"</js>),
 	
@@ -16417,6 +16423,12 @@
 			TBD
 		</p>
 		
+		<h5 class='topic'>juneau-marshall</h5>
+		<ul class='spaced-list'>
+			<li>
+				Fixed bug where <code><ja>@Bean</ja>(typeName)</code> was not
being detected on non-bean POJO classes.
+		</ul>
+		
 		<h5 class='topic'>juneau-server</h5>
 		<ul class='spaced-list'>
 			<li>
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
index 5ed9e4b..20713ca 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
@@ -91,6 +91,12 @@ import org.apache.juneau.utils.*;
 		// Use single quotes.
 		@Property(name=SERIALIZER_quoteChar, value="'"),
 
+		// Enable XML namespaces.
+		@Property(name=XML_enableNamespaces, value="true"),
+
+		// Add namespace URIs to root node.
+		@Property(name=XML_addNamespaceUrisToRoot, value="true"),
+		
 		// Make RDF/XML readable.
 		@Property(name=RDF_rdfxml_tab, value="5"),
 

-- 
To stop receiving notification emails like this one, please contact
jamesbognar@apache.org.

Mime
View raw message