You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Kaloyan Kolev (JIRA)" <ji...@apache.org> on 2010/10/28 17:24:21 UTC
[jira] Created: (WINK-325) Allow
AtomCommonAttributes#otherAttributes to be lazy initialized.
Allow AtomCommonAttributes#otherAttributes to be lazy initialized.
------------------------------------------------------------------
Key: WINK-325
URL: https://issues.apache.org/jira/browse/WINK-325
Project: Wink
Issue Type: Improvement
Components: Common
Affects Versions: 1.1.2
Reporter: Kaloyan Kolev
Priority: Trivial
Fix For: 1.1.2
I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
For as simple input as:
{code}
return new AtomText("someValue");
{code}
I get:
{code}
{
"otherAttributes" : {
},
"type" : "text",
"value" : "someValue"
}
{code}
AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927014#action_12927014 ]
Bryant Luk commented on WINK-325:
---------------------------------
Which version of Jackson are you using?
In unit tests with Jackson 1.5.5 and 1.6.0:
{code}
ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
AnnotationIntrospector pair =
new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
new JacksonAnnotationIntrospector());
mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
mapper.getSerializationConfig().setAnnotationIntrospector(pair);
JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(mapper);
AtomText a = new AtomText("hello");
jacksonProvider.writeTo(a, a.getClass(), a.getClass(), new Annotation[0], MediaType.APPLICATION_JSON_TYPE, null, System.out);
{code}
would return:
{code}
{"otherAttributes":{},"type":"text"}
{code}
If instead, I remove the (de)serialization config, I get:
{code}
ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(mapper);
AtomText a = new AtomText("hello");
jacksonProvider.writeTo(a, a.getClass(), a.getClass(), new Annotation[0], MediaType.APPLICATION_JSON_TYPE, null, System.out);
{code}
{code}
{"value":"hello","type":"text","otherAttributes":{}}
{code}
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12926265#action_12926265 ]
Kaloyan Kolev commented on WINK-325:
------------------------------------
I am reconfiguring Jackson to use jax-b annotations with priority as follows:
{code}
ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
AnnotationIntrospector pair =
new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
new JacksonAnnotationIntrospector());
mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
mapper.getSerializationConfig().setAnnotationIntrospector(pair);
this.jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(mapper);
{code}
Do you think that might cause the problem?
Btw, overriding the getOtherAttributes() is not very convenient as then I will have to extend all the Atom types I use (AtomFeed, AtomEntry, etc.)
Thanks.
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Hudson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927163#action_12927163 ]
Hudson commented on WINK-325:
-----------------------------
Integrated in Wink-Trunk-JDK1.5 #417 (See [https://hudson.apache.org/hudson/job/Wink-Trunk-JDK1.5/417/])
Lazily initialize AtomCommonAttributes(SimpleContent)
See [WINK-325]
Thanks to Kaloyan Kolev for reporting the issue.
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927065#action_12927065 ]
Bryant Luk commented on WINK-325:
---------------------------------
I went ahead and lazily initialized the attributes. I'm guessing that whatever workaround code you have also fixes the issue where the "value" property is not output (that's what I was trying to point out in my last comment; I don't think the JSON properties ordering really matters as it's somewhat random).
Let me know if that fixes your issue. I don't think the lazy initialization hurts the XML output but if someone sees an issue, please let us know.
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kaloyan Kolev updated WINK-325:
-------------------------------
Description:
I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
For as simple input as:
{code}
return new AtomText("someValue");
{code}
I get:
{code}
{
"otherAttributes" : {
},
"type" : "text",
"value" : "someValue"
}
{code}
AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
Thanks.
was:
I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
For as simple input as:
{code}
return new AtomText("someValue");
{code}
I get:
{code}
{
"otherAttributes" : {
},
"type" : "text",
"value" : "someValue"
}
{code}
AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
Thanks.
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927016#action_12927016 ]
Kaloyan Kolev commented on WINK-325:
------------------------------------
I am using Jackson 1.5.5.
So in the second case Jackson only switches the places of otherAttributes map? (And probably fixes the output of the @XmlMixed for which I have a workaround and is not high priority one for me)
Thanks.
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12925930#action_12925930 ]
Bryant Luk commented on WINK-325:
---------------------------------
Did you change the Jackson JSON Provider (JacksonJsonProvider) configuration from the defaults? I tried lazily initializing the variable but I think Jackson is using the getter/setter properties before it attempts the instance variables. The closest I could get to your output was:
{code}
AtomText a = new AtomText("hello");
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.configure(Feature.WRITE_NULL_PROPERTIES, Boolean.FALSE);
provider.writeTo(a, a.getClass(), a.getClass(), new Annotation[0], MediaType.APPLICATION_JSON_TYPE, null, System.out);
{code}
For your use case, I think the easiest solution is to override the getter for otherAttributes:
{code}
public class MyAtomText extends AtomText {
public MyAtomText(String value) {
super(value);
}
@Override
public Map<QName, String> getOtherAttributes() {
Map<QName, String> otherAttributes = super.getOtherAttributes();
if(otherAttributes.isEmpty()) {
return null;
}
return otherAttributes;
}
}
{code}
when using the JacksonJsonProvider:
{code}
MyAtomText a = new MyAtomText("hello");
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.configure(Feature.WRITE_NULL_PROPERTIES, Boolean.FALSE);
provider.writeTo(a, a.getClass(), a.getClass(), new Annotation[0], MediaType.APPLICATION_JSON_TYPE, null, System.out);
{code}
I get:
{code}
{"value":"hello","type":"text"}
{code}
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kaloyan Kolev closed WINK-325.
------------------------------
Resolution: Fixed
The fix is just what I was looking for.
Thanks Bryant Luk for your support!
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> I can see this is also relevant for the AtomCommonAttributesSimpleContent class, so updating the summary.
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WINK-325) Allow
AtomCommonAttributes#otherAttributes and
AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WINK-325?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kaloyan Kolev updated WINK-325:
-------------------------------
Summary: Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized. (was: Allow AtomCommonAttributes#otherAttributes to be lazy initialized.)
> Allow AtomCommonAttributes#otherAttributes and AtomCommonAttributesSimpleContent#otherAttributes to be lazy initialized.
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-325
> URL: https://issues.apache.org/jira/browse/WINK-325
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 1.1.2
> Reporter: Kaloyan Kolev
> Priority: Trivial
> Fix For: 1.1.2
>
>
> I am using the Jackson provider to serialize an AtomText which extends AtomCommonAttributes.
> For as simple input as:
> {code}
> return new AtomText("someValue");
> {code}
> I get:
> {code}
> {
> "otherAttributes" : {
> },
> "type" : "text",
> "value" : "someValue"
> }
> {code}
> AtomCommonAttributes#otherAttributes is accessed as in the rest of the Atom* beans. Is it possible to allow the map to be lazily initialized when the AtomCommonAttributes#getOtherAttributes() method is called like in the rest?
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.