You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/08/02 16:40:16 UTC

svn commit: r1153145 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: BundleWiringImpl.java util/SecureAction.java

Author: rickhall
Date: Tue Aug  2 14:40:14 2011
New Revision: 1153145

URL: http://svn.apache.org/viewvc?rev=1153145&view=rev
Log:
Invoke weaving hook in privileged block. (FELIX-2959)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1153145&r1=1153144&r2=1153145&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Tue Aug  2 14:40:14 2011
@@ -1958,8 +1958,8 @@ ex.printStackTrace();
                                 {
                                     try
                                     {
-// TODO: OSGi R4.3 - Need to call all hooks in privileged block.
-                                        wh.weave(wci);
+                                        m_revision.getSecureAction()
+                                            .invokeWeavingHook(wh, wci);
                                     }
                                     catch (Throwable th)
                                     {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java?rev=1153145&r1=1153144&r2=1153145&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java Tue Aug  2 14:40:14 2011
@@ -1091,6 +1091,30 @@ public class SecureAction
         }
     }
 
+    public void invokeWeavingHook(
+        org.osgi.framework.hooks.weaving.WeavingHook wh,
+        org.osgi.framework.hooks.weaving.WovenClass wc)
+        throws Exception
+    {
+        if (System.getSecurityManager() != null)
+        {
+            Actions actions = (Actions) m_actions.get();
+            actions.set(Actions.INVOKE_WEAVING_HOOK, wh, wc);
+            try
+            {
+                AccessController.doPrivileged(actions, m_acc);
+            }
+            catch (PrivilegedActionException e)
+            {
+                throw e.getException();
+            }
+        }
+        else
+        {
+            wh.weave(wc);
+        }
+    }
+
     private static class Actions implements PrivilegedExceptionAction
     {
         public static final int INITIALIZE_CONTEXT_ACTION = 0;
@@ -1135,6 +1159,7 @@ public class SecureAction
         public static final int GET_CLASS_LOADER_ACTION = 39;
         public static final int INVOKE_BUNDLE_FIND_HOOK = 40;
         public static final int INVOKE_BUNDLE_EVENT_HOOK = 41;
+        public static final int INVOKE_WEAVING_HOOK = 42;
 
         private int m_action = -1;
         private Object m_arg1 = null;
@@ -1316,6 +1341,10 @@ public class SecureAction
                     ((org.osgi.framework.hooks.bundle.EventHook) arg1).event(
                         (BundleEvent) arg2, (Collection<BundleContext>) arg3);
                     return null;
+                case INVOKE_WEAVING_HOOK:
+                    ((org.osgi.framework.hooks.weaving.WeavingHook) arg1).weave(
+                        (org.osgi.framework.hooks.weaving.WovenClass) arg2);
+                    return null;
             }
 
             return null;