EclipseLink JAXB (MOXy) provides an XML mapping document as an alternative to using annotations. This mapping document can be provided in many different forms: resource path, URL, File, Source, etc. If however you store your metadata in some sort of repository this flexibility might not be enough. This is why in EclipseLink 2.3 we have introduced a new mechanism to support this use case.
June 3, 2011
Using EclipseLink MOXy with a Metadata Repository
Labels:
EclipseLink,
EclipseLink 2.3,
Extension,
JAXB,
Mapping File,
MOXy
June 2, 2011
MOXy Extensible Models - Multi-Tenant Example
In a multi-tenant architecture a single application runs on a server, serving multiple client organizations (tenants). Good multi-tenant applications allow per-tenant customizations. When these customizations are made to data, it can be difficult for the binding layer to handle them. In this post I'll demonstrate how to leverage EclipseLink JAXB (MOXy)'s support for extensible models to easily handle this use case.
Labels:
EclipseLink,
EclipseLink 2.3,
Extension,
JAXB,
Mapping File,
MOXy,
Multi-Tenant,
XmlVirtualAccessMethods
June 1, 2011
Extensible Models with EclipseLink JAXB (MOXy)
JAXB is designed to work with domain models that have real fields/properties. In EclipseLink 2.3, MOXy introduces the concept of virtual properties. Virtual properties are defined by the MOXy metadata file, and provide a way to extend a class without modifying the source. In this post I'll describe what virtual properties are, and in upcoming posts I'll cover how they can be leveraged:
Labels:
EclipseLink,
EclipseLink 2.3,
Extension,
JAXB,
Mapping File,
MOXy,
XmlVirtualAccessMethods
Ignoring Inheritance with @XmlTransient
In previous articles I have covered how to map inheritance relationships in JAXB and EclipseLink MOXy. In this example I will describe how to remove an inheritance relationship in JAXB by leveraging @XmlTransient at the type level.
May 30, 2011
JAXB and Joda-Time: Dates and Times
Joda-Time provides an alternative to the Date and Calendar classes currently provided in Java SE. Since they are provided in a separate library JAXB does not provide a default mapping for these classes. We can supply the necessary mapping via XmlAdapters. In this post we will cover the following Joda-Time types: DateTime, DateMidnight, LocalDate, LocalTime, LocalDateTime.
May 27, 2011
Overriding JAXB's "Name Mangling" Algorithm with EclipseLink MOXy
JAXB has well established rules for converting Java names to XML names. If you want to override the default name you can always do so through the use of annotations. Where this can become burdensome is if your names follow common rules (such as make everything upper case). In the upcoming EclipseLink 2.3 release we have added a new MOXy JAXB feature that allows you to override the default naming algorithm. You can try this out today using a nightly download:
Labels:
EclipseLink,
EclipseLink 2.3,
Extension,
MOXy
May 24, 2011
JAXB and DTD - Apache log4j Example
There is a common misconception that JAXB requires an XML Schema. This is understandable since JAXB offers the ability to derive Java classes from an XML schema, and generate XML schemas from annotated Java classes. In reality the JAXB annotations are used to map XML to objects, and although not part of the JAXB specification, the XJC tool offers the ability to generate Java classes from a DTD. In this post we will use JAXB to interact with XML that corresponds to the Apache log4j DTD.
May 13, 2011
JAXB and Interface Fronted Models
Usually with JAXB we are mapping POJOs to XML. In this example I will demonstrate how to handle a Java model that is exposed through a set of interfaces. This post was inspired by an answer I gave (feel free to upvote) to a question on Stack Overflow. In the question the poster was running into exceptions like the one below. This post will cover how to properly map this use case.
Exception in thread "main" com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 6 counts of IllegalAnnotationExceptions blog.interfaces.Customer is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at blog.interfaces.Customer blog.interfaces.Customer does not have a no-arg default constructor. this problem is related to the following location: at blog.interfaces.Customer ...
May 5, 2011
Schema to Java: @XmlMimeType & @XmlInlineBinaryData
In a previous post I described the impact of the @XmlInlineBinaryData and @XmlMimeType annotations in a JAX-WS environment where binary data may be sent as attachments. One of the comments I received on that post was how to have those annotations generated onto your classes when starting from an XML schema. In this post I will address that question.
Labels:
Bindings File,
JAXB,
XmlInlineBinaryData,
XmlMimeType
May 3, 2011
Specifying EclipseLink MOXy as Your JAXB Provider
To specify EclipseLink MOXy as the JAXB provider you need to put a jaxb.properties file in one of the packages for your domain classes, that is passed in to bootstrap the JAXBContext.
Subscribe to:
Posts (Atom)