axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntha...@apache.org
Subject svn commit: r1035769 - /axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java
Date Tue, 16 Nov 2010 20:00:11 GMT
Author: nthaker
Date: Tue Nov 16 20:00:10 2010
New Revision: 1035769

URL: http://svn.apache.org/viewvc?rev=1035769&view=rev
Log:
Fix for JIRA AXIS2-4884

With this change @PostConstruct on non-public methods can now be invoked and we will not see
java.lang.IllegalAccessException.

Modified:
    axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java

Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java?rev=1035769&r1=1035768&r2=1035769&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java
(original)
+++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/lifecycle/BaseLifecycleManager.java
Tue Nov 16 20:00:10 2010
@@ -49,10 +49,32 @@ public abstract class BaseLifecycleManag
         }
     }
 
-    protected void invokePostConstruct(Method method) throws LifecycleException {
+    protected void invokePostConstruct(final Method method) throws LifecycleException {
         if (log.isDebugEnabled()) {
             log.debug("Invoking Method with @PostConstruct annotation");
         }
+        /*
+         * As per JSR-250 pre destroy and post construct can be
+         * public, protected, private or default encapsulation.
+         * I will check and make sure the methods are accessible
+         * before we invoke them.
+         * 
+         */
+        
+        try {
+            AccessController.doPrivileged(
+                    new PrivilegedExceptionAction() {
+                        public Object run() throws InvocationTargetException, IllegalAccessException
{
+                            if(!method.isAccessible()){
+                                method.setAccessible(true);
+                            }
+                            return null;
+                        }
+                    }
+            );
+        } catch (PrivilegedActionException e) {
+            throw new LifecycleException(e.getException());
+        }
         invokeMethod(method, null);
         if (log.isDebugEnabled()) {
             log.debug("Completed invoke on Method with @PostConstruct annotation");



Mime
View raw message