org.apache.axis2.jaxws.message.databinding
Class JAXBUtils

java.lang.Object
  extended by org.apache.axis2.jaxws.message.databinding.JAXBUtils

public class JAXBUtils
extends Object

JAXB Utilites to pool JAXBContext and related objects.


Nested Class Summary
static class JAXBUtils.CONSTRUCTION_TYPE
           
 
Field Summary
static String DEFAULT_NAMESPACE_REMAP
           
 
Constructor Summary
JAXBUtils()
           
 
Method Summary
static JAXBContext getJAXBContext(TreeSet<String> contextPackages)
          Deprecated.  
static JAXBContext getJAXBContext(TreeSet<String> contextPackages, ClassLoader cacheKey)
          Deprecated.  
static JAXBContext getJAXBContext(TreeSet<String> contextPackages, Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType, boolean forceArrays, String key, ClassLoader cacheKey, Map<String,?> properties)
          Get a JAXBContext for the class Note: The contextPackage object is used by multiple threads.
static JAXBContext getJAXBContext(TreeSet<String> contextPackages, Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType, String key)
           
static JAXBContext getJAXBContext(TreeSet<String> contextPackages, Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType, String key, ClassLoader cacheKey, Map<String,?> properties)
          Get a JAXBContext for the class Note: The contextPackage object is used by multiple threads.
static JAXBIntrospector getJAXBIntrospector(JAXBContext context)
          get JAXB Introspector
static Marshaller getJAXBMarshaller(JAXBContext context)
          Get JAXBMarshaller
static Unmarshaller getJAXBUnmarshaller(JAXBContext context)
          Get the unmarshaller.
protected static List<String> pruneDirectives(TreeSet<String> contextPackages)
          The contextPackages may declare overrides.
static void releaseJAXBIntrospector(JAXBContext context, JAXBIntrospector introspector)
          Release JAXBIntrospector Do not call this method if an exception occurred while using the JAXBIntrospector.
static void releaseJAXBMarshaller(JAXBContext context, Marshaller marshaller)
          releaseJAXBMarshalller Do not call this method if an exception occurred while using the Marshaller.
static void releaseJAXBUnmarshaller(JAXBContext context, Unmarshaller unmarshaller)
          Release Unmarshaller Do not call this method if an exception occurred while using the Unmarshaller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE_REMAP

public static final String DEFAULT_NAMESPACE_REMAP
Constructor Detail

JAXBUtils

public JAXBUtils()
Method Detail

getJAXBContext

public static JAXBContext getJAXBContext(TreeSet<String> contextPackages)
                                  throws JAXBException
Deprecated. 

Get a JAXBContext for the class

Parameters:
contextPackage - Set
Returns:
JAXBContext
Throws:
JAXBException

getJAXBContext

public static JAXBContext getJAXBContext(TreeSet<String> contextPackages,
                                         ClassLoader cacheKey)
                                  throws JAXBException
Deprecated. 

Get a JAXBContext for the class Note: The contextPackage object is used by multiple threads. It should be considered immutable and not altered by this method.

Parameters:
contextPackage - Set
cacheKey - ClassLoader
Returns:
JAXBContext
Throws:
JAXBException

getJAXBContext

public static JAXBContext getJAXBContext(TreeSet<String> contextPackages,
                                         Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType,
                                         String key)
                                  throws JAXBException
Throws:
JAXBException

getJAXBContext

public static JAXBContext getJAXBContext(TreeSet<String> contextPackages,
                                         Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType,
                                         String key,
                                         ClassLoader cacheKey,
                                         Map<String,?> properties)
                                  throws JAXBException
Get a JAXBContext for the class Note: The contextPackage object is used by multiple threads. It should be considered immutable and not altered by this method.

Parameters:
contextPackage - Set
contructionType - (output value that indicates how the context was constructed)
cacheKey - ClassLoader
Returns:
JAXBContext
Throws:
JAXBException

getJAXBContext

public static JAXBContext getJAXBContext(TreeSet<String> contextPackages,
                                         Holder<JAXBUtils.CONSTRUCTION_TYPE> constructionType,
                                         boolean forceArrays,
                                         String key,
                                         ClassLoader cacheKey,
                                         Map<String,?> properties)
                                  throws JAXBException
Get a JAXBContext for the class Note: The contextPackage object is used by multiple threads. It should be considered immutable and not altered by this method.

Parameters:
contextPackage - Set
contructionType - (output value that indicates how the context was constructed)
forceArrays - (forces the returned JAXBContext to include the array types)
cacheKey - ClassLoader
Returns:
JAXBContext
Throws:
JAXBException

pruneDirectives

protected static List<String> pruneDirectives(TreeSet<String> contextPackages)
The contextPackages may declare overrides. Example: "com.A" "com.B" "com.C" "@com.A" <-- Indicates a reference to a class (versus ns 2 pkg conversion) "com.A > com.B" <-- This says com.A overrides com.B This method prunes the overrides and overriden packages. Example return: "com.A" "com.C"

Parameters:
contextPackages -
Returns:
List class references

getJAXBUnmarshaller

public static Unmarshaller getJAXBUnmarshaller(JAXBContext context)
                                        throws JAXBException
Get the unmarshaller. You must call releaseUnmarshaller to put it back into the pool

Parameters:
context - JAXBContext
Returns:
Unmarshaller
Throws:
JAXBException

releaseJAXBUnmarshaller

public static void releaseJAXBUnmarshaller(JAXBContext context,
                                           Unmarshaller unmarshaller)
Release Unmarshaller Do not call this method if an exception occurred while using the Unmarshaller. We object my be in an invalid state.

Parameters:
context - JAXBContext
unmarshaller - Unmarshaller

getJAXBMarshaller

public static Marshaller getJAXBMarshaller(JAXBContext context)
                                    throws JAXBException
Get JAXBMarshaller

Parameters:
context - JAXBContext
Returns:
Marshaller
Throws:
JAXBException

releaseJAXBMarshaller

public static void releaseJAXBMarshaller(JAXBContext context,
                                         Marshaller marshaller)
releaseJAXBMarshalller Do not call this method if an exception occurred while using the Marshaller. We don't want an object in an invalid state.

Parameters:
context - JAXBContext
marshaller - Marshaller

getJAXBIntrospector

public static JAXBIntrospector getJAXBIntrospector(JAXBContext context)
                                            throws JAXBException
get JAXB Introspector

Parameters:
context - JAXBContext
Returns:
JAXBIntrospector
Throws:
JAXBException

releaseJAXBIntrospector

public static void releaseJAXBIntrospector(JAXBContext context,
                                           JAXBIntrospector introspector)
Release JAXBIntrospector Do not call this method if an exception occurred while using the JAXBIntrospector. We object my be in an invalid state.

Parameters:
context - JAXBContext
introspector - JAXBIntrospector


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.