summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/databinding-jaxb/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-12 23:20:32 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-12 23:20:32 +0000
commit210add386996614b9eca21dabe783038750d12b4 (patch)
tree57dea93b02edca9f8562c12a659b96122437ded5 /branches/sca-java-1.x/modules/databinding-jaxb/src
parent3813b954d54687c720526a76254b219400570f2d (diff)
Fix for TUSCANY-2846
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@743924 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/databinding-jaxb/src')
-rw-r--r--branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
index c64ce81fdf..26da0132e8 100644
--- a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
+++ b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
@@ -108,9 +108,34 @@ public class JAXBContextCache {
defaultContext = getDefaultJAXBContext();
}
+ private static JAXBContext newJAXBContext(final Class<?>... classesToBeBound) throws JAXBException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+ public JAXBContext run() throws JAXBException {
+ return JAXBContext.newInstance(classesToBeBound);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (JAXBException)e.getException();
+ }
+ }
+
+ private static JAXBContext newJAXBContext(final String contextPath, final ClassLoader classLoader)
+ throws JAXBException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+ public JAXBContext run() throws JAXBException {
+ return JAXBContext.newInstance(contextPath, classLoader);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (JAXBException)e.getException();
+ }
+ }
+
public static JAXBContext getDefaultJAXBContext() {
try {
- return JAXBContext.newInstance();
+ return newJAXBContext();
} catch (JAXBException e) {
throw new IllegalArgumentException(e);
}
@@ -239,10 +264,10 @@ public class JAXBContextCache {
}
if (pkg != null && checkPackage(pkg.getName(), cls.getClassLoader())) {
- context = JAXBContext.newInstance(pkg.getName(), cls.getClassLoader());
+ context = newJAXBContext(pkg.getName(), cls.getClassLoader());
cache.put(pkg, context);
} else {
- context = JAXBContext.newInstance(cls);
+ context = newJAXBContext(cls);
cache.put(cls, context);
}
return context;
@@ -288,7 +313,7 @@ public class JAXBContextCache {
if (context != null) {
return context;
}
- context = JAXBContext.newInstance(classSet.toArray(new Class<?>[classSet.size()]));
+ context = newJAXBContext(classSet.toArray(new Class<?>[classSet.size()]));
cache.put(classSet, context);
return context;
}
@@ -327,8 +352,8 @@ public class JAXBContextCache {
new ConcurrentHashMap<K, List<V>>());
// The maps are freed up when a LOAD FACTOR is hit
- private static int MAX_LIST_FACTOR = 50;
- private static int MAX_LOAD_FACTOR = 32; // Maximum number of JAXBContext to store
+ private static final int MAX_LIST_FACTOR = 50;
+ private static final int MAX_LOAD_FACTOR = 32; // Maximum number of JAXBContext to store
/**
* @param key