Author: ffang
Date: Mon Jan 21 07:06:30 2013
New Revision: 1436208
URL: http://svn.apache.org/viewvc?rev=1436208&view=rev
Log:
[CXF-4768]Refact SwaOutInterceptor to honor other JAXB impl(besides JAXB RI)
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?rev=1436208&r1=1436207&r2=1436208&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Mon Jan 21 07:06:30 2013
@@ -25,6 +25,8 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -81,11 +83,20 @@ public class SwAOutInterceptor extends A
addBefore(WrapperClassOutInterceptor.class.getName());
}
- private boolean callSWARefMethod(JAXBContext ctx) {
+ private boolean callSWARefMethod(final JAXBContext ctx) {
Method m = SWA_REF_METHOD.get(ctx.getClass().getName());
if (m == null &&
!SWA_REF_METHOD.containsKey(ctx.getClass().getName())) {
try {
- m = ctx.getClass().getMethod("hasSwaRef", new Class[0]);
+ m = AccessController.doPrivileged(new
PrivilegedExceptionAction<Method>() {
+
+ public Method run() throws Exception {
+ Method hasSwaRefMethod =
ctx.getClass().getMethod("hasSwaRef", new Class[0]);
+ if (!hasSwaRefMethod.isAccessible()) {
+ hasSwaRefMethod.setAccessible(true);
+ }
+ return hasSwaRefMethod;
+ }
+ });
SWA_REF_METHOD.put(ctx.getClass().getName(), m);
} catch (Exception e) {
//ignore
@@ -222,7 +233,8 @@ public class SwAOutInterceptor extends A
atts.add(att);
}
}
- private boolean hasSwaRef(JAXBDataBinding db) {
+
+ protected boolean hasSwaRef(JAXBDataBinding db) {
JAXBContext context = db.getContext();
return callSWARefMethod(context);
}