src/share/jaxws_classes/com/sun/xml/internal/ws/spi/db/MethodSetter.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 23,36 **** * questions. */ package com.sun.xml.internal.ws.spi.db; import java.lang.reflect.Method; ! import java.security.AccessController; ! import java.security.PrivilegedActionException; ! import java.security.PrivilegedExceptionAction; /** * MethodInjection * @author shih-chang.chen@oracle.com --- 23,35 ---- * questions. */ package com.sun.xml.internal.ws.spi.db; + import static com.sun.xml.internal.ws.spi.db.PropertyGetterBase.verifyWrapperType; import java.lang.reflect.Method; ! import javax.xml.ws.WebServiceException; /** * MethodInjection * @author shih-chang.chen@oracle.com
*** 39,48 **** --- 38,48 ---- public class MethodSetter extends PropertySetterBase { private Method method; public MethodSetter(Method m) { + verifyWrapperType(m.getDeclaringClass()); method = m; type = m.getParameterTypes()[0]; } public Method getMethod() {
*** 52,87 **** public <A> A getAnnotation(Class<A> annotationType) { Class c = annotationType; return (A) method.getAnnotation(c); } ! public void set(final Object instance, Object resource) { final Object[] args = {resource}; - if (method.isAccessible()) { try { method.invoke(instance, args); } catch (Exception e) { ! e.printStackTrace(); ! } ! } else { ! try { ! AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { ! public Object run() throws IllegalAccessException { ! if (!method.isAccessible()) { ! method.setAccessible(true); ! } ! try { ! method.invoke(instance, args); ! } catch (Exception e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } ! return null; ! } ! }); ! } catch (PrivilegedActionException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } } } } --- 52,66 ---- public <A> A getAnnotation(Class<A> annotationType) { Class c = annotationType; return (A) method.getAnnotation(c); } ! public void set(final Object instance, Object val) { ! final Object resource = (type.isPrimitive() && val == null)? uninitializedValue(type): val; final Object[] args = {resource}; try { method.invoke(instance, args); } catch (Exception e) { ! throw new WebServiceException(e); } } }