org.faktorips.runtime.util
Class JAXBContextFactory

java.lang.Object
  extended by org.faktorips.runtime.util.JAXBContextFactory

public class JAXBContextFactory
extends Object

Provides static factory methods to create a JAXBContext that can marshal / unmarshall all model classes defined in a given runtime repository.

Author:
Jan Ortmann
See Also:
JAXBContext, IRuntimeRepository

Constructor Summary
JAXBContextFactory()
           
 
Method Summary
static JAXBContext newContext(IRuntimeRepository repository)
          Creates a new JAXBContext that can marshall / unmarshall all modell classes defined in the given repository.
static JAXBContext newContext(IRuntimeRepository repository, ClassLoader cl)
          Creates a new JAXBContext that can marshall / unmarshall all modell classes defined in the given repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXBContextFactory

public JAXBContextFactory()
Method Detail

newContext

public static JAXBContext newContext(IRuntimeRepository repository)
                              throws JAXBException,
                                     ClassNotFoundException
Creates a new JAXBContext that can marshall / unmarshall all modell classes defined in the given repository. If the repository references other repositories (directly or indirectly), the context can also handle the classes defined in these other repositories. Note: The repository contains the model classed by name, so this method needs to actually load the classes. If the repository gives access to a class loader (e.g. ClassloaderRuntimeRepository does), the class loader provided by the repository is taken. Otherwise the class loader that has loaded the class the repository is an instance of, is used.

Parameters:
repository - The repository that contains the information about the model classes
Throws:
ClassNotFoundException - If one of the model classes was not found.
JAXBException - The exception thrown by JAXBContext.newInstance(Class...)
NullPointerException - if repository is null.

newContext

public static JAXBContext newContext(IRuntimeRepository repository,
                                     ClassLoader cl)
                              throws JAXBException,
                                     ClassNotFoundException
Creates a new JAXBContext that can marshall / unmarshall all modell classes defined in the given repository. If the repository references other repositories (directly or indirectly), the context can also handle the classes defined in these other repositories. Note: The repository contains the model classed by name, so this method needs to actually load the classes. This method uses the given class loader do load the classes.

Parameters:
repository - The repository that contains the information about the model classes
cl - The class loader to load the model classes.
Throws:
ClassNotFoundException - If one of the model classes was not found.
JAXBException - The exception thrown by JAXBContext.newInstance(Class...)
NullPointerException - if one of the parametes is null.


Copyright © 2015. All rights reserved.