aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1200093 - in /aries/trunk/util: pom.xml src/main/java/org/apache/aries/util/AriesFrameworkUtil.java src/main/java/org/apache/aries/util/internal/DefaultWorker.java src/main/java/org/apache/aries/util/internal/R43Worker.java
Date Thu, 10 Nov 2011 01:57:22 GMT
Author: djencks
Date: Thu Nov 10 01:57:21 2011
New Revision: 1200093

URL: http://svn.apache.org/viewvc?rev=1200093&view=rev
Log:
ARIES-777 Introduce a R43Worker to get classloader from bundle in r 4.3 frameworks. Also avoid
an NPE I ran into

Added:
    aries/trunk/util/src/main/java/org/apache/aries/util/internal/R43Worker.java
Modified:
    aries/trunk/util/pom.xml
    aries/trunk/util/src/main/java/org/apache/aries/util/AriesFrameworkUtil.java
    aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java

Modified: aries/trunk/util/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/util/pom.xml?rev=1200093&r1=1200092&r2=1200093&view=diff
==============================================================================
--- aries/trunk/util/pom.xml (original)
+++ aries/trunk/util/pom.xml Thu Nov 10 01:57:21 2011
@@ -53,7 +53,9 @@
         </aries.osgi.export.pkg>
         <aries.osgi.import.pkg>
             !org.apache.aries.util*,
+            org.osgi.framework.hooks.bundle;resolution:=optional,
             org.osgi.framework.launch;resolution:=optional,
+            org.osgi.framework.wiring.*;resolution:=optional,
             org.osgi.service.framework;resolution:=optional,
             org.eclipse.osgi.internal.loader;resolution:=optional,
             org.eclipse.osgi.framework.internal.core;resolution:=optional,
@@ -62,7 +64,8 @@
         </aries.osgi.import.pkg>
         <aries.osgi.private.pkg>
             org.apache.aries.util.internal,
-            org.apache.aries.util.filesystem.impl
+            org.apache.aries.util.filesystem.impl,
+            org.apache.aries.util.tracker.hook
         </aries.osgi.private.pkg>
     </properties>
 
@@ -70,6 +73,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <version>4.3.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: aries/trunk/util/src/main/java/org/apache/aries/util/AriesFrameworkUtil.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/AriesFrameworkUtil.java?rev=1200093&r1=1200092&r2=1200093&view=diff
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/AriesFrameworkUtil.java (original)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/AriesFrameworkUtil.java Thu Nov 10
01:57:21 2011
@@ -22,20 +22,25 @@ import org.apache.aries.util.internal.De
 import org.apache.aries.util.internal.EquinoxWorker;
 import org.apache.aries.util.internal.FelixWorker;
 import org.apache.aries.util.internal.FrameworkUtilWorker;
+import org.apache.aries.util.internal.R43Worker;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.ServiceRegistration;
 
-public final class AriesFrameworkUtil 
+public final class AriesFrameworkUtil
 {
   private static FrameworkUtilWorker worker;
   
   static {
+    try {
+      worker = new R43Worker();
+    } catch (Throwable e) {
+    }
     Bundle b = FrameworkUtil.getBundle(AriesFrameworkUtil.class);
-    String bundleClassName = b.getClass().getName();
-    if (isEquinox(bundleClassName)) {
+    String bundleClassName = b == null? "": b.getClass().getName();
+    if (worker == null && isEquinox(bundleClassName)) {
       worker = new EquinoxWorker();
-    } else if (bundleClassName.startsWith("org.apache.felix")) {
+    } else if (worker == null && bundleClassName.startsWith("org.apache.felix"))
{
       worker = new FelixWorker();
     } 
     

Modified: aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java?rev=1200093&r1=1200092&r2=1200093&view=diff
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java (original)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/internal/DefaultWorker.java Thu Nov
10 01:57:21 2011
@@ -39,7 +39,8 @@ public class DefaultWorker implements Fr
 
   static
   {
-    BundleContext myContext = FrameworkUtil.getBundle(DefaultWorker.class).getBundleContext();
+    Bundle bundle = FrameworkUtil.getBundle(DefaultWorker.class);
+    BundleContext myContext = bundle == null? null: bundle.getBundleContext();
     
     // This may be created during framework shutdown when the bundle context is null.
     // So we need to cope and not NPE during construction.
@@ -56,7 +57,7 @@ public class DefaultWorker implements Fr
     ClassLoader cl = get(b);
     
     if (cl != null) return cl;
-    
+
     // so first off try to get the real classloader. We can do this by loading a known class
     // such as the bundle activator. There is no guarantee this will work, so we have a back
door too.
     String activator = (String) b.getHeaders().get(Constants.BUNDLE_ACTIVATOR);

Added: aries/trunk/util/src/main/java/org/apache/aries/util/internal/R43Worker.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/internal/R43Worker.java?rev=1200093&view=auto
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/internal/R43Worker.java (added)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/internal/R43Worker.java Thu Nov 10
01:57:21 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.aries.util.internal;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class R43Worker implements FrameworkUtilWorker {
+
+    static {
+        BundleWiring.class.getClassLoader();
+    }
+
+    public ClassLoader getClassLoader(Bundle b) {
+        return b.adapt(BundleWiring.class).getClassLoader();
+    }
+
+    public boolean isValid() {
+        return true;
+    }
+}



Mime
View raw message