Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Moxy map attribute that doesn't exist in the object model.(XMLTransformationMapping equivalent in annotations or oxm)
Moxy map attribute that doesn't exist in the object model. [message #1387548] Wed, 25 June 2014 08:37 Go to next message
Jaime Metcher is currently offline Jaime MetcherFriend
Messages: 6
Registered: July 2012
Junior Member
This question was asked in 2010: eclipse.1072660.n5.nabble.com/Moxy-map-attribute-that-doesn-t-exist-in-the-object-model-td6519.html

That discussion was in terms of manually creating an XMLTransformationMapping. I've been merrily soldiering on with the oxm file approach and have never come across the XMLTransformationMapping technique in any of the docs.

Using either annotations or an oxm file, a FieldTransformer simply never fires unless it is attached to a java attribute. The technique discussed in the linked thread seems to imply that it's possible to do this without a java attribute.

So, the question is:

1) Is this something that just didn't make it across to the annotation/oxm-based implementation?
2) Is there any documentation about how to actually use a manually created XMLTransformationMapping?

I'm working in a Jersey/Moxy/JAXB environment, but even a standalone example might get me started.
Re: Moxy map attribute that doesn't exist in the object model. [message #1388159 is a reply to message #1387548] Thu, 26 June 2014 04:17 Go to previous message
Jaime Metcher is currently offline Jaime MetcherFriend
Messages: 6
Registered: July 2012
Junior Member
OK, I believe this works. In the OXM file:

<java-type name="Planet" xml-customizer="testing.HrefCustomizer">


and then the customizer:

public class HrefCustomizer implements DescriptorCustomizer {

	@Override
	public void customize(ClassDescriptor descriptor) throws Exception {
        XMLTransformationMapping xtm = new XMLTransformationMapping();
        xtm.addFieldTransformer("@href", new HrefWriter());

        descriptor.addMapping(xtm);
        
	}

}


Finally, for completeness, the transformer (just returning a constant for a POC):

public class HrefWriter implements FieldTransformer {
	
	@Override
	public Object buildFieldValue(Object instance, String fieldName,
			Session session) {
		return "href";
	}

	@Override
	public void initialize(AbstractTransformationMapping mapping) {
		// TODO Auto-generated method stub
		
	}

}


I have to say, this was really, really hard to find. Is this unsupported/deprecated usage?
Previous Topic:Generating tables from entities
Next Topic:EclipseLink 2.3: Clear cache through application
Goto Forum:
  


Current Time: Sat Mar 07 01:54:02 GMT 2015

Powered by FUDForum. Page generated in 0.02610 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software