Package org.apache.axis2.datasource.jaxb
Class JAXBDSContext
- java.lang.Object
-
- org.apache.axis2.datasource.jaxb.JAXBDSContext
-
- Direct Known Subclasses:
JAXBBlockContext
public class JAXBDSContext extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG_ENABLED
-
Constructor Summary
Constructors Constructor Description JAXBDSContext(String contextPackage)
Deprecated.JAXBDSContext(TreeSet<String> packages)
Slightly slower constructorJAXBDSContext(TreeSet<String> packages, String packagesKey)
Full Constructor JAXBDSContext (most performant)JAXBDSContext(JAXBContext jaxbContext)
"Dispatch" Constructor Use this full constructor when the JAXBContent is provided by the customer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AttachmentContext
createAttachmentContext()
ClassLoader
getClassLoader()
JAXBUtils.CONSTRUCTION_TYPE
getConstructionType()
TreeSet<String>
getContextPackages()
JAXBContext
getJAXBContext()
JAXBContext
getJAXBContext(ClassLoader cl)
JAXBContext
getJAXBContext(ClassLoader cl, boolean forceArrays)
MessageContext
getMessageContext()
Class<?>
getProcessType()
boolean
isxmlList()
void
marshal(Object obj, XMLStreamWriter writer)
Marshal the jaxb objectvoid
setIsxmlList(boolean isxmlList)
void
setMessageContext(MessageContext messageContext)
void
setProcessType(Class<?> type)
The procesess type to indicate the class of the target of the unmarshaling.void
setWebServiceNamespace(String namespace)
Object
unmarshal(OMElement element)
Unmarshal the xml into a JAXB objectstatic Object
unmarshalAsListOrArray(XMLStreamReader reader, Unmarshaller u, Class<?> type)
convert the String into a list or arraystatic Object
unmarshalByElement(Unmarshaller u, XMLStreamReader reader)
Preferred way to unmarshal objectsstatic Object
unmarshalByType(Unmarshaller u, XMLStreamReader reader, Class<?> type, boolean isList, JAXBUtils.CONSTRUCTION_TYPE ctype)
The root element being read is defined by schema/JAXB; however its contents are known by schema/JAXB.
-
-
-
Constructor Detail
-
JAXBDSContext
public JAXBDSContext(TreeSet<String> packages, String packagesKey)
Full Constructor JAXBDSContext (most performant)- Parameters:
packages
- Set of packages needed by the JAXBContext.
-
JAXBDSContext
public JAXBDSContext(TreeSet<String> packages)
Slightly slower constructor- Parameters:
packages
-
-
JAXBDSContext
public JAXBDSContext(String contextPackage)
Deprecated.Normal Constructor JAXBBlockContext- Parameters:
contextPackage
-
-
JAXBDSContext
public JAXBDSContext(JAXBContext jaxbContext)
"Dispatch" Constructor Use this full constructor when the JAXBContent is provided by the customer.- Parameters:
jaxbContext
-
-
-
Method Detail
-
getContextPackages
public TreeSet<String> getContextPackages()
- Returns:
- Class representing type of the element
-
getJAXBContext
public JAXBContext getJAXBContext() throws JAXBException
- Throws:
JAXBException
-
getJAXBContext
public JAXBContext getJAXBContext(ClassLoader cl) throws JAXBException
- Returns:
- get the JAXBContext
- Throws:
JAXBException
-
getJAXBContext
public JAXBContext getJAXBContext(ClassLoader cl, boolean forceArrays) throws JAXBException
- Parameters:
ClassLoader
-forceArrays
- boolean (if true, then JAXBContext will automatically contain arrays)- Returns:
- get the JAXBContext
- Throws:
JAXBException
-
setWebServiceNamespace
public void setWebServiceNamespace(String namespace)
-
getProcessType
public Class<?> getProcessType()
- Returns:
- RPC Declared Type
-
setProcessType
public void setProcessType(Class<?> type)
The procesess type to indicate the class of the target of the unmarshaling. This method should only be used in the cases where the element being unmarshaled is not known to the JAXBContext (examples include RPC/Literal processing and Doc/Literal Wrapped processing with a non-element wrapper class)- Parameters:
type
-
-
getConstructionType
public JAXBUtils.CONSTRUCTION_TYPE getConstructionType()
-
isxmlList
public boolean isxmlList()
-
setIsxmlList
public void setIsxmlList(boolean isxmlList)
-
getMessageContext
public MessageContext getMessageContext()
-
setMessageContext
public void setMessageContext(MessageContext messageContext)
-
getClassLoader
public ClassLoader getClassLoader()
-
createAttachmentContext
protected AttachmentContext createAttachmentContext()
-
unmarshal
public Object unmarshal(OMElement element) throws JAXBException
Unmarshal the xml into a JAXB object- Parameters:
element
-- Returns:
- Throws:
JAXBException
-
marshal
public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException
Marshal the jaxb object- Parameters:
obj
-writer
-am
- AttachmentMarshaller, optional Attachment- Throws:
JAXBException
-
unmarshalByType
public static Object unmarshalByType(Unmarshaller u, XMLStreamReader reader, Class<?> type, boolean isList, JAXBUtils.CONSTRUCTION_TYPE ctype) throws WebServiceException
The root element being read is defined by schema/JAXB; however its contents are known by schema/JAXB. Therefore we use unmarshal by the declared type (This method is used to unmarshal rpc elements)- Parameters:
u
- Unmarshallerreader
- XMLStreamReadertype
- Class- Returns:
- Object
- Throws:
WebServiceException
-
unmarshalAsListOrArray
public static Object unmarshalAsListOrArray(XMLStreamReader reader, Unmarshaller u, Class<?> type) throws IllegalAccessException, ParseException, NoSuchMethodException, InstantiationException, DatatypeConfigurationException, InvocationTargetException, JAXBException
convert the String into a list or array- Type Parameters:
T
-- Parameters:
jaxb
-type
-- Returns:
- Throws:
IllegalAccessException
ParseException
NoSuchMethodException
InstantiationException
DatatypeConfigurationException
InvocationTargetException
JAXBException
-
unmarshalByElement
public static Object unmarshalByElement(Unmarshaller u, XMLStreamReader reader) throws WebServiceException
Preferred way to unmarshal objects- Parameters:
u
- Unmarshallerreader
- XMLStreamReader- Returns:
- Object that represents an element
- Throws:
WebServiceException
-
-