You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2008/07/11 02:31:58 UTC
svn commit: r675818 -
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
Author: scheu
Date: Thu Jul 10 17:31:57 2008
New Revision: 675818
URL: http://svn.apache.org/viewvc?rev=675818&view=rev
Log:
Add doPriv to unmarshall calls.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=675818&r1=675817&r2=675818&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java Thu Jul 10 17:31:57 2008
@@ -531,24 +531,43 @@
});
}
- private static Object unmarshalArray(XMLStreamReader reader, Unmarshaller u,
+ private static Object unmarshalArray(final XMLStreamReader reader,
+ final Unmarshaller u,
Class type)
throws Exception {
+ try {
+ if (DEBUG_ENABLED) {
+ log.debug("Invoking unmarshalArray");
+ }
+ Object jaxb = AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return u.unmarshal(reader, String[].class);
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ }
+ });
- Object jaxb = u.unmarshal(reader, String[].class);
-
- Object typeObj = getTypeEnabledObject(jaxb);
-
- // Now convert String Array in to the required Type Array.
- if (typeObj instanceof String[]) {
- String[] strArray = (String[]) typeObj;
- Object obj = XSDListUtils.fromStringArray(strArray, type);
- QName qName =
+ Object typeObj = getTypeEnabledObject(jaxb);
+
+ // Now convert String Array in to the required Type Array.
+ if (typeObj instanceof String[]) {
+ String[] strArray = (String[]) typeObj;
+ Object obj = XSDListUtils.fromStringArray(strArray, type);
+ QName qName =
XMLRootElementUtil.getXmlRootElementQNameFromObject(jaxb);
- jaxb = new JAXBElement(qName, type, obj);
+ jaxb = new JAXBElement(qName, type, obj);
+ }
+
+ return jaxb;
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
}
-
- return jaxb;
}
/**
@@ -564,22 +583,47 @@
* @throws DatatypeConfigurationException
* @throws InvocationTargetException
*/
- public static Object unmarshalAsListOrArray(XMLStreamReader reader, Unmarshaller u,
+ public static Object unmarshalAsListOrArray(final XMLStreamReader reader,
+ final Unmarshaller u,
Class type)
- throws IllegalAccessException, ParseException,NoSuchMethodException,InstantiationException,
+ throws IllegalAccessException, ParseException,NoSuchMethodException,
+ InstantiationException,
DatatypeConfigurationException,InvocationTargetException,JAXBException {
- //If this is an xsd:list, we need to return the appropriate
- // list or array (see NOTE above)
- // First unmarshal as a String
- Object jaxb = u.unmarshal(reader, String.class);
- //Second convert the String into a list or array
- if (getTypeEnabledObject(jaxb) instanceof String) {
- QName qName = XMLRootElementUtil.getXmlRootElementQNameFromObject(jaxb);
- Object obj = XSDListUtils.fromXSDListString((String) getTypeEnabledObject(jaxb), type);
- return new JAXBElement(qName, type, obj);
- } else {
- return jaxb;
- }
+
+
+ if (DEBUG_ENABLED) {
+ log.debug("Invoking unmarshaArray");
+ }
+
+ // If this is an xsd:list, we need to return the appropriate
+ // list or array (see NOTE above)
+ // First unmarshal as a String
+ Object jaxb = null;
+ try {
+ jaxb = AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return u.unmarshal(reader, String.class);
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ }
+ });
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ //Second convert the String into a list or array
+ if (getTypeEnabledObject(jaxb) instanceof String) {
+ QName qName = XMLRootElementUtil.getXmlRootElementQNameFromObject(jaxb);
+ Object obj = XSDListUtils.fromXSDListString((String) getTypeEnabledObject(jaxb), type);
+ return new JAXBElement(qName, type, obj);
+ } else {
+ return jaxb;
+ }
}